一键导入
implement-cards
Fill out the implementation of effects of different attacks, abilities, and trainer cards in this Pokemon TCG Pocket engine codebase.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Fill out the implementation of effects of different attacks, abilities, and trainer cards in this Pokemon TCG Pocket engine codebase.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | implement-cards |
| description | Fill out the implementation of effects of different attacks, abilities, and trainer cards in this Pokemon TCG Pocket engine codebase. |
To implement cards, first read the models module and the state module. Cards
are not implemented if they are a Pokemon that is missing an Ability or Attack implementation,
or a Trainer card (be it a tool or a normal one) missig implementation.
Use TDD for every new card implementation:
test_raikou_rocky_helmet_promotion_order in tests/tools/raikou_rocky_helmet_order_test.rs.Game API level, driving behavior through calls like game.apply_action(...), generate_possible_actions(), get_state_clone(), and observable game state changes.If the user hasn't specified what card to implement, you can use the tool:
cargo run --bin card_status
to see what cards are missing, and choose one. You can also that tool to see what is missing from the specified card.
Get the details of all the cards that have the ability you want to implement by using the following script:
cargo run --bin search "Venusaur"
Copy the ids of cards to implement (including full art versions) in the given JSON. Only choose the ones with the ability you want to implement.
All abilities should use the AbilityMechanic pathway.
effect_ability_mechanic_map.rs.AbilityMechanic when possible. If not, add a new variant in src/actions/abilities/mechanic.rs.map.insert(...) lines in effect_ability_mechanic_map.rs and map them to the correct AbilityMechanic with parameters.forecast_ability_by_mechanic in src/actions/apply_abilities_action.rs.
Outcomes struct (see src/actions/outcomes.rs).Outcomes::single_fn(|rng, state, action| { ... })Outcomes constructor:
Outcomes::binary_coin(heads_mutation, tails_mutation) for a single coin flipOutcomes::binomial_by_heads(n, |heads| mutation) for N flips grouped by heads countOutcomes::geometric_until_tails(max, |heads| mutation) for flip-until-tails effectsmatch arms as one-liners by moving logic into helpers.can_use_ability_by_mechanic in src/move_generation/move_generation_abilities.rs.
match arms as one-liners by moving logic into helpers.If the ability is passive or hook-driven:
src/hooks/.forecast_ability_by_mechanic should panic! for passive mechanics, and can_use_ability_by_mechanic should return false.Add 1 or 2 logic tests before implementation at the Game public API level.
tests/, for example tests/pokemon/..., tests/tools/..., tests/stadiums/..., or tests/mechanics/....test_raikou_rocky_helmet_promotion_order in tests/tools/raikou_rocky_helmet_order_test.rs in style and abstraction level.game.apply_action(...) instead of internal helpers or private implementation details..move_generation_stack; drive behavior through public actions and resulting game state.Get the details of the card with the attack you want to implement by using the following script:
cargo run --bin search "Venusaur" --attack "Giant Bloom"
Search for the effect text in the above JSON in the effect_mechanic_map.rs file.
Decide if we should introduce a new Mechanic or re-use or generalize an existing one. Try to re-use existing ones first.
Identify all the cards that have the same effect text template, and just differ by parameters.
Uncomment all the // map.insert(" lines that pertain to the mechanic, and add the correct value (an Mechanic enum variant with the corresponding parameters).
Implement the mechanic logic in forecast_effect_attack_by_mechanic in src/actions/apply_attack_action.rs.
Outcomes struct (see src/actions/outcomes.rs).Outcomes::single_fn(|rng, state, action| { ... })Outcomes constructor:
Outcomes::binary_coin(heads_mutation, tails_mutation) - single coin flipOutcomes::binomial_by_heads(n, |heads| mutation) - flip N coins, group by heads countOutcomes::geometric_until_tails(max, |heads| mutation) - flip until tailssrc/actions/apply_attack_action.rs to ensure consistency in implementation.Add 1 or 2 Game-level logic tests in the matching tests/ subfolder before implementation when the attack has non-trivial behavior.
test_raikou_rocky_helmet_promotion_order in tests/tools/raikou_rocky_helmet_order_test.rs.Game public API, especially game.apply_action(...) and the resulting public game state.Get the details of the tool card that you want to implement by using the following script:
cargo run --bin search "Leaf Cape"
Copy the ids of cards to implement (including full art versions) in the given JSON.
In tools.rs:
In src/tools.rs:
static EFFECT_NAME_EFFECT: LazyLock<String> constant using tool_effect_text_from_card_id(CardId::...).is_tool_effect_implemented() match expression.can_attach_tool_to().Implement any immediate effects in the tool's core logic rather than a dedicated "on attach" hook.
PlayedCard::get_effective_total_hp().Ensure Tool is correctly handled by forecast_trainer_action.
For tools with ongoing effects (not just on-attach):
hooks/core.rs or other appropriate hook files.has_tool(played_card, CardId::...) to check if a pokemon has a specific tool attached.Add 1 or 2 Game-level integration tests under tests/tools/ before implementation for the observable effect.
test_raikou_rocky_helmet_promotion_order in tests/tools/raikou_rocky_helmet_order_test.rs.Game public API, especially game.apply_action(...) and the resulting public game state.Get the details of the trainer card that you want to implement by using the following script:
cargo run --bin search "Rare Candy"
Copy the ids of cards to implement (including full art versions) in the given JSON.
Implement the "move generation" logic.
move_generation_trainer.rs implement the switch branch. Its often the case the Trainer/Support can always be played, so just add to this case in the switch.Implement the "apply action" logic.
This is the code that actually runs when the card is played.
Visit src/actions/apply_trainer_action.rs.
Return an Outcomes struct (see src/actions/outcomes.rs):
Outcomes::single_fn(|rng, state, action| { ... })Outcomes::binary_coin(...) or other coin constructorsOften its just "applying an effect" in the field (like Leaf).
.turn_effects field in the state. You can use to for effects that apply to
this turn, or a future one.hooks.rs. The idea of hooks.rs is to try to encapsulate
most custom logic that goes outside of the normal business logic. Also consider adding new
pieces of state to the State struct if necessary.Try to keep the match trainer_id cases as one-liners (using helper functions if necessary).
Add 1 or 2 Game-level integration tests in the appropriate tests/ area before implementation if the trainer has logic beyond a trivial draw/search path.
test_raikou_rocky_helmet_promotion_order in tests/tools/raikou_rocky_helmet_order_test.rs.Game public API, especially game.apply_action(...) and the resulting public game state.Get the details of the stadium card that you want to implement by using the following script:
cargo run --bin search "Peculiar Plaza"
Copy the ids of cards to implement (including full art versions) in the given JSON.
In src/stadiums.rs:
LazyLock<String> constant for the stadium's effect text.is_stadium_effect_implemented().get_peculiar_plaza_retreat_reduction).Add Stadium move generation:
move_generation_trainer.rs via can_play_stadium().Hook the stadium effect into the appropriate game mechanic:
hooks/retreat.rs in get_retreat_cost()hooks/core.rs in modify_damage()get_effective_total_hp() or damage calculationStadium effects apply to BOTH players equally.
Test using cargo run --bin card_test -- "CardId".
Add 1 or 2 Game-level integration tests under tests/stadiums/ before implementation.
test_raikou_rocky_helmet_promotion_order in tests/tools/raikou_rocky_helmet_order_test.rs.Game public API, especially game.apply_action(...) and the resulting public game state.After implementing a card, test it like so:
Run the integrated card test command (it generates a temp deck and runs 10,000 random games against all decks in example_decks/):
cargo run --bin card_test -- "Card ID"
Review the results to ensure the games complete without errors.
Run the targeted automated checks for the code you touched:
cargo test --features test-utils --test pokemon
cargo test --features test-utils --test tools
cargo test --features test-utils --test stadiums
cargo test --features test-utils --test mechanics
Pick the relevant test target(s) for your change rather than always running all four.
Make sure to run cargo fmt and cargo clippy --all-targets --all-features -- -D warnings. Also run the relevant targeted tests for the area you changed.