Spaces:
Sleeping
Sleeping
File size: 4,789 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | print("STARTING SCRIPT")
from engine.game.game_state import initialize_game
from engine.models.enums import Area, Group
def test_nonfiction_ability_1_center_cost_diff():
# {{live_start.png|ライブ開始時}}自分のセンターエリアにいる『Liella!』のメンバーのコストが、相手のセンターエリアにいるメンバーより高い場合、このカードのスコアを+1する。
state = initialize_game(use_real_data=True)
p0 = state.players[0]
p1 = state.players[1]
# Setup Live Card: Nonfiction
card_no = "PL!SP-bp4-024-L"
card_id = -1
for cid, c in state.live_db.items():
if c.card_no == card_no:
card_id = cid
break
assert card_id != -1, "Card not found"
# Inject a mock high cost center for P0
p0_center_id = 9999
import numpy as np
from engine.models.card import MemberCard
# P0 Center: Liella (Group 3), Cost 5
p0_member = MemberCard(
card_id=p0_center_id,
card_no="test-p0",
name="Kanon",
cost=5,
hearts=np.zeros(7, dtype=np.int32),
blade_hearts=np.zeros(7, dtype=np.int32),
blades=1,
groups=[Group.LIELLA],
)
state.member_db[p0_center_id] = p0_member
# P1 Center: Cost 2
p1_center_id = 9998
p1_member = MemberCard(
card_id=p1_center_id,
card_no="test-p1",
name="Rival",
cost=2,
hearts=np.zeros(7, dtype=np.int32),
blade_hearts=np.zeros(7, dtype=np.int32),
blades=1,
)
state.member_db[p1_center_id] = p1_member
# Area.CENTER is 1
p0.stage[Area.CENTER] = p0_center_id
p1.stage[Area.CENTER] = p1_center_id
# Play Nonfiction to Live Zone
p0.live_zone = [card_id]
# Ability 1
ability = state.live_db[card_id].abilities[0]
# Trigger manually
print("DEBUG: Triggering Ability 1")
state.triggered_abilities.append((0, ability, {"card_id": card_id}))
state._process_rule_checks()
print("DEBUG: Finished _process_rule_checks Ability 1")
# Check if score boosted in live_score_bonus
assert p0.live_score_bonus == 1
# Case 2: Cost is Lower
p0.live_score_bonus = 0
p0_member.cost = 1
print("DEBUG: Triggering Ability 1 (Case 2)")
state.triggered_abilities.append((0, ability, {"card_id": card_id}))
state._process_rule_checks()
print("DEBUG: Finished _process_rule_checks Ability 1 (Case 2)")
# Should fail condition, no boost
assert p0.live_score_bonus == 0
def test_nonfiction_ability_2_left_side_hearts():
# {{live_start.png|ライブ開始時}}自分のステージの左サイドエリアにいる『Liella!』のメンバーが{{heart_02.png|heart02}}を3つ以上持つ場合、そのメンバーは、ライブ終了時まで、{{icon_blade.png|ブレード}}{{icon_blade.png|ブレード}}を得る。
state = initialize_game(use_real_data=True)
p0 = state.players[0]
card_no = "PL!SP-bp4-024-L"
card_id = -1
for cid, c in state.live_db.items():
if c.card_no == card_no:
card_id = cid
break
# Setup Left Side Member (Area.LEFT = 0)
left_id = 8888
import numpy as np
from engine.models.card import MemberCard
from engine.models.enums import Group
# Liella member, has Heart02 x3
# Heart02 assumed Red (Index 1)
hearts = np.zeros(7, dtype=np.int32)
hearts[1] = 3 # 3 Red Hearts
left_member = MemberCard(
card_id=left_id,
card_no="test-left",
name="Kekeru",
cost=2,
hearts=hearts,
blade_hearts=np.zeros(7, dtype=np.int32),
blades=1,
groups=[Group.LIELLA],
)
state.member_db[left_id] = left_member
p0.stage[Area.LEFT] = left_id
p0.live_zone = [card_id]
# Ability 2
ability = state.live_db[card_id].abilities[1]
from engine.models.ability import TriggerType
assert ability.trigger == TriggerType.ON_LIVE_START
# Execute
print("DEBUG: Triggering Ability 2")
state.triggered_abilities.append((0, ability, {"card_id": card_id}))
state._process_rule_checks()
print("DEBUG: Finished _process_rule_checks Ability 2")
# Check Buff
base_blades = left_member.blades # 1
# Use PlayerState method for effective blades
current_blades = p0.get_effective_blades(Area.LEFT, state.member_db)
assert current_blades == base_blades + 2
print("DEBUG: Ability 2 Test Passed")
if __name__ == "__main__":
test_nonfiction_ability_1_center_cost_diff()
test_nonfiction_ability_2_left_side_hearts()
print("ALL TESTS PASSED")
|