File size: 2,407 Bytes
bb3fbf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import numpy as np
from pytest_bdd import given, scenario, then, when

from engine.models.ability import Condition, ConditionType
from engine.models.card import MemberCard
from engine.models.enums import Group


@scenario("../features/conditions.feature", "Group Filter Condition")
def test_group_filter():
    pass


@scenario("../features/conditions.feature", "Cost Check Condition")
def test_cost_check():
    pass


@scenario("../features/conditions.feature", "Opponent Has Member Condition")
def test_opponent_has():
    pass


@given('a condition requiring group "Aqours"', target_fixture="cond")
def cond_group():
    return Condition(ConditionType.GROUP_FILTER, {"group": "Aqours"})


@given('a member card of group "Aqours"', target_fixture="context")
def member_aqours(game_state):
    m = MemberCard(
        1, "A1", "Aq", 1, np.zeros(7, dtype=int), np.zeros(7, dtype=int), 1, groups=[Group.from_japanese_name("Aqours")]
    )
    game_state.member_db[1] = m
    return {"card_id": 1}


@when("the condition is checked for the member", target_fixture="result")
def check_condition_member(game_state, cond, context):
    p0 = game_state.players[0]
    return game_state._check_condition(p0, cond, context=context)


@then("the result should be True")
def check_true(result):
    assert result is True


@given("a condition requiring cost LE 3", target_fixture="cond")
def cond_cost_le():
    return Condition(ConditionType.COST_CHECK, {"value": 3, "comparison": "LE"})


@given("a member card with cost 3", target_fixture="context")
def member_cost_3(game_state):
    m = MemberCard(2, "C3", "Cost3", 3, np.zeros(7, dtype=int), np.zeros(7, dtype=int), 1)
    game_state.member_db[2] = m
    return {"card_id": 2}


@given("a condition requiring opponent to have a member", target_fixture="cond")
def cond_opponent_has():
    return Condition(ConditionType.OPPONENT_HAS)


@given("the opponent has a member on stage")
def opponent_has_stage(game_state):
    p1 = game_state.players[1]
    m = MemberCard(100, "O1", "Opp", 1, np.zeros(7, dtype=int), np.zeros(7, dtype=int), 1)
    game_state.member_db[100] = m
    p1.stage[0] = 100


@when("the condition is checked", target_fixture="result")
def check_condition_general(game_state, cond):
    p0 = game_state.players[0]
    return game_state._check_condition(p0, cond)