mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ one new game
* added quick play for foundations * improved cards shadow git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@245 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
parent
232dca18fb
commit
50d86dcff6
9 changed files with 84 additions and 39 deletions
|
@ -378,6 +378,8 @@ class TabbyCat(Game):
|
|||
s.talon = self.Talon_Class(x, y, self)
|
||||
l.createText(s.talon, "s")
|
||||
|
||||
self.setRegion(s.foundations, (-999, -999, l.YS*decks-l.CH/2, 999999))
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
|
|
@ -615,7 +615,7 @@ class Quads_RowStack(RK_RowStack):
|
|||
getBottomImage = Stack._getReserveBottomImage
|
||||
|
||||
class Quads(Troika):
|
||||
RowStack_Class = StackWrapper(Quads_RowStack, dir=0,
|
||||
RowStack_Class = FullStackWrapper(Quads_RowStack, dir=0,
|
||||
##base_rank=NO_RANK,
|
||||
max_cards=4)
|
||||
def createGame(self):
|
||||
|
@ -623,10 +623,18 @@ class Quads(Troika):
|
|||
|
||||
def startGame(self):
|
||||
Troika.startGame(self, ncards=4)
|
||||
## for i in range(3):
|
||||
## self.s.talon.dealRow(rows=self.s.rows[:-1], frames=0)
|
||||
## self.startDealSample()
|
||||
## self.s.talon.dealRow(rows=self.s.rows[:-1])
|
||||
|
||||
class QuadsPlus(Quads):
|
||||
def _shuffleHook(self, cards):
|
||||
return self._shuffleHookMoveToTop(cards,
|
||||
lambda c: (c.rank == ACE, c.suit))
|
||||
|
||||
def startGame(self):
|
||||
self.s.talon.dealRow(rows=self.s.foundations, frames=0)
|
||||
for i in range(3):
|
||||
self.s.talon.dealRow(rows=self.s.rows[:-1], frames=0)
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow(rows=self.s.rows[:-1])
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -944,4 +952,6 @@ registerGame(GameInfo(719, School, "School",
|
|||
GI.GT_FAN_TYPE, 1, 2, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(739, ForestGlade, "Forest Glade",
|
||||
GI.GT_FAN_TYPE, 2, 2, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(767, QuadsPlus, "Quads +",
|
||||
GI.GT_FAN_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||
|
||||
|
|
|
@ -1182,33 +1182,33 @@ class LuckyThirteen(Game):
|
|||
if xoffset:
|
||||
xoffset = l.XOFFSET
|
||||
w0 = l.XS+playcards*l.XOFFSET
|
||||
self.setSize(l.XM + 5*w0+2*l.XS, l.YM+4*l.YS)
|
||||
self.setSize(l.XM + 5*w0, l.YM+4*l.YS)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
x, y = l.XM, l.YM+l.YS
|
||||
for i in range(5):
|
||||
stack = self.RowStack_Class(x, y, self, max_move=1)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET = xoffset
|
||||
stack.CARD_YOFFSET = 0
|
||||
x += w0
|
||||
x, y = l.XM+w0, l.YM+l.YS
|
||||
x, y = l.XM+w0, l.YM+2*l.YS
|
||||
for i in range(3):
|
||||
stack = self.RowStack_Class(x, y, self, max_move=1)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET = xoffset
|
||||
stack.CARD_YOFFSET = 0
|
||||
x += w0
|
||||
x, y = l.XM, l.YM+2*l.YS
|
||||
x, y = l.XM, l.YM+3*l.YS
|
||||
for i in range(5):
|
||||
stack = self.RowStack_Class(x, y, self, max_move=1)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET = xoffset
|
||||
stack.CARD_YOFFSET = 0
|
||||
x += w0
|
||||
x, y = self.width-l.XS, l.YM
|
||||
x, y = (self.width-4*l.XS)/2, l.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
||||
y += l.YS
|
||||
x += l.XS
|
||||
x, y = l.XM, self.height-l.YS
|
||||
s.talon = InitialDealTalonStack(x, y, self, max_rounds=1)
|
||||
|
||||
|
|
|
@ -60,6 +60,11 @@ class Terrace_AC_Foundation(AC_FoundationStack):
|
|||
return from_stack in self.game.s.rows
|
||||
return AC_FoundationStack.acceptsCards(self, from_stack, cards)
|
||||
|
||||
def getBaseCard(self):
|
||||
if self.game.getState() == 0:
|
||||
return _('Base card - %s.') % _('any card')
|
||||
return AC_FoundationStack.getBaseCard(self)
|
||||
|
||||
|
||||
class Terrace_SS_Foundation(SS_FoundationStack):
|
||||
def __init__(self, x, y, game, suit, **cap):
|
||||
|
@ -75,6 +80,11 @@ class Terrace_SS_Foundation(SS_FoundationStack):
|
|||
return from_stack in self.game.s.rows
|
||||
return SS_FoundationStack.acceptsCards(self, from_stack, cards)
|
||||
|
||||
def getBaseCard(self):
|
||||
if self.game.getState() == 0:
|
||||
return _('Base card - %s.') % _('any card')
|
||||
return SS_FoundationStack.getBaseCard(self)
|
||||
|
||||
|
||||
class Terrace_RowStack(AC_RowStack):
|
||||
def __init__(self, x, y, game, **cap):
|
||||
|
@ -286,13 +296,11 @@ class Signora(Terrace):
|
|||
# ************************************************************************
|
||||
|
||||
class Madame(Terrace):
|
||||
Talon_Class = WasteTalonStack
|
||||
INITIAL_RESERVE_CARDS = 15
|
||||
def createGame(self):
|
||||
Terrace.createGame(self, rows=10, playcards=20)
|
||||
def startGame(self):
|
||||
Terrace.startGame(self, nrows=10)
|
||||
self.s.talon.dealCards()
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
|
@ -78,8 +78,6 @@ class Images:
|
|||
self._xshadow = []
|
||||
self._shade = []
|
||||
self._shadow_cards = {} # key: (suit, rank)
|
||||
self._highlight_cards = {} # for mahjongg
|
||||
self._shadow_back = None
|
||||
self._pil_shadow = {} # key: (width, height)
|
||||
self._pil_shadow_image = None
|
||||
|
||||
|
@ -354,35 +352,35 @@ class Images:
|
|||
def getShade(self):
|
||||
return self._shade[self._shade_index]
|
||||
|
||||
def getShadowCard(self, deck, suit, rank):
|
||||
if (suit, rank) in self._shadow_cards:
|
||||
shade = self._shadow_cards[(suit, rank)]
|
||||
def _getShadow(self, image, card, color='#3896f8', factor=0.3):
|
||||
if TOOLKIT == 'tk' and Image and Image.VERSION >= '1.1.7':
|
||||
# use alpha image; one for each color
|
||||
if color in self._shadow_cards:
|
||||
shade = self._shadow_cards[color]
|
||||
else:
|
||||
shade = shadowImage(image, color, factor)
|
||||
self._shadow_cards[color] = shade
|
||||
else:
|
||||
image = self.getFace(deck, suit, rank)
|
||||
shade = shadowImage(image)
|
||||
self._shadow_cards[(suit, rank)] = shade
|
||||
if card in self._shadow_cards:
|
||||
shade = self._shadow_cards[card]
|
||||
else:
|
||||
shade = shadowImage(image, color, factor)
|
||||
self._shadow_cards[card] = shade
|
||||
if not shade:
|
||||
return self.getShade()
|
||||
return shade
|
||||
|
||||
def getShadowCard(self, deck, suit, rank):
|
||||
image = self.getFace(deck, suit, rank)
|
||||
return self._getShadow(image, (suit, rank))
|
||||
|
||||
def getHighlightCard(self, deck, suit, rank):
|
||||
if (suit, rank) in self._highlight_cards:
|
||||
shade = self._highlight_cards[(suit, rank)]
|
||||
else:
|
||||
image = self.getFace(deck, suit, rank)
|
||||
shade = shadowImage(image, color='black', factor=0.3)
|
||||
self._highlight_cards[(suit, rank)] = shade
|
||||
if not shade:
|
||||
return self.getShade()
|
||||
return shade
|
||||
image = self.getFace(deck, suit, rank)
|
||||
return self._getShadow(image, (suit, rank, 'black'), 'black')
|
||||
|
||||
def getShadowBack(self):
|
||||
if self._shadow_back:
|
||||
return self._shadow_back
|
||||
image = self.getBack()
|
||||
shade = shadowImage(image)
|
||||
self._shadow_back = shade
|
||||
return shade
|
||||
return self._getShadow(image, 'back')
|
||||
|
||||
def getCardbacks(self):
|
||||
return self._back
|
||||
|
|
|
@ -2131,10 +2131,19 @@ class AbstractFoundationStack(OpenStack):
|
|||
return 0
|
||||
|
||||
def rightclickHandler(self, event):
|
||||
##return 0
|
||||
if self.game.app.opt.quickplay:
|
||||
n = self.quickPlayHandler(event)
|
||||
self.game.stats.quickplay_moves += n
|
||||
return n
|
||||
return 0
|
||||
|
||||
def quickPlayHandler(self, event, from_stacks=None, to_stacks=None):
|
||||
return 0
|
||||
def quickPlayHandler(self, event):
|
||||
##return 0
|
||||
from_stacks = self.game.sg.dropstacks + self.game.s.foundations
|
||||
##to_stacks = self.game.sg.dropstacks
|
||||
to_stacks = from_stacks
|
||||
return OpenStack.quickPlayHandler(self, event, from_stacks, to_stacks)
|
||||
|
||||
getBottomImage = Stack._getSuitBottomImage
|
||||
|
||||
|
|
|
@ -337,6 +337,12 @@ def shadowImage(image, color='#3896f8', factor=0.3):
|
|||
if not hasattr(image, '_pil_image'):
|
||||
return None
|
||||
im = image._pil_image
|
||||
if Image.VERSION >= '1.1.7':
|
||||
# use an alpha image
|
||||
sh = Image.new('RGBA', im.size, color)
|
||||
sh.putalpha(100)
|
||||
out = Image.composite(sh, im, im)
|
||||
return PIL_Image(image=out)
|
||||
sh = Image.new('RGBA', im.size, color)
|
||||
tmp = Image.blend(im, sh, factor)
|
||||
out = Image.composite(tmp, im, im)
|
||||
|
|
|
@ -337,6 +337,12 @@ def shadowImage(image, color='#3896f8', factor=0.3):
|
|||
if not hasattr(image, '_pil_image'):
|
||||
return None
|
||||
im = image._pil_image
|
||||
if Image.VERSION >= '1.1.7':
|
||||
# use an alpha image
|
||||
sh = Image.new('RGBA', im.size, color)
|
||||
sh.putalpha(100)
|
||||
out = Image.composite(sh, im, im)
|
||||
return PIL_Image(image=out)
|
||||
sh = Image.new('RGBA', im.size, color)
|
||||
tmp = Image.blend(im, sh, factor)
|
||||
out = Image.composite(tmp, im, im)
|
||||
|
|
|
@ -23,6 +23,8 @@ cardset_type = {
|
|||
'9': 'Trump only',
|
||||
}
|
||||
|
||||
all_imgs = False
|
||||
|
||||
class Cardset:
|
||||
def __init__(self, dir, name, type, ext, x, y):
|
||||
self.dir, self.name, self.type, self.ext, self.x, self.y = dir, name, type, ext, x, y
|
||||
|
@ -61,8 +63,9 @@ def show_cardset(*args):
|
|||
cs = cardsets_dict[cs_name]
|
||||
ls = glob(os.path.join(cs.dir, '[0-9][0-9][a-z]'+cs.ext))
|
||||
ls += glob(os.path.join(cs.dir, 'back*'+cs.ext))
|
||||
#ls += glob(os.path.join(cs.dir, 'bottom*.gif'))
|
||||
#ls += glob(os.path.join(cs.dir, 'l*.gif'))
|
||||
if all_imgs:
|
||||
ls += glob(os.path.join(cs.dir, 'bottom*.gif'))
|
||||
ls += glob(os.path.join(cs.dir, 'l*.gif'))
|
||||
#ls = glob(os.path.join(cs.dir, '*.gif'))
|
||||
##if not ls: return
|
||||
ls.sort()
|
||||
|
@ -251,6 +254,9 @@ def create_widgets():
|
|||
return root
|
||||
|
||||
if __name__ == '__main__':
|
||||
if '-a' in sys.argv:
|
||||
sys.argv.remove('-a')
|
||||
all_imgs = True
|
||||
if len(sys.argv) > 1:
|
||||
data_dir = sys.argv[1]
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue