Skip to content

Commit

Permalink
Add Little Ishido game
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Jan 25, 2025
1 parent 6006e0f commit 6852bb4
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 12 deletions.
12 changes: 12 additions & 0 deletions html-src/rules/littleishido.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h1>Little Ishido</h1>
<p>
Ishido game type. 2 decks. No redeal.

<h3>Object</h3>
<p>
Move all tiles to the playing area.

<h3>Quick Description</h3>
<p>
Like <a href='ishido.html'>Ishido</a>, but with four colors and symbols,
and a 6X8 grid. The initial tiles are placed in the four corners only.
14 changes: 14 additions & 0 deletions html-src/rules/littleishidorelaxed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h1>Little Ishido Relaxed</h1>
<p>
Ishido game type. 2 decks. No redeal.

<h3>Object</h3>
<p>
Move all tiles to the playing area.

<h3>Quick Description</h3>
<p>
Like <a href='ishido.html'>Ishido</a>, but with four colors and symbols,
and a 6X8 grid. The initial tiles are placed in the four corners only.
Also, there are no restrictions when placing a tile next to two or more
other tiles - they just have to match the color or symbol of each.
2 changes: 1 addition & 1 deletion pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def _callback(gi, gt=game_type):
tuple(range(19000, 19012)) + tuple(range(22303, 22311)) +
tuple(range(22353, 22361))),
('fc-3.1', tuple(range(961, 971))),
('dev', tuple(range(971, 973))),
('dev', tuple(range(971, 973)) + tuple(range(18005, 18007))),
)

# deprecated - the correct way is to or a GI.GT_XXX flag
Expand Down
64 changes: 53 additions & 11 deletions pysollib/games/special/ishido.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class Ishido(Game):
STRICT_FOUR_WAYS = True
SCORING = False

COLS = 12
ROWS = 8

#
# game layout
#
Expand All @@ -115,13 +118,13 @@ def createGame(self):

w2 = max(2 * l.XS, x)
# set window
w, h = w2 + l.XM * 2 + l.CW * 12, l.YM * 2 + l.CH * 8
w, h = w2 + l.XM * 2 + l.CW * self.COLS, l.YM * 2 + l.CH * self.ROWS
self.setSize(w, h)

# Create rows
for j in range(8):
for j in range(self.ROWS):
x, y = w2 + l.XM, l.YM + l.CH * j
for i in range(12):
for i in range(self.COLS):
s.rows.append(self.RowStack_Class(x, y, self))
x = x + l.CW

Expand Down Expand Up @@ -269,17 +272,17 @@ def getState(self):

def getAdjacent(self, playSpace):
adjacentRows = []
if playSpace % 12 != 11:
if playSpace % self.COLS != self.COLS - 1:
adjacentRows.append(self.s.rows[playSpace + 1])

if playSpace % 12 != 0:
if playSpace % self.COLS != 0:
adjacentRows.append(self.s.rows[playSpace - 1])

if playSpace + 12 < 96:
adjacentRows.append(self.s.rows[playSpace + 12])
if playSpace + self.COLS < (self.COLS * self.ROWS):
adjacentRows.append(self.s.rows[playSpace + self.COLS])

if playSpace - 12 > -1:
adjacentRows.append(self.s.rows[playSpace - 12])
if playSpace - self.COLS > -1:
adjacentRows.append(self.s.rows[playSpace - self.COLS])

return adjacentRows

Expand All @@ -301,10 +304,46 @@ class IshidoScored(Ishido):
SCORING = True


class LittleIshido(Ishido):
ROWS = 6
COLS = 8

def startGame(self):
self.score = 0
self.fourways = 0
self.moveMove(1, self.s.talon, self.s.rows[0], frames=0)
self.s.rows[0].flipMove()
self.moveMove(1, self.s.talon, self.s.rows[7], frames=0)
self.s.rows[7].flipMove()
self.moveMove(1, self.s.talon, self.s.rows[40], frames=0)
self.s.rows[40].flipMove()
self.moveMove(1, self.s.talon, self.s.rows[47], frames=0)
self.s.rows[47].flipMove()
self.s.talon.fillStack()

def _shuffleHook(self, cards):
# prepare first cards
symbols = []
colors = []
topcards = []
for c in cards[:]:
if c.suit not in colors and c.rank not in symbols:
topcards.append(c)
cards.remove(c)
symbols.append(c.rank)
colors.append(c.suit)
if len(colors) >= 4 or len(symbols) >= 4:
break
return cards + topcards

class LittleIshidoRelaxed(LittleIshido):
STRICT_FOUR_WAYS = False


def r(id, gameclass, name, decks, redeals, skill_level,
game_type=GI.GT_ISHIDO):
game_type=GI.GT_ISHIDO, colors=6):
gi = GameInfo(id, gameclass, name, game_type, decks, redeals, skill_level,
ranks=list(range(6)), suits=list(range(6)),
ranks=list(range(colors)), suits=list(range(colors)),
category=GI.GC_ISHIDO)
registerGame(gi)
return gi
Expand All @@ -316,3 +355,6 @@ def r(id, gameclass, name, decks, redeals, skill_level,
r(18003, FreeIshidoRelaxed, 'Free Ishido Relaxed', 2, 0, GI.SL_MOSTLY_SKILL)
r(18004, IshidoScored, 'Ishido Scored', 2, 0, GI.SL_MOSTLY_SKILL,
game_type=GI.GT_ISHIDO | GI.GT_SCORE)
r(18005, LittleIshido, 'Little Ishido', 2, 0, GI.SL_MOSTLY_SKILL, colors=4)
r(18006, LittleIshidoRelaxed, 'Little Ishido Relaxed', 2, 0,
GI.SL_MOSTLY_SKILL, colors=4)

0 comments on commit 6852bb4

Please sign in to comment.