Exemple #1
0
def make_gc():
    class FakeCardPool:
        def cards_by_ids(self, ids):
            return map(lambda i: cards[i], ids)

        def discard(self, cards):
            pass

    class FakeActionStack:
        def pop(self):
            pass

    return GameControl(EventList(), FakeCardPool(), None, FakeActionStack())
Exemple #2
0
import core.src.card as card
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.src.player import Player

from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('duel', 1, card.SPADE),
            test_data.CardInfo('fire attack', 2, card.HEART),
            test_data.CardInfo('slash', 3, card.DIAMOND),
            test_data.CardInfo('duel', 4, card.SPADE),

            test_data.CardInfo('slash', 5, card.CLUB),
            test_data.CardInfo('fire attack', 6, card.HEART),
            test_data.CardInfo('dodge', 7, card.DIAMOND),
            test_data.CardInfo('slash', 8, card.DIAMOND),

            test_data.CardInfo('duel', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),
     ])), pc, ActionStack())
players = [Player(91, 4), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()

last_event_id = len(gc.get_events(players[0].token, 0)) # until getting cards

# cards:
# name        | rank (id = rank - 1) | suit
Exemple #3
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('-chitu', 5, card.HEART),
            test_data.CardInfo('-dawan', 13, card.SPADE),
            test_data.CardInfo('+jueying', 5, card.SPADE),
            test_data.CardInfo('slash', 1, card.CLUB),

            test_data.CardInfo('steal', 7, card.CLUB),
            test_data.CardInfo('duel', 8, card.DIAMOND),
            test_data.CardInfo('-zixing', 13, card.DIAMOND),
            test_data.CardInfo('+dilu', 5, card.CLUB),

            test_data.CardInfo('slash', 1, card.CLUB),
            test_data.CardInfo('slash', 1, card.CLUB),
            test_data.CardInfo('slash', 1, card.CLUB),
            test_data.CardInfo('slash', 1, card.CLUB),

            test_data.CardInfo('steal', 9, card.HEART),
            test_data.CardInfo('steal', 10, card.CLUB),

            test_data.CardInfo('steal', 9, card.HEART),
            test_data.CardInfo('steal', 10, card.CLUB),
     ])), pc, ActionStack())
players = [Player(19, 3), Player(91, 4), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()

last_event_id = len(gc.get_events(players[0].token, 0)) # until getting cards
Exemple #4
0
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.src.player import Player

from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards([
            test_data.CardInfo('duel', 1, card.SPADE),
            test_data.CardInfo('zhangba serpent spear', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.DIAMOND),
            test_data.CardInfo('dodge', 4, card.DIAMOND),
            test_data.CardInfo('slash', 5, card.CLUB),
            test_data.CardInfo('sabotage', 6, card.HEART),
            test_data.CardInfo('dodge', 7, card.DIAMOND),
            test_data.CardInfo('slash', 8, card.DIAMOND),
            test_data.CardInfo('duel', 9, card.SPADE),
            test_data.CardInfo('zhangba serpent spear', 10, card.HEART),
        ])), pc, ActionStack())
players = [Player(91, 4), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()

last_event_id = len(gc.get_events(players[0].token, 0))  # until getting cards

result = gc.player_act({
    'token': players[0].token,
Exemple #5
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('-chitu', 5, card.HEART),
            test_data.CardInfo('-dawan', 13, card.SPADE),
            test_data.CardInfo('+jueying', 5, card.SPADE),
            test_data.CardInfo('slash', 1, card.CLUB),

            test_data.CardInfo('-zixing', 13, card.DIAMOND),
            test_data.CardInfo('+dilu', 5, card.CLUB),
            test_data.CardInfo('+hualiu', 5, card.DIAMOND),
            test_data.CardInfo('duel', 2, card.SPADE),

            test_data.CardInfo('sabotage', 3, card.HEART),
            test_data.CardInfo('dodge', 4, card.DIAMOND),
            test_data.CardInfo('slash', 5, card.DIAMOND),
            test_data.CardInfo('slash', 6, card.SPADE),

            test_data.CardInfo('+zhuahuangfeidian', 5, card.HEART),
            test_data.CardInfo('zhangba serpent spear', 7, card.HEART),

            test_data.CardInfo('slash', 8, card.SPADE),
            test_data.CardInfo('slash', 9, card.HEART),
     ])), pc, ActionStack())
players = [Player(19, 4), Player(91, 4), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()

assert_eq(0, gc.distance_between(players[0], players[0]))