1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Fix exception in the Wasp variant.

See https://sourceforge.net/p/pysolfc/bugs/31/ .

unable to move cards in py3.
This commit is contained in:
Shlomi Fish 2018-10-08 23:19:59 +03:00
parent 8d208f8ed6
commit b142366595
4 changed files with 105 additions and 1 deletions

View file

@ -329,7 +329,7 @@ class Rachel(pysollib.game.StartDealRowAndCards, RelaxedSpider):
# * Scorpion Tail - building down by alternate color # * Scorpion Tail - building down by alternate color
# ************************************************************************ # ************************************************************************
class Scorpion_RowStack(Yukon_SS_RowStack, Spider_RowStack): class Scorpion_RowStack(Spider_RowStack, Yukon_SS_RowStack):
canDropCards = Spider_RowStack.canDropCards canDropCards = Spider_RowStack.canDropCards

View file

@ -2423,6 +2423,7 @@ class SequenceStack_StackMethods:
return self._isSequence(cards) return self._isSequence(cards)
def _isMoveableSequence(self, cards): def _isMoveableSequence(self, cards):
# import pdb; pdb.set_trace()
return self._isSequence(cards) return self._isSequence(cards)
def acceptsCards(self, from_stack, cards): def acceptsCards(self, from_stack, cards):

View file

@ -219,6 +219,7 @@ for ver in [2, 3]:
'pysol_tests.import_file1', 'pysol_tests.import_file1',
'pysol_tests.latin1_conv_unit', 'pysol_tests.latin1_conv_unit',
'pysol_tests.ms_deals1', 'pysol_tests.ms_deals1',
'pysol_tests.scorpion_canMove',
]: ]:
open(os.path.join(".", "tests", "unit-generated", open(os.path.join(".", "tests", "unit-generated",
'test__%s__v%d.py' % (mod, ver) 'test__%s__v%d.py' % (mod, ver)

View file

@ -0,0 +1,102 @@
# Written by Shlomi Fish, under the MIT Expat License.
import unittest
from pysollib.acard import AbstractCard
import pysollib.stack
from pysollib.games.spider import Scorpion_RowStack
class MockItem:
def __init__(self):
pass
def tkraise(self):
return
def addtag(self, nouse):
return
class MockCanvas:
def __init__(self):
self.xmargin = self.ymargin = 50
class MockImages:
def __init__(self):
self.CARDW = self.CARDH = self.CARD_YOFFSET = 50
class MockOpt:
def __init__(self):
self.randomize_place = False
class MockApp:
def __init__(self):
self.images = MockImages()
self.opt = MockOpt()
class MockTalon:
def __init__(self, g):
self.cards = [
AbstractCard(1000+r*100+s*10, 0, s, r, g)
for s in range(4) for r in range(13)]
for c in self.cards:
c.item = MockItem()
class MockGame:
def __init__(self):
self.app = MockApp()
self.talon = MockTalon(self)
self.allstacks = []
self.stackmap = {}
self.canvas = MockCanvas()
self.foundations = [
pysollib.stack.SS_FoundationStack(0, 0, self, s) for s in range(4)]
self.rows = [pysollib.stack.Yukon_SS_RowStack(0, 0, self)
for s in range(8)]
self.reserves = [
pysollib.stack.Yukon_SS_RowStack(0, 0, self) for s in range(4)]
self.preview = 0
def _empty_override(*args):
return True
pysollib.stack.MfxCanvasGroup = _empty_override
class Mock_S_Game:
def __init__(self):
self.s = MockGame()
def flipMove(self, foo):
pass
def moveMove(self, cnt, frm, to, frames=0):
c = frm.cards.pop()
c.face_up = True
to.addCard(c)
pass
class MyTests(unittest.TestCase):
def test_import(self):
g = MockGame()
stack = Scorpion_RowStack(0, 0, g)
cards = [
AbstractCard(1000+r*100+s*10, 0, s, r, g)
for s, r in [(2, 5), (3, 7), (2, 7), (2, 0),
(2, 3), (2, 4), (1, 4)]
]
for c in cards:
c.face_up = True
c.item = MockItem()
stack.addCard(c)
stack.canMoveCards(stack.cards[6:])
self.assertTrue(stack)