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

Compare commits

...

4 commits

Author SHA1 Message Date
Joe R
b951d86579 Added Nines game. 2024-06-11 20:01:26 -04:00
Joe R
a189d42328 Fixed incompatibility error with string types on older versions of Python. 2024-06-11 17:48:13 -04:00
Shlomi Fish
abd95b8887
Update the cardsets’ package version to 3.0. (#368)
This is the latest release.
2024-06-09 14:30:37 -04:00
Joe R
90ffaeb2d1 Fixed resetting of cardset on cancelling select game. 2024-06-07 19:11:23 -04:00
7 changed files with 78 additions and 7 deletions

View file

@ -97,10 +97,10 @@ cd PySolFC
gmake test
gmake rules
ln -s data/images images
tar -xvf PySolFC-Cardsets-2.0.tar.bz2 # Needs to be downloaded from sourceforge
tar -xvf PySolFC-Cardsets-3.0.tar.bz2 # Needs to be downloaded from sourceforge
mkdir -p ~/.PySolFC
rmdir ~/.PySolFC/cardsets
ln -s "`pwd`/PySolFC-Cardsets-2.0" ~/.PySolFC/cardsets
ln -s "`pwd`/PySolFC-Cardsets-3.0" ~/.PySolFC/cardsets
python pysol.py
```

18
html-src/rules/nines.html Normal file
View file

@ -0,0 +1,18 @@
<h1>Tens</h1>
<p>
Pairing game type. 1 deck. No redeal.
<h3>Object</h3>
<p>
Move all cards to the single foundation.
<h3>Quick Description</h3>
<p>
Like <a href="tens.html">Tens</a>,
but cards are paired off that total nine, with nines removed
singly. Cards from 10 through King are removed in a sequence
of one of each.
<h3>Notes</h3>
<p>
<i>Autodrop</i> is disabled for this game.

View file

@ -604,6 +604,7 @@ class GI:
tuple(range(13168, 13170)) + tuple(range(18000, 18005)) +
tuple(range(19000, 19012)) + tuple(range(22303, 22311)) +
tuple(range(22353, 22361))),
('dev', tuple(range(961, 962))),
)
# deprecated - the correct way is to or a GI.GT_XXX flag

View file

@ -669,6 +669,7 @@ class SuitElevens(Elevens):
# ************************************************************************
# * Tens
# * Nines
# ************************************************************************
class Tens_RowStack(Elevens_RowStack):
@ -698,6 +699,50 @@ class Tens(ElevensToo):
Elevens.createGame(self, rows=2, cols=7, maxpiles=13, reserves=4)
class Nines_RowStack(Elevens_RowStack):
ACCEPTED_SUM = 7
def clickHandler(self, event):
if not self.cards:
return 0
c = self.cards[-1]
if c.face_up and c.rank == 8 and not self.basicIsBlocked():
self.game.playSample("autodrop", priority=20)
self.playMoveMove(1, self.game.s.foundations[0], sound=False)
return 1
return OpenStack.clickHandler(self, event)
class Nines_Reserve(Tens_Reserve):
def acceptsCards(self, from_stack, cards):
if not ReserveStack.acceptsCards(self, from_stack, cards):
return False
c = cards[0]
if c.rank not in self.ACCEPTED_CARDS:
return False
for s in self.game.s.reserves:
if s.cards and s.cards[0].rank == c.rank:
return False
return True
class Nines_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if cards[0].rank == 8:
return True
# We accept any nine. Pairs will get delivered by _dropPairMove.
return AbstractFoundationStack.acceptsCards(self, from_stack, cards)
class Nines(Tens):
RowStack_Class = Nines_RowStack
Reserve_Class = Nines_Reserve
Foundation_Class = Nines_Foundation
def createGame(self):
Elevens.createGame(self, rows=3, cols=3, reserves=4)
# ************************************************************************
# * The Lucky Number
# ************************************************************************
@ -1829,3 +1874,5 @@ registerGame(GameInfo(937, TheLuckyNumber, "The Lucky Number",
registerGame(GameInfo(950, Eighteens, "Eighteens",
GI.GT_PAIRING_TYPE, 2, 0, GI.SL_MOSTLY_LUCK,
altnames=("Steel Wheels",)))
registerGame(GameInfo(961, Nines, "Nines",
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_LUCK))

View file

@ -330,7 +330,10 @@ class SelectGameDialog(MfxDialog):
self.tree.n_expansions = 1 # save xyview in any case
if button == 1: # Cancel button
# If the user cancels, revert any cardset change from the preview.
self.app.cardset = self.cardset
if self.app.cardset.name != self.cardset.name:
self.app.loadCardset(self.cardset,
id=self.game.gameinfo.category,
tocache=True, noprogress=True)
if button == 10: # Rules
doc = self.app.getGameRulesFilename(self.tree.selection_key)
if not doc:

View file

@ -37,6 +37,8 @@ from pysollib.mfxutil import Image
from pysollib.mygettext import _
from pysollib.settings import DATA_DIRS, TOOLKIT
import six
# ************************************************************************
# * constants
# ************************************************************************
@ -149,8 +151,8 @@ class DataLoader:
def __findFile(self, func, filename, subdirs=None, do_raise=1):
if subdirs is None:
subdirs = ("",)
elif isinstance(subdirs, str):
subdirs = (subdirs,)
elif isinstance(subdirs, six.string_types):
subdirs = (str(subdirs),)
for dir in subdirs:
f = os.path.join(self.dir, dir, filename)
f = os.path.normpath(f)

View file

@ -36,14 +36,14 @@ def main():
if not os.path.exists(dot_pysol):
os.mkdir(dot_pysol)
if not os.path.exists(dot_pysol_cardsets):
cardsets_dir = "PySolFC-Cardsets-2.1"
cardsets_dir = "PySolFC-Cardsets-3.0"
if not os.path.exists(cardsets_dir):
arc = cardsets_dir + ".tar.gz"
if not os.path.exists(arc):
subprocess.check_call([
"wget",
"https://github.com/shlomif/" +
"PySolFC-Cardsets/archive/2.1/" + arc
"PySolFC-Cardsets/archive/3.0/" + arc
])
subprocess.check_call(["tar", "-xvf", arc])
os.symlink(os.getcwd() + "/" + cardsets_dir, dot_pysol_cardsets, )