mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 14:32:06 -08:00
* Added automatic handling for order of triggered abilities going to stack (fixes #701 / related to #328).
This commit is contained in:
parent
47f8483538
commit
532d4e0af0
27 changed files with 914 additions and 665 deletions
|
|
@ -54,11 +54,11 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
|
|||
protected boolean lockedIn = false;
|
||||
|
||||
public BoostControlledEffect(int power, int toughness, Duration duration) {
|
||||
this(power, toughness, duration, new FilterCreaturePermanent("Creatures"), false);
|
||||
this(power, toughness, duration, new FilterCreaturePermanent("creatures"), false);
|
||||
}
|
||||
|
||||
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
||||
this(power, toughness, duration, new FilterCreaturePermanent("Creatures"), false);
|
||||
this(power, toughness, duration, new FilterCreaturePermanent("creatures"), false);
|
||||
}
|
||||
|
||||
public BoostControlledEffect(int power, int toughness, Duration duration, boolean excludeSource) {
|
||||
|
|
|
|||
|
|
@ -29,16 +29,22 @@ package mage.constants;
|
|||
|
||||
/**
|
||||
* Defines player actions for a game
|
||||
*
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public enum PlayerAction {
|
||||
|
||||
PASS_PRIORITY_UNTIL_MY_NEXT_TURN,
|
||||
PASS_PRIORITY_UNTIL_TURN_END_STEP,
|
||||
PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE,
|
||||
PASS_PRIORITY_UNTIL_NEXT_TURN,
|
||||
PASS_PRIORITY_UNTIL_STACK_RESOLVED,
|
||||
PASS_PRIORITY_CANCEL_ALL_ACTIONS,
|
||||
TRIGGER_AUTO_ORDER_ABILITY_FIRST,
|
||||
TRIGGER_AUTO_ORDER_NAME_FIRST,
|
||||
TRIGGER_AUTO_ORDER_ABILITY_LAST,
|
||||
TRIGGER_AUTO_ORDER_NAME_LAST,
|
||||
TRIGGER_AUTO_ORDER_RESET_ALL,
|
||||
ROLLBACK_TURNS,
|
||||
UNDO,
|
||||
CONCEDE,
|
||||
|
|
@ -55,4 +61,4 @@ public enum PlayerAction {
|
|||
DENY_PERMISSON_TO_ROLLBACK_TURN,
|
||||
PERMISSION_REQUESTS_ALLOWED_ON,
|
||||
PERMISSION_REQUESTS_ALLOWED_OFF
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
void fireSelectTargetEvent(UUID playerId, String message, Cards cards, boolean required, Map<String, Serializable> options);
|
||||
|
||||
void fireSelectTargetEvent(UUID playerId, String message, List<TriggeredAbility> abilities);
|
||||
void fireSelectTargetTriggeredAbilityEvent(UUID playerId, String message, List<TriggeredAbility> abilities);
|
||||
|
||||
void fireSelectTargetEvent(UUID playerId, String message, List<Permanent> perms, boolean required);
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ public interface Game extends MageItem, Serializable {
|
|||
void addPermanent(Permanent permanent);
|
||||
|
||||
// priority method
|
||||
void sendPlayerAction(PlayerAction playerAction, UUID playerId);
|
||||
void sendPlayerAction(PlayerAction playerAction, UUID playerId, Object data);
|
||||
|
||||
/**
|
||||
* This version supports copying of copies of any depth.
|
||||
|
|
|
|||
|
|
@ -1136,10 +1136,10 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerAction(PlayerAction playerAction, UUID playerId) {
|
||||
public void sendPlayerAction(PlayerAction playerAction, UUID playerId, Object data) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.sendPlayerAction(playerAction, this);
|
||||
player.sendPlayerAction(playerAction, this, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1929,11 +1929,16 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
playerQueryEventSource.target(playerId, message, cards, required, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only used from human players to select order triggered abilities go to
|
||||
* the stack.
|
||||
*
|
||||
* @param playerId
|
||||
* @param message
|
||||
* @param abilities
|
||||
*/
|
||||
@Override
|
||||
public void fireSelectTargetEvent(UUID playerId, String message, List<TriggeredAbility> abilities) {
|
||||
if (simulation) {
|
||||
return;
|
||||
}
|
||||
public void fireSelectTargetTriggeredAbilityEvent(UUID playerId, String message, List<TriggeredAbility> abilities) {
|
||||
playerQueryEventSource.target(playerId, message, abilities);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.game.events;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -60,8 +61,8 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
private Set<UUID> targets;
|
||||
private Cards cards;
|
||||
private List<Card> booster;
|
||||
private QueryType queryType;
|
||||
private UUID playerId;
|
||||
private final QueryType queryType;
|
||||
private final UUID playerId;
|
||||
private boolean required;
|
||||
private int min;
|
||||
private int max;
|
||||
|
|
@ -72,11 +73,6 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
private Choice choice;
|
||||
|
||||
private PlayerQueryEvent(UUID playerId, String message, List<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required, Map<String, Serializable> options) {
|
||||
this(playerId, message, abilities, choices, targets, cards, queryType, min, max, required);
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
private PlayerQueryEvent(UUID playerId, String message, List<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required) {
|
||||
super(playerId);
|
||||
this.queryType = queryType;
|
||||
this.message = message;
|
||||
|
|
@ -88,6 +84,12 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
this.required = required;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
if (options == null) {
|
||||
this.options = new HashMap<>();
|
||||
} else {
|
||||
this.options = options;
|
||||
}
|
||||
this.options.put("queryType", queryType);
|
||||
}
|
||||
|
||||
private PlayerQueryEvent(UUID playerId, String message, List<Card> booster, QueryType queryType, int time) {
|
||||
|
|
@ -148,7 +150,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
}
|
||||
|
||||
public static PlayerQueryEvent askEvent(UUID playerId, String message) {
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false);
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false, null);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent chooseAbilityEvent(UUID playerId, String message, String objectName, List<? extends ActivatedAbility> choices) {
|
||||
|
|
@ -157,7 +159,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
nameAsSet = new HashSet<>();
|
||||
nameAsSet.add(objectName);
|
||||
}
|
||||
return new PlayerQueryEvent(playerId, message, choices, nameAsSet, null, null, QueryType.CHOOSE_ABILITY, 0, 0, false);
|
||||
return new PlayerQueryEvent(playerId, message, choices, nameAsSet, null, null, QueryType.CHOOSE_ABILITY, 0, 0, false, null);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent choosePileEvent(UUID playerId, String message, List<? extends Card> pile1, List<? extends Card> pile2) {
|
||||
|
|
@ -173,7 +175,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
}
|
||||
|
||||
public static PlayerQueryEvent targetEvent(UUID playerId, String message, Set<UUID> targets, boolean required) {
|
||||
return new PlayerQueryEvent(playerId, message, null, null, targets, null, QueryType.PICK_TARGET, 0, 0, required);
|
||||
return new PlayerQueryEvent(playerId, message, null, null, targets, null, QueryType.PICK_TARGET, 0, 0, required, null);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent targetEvent(UUID playerId, String message, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||
|
|
@ -185,7 +187,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
}
|
||||
|
||||
public static PlayerQueryEvent targetEvent(UUID playerId, String message, List<TriggeredAbility> abilities) {
|
||||
return new PlayerQueryEvent(playerId, message, abilities, null, null, null, QueryType.PICK_ABILITY, 0, 0, true);
|
||||
return new PlayerQueryEvent(playerId, message, abilities, null, null, null, QueryType.PICK_ABILITY, 0, 0, true, null);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent targetEvent(UUID playerId, String message, List<Permanent> perms, boolean required) {
|
||||
|
|
@ -193,7 +195,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
}
|
||||
|
||||
public static PlayerQueryEvent selectEvent(UUID playerId, String message) {
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.SELECT, 0, 0, false);
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.SELECT, 0, 0, false, null);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent selectEvent(UUID playerId, String message, Map<String, Serializable> options) {
|
||||
|
|
@ -205,11 +207,11 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
}
|
||||
|
||||
public static PlayerQueryEvent playXManaEvent(UUID playerId, String message) {
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.PLAY_X_MANA, 0, 0, false);
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.PLAY_X_MANA, 0, 0, false, null);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent amountEvent(UUID playerId, String message, int min, int max) {
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.AMOUNT, min, max, false);
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.AMOUNT, min, max, false, null);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent pickCard(UUID playerId, String message, List<Card> booster, int time) {
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void skip();
|
||||
|
||||
// priority, undo, ...
|
||||
void sendPlayerAction(PlayerAction passPriorityAction, Game game);
|
||||
void sendPlayerAction(PlayerAction passPriorityAction, Game game, Object data);
|
||||
|
||||
int getStoredBookmark();
|
||||
|
||||
|
|
|
|||
|
|
@ -1878,7 +1878,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerAction(PlayerAction playerAction, Game game) {
|
||||
public void sendPlayerAction(PlayerAction playerAction, Game game, Object data) {
|
||||
switch (playerAction) {
|
||||
case PASS_PRIORITY_UNTIL_MY_NEXT_TURN: // F9
|
||||
passedUntilNextMain = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue