Skip to content

Commit

Permalink
merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JayDi85 committed Jan 7, 2025
1 parent 5626c5f commit 0c8d49c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions Mage.Common/src/main/java/mage/utils/SystemUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,11 @@ public static void executeCheatCommands(Game game, String commandsFilePath, Play

case COMMAND_OPPONENT_UNDER_CONTROL_START: {
Target target = new TargetPlayer().withNotTarget(true).withChooseHint("to take under your control");
if (feedbackPlayer.chooseTarget(Outcome.GainControl, target, fakeSourceAbilityTemplate, game)) {
Ability fakeSourceAbility = fakeSourceAbilityTemplate.copy();
if (feedbackPlayer.chooseTarget(Outcome.GainControl, target, fakeSourceAbility, game)) {
Player targetPlayer = game.getPlayer(target.getFirstTarget());
if (targetPlayer != null && targetPlayer != feedbackPlayer) {
CardUtil.takeControlUnderPlayerStart(game, fakeSourceAbilityTemplate, feedbackPlayer, targetPlayer, false);
CardUtil.takeControlUnderPlayerStart(game, fakeSourceAbility, feedbackPlayer, targetPlayer, false);
// allow priority play again in same step (for better cheat UX)
targetPlayer.resetPassed();
}
Expand All @@ -569,10 +570,11 @@ public static void executeCheatCommands(Game game, String commandsFilePath, Play

case COMMAND_OPPONENT_UNDER_CONTROL_END: {
Target target = new TargetPlayer().withNotTarget(true).withChooseHint("to free from your control");
if (feedbackPlayer.chooseTarget(Outcome.GainControl, target, fakeSourceAbilityTemplate, game)) {
Ability fakeSourceAbility = fakeSourceAbilityTemplate.copy();
if (feedbackPlayer.chooseTarget(Outcome.GainControl, target, fakeSourceAbility, game)) {
Player targetPlayer = game.getPlayer(target.getFirstTarget());
if (targetPlayer != null && targetPlayer != feedbackPlayer && !targetPlayer.isGameUnderControl()) {
CardUtil.takeControlUnderPlayerEnd(game, fakeSourceAbilityTemplate, feedbackPlayer, targetPlayer);
CardUtil.takeControlUnderPlayerEnd(game, fakeSourceAbility, feedbackPlayer, targetPlayer);
}
// workaround for refresh priority dialog like avatar click (cheats called from priority in 99%)
game.firePriorityEvent(feedbackPlayer.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public void testCommands(){
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();

setChoice(playerA, "5"); // choose [group 3]: 5 = 2 default menus + 3 group
setChoice(playerA, "7"); // choose [group 3]: 7 = 4 default menus + 3 group
SystemUtil.executeCheatCommands(currentGame, commandsFile, playerA);

assertHandCount(playerA, "Razorclaw Bear", 1);
assertPermanentCount(playerA, "Mountain", 3);
assertHandCount(playerA, "Island", 10); // by cheats
assertHandCount(playerA, "Island", 10); // possible fail: changed in amount of default cheat commands
}
}

0 comments on commit 0c8d49c

Please sign in to comment.