mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Improved Word of Command turn control handling
This commit is contained in:
parent
b7c6afc66d
commit
492c5ab63e
5 changed files with 45 additions and 57 deletions
|
|
@ -33,10 +33,6 @@ public class LoseControlOnOtherPlayersControllerEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
player.resetOtherTurnsControlled();
|
||||
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||
if (targetPlayer != null) {
|
||||
targetPlayer.setGameUnderYourControl(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -393,6 +393,8 @@ public interface Game extends MageItem, Serializable {
|
|||
boolean checkStateAndTriggered();
|
||||
|
||||
void playPriority(UUID activePlayerId, boolean resuming);
|
||||
|
||||
void resetControlAfterSpellResolve(Spell spell);
|
||||
|
||||
boolean endTurn(Ability source);
|
||||
|
||||
|
|
|
|||
|
|
@ -1395,7 +1395,13 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
StackObject top = null;
|
||||
try {
|
||||
top = state.getStack().peek();
|
||||
top.resolve(this);
|
||||
Spell topSpell = getSpell(top.getId());
|
||||
if (topSpell != null) {
|
||||
top.resolve(this);
|
||||
resetControlAfterSpellResolve(topSpell);
|
||||
} else {
|
||||
top.resolve(this);
|
||||
}
|
||||
} finally {
|
||||
if (top != null) {
|
||||
state.getStack().remove(top, this); // seems partly redundant because move card from stack to grave is already done and the stack removed
|
||||
|
|
@ -1409,6 +1415,31 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetControlAfterSpellResolve(Spell spell) {
|
||||
// for Word of Command
|
||||
if (spell.getCommandedBy() != null) {
|
||||
UUID commandedBy = spell.getCommandedBy();
|
||||
UUID spellControllerId = null;
|
||||
if (commandedBy.equals(spell.getControllerId())) {
|
||||
spellControllerId = spell.getSpellAbility().getFirstTarget(); // i.e. resolved spell is Word of Command
|
||||
} else {
|
||||
spellControllerId = spell.getControllerId(); // i.e. resolved spell is the target opponent's spell
|
||||
}
|
||||
if (commandedBy != null && spellControllerId != null) {
|
||||
Player turnController = getPlayer(commandedBy);
|
||||
if (turnController != null) {
|
||||
Player targetPlayer = getPlayer(spellControllerId);
|
||||
if (targetPlayer != null) {
|
||||
informPlayers(turnController.getLogName() + " lost control over " + targetPlayer.getLogName());
|
||||
turnController.resetOtherTurnsControlled();
|
||||
targetPlayer.setGameUnderYourControl(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the stack gets filled iterated, without ever getting empty
|
||||
|
|
|
|||
|
|
@ -36,7 +36,13 @@ public class SpellStack extends ArrayDeque<StackObject> {
|
|||
StackObject top = null;
|
||||
try {
|
||||
top = this.peek();
|
||||
top.resolve(game);
|
||||
Spell topSpell = getSpell(top.getId());
|
||||
if (topSpell != null) {
|
||||
top.resolve(game);
|
||||
game.resetControlAfterSpellResolve(topSpell);
|
||||
} else {
|
||||
top.resolve(game);
|
||||
}
|
||||
} finally {
|
||||
if (top != null) {
|
||||
if (contains(top)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue