mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 14:32:06 -08:00
* Removed some data from player restoring to fix unintended draws after a player concedes game (#1205)
This commit is contained in:
parent
692148d3c2
commit
aa1eb354ef
7 changed files with 65 additions and 29 deletions
|
|
@ -2657,6 +2657,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
for (Player playerObject : getPlayers().values()) {
|
||||
if (playerObject.isHuman() && playerObject.isInGame()) {
|
||||
playerObject.abort();
|
||||
playerObject.resetPlayerPassedActions();
|
||||
}
|
||||
}
|
||||
fireUpdatePlayersEvent();
|
||||
|
|
|
|||
|
|
@ -179,6 +179,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void resetPassed();
|
||||
|
||||
void resetPlayerPassedActions();
|
||||
|
||||
boolean getPassedTurn();
|
||||
|
||||
boolean getPassedUntilEndOfTurn();
|
||||
|
|
@ -620,13 +622,12 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
*/
|
||||
boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
|
||||
// boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName);
|
||||
boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
|
||||
// boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName);
|
||||
boolean moveCards(Set<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
|
||||
// boolean moveCards(Set<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName);
|
||||
boolean moveCardsToExile(Card card, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName);
|
||||
|
||||
boolean moveCardsToExile(Set<Card> cards, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -330,9 +330,21 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.name = player.getName();
|
||||
this.human = player.isHuman();
|
||||
this.life = player.getLife();
|
||||
this.wins = player.hasWon();
|
||||
this.loses = player.hasLost();
|
||||
|
||||
// Don't restore more global states. If restored they are probably cause for unintended draws (https://github.com/magefree/mage/issues/1205).
|
||||
// this.wins = player.hasWon();
|
||||
// this.loses = player.hasLost();
|
||||
// this.left = player.hasLeft();
|
||||
// this.quit = player.hasQuit();
|
||||
// Makes no sense to restore
|
||||
// this.passed = player.isPassed();
|
||||
// this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||
// this.idleTimeout = player.hasIdleTimeout();
|
||||
// this.timerTimeout = player.hasTimerTimeout();
|
||||
// can't change so no need to restore
|
||||
// this.isTestMode = player.isTestMode();
|
||||
// This is meta data and should'nt be restored by rollback
|
||||
// this.userData = player.getUserData();
|
||||
this.library = player.getLibrary().copy();
|
||||
this.sideboard = player.getSideboard().copy();
|
||||
this.hand = player.getHand().copy();
|
||||
|
|
@ -349,10 +361,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.manaPool = player.getManaPool().copy();
|
||||
this.turns = player.getTurns();
|
||||
|
||||
this.left = player.hasLeft();
|
||||
this.quit = player.hasQuit();
|
||||
this.timerTimeout = player.hasTimerTimeout();
|
||||
this.idleTimeout = player.hasIdleTimeout();
|
||||
this.range = player.getRange();
|
||||
this.canGainLife = player.isCanGainLife();
|
||||
this.canLoseLife = player.isCanLoseLife();
|
||||
|
|
@ -361,7 +369,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
this.inRange.clear();
|
||||
this.inRange.addAll(player.getInRange());
|
||||
this.userData = player.getUserData();
|
||||
this.canPayLifeCost = player.canPayLifeCost();
|
||||
this.canPaySacrificeCost = player.canPaySacrificeCost();
|
||||
this.loseByZeroOrLessLife = player.canLoseByZeroOrLessLife();
|
||||
|
|
@ -371,12 +378,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.topCardRevealed = player.isTopCardRevealed();
|
||||
this.playersUnderYourControl.clear();
|
||||
this.playersUnderYourControl.addAll(player.getPlayersUnderYourControl());
|
||||
this.isTestMode = player.isTestMode();
|
||||
this.isGameUnderControl = player.isGameUnderControl();
|
||||
|
||||
this.turnController = player.getTurnControlledBy();
|
||||
this.passed = player.isPassed();
|
||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||
this.reachedNextTurnAfterLeaving = player.hasReachedNextTurnAfterLeaving();
|
||||
this.castSourceIdWithAlternateMana = player.getCastSourceIdWithAlternateMana();
|
||||
this.castSourceIdManaCosts = player.getCastSourceIdManaCosts();
|
||||
|
|
@ -1823,6 +1827,15 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.passed = this.loses || this.hasLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerPassedActions() {
|
||||
this.passedAllTurns = false;
|
||||
this.passedTurn = false;
|
||||
this.passedUntilEndOfTurn = false;
|
||||
this.passedUntilNextMain = false;
|
||||
this.passedUntilStackResolved = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quit(Game game) {
|
||||
quit = true;
|
||||
|
|
@ -2949,6 +2962,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardsToExile(Card card, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName) {
|
||||
Set<Card> cards = new HashSet<>();
|
||||
cards.add(card);
|
||||
return moveCardsToExile(cards, source, game, withName, exileId, exileZoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardsToExile(Set<Card> cards, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName) {
|
||||
if (cards.isEmpty()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue