Merge branch 'master' into move_magepermanent_method

This commit is contained in:
ingmargoudt 2017-04-28 19:29:20 +02:00 committed by GitHub
commit 12eb4c2fb7
9 changed files with 238 additions and 61 deletions

View file

@ -57,25 +57,24 @@ public final class CardUtil {
private static final String SOURCE_EXILE_ZONE_TEXT = "SourceExileZone";
static final String[] numberStrings = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "ninteen", "twenty"};
public static final String[] NON_CHANGELING_SUBTYPES_VALUES = new String[]{
// basic lands subtypes
"Mountain", "Forest", "Plains", "Swamp", "Island",
// Enchantment subtypes
"Aura", "Curse", "Shrine",
// Artifact subtypes
"Clue", "Equipment", "Fortification", "Contraption", "Vehicle",
// Land subtypes
"Desert", "Gate", "Lair", "Locus", "Urza's", "Mine", "Power-Plant", "Tower",
// Planeswalker subtypes
"Ajani", "Arlinn", "Ashiok", "Bolas", "Chandra", "Dack", "Daretti", "Domri", "Dovin", "Elspeth", "Freyalise", "Garruk", "Gideon", "Jace",
"Karn", "Kiora", "Koth", "Liliana", "Nahiri", "Nissa", "Narset", "Nixilis", "Ral", "Saheeli", "Sarkhan", "Sorin", "Tamiyo", "Teferi",
"Tezzeret", "Tibalt", "Ugin", "Venser", "Vraska", "Xenagos",
// Instant sorcery subtypes
"Trap", "Arcane"};
public static final Set<String> NON_CREATURE_SUBTYPES = new HashSet<>(Arrays.asList(NON_CHANGELING_SUBTYPES_VALUES));
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"};
private static final String[] NON_CHANGELING_SUBTYPES_VALUES = new String[]{
// basic lands subtypes
"Mountain", "Forest", "Plains", "Swamp", "Island",
// Enchantment subtypes
"Aura", "Cartouche", "Curse", "Shrine",
// Artifact subtypes
"Clue", "Equipment", "Fortification", "Contraption", "Vehicle",
// Land subtypes
"Desert", "Gate", "Lair", "Locus", "Urza's", "Mine", "Power-Plant", "Tower",
// Planeswalker subtypes
"Ajani", "Arlinn", "Ashiok", "Bolas", "Chandra", "Dack", "Daretti", "Domri", "Dovin", "Elspeth", "Freyalise", "Garruk", "Gideon", "Jace",
"Karn", "Kiora", "Koth", "Liliana", "Nahiri", "Nissa", "Narset", "Nixilis", "Ral", "Saheeli", "Sarkhan", "Sorin", "Tamiyo", "Teferi",
"Tezzeret", "Tibalt", "Ugin", "Venser", "Vraska", "Xenagos",
// Instant sorcery subtypes
"Trap", "Arcane"};
private static final Set<String> NON_CREATURE_SUBTYPES = new HashSet<>(Arrays.asList(NON_CHANGELING_SUBTYPES_VALUES));
/**
* Increase spell or ability cost to be paid.

View file

@ -41,50 +41,45 @@ import mage.watchers.Watcher;
/**
* Stores cards that were cycled or discarded by any player this turn.
*
* @author jeffwadsworth
*/
public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher {
private final Map<UUID, Cards> cycledOrDiscardedCardsThisTurn = new HashMap<>();
Cards cards = new CardsImpl();
public CardsCycledOrDiscardedThisTurnWatcher() {
super("CardsCycledOrDiscardedThisTurnWatcher", WatcherScope.GAME);
super(CardsCycledOrDiscardedThisTurnWatcher.class.getName(), WatcherScope.GAME);
}
public CardsCycledOrDiscardedThisTurnWatcher(final CardsCycledOrDiscardedThisTurnWatcher watcher) {
super(watcher);
for (Entry<UUID, Cards> entry : watcher.cycledOrDiscardedCardsThisTurn.entrySet()) {
cycledOrDiscardedCardsThisTurn.put(entry.getKey(), entry.getValue());
cycledOrDiscardedCardsThisTurn.put(entry.getKey(), entry.getValue().copy());
}
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.UNTAP_STEP_PRE) {
reset();
}
if (event.getType() == GameEvent.EventType.CYCLED_CARD
|| event.getType() == GameEvent.EventType.DISCARDED_CARD) {
UUID playerId = event.getPlayerId();
if (playerId != null
&& game.getCard(event.getTargetId()) != null) {
if (event.getPlayerId() != null) {
Card card = game.getCard(event.getTargetId());
cards.add(card);
cycledOrDiscardedCardsThisTurn.putIfAbsent(playerId, cards);
if (card != null) {
getCardsCycledOrDiscardedThisTurn(event.getPlayerId()).add(card);
}
}
}
}
public Cards getCardsCycledOrDiscardedThisTurn(UUID playerId) {
return cycledOrDiscardedCardsThisTurn.get(playerId);
public Cards getCardsCycledOrDiscardedThisTurn(UUID playerId) {
return cycledOrDiscardedCardsThisTurn.getOrDefault(playerId, new CardsImpl());
}
@Override
public void reset() {
super.reset();
cycledOrDiscardedCardsThisTurn.clear();
cards.clear();
}
@Override