mirror of
https://github.com/correl/mage.git
synced 2025-04-12 09:11:05 -09:00
AbilityPicker shows abilities now always in the order they were defined on the object.
This commit is contained in:
parent
4dfadb3ea1
commit
7c44b16504
9 changed files with 29 additions and 28 deletions
Mage.Common/src/mage/view
Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human
Mage.Server/src/main/java/mage/server/game
Mage/src/mage
abilities
game
players
|
@ -29,8 +29,8 @@
|
|||
package mage.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -42,9 +42,9 @@ import mage.abilities.Ability;
|
|||
public class AbilityPickerView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Map<UUID, String> choices = new HashMap<UUID, String>();
|
||||
private Map<UUID, String> choices = new LinkedHashMap<UUID, String>();
|
||||
|
||||
public AbilityPickerView(Collection<? extends Ability> abilities) {
|
||||
public AbilityPickerView(List<? extends Ability> abilities) {
|
||||
for (Ability ability: abilities) {
|
||||
choices.put(ability.getId(), ability.getRule(true));
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
} else if (response.getUUID() != null) {
|
||||
MageObject object = game.getObject(response.getUUID());
|
||||
if (object != null) {
|
||||
Map<UUID, ActivatedAbility> useableAbilities = null;
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = null;
|
||||
Zone zone = game.getState().getZone(object.getId());
|
||||
if (zone != null) {
|
||||
useableAbilities = getUseableActivatedAbilities(object, zone, game);
|
||||
|
@ -492,7 +492,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
updateGameStatePriority("playManaAbilities", game);
|
||||
MageObject object = game.getObject(response.getUUID());
|
||||
if (object == null) return;
|
||||
Map<UUID, ManaAbility> useableAbilities = null;
|
||||
LinkedHashMap<UUID, ManaAbility> useableAbilities = null;
|
||||
Zone zone = game.getState().getZone(object.getId());
|
||||
if (zone != null) {
|
||||
useableAbilities = getUseableManaAbilities(object, zone, game);
|
||||
|
@ -686,8 +686,8 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
|
||||
protected void specialAction(Game game) {
|
||||
updateGameStatePriority("specialAction", game);
|
||||
Map<UUID, SpecialAction> specialActions = game.getState().getSpecialActions().getControlledBy(playerId);
|
||||
game.fireGetChoiceEvent(playerId, name, specialActions.values());
|
||||
LinkedHashMap<UUID, SpecialAction> specialActions = game.getState().getSpecialActions().getControlledBy(playerId);
|
||||
game.fireGetChoiceEvent(playerId, name, new ArrayList<SpecialAction>(specialActions.values()));
|
||||
waitForResponse();
|
||||
if (response.getUUID() != null) {
|
||||
if (specialActions.containsKey(response.getUUID()))
|
||||
|
@ -695,7 +695,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
}
|
||||
}
|
||||
|
||||
protected void activateAbility(Map<UUID, ? extends ActivatedAbility> abilities, Game game) {
|
||||
protected void activateAbility(LinkedHashMap<UUID, ? extends ActivatedAbility> abilities, Game game) {
|
||||
updateGameStatePriority("activateAbility", game);
|
||||
if (abilities.size() == 1) {
|
||||
ActivatedAbility ability = abilities.values().iterator().next();
|
||||
|
@ -704,7 +704,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
return;
|
||||
}
|
||||
}
|
||||
game.fireGetChoiceEvent(playerId, name, abilities.values());
|
||||
game.fireGetChoiceEvent(playerId, name, new ArrayList<ActivatedAbility>(abilities.values()));
|
||||
waitForResponse();
|
||||
if (response.getUUID() != null) {
|
||||
if (abilities.containsKey(response.getUUID()))
|
||||
|
|
|
@ -385,7 +385,7 @@ public class GameController implements GameCallback {
|
|||
|
||||
}
|
||||
|
||||
private synchronized void chooseAbility(UUID playerId, final Collection<? extends Ability> choices) throws MageException {
|
||||
private synchronized void chooseAbility(UUID playerId, final List<? extends Ability> choices) throws MageException {
|
||||
perform(playerId, new Command() {
|
||||
public void execute(UUID playerId) {
|
||||
gameSessions.get(playerId).chooseAbility(new AbilityPickerView(choices));
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
package mage.abilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -44,8 +43,8 @@ public class SpecialActions extends AbilitiesImpl<SpecialAction> {
|
|||
super(actions);
|
||||
}
|
||||
|
||||
public Map<UUID, SpecialAction> getControlledBy(UUID controllerId) {
|
||||
HashMap<UUID, SpecialAction> controlledBy = new HashMap<UUID, SpecialAction>();
|
||||
public LinkedHashMap<UUID, SpecialAction> getControlledBy(UUID controllerId) {
|
||||
LinkedHashMap<UUID, SpecialAction> controlledBy = new LinkedHashMap<UUID, SpecialAction>();
|
||||
for (SpecialAction action: this) {
|
||||
if (action.getControllerId().equals(controllerId))
|
||||
controlledBy.put(action.id, action);
|
||||
|
|
|
@ -139,7 +139,7 @@ public interface Game extends MageItem, Serializable {
|
|||
public void firePriorityEvent(UUID playerId);
|
||||
public void firePlayManaEvent(UUID playerId, String message);
|
||||
public void firePlayXManaEvent(UUID playerId, String message);
|
||||
public void fireGetChoiceEvent(UUID playerId, String message, Collection<? extends ActivatedAbility> choices);
|
||||
public void fireGetChoiceEvent(UUID playerId, String message, List<? extends ActivatedAbility> choices);
|
||||
public void fireGetModeEvent(UUID playerId, String message, Map<UUID, String> modes);
|
||||
public void fireGetAmountEvent(UUID playerId, String message, int min, int max);
|
||||
public void fireChoosePileEvent(UUID playerId, String message, List<? extends Card> pile1, List<? extends Card> pile2);
|
||||
|
|
|
@ -1164,7 +1164,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fireGetChoiceEvent(UUID playerId, String message, Collection<? extends ActivatedAbility> choices) {
|
||||
public void fireGetChoiceEvent(UUID playerId, String message, List<? extends ActivatedAbility> choices) {
|
||||
if (simulation) return;
|
||||
playerQueryEventSource.chooseAbility(playerId, message, choices);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
}
|
||||
|
||||
private String message;
|
||||
private Collection<? extends Ability> abilities;
|
||||
private List<? extends Ability> abilities;
|
||||
private List<Permanent> perms;
|
||||
private Set<String> choices;
|
||||
private Set<UUID> targets;
|
||||
|
@ -66,12 +66,12 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
private List<? extends Card> pile2;
|
||||
|
||||
|
||||
private PlayerQueryEvent(UUID playerId, String message, Collection<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required, Map<String, Serializable> 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, Map<String, Serializable> options) {
|
||||
this(playerId, message, abilities, choices, targets, cards, queryType, min, max, required);
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
private PlayerQueryEvent(UUID playerId, String message, Collection<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required) {
|
||||
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;
|
||||
|
@ -139,7 +139,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent chooseAbilityEvent(UUID playerId, String message, Collection<? extends ActivatedAbility> choices) {
|
||||
public static PlayerQueryEvent chooseAbilityEvent(UUID playerId, String message, List<? extends ActivatedAbility> choices) {
|
||||
return new PlayerQueryEvent(playerId, message, choices, null, null, null, QueryType.CHOOSE_ABILITY, 0, 0, false);
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
return queryType;
|
||||
}
|
||||
|
||||
public Collection<? extends Ability> getAbilities() {
|
||||
public List<? extends Ability> getAbilities() {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PlayerQueryEventSource implements EventSource<PlayerQueryEvent>, Se
|
|||
dispatcher.fireEvent(PlayerQueryEvent.selectEvent(playerId, message));
|
||||
}
|
||||
|
||||
public void chooseAbility(UUID playerId, String message, Collection<? extends ActivatedAbility> choices) {
|
||||
public void chooseAbility(UUID playerId, String message, List<? extends ActivatedAbility> choices) {
|
||||
dispatcher.fireEvent(PlayerQueryEvent.chooseAbilityEvent(playerId, message, choices));
|
||||
}
|
||||
|
||||
|
|
|
@ -671,11 +671,13 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
return false;
|
||||
}
|
||||
|
||||
protected Map<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
Map<UUID, ActivatedAbility> useable = new HashMap<UUID, ActivatedAbility>();
|
||||
protected LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<UUID, ActivatedAbility>();
|
||||
for (ActivatedAbility ability: object.getAbilities().getActivatedAbilities(zone)) {
|
||||
if (ability.canActivate(playerId, game))
|
||||
|
||||
if (ability.canActivate(playerId, game)) {
|
||||
useable.put(ability.getId(), ability);
|
||||
}
|
||||
}
|
||||
if (zone != Zone.HAND) {
|
||||
if (zone != Zone.BATTLEFIELD && game.getContinuousEffects().asThough(object.getId(), AsThoughEffectType.CAST, game)) {
|
||||
|
@ -702,8 +704,8 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
return useable;
|
||||
}
|
||||
|
||||
protected Map<UUID, ManaAbility> getUseableManaAbilities(MageObject object, Zone zone, Game game) {
|
||||
Map<UUID, ManaAbility> useable = new HashMap<UUID, ManaAbility>();
|
||||
protected LinkedHashMap<UUID, ManaAbility> getUseableManaAbilities(MageObject object, Zone zone, Game game) {
|
||||
LinkedHashMap<UUID, ManaAbility> useable = new LinkedHashMap<UUID, ManaAbility>();
|
||||
for (ManaAbility ability: object.getAbilities().getManaAbilities(zone)) {
|
||||
if (ability.canActivate(playerId, game))
|
||||
useable.put(ability.getId(), ability);
|
||||
|
|
Loading…
Add table
Reference in a new issue