mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Fix spider illegal moves canMove bug.
See https://sourceforge.net/p/pysolfc/bugs/36/ . TODO: add tests.
This commit is contained in:
parent
91e5cdafa3
commit
d3b1674a47
3 changed files with 18 additions and 2 deletions
|
@ -326,6 +326,7 @@ class Rachel(pysollib.game.StartDealRowAndCards, RelaxedSpider):
|
|||
|
||||
class Scorpion_RowStack(Yukon_SS_RowStack, Spider_RowStack):
|
||||
canDropCards = Spider_RowStack.canDropCards
|
||||
canMoveCards = OpenStack.canMoveCards
|
||||
|
||||
|
||||
class Scorpion(RelaxedSpider):
|
||||
|
|
|
@ -2473,7 +2473,7 @@ class BasicRowStack(OpenStack):
|
|||
|
||||
# Abstract class.
|
||||
class SequenceRowStack(SequenceStack_StackMethods, BasicRowStack):
|
||||
canMoveCards = OpenStack.canMoveCards
|
||||
# canMoveCards = OpenStack.canMoveCards
|
||||
|
||||
def __init__(self, x, y, game, **cap):
|
||||
kwdefault(cap, max_move=999999, max_accept=999999)
|
||||
|
|
|
@ -6,7 +6,7 @@ from pysol_tests.common_mocks1 import MockApp, MockCanvas, MockItem, MockTalon
|
|||
|
||||
import pysollib.stack
|
||||
from pysollib.acard import AbstractCard
|
||||
from pysollib.games.spider import Scorpion_RowStack
|
||||
from pysollib.games.spider import Scorpion_RowStack, Spider_RowStack
|
||||
|
||||
|
||||
class MockGame:
|
||||
|
@ -60,3 +60,18 @@ class MyTests(unittest.TestCase):
|
|||
stack = self._calc_Scorpion_stack()
|
||||
self.assertTrue(stack.canMoveCards(stack.cards[4:]))
|
||||
self.assertTrue(stack)
|
||||
|
||||
def _calc_Spider_stack(self):
|
||||
g = MockGame()
|
||||
stack = Spider_RowStack(0, 0, g)
|
||||
for s, r in [(2, 5), (3, 7), (2, 7), (2, 0), (2, 3), (2, 5), (1, 4)]:
|
||||
c = AbstractCard(1000+r*100+s*10, 0, s, r, g)
|
||||
c.face_up = True
|
||||
c.item = MockItem()
|
||||
stack.addCard(c)
|
||||
return stack
|
||||
|
||||
def test_Spider_canMoveCards_non_top(self):
|
||||
stack = self._calc_Spider_stack()
|
||||
self.assertFalse(stack.canMoveCards(stack.cards[5:]))
|
||||
self.assertTrue(stack)
|
||||
|
|
Loading…
Add table
Reference in a new issue