mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
PlayerControllerHuman: sortCreatureTypes refactor code for Changeling, Clone and other stuff
This commit is contained in:
@@ -8,8 +8,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import forge.game.ability.AbilityFactory;
|
|
||||||
import forge.game.keyword.Keyword;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.MutablePair;
|
import org.apache.commons.lang3.tuple.MutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
@@ -28,6 +26,7 @@ import forge.deck.Deck;
|
|||||||
import forge.deck.DeckSection;
|
import forge.deck.DeckSection;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.GameObject;
|
import forge.game.GameObject;
|
||||||
|
import forge.game.ability.AbilityFactory;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.ability.ApiType;
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
@@ -41,9 +40,12 @@ import forge.game.card.CardUtil;
|
|||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.combat.CombatUtil;
|
import forge.game.combat.CombatUtil;
|
||||||
|
import forge.game.keyword.Keyword;
|
||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.game.replacement.ReplacementEffect;
|
||||||
|
import forge.game.replacement.ReplacementLayer;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.staticability.StaticAbility;
|
import forge.game.staticability.StaticAbility;
|
||||||
import forge.game.trigger.Trigger;
|
import forge.game.trigger.Trigger;
|
||||||
@@ -606,64 +608,105 @@ public class ComputerUtilCard {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, Integer> map = Maps.newHashMap();
|
final Map<String, Integer> typesInDeck = Maps.newHashMap();
|
||||||
|
|
||||||
|
// TODO JAVA 8 use getOrDefault
|
||||||
for (final Card c : list) {
|
for (final Card c : list) {
|
||||||
for (final String var : c.getType()) {
|
|
||||||
if (valid.contains(var)) {
|
// Changeling are all creature types, they are not interesting for
|
||||||
if (!map.containsKey(var)) {
|
// counting creature types
|
||||||
map.put(var, 1);
|
if (c.hasStartOfKeyword(Keyword.CHANGELING.toString())) {
|
||||||
} else {
|
continue;
|
||||||
map.put(var, map.get(var) + 1);
|
}
|
||||||
}
|
// ignore cards that does enter the battlefield as clones
|
||||||
|
boolean isClone = false;
|
||||||
|
for (ReplacementEffect re : c.getReplacementEffects()) {
|
||||||
|
if (re.getLayer() == ReplacementLayer.Copy) {
|
||||||
|
isClone = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isClone) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> cardCreatureTypes = c.getType().getCreatureTypes();
|
||||||
|
for (String type : cardCreatureTypes) {
|
||||||
|
Integer count = typesInDeck.get(type);
|
||||||
|
if (count == null) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
typesInDeck.put(type, count + 1);
|
||||||
|
}
|
||||||
//also take into account abilities that generate tokens
|
//also take into account abilities that generate tokens
|
||||||
for(SpellAbility sa:c.getSpellAbilities()){
|
for (SpellAbility sa : c.getAllSpellAbilities()) {
|
||||||
if(sa.getParam("TokenName")!=null){
|
if (sa.getApi() != ApiType.Token) {
|
||||||
for(String var:sa.getParam("TokenName").split(" ")){
|
|
||||||
if (valid.contains(var)) {
|
|
||||||
if (!map.containsKey(var)) {
|
|
||||||
map.put(var, 1);
|
|
||||||
} else {
|
|
||||||
map.put(var, map.get(var) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(Trigger t:c.getTriggers()){
|
|
||||||
final String execute = t.getMapParams().get("Execute");
|
|
||||||
if (execute == null) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final SpellAbility sa = AbilityFactory.getAbility(c.getSVar(execute), c);
|
if (sa.hasParam("TokenTypes")) {
|
||||||
if(sa.getParam("TokenName")!=null){
|
for (String var : sa.getParam("TokenTypes").split(",")) {
|
||||||
String tokenName=sa.getParam("TokenName");
|
if (!CardType.isACreatureType(var)) {
|
||||||
for(String var:tokenName.split(" ")){
|
continue;
|
||||||
if (valid.contains(var)) {
|
|
||||||
if (!map.containsKey(var)) {
|
|
||||||
map.put(var, 1);
|
|
||||||
} else {
|
|
||||||
map.put(var, map.get(var) + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Integer count = typesInDeck.get(var);
|
||||||
|
if (count == null) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
typesInDeck.put(var, count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c.hasStartOfKeyword(Keyword.FABRICATE.toString())){
|
// same for Trigger that does make Tokens
|
||||||
if (!map.containsKey("Servo")) {
|
for(Trigger t:c.getTriggers()){
|
||||||
map.put("Servo", 1);
|
SpellAbility sa = t.getOverridingAbility();
|
||||||
} else {
|
String sTokenTypes = null;
|
||||||
map.put("Servo", map.get("Servo") + 1);
|
if (sa != null) {
|
||||||
|
if (sa.getApi() != ApiType.Token || !sa.hasParam("TokenTypes")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sTokenTypes = sa.getParam("TokenTypes");
|
||||||
|
} else if (t.hasParam("Execute")) {
|
||||||
|
String name = t.getParam("Execute");
|
||||||
|
if (!c.hasSVar(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> params = AbilityFactory.getMapParams(c.getSVar(name));
|
||||||
|
if (!params.containsKey("TokenTypes")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sTokenTypes = params.get("TokenTypes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sTokenTypes == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String var : sTokenTypes.split(",")) {
|
||||||
|
if (!CardType.isACreatureType(var)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Integer count = typesInDeck.get(var);
|
||||||
|
if (count == null) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
typesInDeck.put(var, count + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// special rule for Fabricate and Servo
|
||||||
|
if(c.hasStartOfKeyword(Keyword.FABRICATE.toString())){
|
||||||
|
Integer count = typesInDeck.get("Servo");
|
||||||
|
if (count == null) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
typesInDeck.put("Servo", count + 1);
|
||||||
}
|
}
|
||||||
} // for
|
} // for
|
||||||
|
|
||||||
int max = 0;
|
int max = 0;
|
||||||
String maxType = "";
|
String maxType = "";
|
||||||
|
|
||||||
for (final Entry<String, Integer> entry : map.entrySet()) {
|
for (final Entry<String, Integer> entry : typesInDeck.entrySet()) {
|
||||||
final String type = entry.getKey();
|
final String type = entry.getKey();
|
||||||
// Log.debug(type + " - " + entry.getValue());
|
// Log.debug(type + " - " + entry.getValue());
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,17 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import forge.game.ability.AbilityFactory;
|
import forge.game.ability.AbilityFactory;
|
||||||
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.keyword.Keyword;
|
import forge.game.keyword.Keyword;
|
||||||
import org.apache.commons.lang3.Range;
|
import org.apache.commons.lang3.Range;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -34,6 +32,7 @@ import com.google.common.collect.ListMultimap;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.GuiBase;
|
import forge.GuiBase;
|
||||||
@@ -42,6 +41,7 @@ import forge.achievement.AchievementCollection;
|
|||||||
import forge.ai.GameState;
|
import forge.ai.GameState;
|
||||||
import forge.assets.FSkinProp;
|
import forge.assets.FSkinProp;
|
||||||
import forge.card.CardDb;
|
import forge.card.CardDb;
|
||||||
|
import forge.card.CardType;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.ICardFace;
|
import forge.card.ICardFace;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
@@ -80,6 +80,7 @@ import forge.game.player.PlayerActionConfirmMode;
|
|||||||
import forge.game.player.PlayerController;
|
import forge.game.player.PlayerController;
|
||||||
import forge.game.player.PlayerView;
|
import forge.game.player.PlayerView;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
|
import forge.game.replacement.ReplacementLayer;
|
||||||
import forge.game.spellability.AbilityManaPart;
|
import forge.game.spellability.AbilityManaPart;
|
||||||
import forge.game.spellability.AbilitySub;
|
import forge.game.spellability.AbilitySub;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -186,7 +187,7 @@ public class PlayerControllerHuman
|
|||||||
return mayLookAtAllCards;
|
return mayLookAtAllCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set<Card> tempShownCards = new HashSet<Card>();
|
private final Set<Card> tempShownCards = Sets.newHashSet();
|
||||||
public <T> void tempShow(final Iterable<T> objects) {
|
public <T> void tempShow(final Iterable<T> objects) {
|
||||||
for (final T t : objects) {
|
for (final T t : objects) {
|
||||||
// assume you may see any card passed through here
|
// assume you may see any card passed through here
|
||||||
@@ -791,7 +792,7 @@ public class PlayerControllerHuman
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Mana chooseManaFromPool(final List<Mana> manaChoices) {
|
public Mana chooseManaFromPool(final List<Mana> manaChoices) {
|
||||||
final List<String> options = new ArrayList<String>();
|
final List<String> options = Lists.newArrayList();
|
||||||
for (int i = 0; i < manaChoices.size(); i++) {
|
for (int i = 0; i < manaChoices.size(); i++) {
|
||||||
final Mana m = manaChoices.get(i);
|
final Mana m = manaChoices.get(i);
|
||||||
options.add(String.format("%d. %s mana from %s", 1+i, MagicColor.toLongString(m.getColor()), m.getSourceCard()));
|
options.add(String.format("%d. %s mana from %s", 1+i, MagicColor.toLongString(m.getColor()), m.getSourceCard()));
|
||||||
@@ -823,61 +824,94 @@ public class PlayerControllerHuman
|
|||||||
private void sortCreatureTypes(List<String> types) {
|
private void sortCreatureTypes(List<String> types) {
|
||||||
//build map of creature types in player's main deck against the occurrences of each
|
//build map of creature types in player's main deck against the occurrences of each
|
||||||
CardCollection pool = CardLists.filterControlledBy(game.getCardsInGame(),player);
|
CardCollection pool = CardLists.filterControlledBy(game.getCardsInGame(),player);
|
||||||
HashMap<String, Integer> typesInDeck = new HashMap<String, Integer>();
|
Map<String, Integer> typesInDeck = Maps.newHashMap();
|
||||||
|
|
||||||
|
// TODO JAVA 8 use getOrDefault
|
||||||
for (Card c : pool) {
|
for (Card c : pool) {
|
||||||
if(c.getRules()==null || c.getRules().getType()==null){
|
|
||||||
|
// Changeling are all creature types, they are not interesting for counting creature types
|
||||||
|
if (c.hasStartOfKeyword(Keyword.CHANGELING.toString())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Set<String> cardCreatureTypes = c.getRules().getType().getCreatureTypes();
|
// ignore cards that does enter the battlefield as clones
|
||||||
|
boolean isClone = false;
|
||||||
|
for (ReplacementEffect re : c.getReplacementEffects()) {
|
||||||
|
if (re.getLayer() == ReplacementLayer.Copy) {
|
||||||
|
isClone = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isClone) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> cardCreatureTypes = c.getType().getCreatureTypes();
|
||||||
for (String type : cardCreatureTypes) {
|
for (String type : cardCreatureTypes) {
|
||||||
Integer count = typesInDeck.get(type);
|
Integer count = typesInDeck.get(type);
|
||||||
if (count == null) { count = 0; }
|
if (count == null) { count = 0; }
|
||||||
typesInDeck.put(type, count + 1);
|
typesInDeck.put(type, count + 1);
|
||||||
}
|
}
|
||||||
//also take into account abilities that generate tokens
|
//also take into account abilities that generate tokens
|
||||||
for(SpellAbility sa:c.getAllSpellAbilities()){
|
for(SpellAbility sa: c.getAllSpellAbilities()){
|
||||||
if(sa.getParam("TokenName")!=null){
|
if (sa.getApi() != ApiType.Token) {
|
||||||
for(String var:sa.getParam("TokenName").split(" ")){
|
|
||||||
if (types.contains(var)) {
|
|
||||||
if (!typesInDeck.containsKey(var)) {
|
|
||||||
typesInDeck.put(var, 1);
|
|
||||||
} else {
|
|
||||||
typesInDeck.put(var, typesInDeck.get(var) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(Trigger t:c.getTriggers()){
|
|
||||||
final String execute = t.getMapParams().get("Execute");
|
|
||||||
if (execute == null) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final SpellAbility sa = AbilityFactory.getAbility(c.getSVar(execute), c);
|
if(sa.hasParam("TokenTypes")){
|
||||||
if(sa.getParam("TokenName")!=null){
|
for(String var: sa.getParam("TokenTypes").split(",")){
|
||||||
String tokenName=sa.getParam("TokenName");
|
if (!CardType.isACreatureType(var)) {
|
||||||
for(String var:tokenName.split(" ")){
|
continue;
|
||||||
if (types.contains(var)) {
|
|
||||||
if (!typesInDeck.containsKey(var)) {
|
|
||||||
typesInDeck.put(var, 1);
|
|
||||||
} else {
|
|
||||||
typesInDeck.put(var, typesInDeck.get(var) + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Integer count = typesInDeck.get(var);
|
||||||
|
if (count == null) { count = 0; }
|
||||||
|
typesInDeck.put(var, count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c.hasStartOfKeyword(Keyword.FABRICATE.toString())){
|
// same for Trigger that does make Tokens
|
||||||
if (!typesInDeck.containsKey("Servo")) {
|
for(Trigger t:c.getTriggers()){
|
||||||
typesInDeck.put("Servo", 1);
|
SpellAbility sa = t.getOverridingAbility();
|
||||||
} else {
|
String sTokenTypes = null;
|
||||||
typesInDeck.put("Servo", typesInDeck.get("Servo") + 1);
|
if (sa != null) {
|
||||||
|
if (sa.getApi() != ApiType.Token || !sa.hasParam("TokenTypes")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sTokenTypes = sa.getParam("TokenTypes");
|
||||||
|
} else if (t.hasParam("Execute")) {
|
||||||
|
String name = t.getParam("Execute");
|
||||||
|
if (!c.hasSVar(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String,String> params = AbilityFactory.getMapParams(c.getSVar(name));
|
||||||
|
if (!params.containsKey("TokenTypes")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sTokenTypes = params.get("TokenTypes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sTokenTypes == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String var: sTokenTypes.split(",")){
|
||||||
|
if (!CardType.isACreatureType(var)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Integer count = typesInDeck.get(var);
|
||||||
|
if (count == null) { count = 0; }
|
||||||
|
typesInDeck.put(var, count + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// special rule for Fabricate and Servo
|
||||||
|
if(c.hasStartOfKeyword(Keyword.FABRICATE.toString())){
|
||||||
|
Integer count = typesInDeck.get("Servo");
|
||||||
|
if (count == null) { count = 0; }
|
||||||
|
typesInDeck.put("Servo", count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//create sorted list from map from least to most frequent
|
//create sorted list from map from least to most frequent
|
||||||
List<Entry<String, Integer>> sortedList = new LinkedList<Entry<String, Integer>>(typesInDeck.entrySet());
|
List<Entry<String, Integer>> sortedList = Lists.newArrayList(typesInDeck.entrySet());
|
||||||
Collections.sort(sortedList, new Comparator<Entry<String, Integer>>() {
|
Collections.sort(sortedList, new Comparator<Entry<String, Integer>>() {
|
||||||
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
|
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
|
||||||
return o1.getValue().compareTo(o2.getValue());
|
return o1.getValue().compareTo(o2.getValue());
|
||||||
@@ -1041,7 +1075,7 @@ public class PlayerControllerHuman
|
|||||||
for (final SpellAbility sa : usableFromOpeningHand) {
|
for (final SpellAbility sa : usableFromOpeningHand) {
|
||||||
srcCards.add(sa.getHostCard());
|
srcCards.add(sa.getHostCard());
|
||||||
}
|
}
|
||||||
final List<SpellAbility> result = new ArrayList<SpellAbility>();
|
final List<SpellAbility> result = Lists.newArrayList();
|
||||||
if (srcCards.isEmpty()) {
|
if (srcCards.isEmpty()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1243,7 +1277,7 @@ public class PlayerControllerHuman
|
|||||||
}
|
}
|
||||||
|
|
||||||
//stores saved order for different sets of SpellAbilities
|
//stores saved order for different sets of SpellAbilities
|
||||||
private final HashMap<String, List<Integer>> orderedSALookup = new HashMap<String, List<Integer>>();
|
private final Map<String, List<Integer>> orderedSALookup = Maps.newHashMap();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void orderAndPlaySimultaneousSa(final List<SpellAbility> activePlayerSAs) {
|
public void orderAndPlaySimultaneousSa(final List<SpellAbility> activePlayerSAs) {
|
||||||
@@ -1274,7 +1308,7 @@ public class PlayerControllerHuman
|
|||||||
List<Integer> savedOrder = orderedSALookup.get(saLookupKey);
|
List<Integer> savedOrder = orderedSALookup.get(saLookupKey);
|
||||||
|
|
||||||
if (savedOrder != null) {
|
if (savedOrder != null) {
|
||||||
orderedSAs = new ArrayList<SpellAbility>();
|
orderedSAs = Lists.newArrayList();
|
||||||
for (Integer index : savedOrder) {
|
for (Integer index : savedOrder) {
|
||||||
orderedSAs.add(activePlayerSAs.get(index));
|
orderedSAs.add(activePlayerSAs.get(index));
|
||||||
}
|
}
|
||||||
@@ -1282,12 +1316,12 @@ public class PlayerControllerHuman
|
|||||||
if (savedOrder != null) {
|
if (savedOrder != null) {
|
||||||
boolean preselect = FModel.getPreferences().getPrefBoolean(FPref.UI_PRESELECT_PREVIOUS_ABILITY_ORDER);
|
boolean preselect = FModel.getPreferences().getPrefBoolean(FPref.UI_PRESELECT_PREVIOUS_ABILITY_ORDER);
|
||||||
orderedSAs = getGui().order("Reorder simultaneous abilities", "Resolve first", 0, 0,
|
orderedSAs = getGui().order("Reorder simultaneous abilities", "Resolve first", 0, 0,
|
||||||
preselect ? new ArrayList<SpellAbility>() : orderedSAs, preselect ? orderedSAs : new ArrayList<SpellAbility>(), null, false);
|
preselect ? Lists.<SpellAbility>newArrayList() : orderedSAs, preselect ? orderedSAs : Lists.<SpellAbility>newArrayList(), null, false);
|
||||||
} else {
|
} else {
|
||||||
orderedSAs = getGui().order("Select order for simultaneous abilities", "Resolve first", orderedSAs, null);
|
orderedSAs = getGui().order("Select order for simultaneous abilities", "Resolve first", orderedSAs, null);
|
||||||
}
|
}
|
||||||
//save order to avoid needing to prompt a second time to order the same abilities
|
//save order to avoid needing to prompt a second time to order the same abilities
|
||||||
savedOrder = new ArrayList<Integer>(activePlayerSAs.size());
|
savedOrder = Lists.newArrayListWithCapacity(activePlayerSAs.size());
|
||||||
for (SpellAbility sa : orderedSAs) {
|
for (SpellAbility sa : orderedSAs) {
|
||||||
savedOrder.add(activePlayerSAs.indexOf(sa));
|
savedOrder.add(activePlayerSAs.indexOf(sa));
|
||||||
}
|
}
|
||||||
@@ -1391,7 +1425,7 @@ public class PlayerControllerHuman
|
|||||||
if (c.getShieldCount() < 2) {
|
if (c.getShieldCount() < 2) {
|
||||||
return Iterables.getFirst(c.getShields(), null);
|
return Iterables.getFirst(c.getShields(), null);
|
||||||
}
|
}
|
||||||
final List<CardShields> shields = new ArrayList<CardShields>();
|
final List<CardShields> shields = Lists.newArrayList();
|
||||||
for (final CardShields shield : c.getShields()) {
|
for (final CardShields shield : c.getShields()) {
|
||||||
shields.add(shield);
|
shields.add(shield);
|
||||||
}
|
}
|
||||||
@@ -1601,7 +1635,7 @@ public class PlayerControllerHuman
|
|||||||
|
|
||||||
final Card dummy = new Card(-777777, game);
|
final Card dummy = new Card(-777777, game);
|
||||||
dummy.setOwner(pPriority);
|
dummy.setOwner(pPriority);
|
||||||
final Map<String, String> produced = new HashMap<String, String>();
|
final Map<String, String> produced = Maps.newHashMap();
|
||||||
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
||||||
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
||||||
game.getAction().invoke(new Runnable() {
|
game.getAction().invoke(new Runnable() {
|
||||||
@@ -1690,7 +1724,7 @@ public class PlayerControllerHuman
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CardCollection lib = (CardCollection)pPriority.getCardsIn(ZoneType.Library);
|
final CardCollection lib = (CardCollection)pPriority.getCardsIn(ZoneType.Library);
|
||||||
final List<ZoneType> origin = new ArrayList<ZoneType>();
|
final List<ZoneType> origin = Lists.newArrayList();
|
||||||
origin.add(ZoneType.Library);
|
origin.add(ZoneType.Library);
|
||||||
final SpellAbility sa = new SpellAbility.EmptySa(new Card(-1, game));
|
final SpellAbility sa = new SpellAbility.EmptySa(new Card(-1, game));
|
||||||
final Card card = chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, null, "Choose a card", true, pPriority);
|
final Card card = chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, null, "Choose a card", true, pPriority);
|
||||||
@@ -1984,7 +2018,7 @@ public class PlayerControllerHuman
|
|||||||
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) { return; }
|
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) { return; }
|
||||||
final Player p = game.getPhaseHandler().getPlayerTurn();
|
final Player p = game.getPhaseHandler().getPlayerTurn();
|
||||||
|
|
||||||
final List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
final List<PaperCard> allPlanars = Lists.newArrayList();
|
||||||
for (final PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
|
for (final PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
|
||||||
if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) {
|
if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) {
|
||||||
allPlanars.add(c);
|
allPlanars.add(c);
|
||||||
@@ -2024,7 +2058,7 @@ public class PlayerControllerHuman
|
|||||||
private int sequenceIndex = 0;
|
private int sequenceIndex = 0;
|
||||||
// "Actions" are stored as a pair of the "action" recipient (the entity
|
// "Actions" are stored as a pair of the "action" recipient (the entity
|
||||||
// to "click") and a boolean representing whether the entity is a player.
|
// to "click") and a boolean representing whether the entity is a player.
|
||||||
private final List<Pair<GameEntityView, Boolean>> rememberedActions = new ArrayList<>();
|
private final List<Pair<GameEntityView, Boolean>> rememberedActions = Lists.newArrayList();
|
||||||
private String rememberedSequenceText = "";
|
private String rememberedSequenceText = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2040,7 +2074,7 @@ public class PlayerControllerHuman
|
|||||||
int currentIndex = sequenceIndex;
|
int currentIndex = sequenceIndex;
|
||||||
sequenceIndex = 0;
|
sequenceIndex = 0;
|
||||||
// Use a Pair so we can keep a flag for isPlayer
|
// Use a Pair so we can keep a flag for isPlayer
|
||||||
final List<Pair<Integer, Boolean>> entityInfo = new ArrayList<>();
|
final List<Pair<Integer, Boolean>> entityInfo = Lists.newArrayList();
|
||||||
final int playerID = getPlayer().getId();
|
final int playerID = getPlayer().getId();
|
||||||
// Only support 1 opponent for now. There are some ideas about supporting
|
// Only support 1 opponent for now. There are some ideas about supporting
|
||||||
// multiplayer games in the future, but for now it would complicate the parsing
|
// multiplayer games in the future, but for now it would complicate the parsing
|
||||||
|
|||||||
Reference in New Issue
Block a user