Example #1
0
def statuses_mode(players_tokens):
    if len(players_tokens) < 2:
        raise ValueError('too few players, need at least 2')
    if 8 < len(players_tokens):
        raise ValueError('too much players, need at most 8')
    random.shuffle(players_tokens)

    players = [Player(t) for t in players_tokens]
    pc = PlayersControl()
    for p in players: pc.add_player(p)

    gc = GameControl(EventList(), CardPool.create(), pc, ActionStack())
    gc.game_init(players)

    host = players[0]
    others = players[1:]
    def after_host_selected():
        gc.push_frame(_SelectCharacter(
                    gc, others,
                    { p.token: characters_select_dict(random_pick_characters(3))
                            for p in others },
                    gc.start))
    gc.push_frame(_SelectCharacter(
              gc, [host],
              { host.token: characters_select_dict(random_pick_characters(3)) },
              after_host_selected))
    return gc
Example #2
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())
Example #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
Example #4
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),

            test_data.CardInfo('rattan armor', 2, card.SPADE),
            test_data.CardInfo('fire attack', 6, card.HEART),
            test_data.CardInfo('fire attack', 7, card.HEART),
            test_data.CardInfo('duel', 8, card.HEART),

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.HEART),

            test_data.CardInfo('dodge', 13, card.DIAMOND),
            test_data.CardInfo('dodge', 1, card.DIAMOND),
            test_data.CardInfo('dodge', 2, card.DIAMOND),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
     ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
heavenly_scent.add_to(players[0])
gc.start()
Example #5
0
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('slash', 1, card.SPADE),
            test_data.CardInfo('fire attack', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
            test_data.CardInfo('fire attack', 4, card.HEART),
            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('dodge', 8, card.DIAMOND),
            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),
            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.DIAMOND),
        ])), 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:
Example #6
0
import core.src.card as card
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.test.fake_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('arson 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('arson 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

assert_eq({
    'code': ret_code.OK,
    'action': 'use',
Example #7
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,
from test_common import *
import test_data

players = [Player(19, 3), Player(91, 3), Player(1729, 3)]
pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('slash', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('peach', 4, card.HEART),

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

            test_data.CardInfo('peach', 9, card.HEART),
            test_data.CardInfo('peach', 10, card.HEART),
            test_data.CardInfo('peach', 11, card.HEART),
            test_data.CardInfo('peach', 12, card.HEART),

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

            test_data.CardInfo('dodge', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.HEART),
     ])), pc, ActionStack())
map(lambda p: pc.add_player(p), players)
gc.start()

# cards:
# name         | rank | id | suit
Example #9
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),

            test_data.CardInfo('rattan armor', 2, card.SPADE),
            test_data.CardInfo('arson attack', 6, card.HEART),
            test_data.CardInfo('arson attack', 7, card.HEART),
            test_data.CardInfo('duel', 8, card.HEART),

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.HEART),

            test_data.CardInfo('slash', 13, card.CLUB),
            test_data.CardInfo('dodge', 1, card.DIAMOND),
            test_data.CardInfo('dodge', 2, card.DIAMOND),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
     ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
heavenly_scent.add_to(players[0])
youth_beauty.add_to(players[0])
gc.start()
Example #10
0
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('slash', 1, card.SPADE),
            test_data.CardInfo('fire attack', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
            test_data.CardInfo('fire attack', 4, card.HEART),

            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('dodge', 8, card.DIAMOND),

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.DIAMOND),
     ])), 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:
Example #11
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards(
            [
                test_data.CardInfo("sabotage", 1, card.SPADE),
                test_data.CardInfo("sabotage", 2, card.SPADE),
                test_data.CardInfo("sabotage", 3, card.SPADE),
                test_data.CardInfo("sabotage", 4, card.SPADE),
                test_data.CardInfo("slash", 5, card.SPADE),
                test_data.CardInfo("dodge", 6, card.HEART),
                test_data.CardInfo("slash", 7, card.CLUB),
                test_data.CardInfo("dodge", 8, card.DIAMOND),
                test_data.CardInfo("sabotage", 9, card.HEART),
                test_data.CardInfo("sabotage", 10, card.CLUB),
            ]
        )
    ),
    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
Example #12
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('sabotage', 1, card.SPADE),
            test_data.CardInfo('sabotage', 2, card.SPADE),
            test_data.CardInfo('sabotage', 3, card.SPADE),
            test_data.CardInfo('sabotage', 4, card.SPADE),

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

            test_data.CardInfo('sabotage', 9, card.HEART),
            test_data.CardInfo('sabotage', 10, card.CLUB),
     ])), 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
Example #13
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
Example #14
0
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('rattan armor', 2, card.CLUB),
            test_data.CardInfo('rattan armor', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),
            test_data.CardInfo('steal', 5, card.CLUB),
            test_data.CardInfo('fire attack', 6, card.HEART),
            test_data.CardInfo('dodge', 7, card.HEART),
            test_data.CardInfo('duel', 8, card.HEART),
            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),
            test_data.CardInfo('fire attack', 11, card.CLUB),
            test_data.CardInfo('dodge', 12, card.HEART),
        ])), pc, ActionStack())
players = [Player(91, 8), Player(1729, 8)]
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:
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards(
            [
                test_data.CardInfo("sabotage", 1, card.SPADE),
                test_data.CardInfo("rattan armor", 2, card.SPADE),
                test_data.CardInfo("sabotage", 3, card.SPADE),
                test_data.CardInfo("sabotage", 4, card.SPADE),
                test_data.CardInfo("sabotage", 5, card.SPADE),
                test_data.CardInfo("sabotage", 6, card.HEART),
                test_data.CardInfo("sabotage", 7, card.CLUB),
                test_data.CardInfo("sabotage", 8, card.DIAMOND),
                test_data.CardInfo("sabotage", 9, card.HEART),
                test_data.CardInfo("sabotage", 10, card.CLUB),
                test_data.CardInfo("sabotage", 11, card.HEART),
                test_data.CardInfo("sabotage", 12, card.CLUB),
            ]
        )
    ),
    pc,
    ActionStack(),
)
players = [Player(91, 1), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()
Example #16
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('arson attack', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),

            test_data.CardInfo('dodge', 5, card.HEART),
            test_data.CardInfo('dodge', 6, card.HEART),
            test_data.CardInfo('dodge', 7, card.HEART),
            test_data.CardInfo('dodge', 8, card.HEART),

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.HEART),
            test_data.CardInfo('dodge', 13, card.HEART),
            test_data.CardInfo('duel', 1, card.DIAMOND),

            test_data.CardInfo('dodge', 2, card.DIAMOND),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
     ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
bequeathed_strategy.add_to(players[0])
gc.start()
Example #17
0
from ext.src.players_control import PlayersControl
from ext.test.fake_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('slash', 1, card.SPADE),
            test_data.CardInfo('arson attack', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
            test_data.CardInfo('arson attack', 4, card.HEART),

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

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.DIAMOND),
     ])), 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

assert_eq({
Example #18
0
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.test.fake_player import Player
import ext.src.skills.fury_pith as fury_pith

from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('+jueying', 5, card.SPADE),
            test_data.CardInfo('duel', 2, card.HEART),
            test_data.CardInfo('duel', 3, card.HEART),
            test_data.CardInfo('duel', 4, card.HEART),

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

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

# cards:
# name     | rank | id | suit

# +jueying | 1    | 0  | SPADE
Example #19
0
from ext.src.players_control import PlayersControl
from ext.test.fake_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('slash', 1, card.SPADE),
            test_data.CardInfo('slash', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
            test_data.CardInfo('slash', 4, card.HEART),

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

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.DIAMOND),
     ])), pc, ActionStack())
players = [Player(91, 5), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()

result = gc.player_act({
    'token': players[0].token,
    'action': 'card',
Example #20
0
import test_data

pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards([
            test_data.CardInfo('fire attack', 1, card.HEART),
            test_data.CardInfo('slash', 2, card.CLUB),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),
            test_data.CardInfo('slash', 5, card.CLUB),
            test_data.CardInfo('slash', 6, card.CLUB),
            test_data.CardInfo('slash', 7, card.CLUB),
            test_data.CardInfo('slash', 8, card.CLUB),
            test_data.CardInfo('slash', 9, card.CLUB),
            test_data.CardInfo('slash', 10, card.CLUB),
            test_data.CardInfo('slash', 11, card.CLUB),
            test_data.CardInfo('slash', 12, card.CLUB),
            test_data.CardInfo('slash', 13, card.CLUB),
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('slash', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.SPADE),
            test_data.CardInfo('slash', 4, card.SPADE),
            test_data.CardInfo('slash', 5, card.SPADE),
            test_data.CardInfo('slash', 6, card.SPADE),
            test_data.CardInfo('slash', 7, card.SPADE),
        ])), pc, ActionStack())
players = [Player(19, 1), Player(91, 1), Player(1729, 1)]
map(lambda p: pc.add_player(p), players)
gc.start()
from test_common import *
import test_data

players = [Player(19, 3), Player(91, 3), Player(1729, 3)]
pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('slash', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('peach', 4, card.HEART),

            test_data.CardInfo('slash', 5, card.HEART),
            test_data.CardInfo('arson attack', 6, card.HEART),
            test_data.CardInfo('arson attack', 7, card.HEART),
            test_data.CardInfo('peach', 8, card.HEART),

            test_data.CardInfo('peach', 9, card.HEART),
            test_data.CardInfo('peach', 10, card.HEART),
            test_data.CardInfo('peach', 11, card.HEART),
            test_data.CardInfo('peach', 12, card.HEART),

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

            test_data.CardInfo('dodge', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.HEART),
     ])), pc, ActionStack())
map(lambda p: pc.add_player(p), players)
gc.start()

# cards:
# name         | rank | id | suit
Example #22
0
from test_common import *
import test_data

players = [Player(19, 3), Player(91, 3), Player(1729, 3)]
pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards([
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('slash', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('peach', 4, card.HEART),
            test_data.CardInfo('slash', 5, card.HEART),
            test_data.CardInfo('fire attack', 6, card.HEART),
            test_data.CardInfo('fire attack', 7, card.HEART),
            test_data.CardInfo('peach', 8, card.HEART),
            test_data.CardInfo('peach', 9, card.HEART),
            test_data.CardInfo('peach', 10, card.HEART),
            test_data.CardInfo('peach', 11, card.HEART),
            test_data.CardInfo('peach', 12, card.HEART),
            test_data.CardInfo('slash', 13, card.SPADE),
            test_data.CardInfo('slash', 1, card.CLUB),
            test_data.CardInfo('dodge', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.HEART),
        ])), pc, ActionStack())
map(lambda p: pc.add_player(p), players)
gc.start()

# cards:
# name         | rank | id | suit
Example #23
0
import core.src.card as card
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.test.fake_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

assert_eq({
    'code': ret_code.OK,
    'action': 'use',
Example #24
0
from ext.src.players_control import PlayersControl
from ext.test.fake_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('rattan armor', 2, card.CLUB),
            test_data.CardInfo('rattan armor', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),

            test_data.CardInfo('steal', 5, card.CLUB),
            test_data.CardInfo('arson attack', 6, card.HEART),
            test_data.CardInfo('dodge', 7, card.HEART),
            test_data.CardInfo('duel', 8, card.HEART),

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),

            test_data.CardInfo('arson attack', 11, card.CLUB),
            test_data.CardInfo('dodge', 12, card.HEART),
     ])), pc, ActionStack())
players = [Player(91, 8), Player(1729, 8)]
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:
Example #25
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]))
from test_common import *
import test_data

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

            test_data.CardInfo('dodge', 5, card.HEART),
            test_data.CardInfo('dodge', 6, card.HEART),
            test_data.CardInfo('dodge', 7, card.HEART),
            test_data.CardInfo('dodge', 8, card.HEART),

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.HEART),
            test_data.CardInfo('dodge', 13, card.HEART),
            test_data.CardInfo('duel', 1, card.DIAMOND),

            test_data.CardInfo('dodge', 2, card.DIAMOND),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
     ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
bequeathed_strategy.add_to(players[0])
gc.start()
Example #27
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards(
            [
                test_data.CardInfo("+jueying", 5, card.SPADE),
                test_data.CardInfo("duel", 2, card.HEART),
                test_data.CardInfo("duel", 3, card.HEART),
                test_data.CardInfo("duel", 4, card.HEART),
                test_data.CardInfo("dodge", 5, card.DIAMOND),
                test_data.CardInfo("slash", 6, card.HEART),
                test_data.CardInfo("slash", 7, card.HEART),
                test_data.CardInfo("slash", 8, card.HEART),
                test_data.CardInfo("duel", 9, card.HEART),
                test_data.CardInfo("duel", 10, card.HEART),
            ]
        )
    ),
    pc,
    ActionStack(),
)
players = [Player(91, 4), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
fury_pith.add_to(players[1])
gc.start()
Example #28
0
from ext.src.players_control import PlayersControl
from ext.test.fake_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('slash', 1, card.SPADE),
            test_data.CardInfo('arson attack', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
            test_data.CardInfo('arson attack', 4, card.HEART),

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

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),

            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.DIAMOND),
     ])), pc, ActionStack())
players = [Player(91, 4), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()

# cards:
# name         | rank (id = rank - 1) | suit
Example #29
0
from test_common import *
import test_data
import fake_players_control
import fake_player

pc = fake_players_control.PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('slash', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.SPADE),
            test_data.CardInfo('slash', 4, card.SPADE),
            test_data.CardInfo('slash', 5, card.SPADE),
            test_data.CardInfo('slash', 6, card.SPADE),
            test_data.CardInfo('slash', 7, card.SPADE),
            test_data.CardInfo('slash', 8, card.SPADE),
            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),
            test_data.CardInfo('slash', 11, card.SPADE),
            test_data.CardInfo('slash', 12, card.SPADE),
            test_data.CardInfo('slash', 13, card.SPADE),
            test_data.CardInfo('dodge', 1, card.HEART),
            test_data.CardInfo('dodge', 2, card.HEART),
            test_data.CardInfo('dodge', 3, card.HEART),
            test_data.CardInfo('dodge', 4, card.HEART),
            test_data.CardInfo('dodge', 5, card.HEART),
     ])), pc, ActionStack())
players = [fake_player.Player(6), fake_player.Player(24),
           fake_player.Player(1729)]
map(lambda p: pc.add_player(p), players)
gc.start()
assert_eq(200, gc.player_act({
                                 'token': players[0].token,
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards([
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('fire attack', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),
            test_data.CardInfo('dodge', 5, card.HEART),
            test_data.CardInfo('dodge', 6, card.HEART),
            test_data.CardInfo('dodge', 7, card.HEART),
            test_data.CardInfo('dodge', 8, card.HEART),
            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),
            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.HEART),
            test_data.CardInfo('dodge', 13, card.HEART),
            test_data.CardInfo('duel', 1, card.DIAMOND),
            test_data.CardInfo('dodge', 2, card.DIAMOND),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
        ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
bequeathed_strategy.add_to(players[0])
gc.start()
Example #31
0
from ext.src.player import Player
import ext.src.skills.merciless as merciless

from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),

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

            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),

            test_data.CardInfo('dodge', 11, card.CLUB),
            test_data.CardInfo('dodge', 12, card.HEART),
     ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
merciless.add_to(players[1])
gc.start()

# cards:
# name         | rank | id | suit
Example #32
0
import core.src.card as card
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.test.fake_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('slash', 1, card.SPADE),
    test_data.CardInfo('slash', 2, card.HEART),
    test_data.CardInfo('slash', 3, card.DIAMOND),
    test_data.CardInfo('slash', 4, card.SPADE),

    test_data.CardInfo('dodge', 5, card.HEART),
    test_data.CardInfo('dodge', 6, card.HEART),
    test_data.CardInfo('dodge', 7, card.DIAMOND),
    test_data.CardInfo('dodge', 8, card.DIAMOND),

    test_data.CardInfo('slash', 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()

assert_eq({
    'code': ret_code.OK,
    'action': 'use',
    'card': {
        0: {
Example #33
0
import core.src.card as card
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.test.fake_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('vermilion feather fan', 1, card.DIAMOND),
    test_data.CardInfo('duel', 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('slash', 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('thunder slash', 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

assert_eq({
    'code': ret_code.OK,
    'action': 'use',
Example #34
0
pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('fire attack', 1, card.HEART),
            test_data.CardInfo('slash', 2, card.CLUB),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),

            test_data.CardInfo('slash', 5, card.CLUB),
            test_data.CardInfo('slash', 6, card.CLUB),
            test_data.CardInfo('slash', 7, card.CLUB),
            test_data.CardInfo('slash', 8, card.CLUB),

            test_data.CardInfo('slash', 9, card.CLUB),
            test_data.CardInfo('slash', 10, card.CLUB),
            test_data.CardInfo('slash', 11, card.CLUB),
            test_data.CardInfo('slash', 12, card.CLUB),

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

            test_data.CardInfo('slash', 2, card.SPADE),
            test_data.CardInfo('slash', 3, card.SPADE),

            test_data.CardInfo('slash', 4, card.SPADE),
            test_data.CardInfo('slash', 5, card.SPADE),

            test_data.CardInfo('slash', 6, card.SPADE),
            test_data.CardInfo('slash', 7, card.SPADE),
     ])), pc, ActionStack())
players = [Player(19, 1), Player(91, 1), Player(1729, 1)]
map(lambda p: pc.add_player(p), players)
Example #35
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
from ext.src.players_control import PlayersControl
from ext.test.fake_player import Player
import ext.src.skills.martial_saint as martial_saint
import ext.src.skills.dragon_heart as dragon_heart

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('arson attack', 2, card.HEART),
            test_data.CardInfo('slash', 3, card.CLUB),
            test_data.CardInfo('duel', 4, card.SPADE),

            test_data.CardInfo('slash', 5, card.CLUB),
            test_data.CardInfo('arson 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)
martial_saint.add_to(players[0])
dragon_heart.add_to(players[1])

gc.start()

# cards:
# name         | rank (id = rank - 1) | suit
Example #37
0
import core.src.ret_code as ret_code
from ext.src.players_control import PlayersControl
from ext.test.fake_player import Player
import ext.src.skills.surprise_raid as surprise_raid

from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(EventList(), test_data.CardPool(test_data.gen_cards([
            test_data.CardInfo('zhangba serpent spear', 12, card.SPADE),
            test_data.CardInfo('slash', 2, card.CLUB),
            test_data.CardInfo('slash', 3, card.CLUB),
            test_data.CardInfo('dodge', 4, card.DIAMOND),

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

            test_data.CardInfo('slash', 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)
surprise_raid.add_to(players[0])
gc.start()

assert_eq({
    'code': ret_code.OK,
    'action': 'use',
    'card': {
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('zhangba serpent spear', 1, card.SPADE),
            test_data.CardInfo('slash', 2, card.HEART),
            test_data.CardInfo('slash', 3, card.DIAMOND),
            test_data.CardInfo('slash', 4, card.HEART),
            test_data.CardInfo('fire attack', 5, card.CLUB),
            test_data.CardInfo('sabotage', 6, card.HEART),
            test_data.CardInfo('sabotage', 7, card.DIAMOND),
            test_data.CardInfo('sabotage', 8, card.DIAMOND),
            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.SPADE),
            test_data.CardInfo('fire attack', 11, card.HEART),
            test_data.CardInfo('sabotage', 12, card.DIAMOND),
        ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
gc.start()

result = gc.player_act({
    'token': players[0].token,
    'action': 'equip',
Example #39
0
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)
Example #40
0
from test_common import *
import test_data

pc = PlayersControl()
gc = GameControl(
    EventList(),
    test_data.CardPool(
        test_data.gen_cards([
            test_data.CardInfo('slash', 1, card.SPADE),
            test_data.CardInfo('rattan armor', 2, card.CLUB),
            test_data.CardInfo('slash', 3, card.HEART),
            test_data.CardInfo('slash', 4, card.HEART),
            test_data.CardInfo('rattan armor', 2, card.SPADE),
            test_data.CardInfo('fire attack', 6, card.HEART),
            test_data.CardInfo('fire attack', 7, card.HEART),
            test_data.CardInfo('duel', 8, card.HEART),
            test_data.CardInfo('slash', 9, card.SPADE),
            test_data.CardInfo('slash', 10, card.CLUB),
            test_data.CardInfo('dodge', 11, card.HEART),
            test_data.CardInfo('dodge', 12, card.HEART),
            test_data.CardInfo('dodge', 13, card.DIAMOND),
            test_data.CardInfo('dodge', 1, card.DIAMOND),
            test_data.CardInfo('dodge', 2, card.DIAMOND),
            test_data.CardInfo('dodge', 3, card.DIAMOND),
        ])), pc, ActionStack())
players = [Player(91, 3), Player(1729, 4)]
map(lambda p: pc.add_player(p), players)
heavenly_scent.add_to(players[0])
gc.start()