mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Fix for preview bottoms and undo in Cruel.
This commit is contained in:
parent
41ff8873e5
commit
42b97cf1ed
3 changed files with 55 additions and 37 deletions
|
@ -31,6 +31,7 @@ from pysollib.stack import \
|
||||||
AC_FoundationStack, \
|
AC_FoundationStack, \
|
||||||
AC_RowStack, \
|
AC_RowStack, \
|
||||||
InitialDealTalonStack, \
|
InitialDealTalonStack, \
|
||||||
|
InvisibleStack, \
|
||||||
RK_RowStack, \
|
RK_RowStack, \
|
||||||
SS_FoundationStack, \
|
SS_FoundationStack, \
|
||||||
SS_RowStack, \
|
SS_RowStack, \
|
||||||
|
@ -55,6 +56,8 @@ class CastlesInSpain(Game):
|
||||||
Hint_Class = CautiousDefaultHint
|
Hint_Class = CautiousDefaultHint
|
||||||
Solver_Class = FreeCellSolverWrapper()
|
Solver_Class = FreeCellSolverWrapper()
|
||||||
|
|
||||||
|
GAME_VERSION = 2
|
||||||
|
|
||||||
#
|
#
|
||||||
# game layout
|
# game layout
|
||||||
#
|
#
|
||||||
|
@ -73,6 +76,7 @@ class CastlesInSpain(Game):
|
||||||
for r in l.s.rows:
|
for r in l.s.rows:
|
||||||
s.rows.append(self.RowStack_Class(r.x, r.y, self))
|
s.rows.append(self.RowStack_Class(r.x, r.y, self))
|
||||||
# default
|
# default
|
||||||
|
self.s.internals.append(InvisibleStack(self))
|
||||||
l.defaultAll()
|
l.defaultAll()
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
@ -218,18 +222,20 @@ class Cruel_Talon(TalonStack):
|
||||||
for r in rows:
|
for r in rows:
|
||||||
for i in range(len(r.cards)):
|
for i in range(len(r.cards)):
|
||||||
num_cards = num_cards + 1
|
num_cards = num_cards + 1
|
||||||
self.game.moveMove(1, r, self, frames=0)
|
self.game.moveMove(1, r, self.game.s.internals[0], frames=0)
|
||||||
assert len(self.cards) == num_cards
|
|
||||||
|
|
||||||
temp_cards = []
|
if len(self.game.s.internals[0].cards) % 4 != 0:
|
||||||
while len(self.cards) > 0:
|
self.game.moveMove(len(self.game.s.internals[0].cards) % 4,
|
||||||
temp = self.cards[:4]
|
self.game.s.internals[0], self, frames=0)
|
||||||
temp_cards = temp + temp_cards
|
|
||||||
del self.cards[:4]
|
while len(self.game.s.internals[0].cards) > 0:
|
||||||
self.cards = temp_cards.copy()
|
self.game.moveMove(4, self.game.s.internals[0], self, frames=0)
|
||||||
|
|
||||||
|
assert len(self.cards) == num_cards
|
||||||
|
|
||||||
if num_cards == 0: # game already finished
|
if num_cards == 0: # game already finished
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# redeal in packs of 4 cards
|
# redeal in packs of 4 cards
|
||||||
self.game.nextRoundMove(self)
|
self.game.nextRoundMove(self)
|
||||||
n, i = num_cards, 0
|
n, i = num_cards, 0
|
||||||
|
|
|
@ -189,7 +189,7 @@ class Images:
|
||||||
if progress:
|
if progress:
|
||||||
progress.update(step=1)
|
progress.update(step=1)
|
||||||
|
|
||||||
if not USE_PIL:
|
# todo - fix duplication of loading bottoms
|
||||||
# load bottoms
|
# load bottoms
|
||||||
for i in range(self.cs.nbottoms):
|
for i in range(self.cs.nbottoms):
|
||||||
name = "bottom%02d" % (i + 1)
|
name = "bottom%02d" % (i + 1)
|
||||||
|
|
|
@ -289,6 +289,18 @@ def masking(image):
|
||||||
|
|
||||||
image = image.convert("RGBA") # make sure it has alphachannel
|
image = image.convert("RGBA") # make sure it has alphachannel
|
||||||
mask = image.copy()
|
mask = image.copy()
|
||||||
|
|
||||||
|
# calculate median transparency value
|
||||||
|
# this will determine if the masking will have a significant
|
||||||
|
# effect on performance.
|
||||||
|
transparency = [row[3] for row in image.getdata()]
|
||||||
|
n = len(transparency)
|
||||||
|
s = sorted(transparency)
|
||||||
|
median = (s[n // 2 - 1] / 2.0 + s[n // 2] / 2.0, s[n // 2])[n % 2]
|
||||||
|
|
||||||
|
if median > 0:
|
||||||
|
return image
|
||||||
|
|
||||||
# important alpha must be bigger than 0
|
# important alpha must be bigger than 0
|
||||||
mask.putalpha(1)
|
mask.putalpha(1)
|
||||||
mask.paste(image, (0, 0), image)
|
mask.paste(image, (0, 0), image)
|
||||||
|
|
Loading…
Add table
Reference in a new issue