Skip to content

Commit

Permalink
Added basic, but workable, hint logic for Ishido type games.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed May 23, 2024
1 parent 66d2eab commit b64ef10
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pysollib/games/special/ishido.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from pysollib.game import Game
from pysollib.gamedb import GI, GameInfo, registerGame
from pysollib.hint import AbstractHint
from pysollib.layout import Layout
from pysollib.mygettext import _
from pysollib.pysoltk import MfxCanvasText
Expand All @@ -36,6 +37,24 @@
# ************************************************************************


class Ishido_Hint(AbstractHint):
# FIXME: no intelligence whatsoever is implemented here

def computeHints(self):
game = self.game
for r in game.s.rows:
if (not r.cards and
game.isValidPlay(r.id,
game.s.talon.getCard().rank,
game.s.talon.getCard().suit)):
adjacentPiles = game.getAdjacent(r.id)
adjacent = 0
for pile in adjacentPiles:
if len(pile.cards) > 0:
adjacent += 1
self.addHint(100 * adjacent, 1, game.s.talon, r)


class Ishido_RowStack(ReserveStack):
def clickHandler(self, event):
if (not self.cards and self.game.s.talon.cards and
Expand Down Expand Up @@ -74,7 +93,7 @@ def moveMove(self, ncards, to_stack, frames=-1, shadow=-1):
class Ishido(Game):
Talon_Class = Ishido_Talon
RowStack_Class = StackWrapper(Ishido_RowStack, max_move=0)
Hint_Class = None
Hint_Class = Ishido_Hint

REQUIRE_ADJACENT = True
STRICT_FOUR_WAYS = True
Expand Down

0 comments on commit b64ef10

Please sign in to comment.