mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
fixed issue 141
This commit is contained in:
parent
f2c44688d0
commit
15f75f8d11
7 changed files with 27 additions and 19 deletions
|
|
@ -132,6 +132,25 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* bookmarks the current state and restores it if player doesn't pay the mana cost
|
||||
*
|
||||
* @param ability
|
||||
* @param game
|
||||
* @param sourceId
|
||||
* @param controllerId
|
||||
* @return true if the cost was paid
|
||||
*/
|
||||
public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID controllerId) {
|
||||
int bookmark = game.bookmarkState();
|
||||
if (pay(ability, game, sourceId, controllerId, false)) {
|
||||
game.removeBookmark(bookmark);
|
||||
return true;
|
||||
}
|
||||
game.restoreState(bookmark);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaCosts<T> getUnpaid() {
|
||||
ManaCosts<T> unpaid = new ManaCostsImpl<T>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue