mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
102 lines
2.3 KiB
Python
102 lines
2.3 KiB
Python
# 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)
|