Skip to content

Commit

Permalink
Added Ninety-One game.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Mar 16, 2024
1 parent d3a4548 commit 713f498
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 2 deletions.
23 changes: 23 additions & 0 deletions html-src/rules/ninetyone.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h1>Ninety-One</h1>
<p>
One-Deck game type. 1 deck. No redeal.

<h3>Object</h3>
<p>
Remove all the cards.

<h3>Rules</h3>
<p>
The deck is dealt evenly to thirteen piles. Single cards may be moved
between piles without restriction. If the total rank of the top cards
of all thirteen piles totals 91 (kings are 13, queens are 12, jacks
are 11), those cards are removed.
<p>
The game is won if you can remove all cards in four groups of 91.

<h3>Notes</h3>
<p>
<i>Autodrop</i> is disabled for this game.
<p>
The ranks of a full sequence of cards, from ace to king, will total 91.
But there are other possible sequences too.
3 changes: 3 additions & 0 deletions po/de_pysol.po
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ msgstr[1] "%d Wiederholungen"
msgid "Talon."
msgstr "Talon."

msgid "Reserve."
msgstr "Reserve."

#: pysollib/stack.py:2228 pysollib/stack.py:2992
msgid "Reserve. No building."
msgstr "Reserve. Nicht aufgebaut."
Expand Down
3 changes: 3 additions & 0 deletions po/fr_pysol.po
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,9 @@ msgstr[1] "%d donnes"
msgid "Talon."
msgstr "Talon."

msgid "Reserve."
msgstr "Réserve."

#: pysollib/stack.py:2228 pysollib/stack.py:2992
msgid "Reserve. No building."
msgstr "Réserve. Aucun empilement."
Expand Down
3 changes: 3 additions & 0 deletions po/it_pysol.po
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,9 @@ msgstr ""
"Tableau: Decrescente per colore. Sequenze di carte dello stesso seme possono "
"essere spostate in gruppo"

msgid "Reserve."
msgstr "Riserva."

#: pysollib/games/klondike.py:461
msgid "Reserve. Only Kings are acceptable."
msgstr "Riserva. Accetta solo i Re"
Expand Down
3 changes: 3 additions & 0 deletions po/pl_pysol.po
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,9 @@ msgstr[2] "%d rozdań"
msgid "Talon."
msgstr "Stos wyjściowy."

msgid "Reserve."
msgstr "Stos rezerwowy."

#: pysollib/stack.py:2228 pysollib/stack.py:2992
msgid "Reserve. No building."
msgstr "Stos rezerwowy. Nie układaj."
Expand Down
3 changes: 3 additions & 0 deletions po/pt_BR_pysol.po
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,9 @@ msgstr[1] "%d redistribuições"
msgid "Talon."
msgstr "Monte"

msgid "Reserve."
msgstr "Reservar."

#: pysollib/stack.py:2228 pysollib/stack.py:2992
msgid "Reserve. No building."
msgstr "Reservar. Sem construção."
Expand Down
3 changes: 3 additions & 0 deletions po/pysol.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,9 @@ msgid ""
"moved as a unit."
msgstr ""

msgid "Reserve."
msgstr ""

#: pysollib/games/klondike.py:461
msgid "Reserve. Only Kings are acceptable."
msgstr ""
Expand Down
3 changes: 3 additions & 0 deletions po/ru_pysol.po
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,9 @@ msgstr[2] "%d пересдач"
msgid "Talon."
msgstr "Колода."

msgid "Reserve."
msgstr "Резерв."

#: pysollib/stack.py:2228 pysollib/stack.py:2992
msgid "Reserve. No building."
msgstr "Резерв. Без выкладывания."
Expand Down
2 changes: 1 addition & 1 deletion pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def _callback(gi, gt=game_type):
('fc-2.20', tuple(range(855, 897))),
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
tuple(range(13160, 13163)) + (16682,)),
('dev', tuple(range(906, 958)) + tuple(range(11017, 11020)) +
('dev', tuple(range(906, 959)) + tuple(range(11017, 11020)) +
tuple(range(5600, 5624)) + tuple(range(18000, 18005)) +
tuple(range(19000, 19012)) + tuple(range(22303, 22311)) +
tuple(range(22353, 22361))),
Expand Down
90 changes: 90 additions & 0 deletions pysollib/games/numerica.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from pysollib.pysoltk import MfxCanvasText
from pysollib.stack import \
AC_RowStack, \
AbstractFoundationStack, \
BasicRowStack, \
DealRowTalonStack, \
InitialDealTalonStack, \
Expand Down Expand Up @@ -1313,6 +1314,93 @@ def startGame(self):
self.s.talon.dealRow(rows=self.s.rows)


# ************************************************************************
# * Ninety-One
# ************************************************************************

class NinetyOne_RowStack(OpenStack):

def moveMove(self, ncards, to_stack, frames=-1, shadow=-1):
OpenStack.moveMove(self, ncards, to_stack, frames=frames,
shadow=shadow)
if to_stack in self.game.s.rows:
self.game.checkTotal()


class NinetyOne(Game):
Hint_Class = None

def createGame(self):
# create layout
l, s = Layout(self), self.s

self.setSize(l.XM + 7 * l.XS, l.YM + 2 * l.YS)

x, y = l.XM, l.YM
# create stacks
for j in range(7):
s.rows.append(NinetyOne_RowStack(x, y, self, max_move=1,
max_accept=1))
x += l.XS
x, y = l.XM, l.YM + l.YS
for j in range(6):
s.rows.append(NinetyOne_RowStack(x, y, self, max_move=1,
max_accept=1))
x += l.XS

# create text
if self.preview <= 1:
y += l.YS // 2
self.texts.score = MfxCanvasText(
self.canvas, x, y, anchor="sw",
font=self.app.getFont("canvas_large"))

x, y = self.getInvisibleCoords()
s.talon = InitialDealTalonStack(x, y, self)
s.foundations.append(AbstractFoundationStack(x, y, self,
max_move=0,
max_accept=0,
suit=ANY_SUIT))

# define stack-groups
l.defaultStackGroups()

def startGame(self):
for i in range(3):
self.s.talon.dealRow(frames=0)
self._startAndDealRow()

def updateText(self):
if self.preview > 1 or not self.texts.score:
return
self.texts.score.config(text=self.getTotal())

def getTotal(self):
total = 0
for r in self.s.rows:
if len(r.cards) == 0:
continue
total += r.cards[-1].rank + 1
return total

def checkTotal(self):
self.updateText()
if self.getTotal() == 91:
for r in self.s.rows:
if len(r.cards) == 0:
return
self.startDealSample()
old_state = self.enterState(self.S_FILL)
for r in self.s.rows:
r.moveMove(1, self.s.foundations[0])
self.leaveState(old_state)
self.stopSamples()
self.checkTotal()

def getAutoStacks(self, event=None):
return ((), (), ())


# register the game
registerGame(GameInfo(257, Numerica, "Numerica",
GI.GT_NUMERICA | GI.GT_CONTRIB, 1, 0, GI.SL_BALANCED,
Expand Down Expand Up @@ -1370,3 +1458,5 @@ def startGame(self):
GI.GT_NUMERICA, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(931, TheBogey, "The Bogey",
GI.GT_1DECK_TYPE, 1, -1, GI.SL_BALANCED))
registerGame(GameInfo(958, NinetyOne, "Ninety-One",
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_SKILL))
2 changes: 1 addition & 1 deletion pysollib/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,7 @@ def quickPlayHandler(self, event, from_stacks=None, to_stacks=None):
def getHelp(self):
if self.cap.max_accept == 0:
return _('Reserve. No building.')
return ''
return 'Reserve.'


# ************************************************************************
Expand Down

0 comments on commit 713f498

Please sign in to comment.