mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ 3 new games
git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@144 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
parent
5b45c9839e
commit
2b6b19dd49
9 changed files with 264 additions and 26 deletions
|
@ -1411,7 +1411,7 @@ Please select a %s type %s.
|
||||||
try:
|
try:
|
||||||
loadGame(m.group(1), n)
|
loadGame(m.group(1), n)
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
print >> sys.stderr, "Error loading plugin " + n + ": " + str(ex)
|
print >> sys.stderr, _("Error loading plugin %s: %s") % (n, ex)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.path = p
|
sys.path = p
|
||||||
|
|
||||||
|
@ -1429,7 +1429,7 @@ Please select a %s type %s.
|
||||||
finally:
|
finally:
|
||||||
if f: f.close()
|
if f: f.close()
|
||||||
lines = [l.strip() for l in lines]
|
lines = [l.strip() for l in lines]
|
||||||
if lines[0].find("PySol") != 0:
|
if not lines[0].startswith("PySol"):
|
||||||
return None
|
return None
|
||||||
config = CardsetConfig()
|
config = CardsetConfig()
|
||||||
if not self._parseCardsetConfig(config, lines):
|
if not self._parseCardsetConfig(config, lines):
|
||||||
|
|
|
@ -320,6 +320,39 @@ class Opus(Penguin):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# /***********************************************************************
|
||||||
|
# // Flipper
|
||||||
|
# ************************************************************************/
|
||||||
|
|
||||||
|
class Flipper_Row(AC_RowStack):
|
||||||
|
def canFlipCard(self):
|
||||||
|
if not OpenStack.canFlipCard(self):
|
||||||
|
return False
|
||||||
|
i = list(self.game.s.rows).index(self)
|
||||||
|
return len(self.game.s.reserves[i].cards) == 0
|
||||||
|
|
||||||
|
|
||||||
|
class Flipper(Tuxedo):
|
||||||
|
|
||||||
|
RowStack_Class = Flipper_Row
|
||||||
|
Foundation_Class = SS_FoundationStack
|
||||||
|
Hint_Class = DefaultHint
|
||||||
|
Solver_Class = None
|
||||||
|
|
||||||
|
def fillStack(self, stack):
|
||||||
|
i = 0
|
||||||
|
for s in self.s.reserves:
|
||||||
|
r = self.s.rows[i]
|
||||||
|
if r.cards:
|
||||||
|
if ((s.cards and r.cards[-1].face_up) or
|
||||||
|
(not s.cards and not r.cards[-1].face_up)):
|
||||||
|
r.flipMove(animation=True)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# register the game
|
# register the game
|
||||||
registerGame(GameInfo(45, BakersGame, "Baker's Game",
|
registerGame(GameInfo(45, BakersGame, "Baker's Game",
|
||||||
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_SKILL))
|
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_SKILL))
|
||||||
|
@ -339,3 +372,5 @@ registerGame(GameInfo(427, Opus, "Opus",
|
||||||
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||||
registerGame(GameInfo(629, Tuxedo, "Tuxedo",
|
registerGame(GameInfo(629, Tuxedo, "Tuxedo",
|
||||||
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||||
|
registerGame(GameInfo(713, Flipper, "Flipper",
|
||||||
|
GI.GT_FREECELL | GI.GT_ORIGINAL, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||||
|
|
|
@ -746,6 +746,63 @@ class BrazilianPatience(Gypsy):
|
||||||
self.s.talon.dealRow()
|
self.s.talon.dealRow()
|
||||||
|
|
||||||
|
|
||||||
|
# /***********************************************************************
|
||||||
|
# // Leprechaun
|
||||||
|
# ************************************************************************/
|
||||||
|
|
||||||
|
class Leprechaun_Reserve(OpenStack):
|
||||||
|
def canFlipCard(self):
|
||||||
|
if not OpenStack.canFlipCard(self):
|
||||||
|
return False
|
||||||
|
i = list(self.game.s.reserves).index(self)
|
||||||
|
return len(self.game.s.foundations[i].cards) != 0
|
||||||
|
|
||||||
|
|
||||||
|
class Leprechaun(Game):
|
||||||
|
|
||||||
|
def createGame(self):
|
||||||
|
|
||||||
|
# create layout
|
||||||
|
l, s = Layout(self), self.s
|
||||||
|
|
||||||
|
# set window
|
||||||
|
self.setSize(l.XM+9.5*l.XS, l.YM+3*l.YS+l.TEXT_HEIGHT+12*l.YOFFSET)
|
||||||
|
|
||||||
|
# create stacks
|
||||||
|
x, y = l.XM+1.5*l.XS, l.TEXT_HEIGHT
|
||||||
|
for i in range(8):
|
||||||
|
stack = Leprechaun_Reserve(x, y, self)
|
||||||
|
s.reserves.append(stack)
|
||||||
|
l.createText(stack, 'n')
|
||||||
|
x += l.XS
|
||||||
|
|
||||||
|
x, y = l.XM+1.5*l.XS, l.YS+l.TEXT_HEIGHT
|
||||||
|
for i in range(8):
|
||||||
|
s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2))
|
||||||
|
x += l.XS
|
||||||
|
|
||||||
|
x, y = l.XM+1.5*l.XS, 2*l.YS+l.TEXT_HEIGHT
|
||||||
|
for i in range(8):
|
||||||
|
s.rows.append(AC_RowStack(x, y, self))
|
||||||
|
x += l.XS
|
||||||
|
|
||||||
|
s.talon = DealRowTalonStack(l.XM, l.YM, self)
|
||||||
|
l.createText(s.talon, 's')
|
||||||
|
|
||||||
|
# define stack-groups
|
||||||
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
def startGame(self):
|
||||||
|
for i in range(4):
|
||||||
|
self.s.talon.dealRow(rows=self.s.reserves, flip=0, frames=0)
|
||||||
|
self.s.talon.dealRow(flip=0, frames=0)
|
||||||
|
self.s.talon.dealRow(flip=0, frames=0)
|
||||||
|
self.startDealSample()
|
||||||
|
self.s.talon.dealRow()
|
||||||
|
|
||||||
|
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# register the game
|
# register the game
|
||||||
registerGame(GameInfo(1, Gypsy, "Gypsy",
|
registerGame(GameInfo(1, Gypsy, "Gypsy",
|
||||||
|
@ -811,3 +868,5 @@ registerGame(GameInfo(640, BrazilianPatience, "Brazilian Patience",
|
||||||
GI.GT_GYPSY, 2, 0, GI.SL_MOSTLY_SKILL))
|
GI.GT_GYPSY, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||||
registerGame(GameInfo(666, TrapdoorSpider, "Trapdoor Spider",
|
registerGame(GameInfo(666, TrapdoorSpider, "Trapdoor Spider",
|
||||||
GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||||
|
registerGame(GameInfo(712, Leprechaun, "Leprechaun",
|
||||||
|
GI.GT_GYPSY | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||||
|
|
|
@ -539,12 +539,12 @@ class AbstractMahjonggGame(Game):
|
||||||
del cards[i]
|
del cards[i]
|
||||||
break
|
break
|
||||||
#
|
#
|
||||||
free_stacks = []
|
free_stacks = [] # none-blocked stacks
|
||||||
for r in rows:
|
for r in rows:
|
||||||
if new_cards[r.id] is None and not is_blocked(r, new_cards):
|
if new_cards[r.id] is None and not is_blocked(r, new_cards):
|
||||||
free_stacks.append(r)
|
free_stacks.append(r)
|
||||||
if len(free_stacks) < 2:
|
if len(free_stacks) < 2:
|
||||||
return None
|
return None # try another way
|
||||||
#
|
#
|
||||||
i = factorial(len(free_stacks))/2/factorial(len(free_stacks)-2)
|
i = factorial(len(free_stacks))/2/factorial(len(free_stacks)-2)
|
||||||
old_pairs = []
|
old_pairs = []
|
||||||
|
@ -559,15 +559,16 @@ class AbstractMahjonggGame(Game):
|
||||||
if (r1, r2) not in old_pairs and (r2, r1) not in old_pairs:
|
if (r1, r2) not in old_pairs and (r2, r1) not in old_pairs:
|
||||||
old_pairs.append((r1, r2))
|
old_pairs.append((r1, r2))
|
||||||
break
|
break
|
||||||
|
# add two selected cards to new_cards
|
||||||
s1 = free_stacks[r1]
|
s1 = free_stacks[r1]
|
||||||
s2 = free_stacks[r2]
|
s2 = free_stacks[r2]
|
||||||
nc[s1.id] = c1
|
nc[s1.id] = c1
|
||||||
nc[s2.id] = c2
|
nc[s2.id] = c2
|
||||||
|
# check if this layout is solvable (backtracking)
|
||||||
nc = create_solvable(cards[:], nc)
|
nc = create_solvable(cards[:], nc)
|
||||||
if nc:
|
if nc:
|
||||||
return nc
|
return nc
|
||||||
|
return None # try another way
|
||||||
return None
|
|
||||||
|
|
||||||
new_cards = create_solvable(cards, [None]*len(cards))
|
new_cards = create_solvable(cards, [None]*len(cards))
|
||||||
if new_cards:
|
if new_cards:
|
||||||
|
|
|
@ -1274,6 +1274,114 @@ class Bebop(Game):
|
||||||
shallHighlightMatch = Game._shallHighlightMatch_RK
|
shallHighlightMatch = Game._shallHighlightMatch_RK
|
||||||
|
|
||||||
|
|
||||||
|
# /***********************************************************************
|
||||||
|
# // The Jolly Roger
|
||||||
|
# ************************************************************************/
|
||||||
|
|
||||||
|
class TheJollyRoger_Foundation(AbstractFoundationStack):
|
||||||
|
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
|
||||||
|
return False
|
||||||
|
return isSameColorSequence(cards, self.cap.mod, self.cap.dir)
|
||||||
|
|
||||||
|
def getBottomImage(self):
|
||||||
|
return self.game.app.images.getLetter(ACE)
|
||||||
|
|
||||||
|
|
||||||
|
class TheJollyRoger_RowStack(BasicRowStack):
|
||||||
|
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
if not BasicRowStack.acceptsCards(self, from_stack, cards):
|
||||||
|
return False
|
||||||
|
if not self.cards:
|
||||||
|
return True
|
||||||
|
c1, c2 = self.cards[-1], cards[0]
|
||||||
|
if c2.rank == ACE:
|
||||||
|
return c1.rank == ACE
|
||||||
|
return c1.rank == c2.rank+2
|
||||||
|
|
||||||
|
def canMoveCards(self, cards):
|
||||||
|
if cards[0].rank == ACE:
|
||||||
|
return isSameColorSequence(cards, dir=0)
|
||||||
|
elif cards[-1].rank == ACE:
|
||||||
|
return False # 5-3-ace
|
||||||
|
return isSameSuitSequence(cards, dir=-2)
|
||||||
|
|
||||||
|
def canDropCards(self, stacks):
|
||||||
|
cards = self.cards
|
||||||
|
if not cards:
|
||||||
|
return (None, 0)
|
||||||
|
dcards = None
|
||||||
|
if cards[-1].rank == ACE:
|
||||||
|
if len(cards) < 4:
|
||||||
|
return (None, 0)
|
||||||
|
if isSameColorSequence(cards[-4:], dir=0):
|
||||||
|
dcards = cards[-4:]
|
||||||
|
else:
|
||||||
|
if len(cards) < 6:
|
||||||
|
return (None, 0)
|
||||||
|
if isSameSuitSequence(cards, dir=-2):
|
||||||
|
dcards = cards[-6:]
|
||||||
|
if not dcards:
|
||||||
|
return (None, 0)
|
||||||
|
for s in stacks:
|
||||||
|
if s is not self and s.acceptsCards(self, dcards):
|
||||||
|
return (s, len(dcards))
|
||||||
|
return (None, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class TheJollyRoger(Game):
|
||||||
|
Hint_Class = Spider_Hint
|
||||||
|
|
||||||
|
def createGame(self):
|
||||||
|
# create layout
|
||||||
|
l, s = Layout(self), self.s
|
||||||
|
|
||||||
|
# set window
|
||||||
|
self.setSize(l.XM+13*l.XS, l.YM+3*l.YS+12*l.YOFFSET)
|
||||||
|
|
||||||
|
# create stacks
|
||||||
|
y = l.YM
|
||||||
|
for i in range(2):
|
||||||
|
x = l.XM+2*l.XS
|
||||||
|
for j in range(8):
|
||||||
|
s.foundations.append(Spider_SS_Foundation(x, y, self,
|
||||||
|
dir=-2, base_rank=ANY_RANK,
|
||||||
|
min_accept=6, max_cards=6, max_move=0))
|
||||||
|
x += l.XS
|
||||||
|
s.foundations.append(TheJollyRoger_Foundation(x, y, self,
|
||||||
|
suit=ANY_SUIT, dir=0,
|
||||||
|
min_accept=4, max_accept=4,
|
||||||
|
max_cards=4, max_move=0))
|
||||||
|
y += l.YS
|
||||||
|
|
||||||
|
x, y = l.XM, l.YM+2*l.YS
|
||||||
|
for i in range(13):
|
||||||
|
s.rows.append(TheJollyRoger_RowStack(x, y, self, dir=2,
|
||||||
|
max_move=UNLIMITED_MOVES, max_accept=UNLIMITED_ACCEPTS))
|
||||||
|
x += l.XS
|
||||||
|
s.talon = DealRowTalonStack(l.XM, l.YM, self)
|
||||||
|
l.createText(s.talon, 's')
|
||||||
|
|
||||||
|
# define stack-groups
|
||||||
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
def startGame(self):
|
||||||
|
for i in range(2):
|
||||||
|
self.s.talon.dealRow(frames=0)
|
||||||
|
self.startDealSample()
|
||||||
|
self.s.talon.dealRow()
|
||||||
|
|
||||||
|
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||||
|
if card1.rank != ACE and card2.rank != ACE:
|
||||||
|
# by rank
|
||||||
|
return abs(card1.rank-card2.rank) == 2
|
||||||
|
return card1.rank == ACE and card2.rank == ACE
|
||||||
|
|
||||||
|
getQuickPlayScore = Game._getSpiderQuickPlayScore
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# register the game
|
# register the game
|
||||||
registerGame(GameInfo(10, RelaxedSpider, "Relaxed Spider",
|
registerGame(GameInfo(10, RelaxedSpider, "Relaxed Spider",
|
||||||
|
@ -1396,6 +1504,8 @@ registerGame(GameInfo(685, FechtersGame, "Fechter's Game",
|
||||||
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL))
|
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||||
registerGame(GameInfo(710, Bebop, "Bebop",
|
registerGame(GameInfo(710, Bebop, "Bebop",
|
||||||
GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||||
#registerGame(GameInfo(711, SimpleSimonII, "Simple Simon II",
|
#registerGame(GameInfo(000, SimpleSimonII, "Simple Simon II",
|
||||||
# GI.GT_SPIDER | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
# GI.GT_SPIDER | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||||
|
registerGame(GameInfo(711, TheJollyRoger, "The Jolly Roger",
|
||||||
|
GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||||
|
|
||||||
|
|
|
@ -694,6 +694,9 @@ class Hawaiian(Game):
|
||||||
self.startDealSample()
|
self.startDealSample()
|
||||||
self.s.talon.dealRow()
|
self.s.talon.dealRow()
|
||||||
|
|
||||||
|
def getHighlightPilesStacks(self):
|
||||||
|
return ()
|
||||||
|
|
||||||
shallHighlightMatch = Game._shallHighlightMatch_AC
|
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,7 @@ class Images:
|
||||||
im = c._active_image._pil_image
|
im = c._active_image._pil_image
|
||||||
mask.paste(im, (x, y), im)
|
mask.paste(im, (x, y), im)
|
||||||
# create shadow
|
# create shadow
|
||||||
|
if 0:
|
||||||
sh = self._pil_shadow_image
|
sh = self._pil_shadow_image
|
||||||
shw, shh = sh.size
|
shw, shh = sh.size
|
||||||
shadow = Image.new('RGBA', (w, h))
|
shadow = Image.new('RGBA', (w, h))
|
||||||
|
@ -329,6 +330,29 @@ class Images:
|
||||||
mask = mask.crop((sx,sy,w,h))
|
mask = mask.crop((sx,sy,w,h))
|
||||||
tmp = Image.new('RGBA', (w-sx,h-sy))
|
tmp = Image.new('RGBA', (w-sx,h-sy))
|
||||||
shadow.paste(tmp, (0,0), mask)
|
shadow.paste(tmp, (0,0), mask)
|
||||||
|
elif 0:
|
||||||
|
import ImageFilter
|
||||||
|
dx, dy = 5, 5
|
||||||
|
sh_color = (0x00,0x00,0x00,0x80)
|
||||||
|
shadow = Image.new('RGBA', (w+dx, h+dy))
|
||||||
|
sx, sy = self.SHADOW_XOFFSET, self.SHADOW_YOFFSET
|
||||||
|
shadow.paste(sh_color, (0, 0, w, h), mask)
|
||||||
|
for i in range(3):
|
||||||
|
shadow = shadow.filter(ImageFilter.BLUR)
|
||||||
|
shadow = shadow.crop((dx,dy,w,h))
|
||||||
|
sx, sy = self.SHADOW_XOFFSET, self.SHADOW_YOFFSET
|
||||||
|
mask = mask.crop((sx,sy,w,h))
|
||||||
|
tmp = Image.new('RGBA', (w-sx,h-sy))
|
||||||
|
shadow.paste(tmp, (0,0), mask)
|
||||||
|
else:
|
||||||
|
sh_color = (0x00,0x00,0x00,0x50)
|
||||||
|
shadow = Image.new('RGBA', (w, h))
|
||||||
|
shadow.paste(sh_color, (0, 0, w, h), mask)
|
||||||
|
sx, sy = self.SHADOW_XOFFSET, self.SHADOW_YOFFSET
|
||||||
|
mask = mask.crop((sx,sy,w,h))
|
||||||
|
tmp = Image.new('RGBA', (w-sx,h-sy))
|
||||||
|
shadow.paste(tmp, (0,0), mask)
|
||||||
|
|
||||||
#
|
#
|
||||||
shadow = ImageTk.PhotoImage(shadow)
|
shadow = ImageTk.PhotoImage(shadow)
|
||||||
self._pil_shadow[(w,h)] = shadow
|
self._pil_shadow[(w,h)] = shadow
|
||||||
|
|
|
@ -26,11 +26,12 @@ n_ = lambda x: x # for gettext
|
||||||
|
|
||||||
#PACKAGE = 'PySolFC'
|
#PACKAGE = 'PySolFC'
|
||||||
PACKAGE = 'PySol'
|
PACKAGE = 'PySol'
|
||||||
|
#PACKAGE_URL = 'http://pysolfc/sourceforge.net/'
|
||||||
PACKAGE_URL = 'http://sourceforge.net/projects/pysolfc/'
|
PACKAGE_URL = 'http://sourceforge.net/projects/pysolfc/'
|
||||||
|
|
||||||
VERSION = '4.82'
|
VERSION = '4.82'
|
||||||
FC_VERSION = '1.0'
|
FC_VERSION = '1.0.1'
|
||||||
VERSION_TUPLE = (10, 0)
|
VERSION_TUPLE = (10, 0, 1)
|
||||||
|
|
||||||
# Tk windowing system (auto determine in init.py)
|
# Tk windowing system (auto determine in init.py)
|
||||||
WIN_SYSTEM = 'x11' # win32, x11, aqua, classic
|
WIN_SYSTEM = 'x11' # win32, x11, aqua, classic
|
||||||
|
|
|
@ -110,6 +110,11 @@ def show_cardset(*args):
|
||||||
# zoom
|
# zoom
|
||||||
z = 1.0 + zoom/10.0
|
z = 1.0 + zoom/10.0
|
||||||
z = max(0.2, z)
|
z = max(0.2, z)
|
||||||
|
if 1:
|
||||||
|
tmp = Image.new('RGBA', (w+2, h+2))
|
||||||
|
tmp.paste(im, (1,1), im)
|
||||||
|
im = tmp.resize((int(w*z), int(h*z)), resample=filter)
|
||||||
|
else:
|
||||||
im = im.resize((int(w*z), int(h*z)), resample=filter)
|
im = im.resize((int(w*z), int(h*z)), resample=filter)
|
||||||
t = '%d %%' % int(z*100)
|
t = '%d %%' % int(z*100)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue