mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
* improved the mahjongg games
+ added `shuffle' icons git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@167 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
parent
500d8635f9
commit
2aa94c2858
7 changed files with 21 additions and 10 deletions
BIN
data/images/toolbar/bluecurve/large/shuffle.gif
Normal file
BIN
data/images/toolbar/bluecurve/large/shuffle.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 915 B |
BIN
data/images/toolbar/bluecurve/small/shuffle.gif
Normal file
BIN
data/images/toolbar/bluecurve/small/shuffle.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 506 B |
BIN
data/images/toolbar/crystal/large/shuffle.gif
Normal file
BIN
data/images/toolbar/crystal/large/shuffle.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
data/images/toolbar/crystal/small/shuffle.gif
Normal file
BIN
data/images/toolbar/crystal/small/shuffle.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -801,6 +801,8 @@ class Application:
|
||||||
del self.opt.recent_gameid[self.opt.num_recent_games:]
|
del self.opt.recent_gameid[self.opt.num_recent_games:]
|
||||||
self.menubar.updateRecentGamesMenu(self.opt.recent_gameid)
|
self.menubar.updateRecentGamesMenu(self.opt.recent_gameid)
|
||||||
self.menubar.updateFavoriteGamesMenu()
|
self.menubar.updateFavoriteGamesMenu()
|
||||||
|
# hide/show "Shuffle" button
|
||||||
|
self.toolbar.config('shuffle', self.game.canShuffle())
|
||||||
# delete intro progress bar
|
# delete intro progress bar
|
||||||
if self.intro.progress:
|
if self.intro.progress:
|
||||||
self.intro.progress.destroy()
|
self.intro.progress.destroy()
|
||||||
|
|
|
@ -361,6 +361,7 @@ class Game:
|
||||||
autoplay_moves = 0, # number of moves
|
autoplay_moves = 0, # number of moves
|
||||||
quickplay_moves = 0, # number of quickplay moves
|
quickplay_moves = 0, # number of quickplay moves
|
||||||
goto_bookmark_moves = 0, # number of goto bookmark
|
goto_bookmark_moves = 0, # number of goto bookmark
|
||||||
|
shuffle_moves = 0, # number of shuffles (Mahjongg)
|
||||||
demo_updated = 0, # did this game already update the demo stats ?
|
demo_updated = 0, # did this game already update the demo stats ?
|
||||||
update_time = time.time(), # for updateTime()
|
update_time = time.time(), # for updateTime()
|
||||||
elapsed_time = 0.0,
|
elapsed_time = 0.0,
|
||||||
|
@ -1618,10 +1619,11 @@ class Game:
|
||||||
# sorry, you lose
|
# sorry, you lose
|
||||||
return won, 0, self.U_LOST
|
return won, 0, self.U_LOST
|
||||||
if (self.stats.undo_moves == 0 and
|
if (self.stats.undo_moves == 0 and
|
||||||
self.stats.goto_bookmark_moves == 0 and
|
self.stats.goto_bookmark_moves == 0 and
|
||||||
### self.stats.quickplay_moves == 0 and
|
### self.stats.quickplay_moves == 0 and
|
||||||
self.stats.highlight_piles == 0 and
|
self.stats.highlight_piles == 0 and
|
||||||
self.stats.highlight_cards == 0):
|
self.stats.highlight_cards == 0 and
|
||||||
|
self.stats.shuffle_moves == 0):
|
||||||
# perfect !
|
# perfect !
|
||||||
return won, 2, self.U_PERFECT
|
return won, 2, self.U_PERFECT
|
||||||
return won, 1, self.U_WON
|
return won, 1, self.U_WON
|
||||||
|
|
|
@ -43,7 +43,7 @@ from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
|
||||||
from pysollib.pysoltk import MfxCanvasText, MfxCanvasImage
|
from pysollib.pysoltk import MfxCanvasText, MfxCanvasImage
|
||||||
from pysollib.pysoltk import bind, EVENT_HANDLED, ANCHOR_NW
|
from pysollib.pysoltk import bind, EVENT_HANDLED, ANCHOR_NW
|
||||||
from pysollib.pysoltk import MfxMessageDialog
|
from pysollib.pysoltk import MfxMessageDialog
|
||||||
from pysollib.settings import TOOLKIT
|
from pysollib.settings import TOOLKIT, DEBUG
|
||||||
|
|
||||||
|
|
||||||
def factorial(x):
|
def factorial(x):
|
||||||
|
@ -557,6 +557,7 @@ class AbstractMahjonggGame(Game):
|
||||||
|
|
||||||
|
|
||||||
def _shuffleHook1(self, cards):
|
def _shuffleHook1(self, cards):
|
||||||
|
# old version; it generate a very easy layouts
|
||||||
old_cards = cards[:]
|
old_cards = cards[:]
|
||||||
rows = self.s.rows
|
rows = self.s.rows
|
||||||
|
|
||||||
|
@ -703,16 +704,16 @@ class AbstractMahjonggGame(Game):
|
||||||
if time.time() - start_time > max_time:
|
if time.time() - start_time > max_time:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# select two suitable stacks
|
||||||
while True:
|
while True:
|
||||||
# create uniq pair
|
# create a uniq pair
|
||||||
r1 = self.random.randrange(0, len(suitable_stacks))
|
r1 = self.random.randrange(0, len(suitable_stacks))
|
||||||
r2 = self.random.randrange(0, len(suitable_stacks)-1)
|
r2 = self.random.randrange(0, len(suitable_stacks))
|
||||||
if r2 >= r1:
|
if r1 == r2:
|
||||||
r2 += 1
|
continue
|
||||||
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
|
||||||
# select two suitable stacks
|
|
||||||
s1 = suitable_stacks[r1]
|
s1 = suitable_stacks[r1]
|
||||||
s2 = suitable_stacks[r2]
|
s2 = suitable_stacks[r2]
|
||||||
# check if s1 don't block s2
|
# check if s1 don't block s2
|
||||||
|
@ -739,6 +740,8 @@ class AbstractMahjonggGame(Game):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
ret = create_solvable(cards[:], new_cards)
|
ret = create_solvable(cards[:], new_cards)
|
||||||
|
if DEBUG:
|
||||||
|
print 'create_solvable time:', time.time() - start_time
|
||||||
if ret:
|
if ret:
|
||||||
ret.reverse()
|
ret.reverse()
|
||||||
return ret
|
return ret
|
||||||
|
@ -788,9 +791,13 @@ a solvable configuration.'''),
|
||||||
bitmap='warning')
|
bitmap='warning')
|
||||||
self.leaveState(old_state)
|
self.leaveState(old_state)
|
||||||
##self.finishMove()
|
##self.finishMove()
|
||||||
self.moves.current = [] # hack
|
# hack
|
||||||
|
am = self.moves.current[0]
|
||||||
|
am.undo(self) # restore random
|
||||||
|
self.moves.current = []
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.stats.shuffle_moves += 1
|
||||||
# move new_cards to talon
|
# move new_cards to talon
|
||||||
for c in new_cards:
|
for c in new_cards:
|
||||||
for r in rows:
|
for r in rows:
|
||||||
|
|
Loading…
Add table
Reference in a new issue