Spaces:
Sleeping
Sleeping
| from engine.game.mixins.effect_mixin import EffectMixin | |
| from engine.models.ability import Condition, ConditionType | |
| from engine.models.card import MemberCard | |
| from engine.models.enums import Group | |
| class MockGameState(EffectMixin): | |
| def __init__(self): | |
| self.member_db = {} | |
| self.live_db = {} | |
| self.turn_number = 1 | |
| self.looked_cards = [] | |
| def test_condition_turn_1(): | |
| gs = MockGameState() | |
| gs.turn_number = 1 | |
| cond = Condition(ConditionType.TURN_1, {}, 0) | |
| assert gs._check_condition(None, cond) == True | |
| gs.turn_number = 2 | |
| assert gs._check_condition(None, cond) == False | |
| def test_condition_group_filter_basic(game_state): | |
| # Using real GameState fixture for more complex setup if needed, | |
| # but Mock is faster for pure logic check. | |
| # EffectMixin relies on self.member_db/live_db | |
| gs = MockGameState() | |
| # Mock Cards | |
| # Card 1: μ's (Group 1) | |
| c1 = MemberCard(1, "1", "Honoka", 0, [0] * 7, [0] * 7, 0, [Group.MUSE], []) | |
| gs.member_db[1] = c1 | |
| # Card 2: Aqours (Group 2) | |
| c2 = MemberCard(2, "2", "Chika", 0, [0] * 7, [0] * 7, 0, [Group.AQOURS], []) | |
| gs.member_db[2] = c2 | |
| # Player Setup (Mock object) | |
| class MockPlayer: | |
| def __init__(self): | |
| self.stage = [1, 2, -1] # Honoka, Chika, Empty | |
| self.moved_members_this_turn = set() | |
| self.members_tapped_by_opponent_this_turn = set() | |
| self.discard = [] | |
| self.hand = [] | |
| self.main_deck = [] | |
| self.live_zone = [] | |
| p = MockPlayer() | |
| # Test 1: Count μ's in Stage (Should be 1) | |
| cond_muse = Condition(ConditionType.GROUP_FILTER, {"group": "μ's", "zone": "STAGE", "min": 1}, 0) | |
| assert gs._check_condition(p, cond_muse) == True | |
| cond_muse_2 = Condition(ConditionType.GROUP_FILTER, {"group": "μ's", "zone": "STAGE", "min": 2}, 0) | |
| assert gs._check_condition(p, cond_muse_2) == False | |
| # Test 2: Aqours (Should be 1) | |
| cond_aqours = Condition(ConditionType.GROUP_FILTER, {"group": "Aqours", "zone": "STAGE"}, 0) | |
| assert gs._check_condition(p, cond_aqours) == True | |
| # Test 3: Liella (Should be 0) | |
| cond_liella = Condition(ConditionType.GROUP_FILTER, {"group": "Liella!", "zone": "STAGE"}, 0) | |
| assert gs._check_condition(p, cond_liella) == False | |
| # Test 4: Context (Revealed) | |
| gs.looked_cards = [1] # Honoka | |
| cond_context = Condition(ConditionType.GROUP_FILTER, {"group": "μ's", "context": "revealed", "min": 1}, 0) | |
| assert gs._check_condition(p, cond_context) == True | |