mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Scoring option for Ishido.
This commit is contained in:
parent
9db799f330
commit
10af041972
3 changed files with 139 additions and 4 deletions
36
html-src/rules/ishidoscored.html
Normal file
36
html-src/rules/ishidoscored.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
<h1>Ishido Scored</h1>
|
||||
<p>
|
||||
Ishido game type. 2 decks. No redeal.
|
||||
|
||||
<h3>Object</h3>
|
||||
<p>
|
||||
Move all tiles to the playing area, and get the highest score possible.
|
||||
|
||||
<h3>Quick Description</h3>
|
||||
<p>
|
||||
Like <a href='ishido.html'>Ishido</a>, but with scoring. Scoring works
|
||||
as follows:
|
||||
<ul>
|
||||
<li>Each tile placed on the board scores depending on the number of adjacent
|
||||
tiles. Tiles placed on the edge of the play area do not score:
|
||||
<ul>
|
||||
<li>One adjacent tile: 1 point
|
||||
<li>Two adjacent tiles: 2 points
|
||||
<li>Three adjacent tiles: 4 points
|
||||
<li>Four adjacent tiles: 8 points
|
||||
</ul>
|
||||
<li>A bonus of 25 points is scored each time a tile is placed next to four
|
||||
adjacent tiles, forming a four-way match.
|
||||
<li>After each four-way match is formed, the aforementioned scoring is doubled
|
||||
for the rest of the game.
|
||||
<li>At the end of the game, an additional bonus is given when there are only
|
||||
a few tiles left to place - only the highest of these bonuses is received:
|
||||
<ul>
|
||||
<li>Two tiles left: 100 points
|
||||
<li>One tile left: 500 points
|
||||
<li>No tiles left: 1000 points
|
||||
</ul>
|
||||
</ul>
|
||||
<p>With this scoring system, it is possible to gain higher scores without
|
||||
successfully placing all the tiles than you can earn by placing the tiles.
|
||||
Try and get the highest score possible.
|
|
@ -593,7 +593,7 @@ class GI:
|
|||
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
|
||||
tuple(range(13160, 13163)) + (16682,)),
|
||||
('dev', tuple(range(906, 936)) + tuple(range(11017, 11020)) +
|
||||
tuple(range(5600, 5624)) + tuple(range(18000, 18004)) +
|
||||
tuple(range(5600, 5624)) + tuple(range(18000, 18005)) +
|
||||
tuple(range(22303, 22311)) + tuple(range(22353, 22361))),
|
||||
)
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
from pysollib.game import Game
|
||||
from pysollib.gamedb import GI, GameInfo, registerGame
|
||||
from pysollib.layout import Layout
|
||||
from pysollib.mygettext import _
|
||||
from pysollib.pysoltk import MfxCanvasText
|
||||
from pysollib.stack import \
|
||||
OpenTalonStack, \
|
||||
ReserveStack, \
|
||||
|
@ -55,13 +57,28 @@ class Ishido_RowStack(ReserveStack):
|
|||
return False
|
||||
|
||||
|
||||
class Ishido_Talon(OpenTalonStack):
|
||||
|
||||
def moveMove(self, ncards, to_stack, frames=-1, shadow=-1):
|
||||
if self.game.SCORING:
|
||||
game = self.game
|
||||
old_state = game.enterState(game.S_FILL)
|
||||
game.saveStateMove(2 | 16) # for undo
|
||||
game.updateScore(to_stack.id)
|
||||
game.saveStateMove(1 | 16) # for redo
|
||||
game.leaveState(old_state)
|
||||
OpenTalonStack.moveMove(self, ncards, to_stack, frames=frames,
|
||||
shadow=shadow)
|
||||
|
||||
|
||||
class Ishido(Game):
|
||||
Talon_Class = OpenTalonStack
|
||||
Talon_Class = Ishido_Talon
|
||||
RowStack_Class = StackWrapper(Ishido_RowStack, max_move=0)
|
||||
Hint_Class = None
|
||||
|
||||
REQUIRE_ADJACENT = True
|
||||
STRICT_FOUR_WAYS = True
|
||||
SCORING = False
|
||||
|
||||
#
|
||||
# game layout
|
||||
|
@ -71,6 +88,9 @@ class Ishido(Game):
|
|||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
|
||||
self.score = 0
|
||||
self.fourways = 0
|
||||
|
||||
ta = "ss"
|
||||
x, y = l.XM, l.YM + 2 * l.YS
|
||||
|
||||
|
@ -89,11 +109,21 @@ class Ishido(Game):
|
|||
s.talon = self.Talon_Class(l.XM, l.YM, self)
|
||||
l.createText(s.talon, anchor=ta)
|
||||
|
||||
# create text
|
||||
x, y = l.XM, h - l.YM
|
||||
if self.preview <= 1:
|
||||
self.texts.score = MfxCanvasText(
|
||||
self.canvas, x, y, anchor="sw",
|
||||
font=self.app.getFont("canvas_large"))
|
||||
x = self.texts.score.bbox()[1][0] + 16
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
return l
|
||||
|
||||
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[11], frames=0)
|
||||
|
@ -155,6 +185,69 @@ class Ishido(Game):
|
|||
|
||||
return True
|
||||
|
||||
def updateScore(self, playSpace):
|
||||
if len(self.s.talon.cards) == 3:
|
||||
self.score += 100
|
||||
elif len(self.s.talon.cards) == 2:
|
||||
self.score += 400
|
||||
elif len(self.s.talon.cards) == 1:
|
||||
self.score += 500
|
||||
|
||||
if playSpace % 12 in (0, 11):
|
||||
return 0
|
||||
|
||||
if playSpace + 12 > 96 or playSpace - 12 < -1:
|
||||
return 0
|
||||
|
||||
adjacentPiles = self.getAdjacent(playSpace)
|
||||
adjacent = 0
|
||||
for pile in adjacentPiles:
|
||||
if len(pile.cards) > 0:
|
||||
adjacent += 1
|
||||
if adjacent >= 4:
|
||||
movescore = 8 + 25
|
||||
elif adjacent == 3:
|
||||
movescore = 4
|
||||
else:
|
||||
movescore = adjacent
|
||||
|
||||
movescore *= (1 + self.fourways)
|
||||
|
||||
if adjacent >= 4:
|
||||
self.fourways += 1
|
||||
|
||||
self.score += movescore
|
||||
|
||||
def updateText(self):
|
||||
if self.preview > 1 or not self.texts.score or not self.SCORING:
|
||||
return
|
||||
t = _("Points: %d") % self.score
|
||||
self.texts.score.config(text=t)
|
||||
|
||||
def getGameScore(self):
|
||||
return self.score
|
||||
|
||||
def _restoreGameHook(self, game):
|
||||
self.score = game.loadinfo.score
|
||||
self.fourways = game.loadinfo.fourways
|
||||
|
||||
def _loadGameHook(self, p):
|
||||
self.loadinfo.addattr(score=p.load())
|
||||
self.loadinfo.addattr(fourways=p.load())
|
||||
|
||||
def _saveGameHook(self, p):
|
||||
p.dump(self.score)
|
||||
p.dump(self.fourways)
|
||||
|
||||
def setState(self, state):
|
||||
# restore saved vars (from undo/redo)
|
||||
self.score = state[0]
|
||||
self.fourways = state[1]
|
||||
|
||||
def getState(self):
|
||||
# save vars (for undo/redo)
|
||||
return [self.score, self.fourways]
|
||||
|
||||
def getAdjacent(self, playSpace):
|
||||
adjacentRows = []
|
||||
if playSpace % 12 != 11:
|
||||
|
@ -185,8 +278,12 @@ class FreeIshidoRelaxed(Ishido):
|
|||
REQUIRE_ADJACENT = False
|
||||
|
||||
|
||||
def r(id, gameclass, name, decks, redeals, skill_level):
|
||||
game_type = GI.GT_ISHIDO
|
||||
class IshidoScored(Ishido):
|
||||
SCORING = True
|
||||
|
||||
|
||||
def r(id, gameclass, name, decks, redeals, skill_level,
|
||||
game_type=GI.GT_ISHIDO):
|
||||
gi = GameInfo(id, gameclass, name, game_type, decks, redeals, skill_level,
|
||||
ranks=list(range(6)), suits=list(range(6)),
|
||||
category=GI.GC_ISHIDO)
|
||||
|
@ -198,3 +295,5 @@ r(18000, Ishido, 'Ishido', 2, 0, GI.SL_MOSTLY_SKILL)
|
|||
r(18001, IshidoRelaxed, 'Ishido Relaxed', 2, 0, GI.SL_MOSTLY_SKILL)
|
||||
r(18002, FreeIshido, 'Free Ishido', 2, 0, GI.SL_MOSTLY_SKILL)
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue