GameCopier throws "Couldn't map" after Initiative or Monarch changes players
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Player.mapEffectCard()から始め、キャッシュされたInitiativeおよびMonarchの効果カードが、記録されたゾーンにどのように対応付けられるかを調べてください。InitiativeとMonarchの変更に関する添付の再現テストを使い、実行してGameCopier.makeCopy()が成功し、コピーが現在の保持者と有効な効果カードをちょうど1枚維持することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
GameCopier.makeCopy() throws a RuntimeException after the Initiative or Monarch status moves from one player to another.
The previous holder's cached effect card remains in Player.initiativeEffect or Player.monarchEffect, even though it has been removed from the Command zone.
Player.mapEffectCard() checks whether effect.getZone() is non-null but does not verify that the card is still present in that zone. Consequently, it attempts to map an effect card that was not copied.
This affects AI simulations using GameCopier, including Flat Monte Carlo rollouts.
Steps to reproduce
Using a minimal Java test with two players:
- Initialize a game and move to MAIN1.
- Call
game.getAction().takeInitiative(playerA, "CLB"). - Call
game.getAction().takeInitiative(playerB, "CLB"). - Call
new GameCopier(game).withStack(false).makeCopy().
The copy throws a RuntimeException: Couldn't map The Initiative.
The same problem occurs when Monarch moves between players using becomeMonarch().
Expected behavior
The game copy should succeed, preserve the current Initiative or Monarch holder and contain exactly one active corresponding effect card.
An effect removed from its zone should not be passed to the object mapper.
Root cause
Zone.remove() removes the card from the zone's collection without clearing its cached zone reference. The cached effect object can be reused when a player regains the status.
However, GameCopier traverses the actual zone contents, so the removed effect card is absent from its object map.
The insufficient check is in Player.mapEffectCard().
Proposed minimal fix
Before calling the mapper, verify that the effect is still present in its recorded zone:
return effect == null || effect.getZone() == null || !effect.getZone().contains(effect)
? null : mapper.apply(effect);
This avoids changing the existing effect lifecycle, Zone.remove() or GameCopier.find().
Verification
Both failures were independently reproduced on an unchanged upstream master checkout.
- Tests executed: 2
- Passed: 0
- Failed: 2
- Skipped: 0
Both tests failed with the expected mapping exceptions.
The proposed patch passes git apply --check but was not applied during the upstream verification.
Environment
- Repository: Card-Forge/forge
- Branch: master
- Commit:
3460eccd2629a05032e489bc3d70c082a57a1eee - Forge version: 2.0.17-SNAPSHOT
- OS: Windows
- Java: Temurin OpenJDK 17.0.17
Additional context
Related: #11203, which introduced copyEffectCardsToSnapshot() to address duplication of player-managed effect cards.
The attached ZIP contains the reproduction tests, execution instructions, upstream test results and the proposed minimal patch.
- 主要言語
- Java
- スター
- 2.7k
- フォーク
- 1.1k
- 平均マージ
- 20時間 38分
- マージ済み PR(30日)
- 323
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Card-Forge/forge のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Card-Forge/forge#13128 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Card-Forge/forge#12877 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Card-Forge/forge#12710 ·
メンテナーはふだん 1 日以内に返信
-
Shandalar "The Drunken Plea" quest completes prematurely再び着手できるかも @Simisays が 35 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Card-Forge/forge#12306 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
Card-Forge/forge#12206 ·
メンテナーはふだん 1 日以内に返信
Card-Forge/forge の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
client documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
ClickHouse/clickhouse-java#3469 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/flink-agents#1480 ·
メンテナーはふだん 2 日以内に返信
-
Beam P2
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信