1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Compare commits

...

7 commits

Author SHA1 Message Date
lufebe16
81fab2028a Corrections on game 'pyramid'
- For TypeError reported with #147. (clickhandler failed to return a value)
- For index out of range (in pyramid.y)
2020-02-10 18:01:20 +01:00
Juhani Numminen
80d99e508d Fix 'TclError: unknown option' for tk
Partly reverts commit b9a46ecf35
2020-02-09 22:19:47 +02:00
Juhani Numminen
032b645e0f Do not catch exceptions too broadly in mainloop
StopIteration seems to be the expected way to stop, at least
for the tk and tile interfaces.
2020-02-09 22:07:16 +02:00
Juhani Numminen
00f6f70e93 Fix menu colors on macOS with dark menu bar
Widget colors and all scrollbars look just fine without these lines
despite the comments.
2020-02-09 17:36:26 +02:00
Shlomi Fish
57b9c9d41e fix a crash on "open game" 2020-02-09 11:44:52 +02:00
Shlomi Fish
2258274c77 Refactoring / code cleanup.
Use a frozenset()-like list.

See:

* https://en.wikipedia.org/wiki/Code_refactoring

* https://www.refactoring.com/

* https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/

Some small optimisations may have slipped in as well.
2020-02-07 11:44:24 +02:00
Shlomi Fish
0306d648fa fix load/save 2020-02-07 11:31:34 +02:00
6 changed files with 21 additions and 25 deletions

View file

@ -183,7 +183,7 @@ class Application:
try:
approc = self.mainproc() # setup process
approc.send(None) # and go
except Exception:
except StopIteration:
pass
def gameproc(self):

View file

@ -67,6 +67,8 @@ from pysollib.settings import PACKAGE, TITLE, TOOLKIT, TOP_SIZE
from pysollib.settings import VERSION, VERSION_TUPLE
from pysollib.struct_new import NewStruct
import random2
import six
from six import BytesIO
from six.moves import range
@ -471,6 +473,10 @@ class GameSaveInfo(NewStruct):
stack_caps = attr.ib(factory=list)
_Game_LOAD_CLASSES = [GameGlobalSaveInfo, GameGlobalStatsStruct, GameMoves,
GameSaveInfo, GameStatsStruct, ]
class Game(object):
# for self.gstats.updated
U_PLAY = _GLOBAL_U_PLAY
@ -3147,9 +3153,7 @@ class Game(object):
if isinstance(t, type):
if not isinstance(obj, t):
# accept old storage format in case:
if (t == GameMoves
or t == GameGlobalStatsStruct
or t == GameStatsStruct):
if t in _Game_LOAD_CLASSES:
assert isinstance(obj, Struct), err_txt
else:
assert False, err_txt
@ -3194,7 +3198,9 @@ class Game(object):
initial_seed = random__long2str(pload(int))
game.random = constructRandom(initial_seed)
state = pload()
game.random.setstate(state)
if not (isinstance(game.random, random2.Random) and
isinstance(state, int)):
game.random.setstate(state)
# if not hasattr(game.random, "origin"):
# game.random.origin = game.random.ORIGIN_UNKNOWN
game.loadinfo.stacks = []
@ -3215,9 +3221,9 @@ class Game(object):
game.loadinfo.talon_round = pload()
game.finished = pload()
if 0 <= bookmark <= 1:
saveinfo = pload(Struct)
saveinfo = pload(GameSaveInfo)
game.saveinfo.__dict__.update(saveinfo.__dict__)
gsaveinfo = pload(Struct)
gsaveinfo = pload(GameGlobalSaveInfo)
game.gsaveinfo.__dict__.update(gsaveinfo.__dict__)
moves = pload(GameMoves)
game.moves.__dict__.update(moves.__dict__)

View file

@ -82,8 +82,10 @@ class Pyramid_StackMethods:
def _dropPairMove(self, n, other_stack, frames=-1, shadow=-1):
if not self.game.demo:
self.game.playSample("droppair", priority=200)
assert n == 1 and self.acceptsCards(
other_stack, [other_stack.cards[-1]])
if not (n == 1
and other_stack.cards
and self.acceptsCards(other_stack, [other_stack.cards[-1]])):
return
old_state = self.game.enterState(self.game.S_FILL)
f = self.game.s.foundations[0]
self.game.moveMove(n, self, f, frames=frames, shadow=shadow)

View file

@ -2935,9 +2935,10 @@ class FaceUpWasteTalonStack(WasteTalonStack):
self.game.fillStack(self)
def dealCards(self, sound=False):
WasteTalonStack.dealCards(self, sound=sound)
retval = WasteTalonStack.dealCards(self, sound=sound)
if self.canFlipCard():
self.flipMove()
return retval
class OpenTalonStack(TalonStack, OpenStack):

View file

@ -156,7 +156,7 @@ class PysolStatusbar(MfxStatusbar):
self._createLabel(n, tooltip=t, width=w)
#
label = self._createLabel('info', expand=True)
label.config(padding=(8, 0))
label.config(padx=8)
class HelpStatusbar(MfxStatusbar):

View file

@ -25,11 +25,6 @@ from pysollib.macosx.appSupport import hideTkConsole
from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.winsystems.common import BaseTkSettings, base_init_root_window
from six.moves import tkinter
if USE_TILE:
from pysollib.tile import ttk
def init_root_window(root, app):
base_init_root_window(root, app)
@ -38,15 +33,7 @@ def init_root_window(root, app):
if TOOLKIT == 'gtk':
pass
elif USE_TILE:
style = ttk.Style(root)
color = style.lookup('.', 'background')
if color:
root.tk_setPalette(color) # for non-ttk widgets
if app.opt.tile_theme == 'aqua':
# standard Tk scrollbars work on OS X, but ttk ones look weird
ttk.Scrollbar = tkinter.Scrollbar
pass
else: # pure Tk
# root.option_add(...)
pass