mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Add enum and instance classes for keywords
This commit is contained in:
13
.gitattributes
vendored
13
.gitattributes
vendored
@@ -287,7 +287,6 @@ forge-game/src/main/java/forge/game/GameView.java -text
|
||||
forge-game/src/main/java/forge/game/GlobalRuleChange.java -text
|
||||
forge-game/src/main/java/forge/game/IHasGameType.java -text
|
||||
forge-game/src/main/java/forge/game/IIdentifiable.java -text
|
||||
forge-game/src/main/java/forge/game/KeywordsChange.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/Match.java -text
|
||||
forge-game/src/main/java/forge/game/PlanarDice.java -text
|
||||
forge-game/src/main/java/forge/game/StaticEffect.java svneol=native#text/plain
|
||||
@@ -533,6 +532,18 @@ forge-game/src/main/java/forge/game/event/package-info.java -text
|
||||
forge-game/src/main/java/forge/game/io/GameStateDeserializer.java -text
|
||||
forge-game/src/main/java/forge/game/io/GameStateSerializer.java -text
|
||||
forge-game/src/main/java/forge/game/io/IGameStateObject.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/Cycling.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/Keyword.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordCollection.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordInstance.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordWithAmount.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordWithCost.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordWithCostAndAmount.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordWithCostAndType.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordWithType.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/KeywordsChange.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/Protection.java -text
|
||||
forge-game/src/main/java/forge/game/keyword/SimpleKeyword.java -text
|
||||
forge-game/src/main/java/forge/game/mana/Mana.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/mana/ManaCostAdjustment.java -text
|
||||
forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java svneol=native#text/plain
|
||||
|
||||
18
forge-game/src/main/java/forge/game/keyword/Cycling.java
Normal file
18
forge-game/src/main/java/forge/game/keyword/Cycling.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
public class Cycling extends KeywordWithCost {
|
||||
private String type;
|
||||
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
if (type == null) {
|
||||
return super.formatReminderText(reminderText);
|
||||
}
|
||||
//handle special case of type cycling
|
||||
return super.formatReminderText("%s, Discard this card: Search your library for a " + type + " card, reveal it, and put it into your hand. Then shuffle your library.");
|
||||
}
|
||||
}
|
||||
104
forge-game/src/main/java/forge/game/keyword/Keyword.java
Normal file
104
forge-game/src/main/java/forge/game/keyword/Keyword.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
public enum Keyword {
|
||||
Absorb(KeywordWithAmount.class, true, "If a source would deal damage to this creature, prevent %d of that damage."),
|
||||
Affinity(KeywordWithType.class, true, "This spell costs you {1} less to cast for each %s you control."),
|
||||
Amplify(KeywordWithAmount.class, true, "As this card enters the battlefield, reveal any number of cards from your hand that share a creature type with it. This permanent enters the battlefield with %d +1/+1 counters on it for each card revealed this way. You can't reveal this card or any other cards that are entering the battlefield at the same time as this card."),
|
||||
Annihilator(KeywordWithAmount.class, true, "Whenever this creature attacks, defending player sacrifices %d permanents."),
|
||||
AuraSwap(KeywordWithCost.class, true, "%s: You may exchange this permanent with an Aura card in your hand."),
|
||||
Banding(SimpleKeyword.class, false, "Any creatures with banding, and up to one without, can attack in a band. Bands are blocked as a group. If any creatures with banding you control are blocking or being blocked by a creature, you divide that creature's combat damage, not its controller, among any of the creatures it's being blocked by or is blocking."),
|
||||
BattleCry(KeywordWithAmount.class, true, "Whenever this creature attacks, each other attacking creature gets +1/+0 until end of turn."),
|
||||
Bloodthirst(KeywordWithAmount.class, true, "If an opponent was dealt damage this turn, this permanent enters the battlefield with %d +1/+1 counters on it."),
|
||||
Bushido(KeywordWithAmount.class, true, "Whenever this creature blocks or becomes blocked, it gets +N/+N until end of turn."),
|
||||
Buyback(KeywordWithCost.class, true, "You may pay an additional %s as you cast this spell. If you do, put it into your hand instead of your graveyard as it resolves."),
|
||||
Cascade(SimpleKeyword.class, true, "When you cast this spell, exile cards from the top of your library until you exile a nonland card whose converted mana cost is less than this spell's converted mana cost. You may cast that card without paying its mana cost. Then put all cards exiled this way that weren't cast on the bottom of your library in a random order."),
|
||||
Champion(KeywordWithType.class, true, "When this permanent enters the battlefield, sacrifice it unless you exile another %s you control. When this permanent leaves the battlefield, return the exiled card to the battlefield under its owner's control."),
|
||||
Changeling(SimpleKeyword.class, false, "This card is every creature type at all times."),
|
||||
Conspire(SimpleKeyword.class, true, "As an additional cost to cast this spell, you may tap two untapped creatures you control that each share a color with it. If you do, copy it."),
|
||||
Convoke(SimpleKeyword.class, false, "Each creature you tap while playing this spell reduces its cost by {1} or by one mana of that creature's color."),
|
||||
CumulativeUpkeep(KeywordWithCost.class, true, "At the beginning of your upkeep, put an age counter on this permanent. Then you may pay %s for each age counter on it. If you don't, sacrifice it."),
|
||||
Cycling(Cycling.class, true, "%s, Discard this card: Draw a card."), //Typecycling reminder text handled by Cycling class
|
||||
Deathtouch(SimpleKeyword.class, false, "Any amount of damage this deals to a creature is enough to destroy it."),
|
||||
Defender(SimpleKeyword.class, false, "This creature can't attack."),
|
||||
Delve(SimpleKeyword.class, false, "As an additional cost to cast this spell, you may exile any number of cards from your graveyard. Each card exiled this way reduces the cost to cast this spell by {1}."),
|
||||
Devour(KeywordWithAmount.class, false, "As this creature enters the battlefield, you may sacrifice any number of creatures. This creature enters the battlefield with %d +1/+1 counters on it for each creature sacrificed this way."),
|
||||
DoubleStrike(SimpleKeyword.class, false, "This creature deals both first-strike and regular combat damage."),
|
||||
Dredge(KeywordWithAmount.class, false, "If you would draw a card, you may instead put %d cards from the top of your library into your graveyard and return this card from your graveyard to your hand."),
|
||||
Echo(KeywordWithCost.class, true, "At the beginning of your upkeep, if this permanent came under your control since the beginning of your last upkeep, sacrifice it unless you pay %s."),
|
||||
Enchant(KeywordWithType.class, true, "Target a %s as you play this. This card enters the battlefield attached to that %s."),
|
||||
Entwine(KeywordWithCost.class, false, "You may choose all modes of this spell instead of just one. If you do, you pay an additional %s."),
|
||||
Epic(SimpleKeyword.class, false, "For the rest of the game, you can't cast spells. At the beginning of each of your upkeeps for the rest of the game, copy this spell except for its epic ability. If the spell has any targets, you may choose new targets for the copy."),
|
||||
Equip(KeywordWithCost.class, true, "%s: Attach this permanent to target creature you control. Activate this ability only any time you could cast a sorcery."),
|
||||
Evoke(KeywordWithCost.class, true, "You may cast this card by paying %s rather than paying its mana cost. If you do, it's sacrificed when it enters the battlefield."),
|
||||
Exalted(KeywordWithAmount.class, true, "Whenever a creature you control attacks alone, that creature gets +1/+1 until end of turn."),
|
||||
Fading(KeywordWithAmount.class, true, "This permanent enters the battlefield with %d fade counters on it. At the beginning of your upkeep, remove a fade counter from it. If you can't, sacrifice it."),
|
||||
Fateseal(KeywordWithAmount.class, true, "Look at the top %d cards of an opponent's library, then put any number of them on the bottom of that player's library and the rest on top in any order."),
|
||||
Fear(SimpleKeyword.class, false, "This creature can't be blocked except by artifact creatures and/or black creatures."),
|
||||
FirstStrike(SimpleKeyword.class, false, "This creature deals combat damage before creatures without first strike."),
|
||||
Flanking(SimpleKeyword.class, true, "Whenever this creature becomes blocked by a creature without flanking, the blocking creature gets -1/-1 until end of turn."),
|
||||
Flash(SimpleKeyword.class, false, "You may play this card any time you could cast an instant."),
|
||||
Flashback(KeywordWithCost.class, true, "You may cast this card from your graveyard by paying %s rather than paying its mana cost. If you do, exile it as it resolves."),
|
||||
Flying(SimpleKeyword.class, false, "This creature can't be blocked except by creatures with flying or reach."),
|
||||
Forecast(KeywordWithCost.class, true, "Play this ability only during your upkeep and only once each turn."),
|
||||
Fortify(KeywordWithCost.class, true, "%s: Attach this permanent to target land you control. Activate this ability only any time you could cast a sorcery."),
|
||||
Frenzy(KeywordWithAmount.class, true, "Whenever this creature attacks and isn't blocked, it gets +%d/+0 until end of turn."),
|
||||
Graft(KeywordWithAmount.class, true, "This permanent enters the battlefield with %d +1/+1 counters on it. Whenever another creature enters the battlefield, you may move a +1/+1 counter from this permanent onto it."),
|
||||
Gravestorm(SimpleKeyword.class, true, "When you cast this spell, copy it for each permanent that was put into a graveyard from the battlefield this turn. You may choose new targets for the copies."),
|
||||
Haste(SimpleKeyword.class, false, "This creature can attack and {T} as soon as it comes under your control."),
|
||||
Haunt(SimpleKeyword.class, true, "When this is put into a graveyard, exile it haunting target creature."),
|
||||
Hexproof(SimpleKeyword.class, false, "This can't be the target of spells or abilities your opponents control."),
|
||||
Hideaway(SimpleKeyword.class, true, "This permanent enters the battlefield tapped. When it does, look at the top four cards of your library, exile one of them face down, then put the rest on the bottom of your library in any order."),
|
||||
Horsemanship(SimpleKeyword.class, false, "This creature can't be blocked except by creatures with horsemanship."),
|
||||
Infect(SimpleKeyword.class, false, " This creature deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters."),
|
||||
Intimidate(SimpleKeyword.class, false, "This creature can't be blocked except by artifact creatures and/or creatures that share a color with it."),
|
||||
Kicker(KeywordWithCost.class, true, "You may pay an additional %s as you cast this spell."),
|
||||
Landwalk(KeywordWithType.class, true, "This creature is unblockable as long as defending player controls a %s."),
|
||||
LevelUp(KeywordWithCost.class, true, "%s: Put a level counter on this permanent. Activate this ability only any time you could cast a sorcery."),
|
||||
Lifelink(SimpleKeyword.class, false, "Damage dealt by this creature also causes its controller to gain that much life."),
|
||||
LivingWeapon(SimpleKeyword.class, false, "When this Equipment enters the battlefield, put a 0/0 black Germ creature token onto the battlefield, then attach this Equipment to it."),
|
||||
Madness(KeywordWithCost.class, false, "If you discard this card, you may cast it for %s instead of putting it into your graveyard."),
|
||||
Modular(KeywordWithAmount.class, true, "This creature enters the battlefield with %d +1/+1 counters on it. When it dies, you may put its +1/+1 counters on target artifact creature."),
|
||||
Morph(KeywordWithCost.class, false, "You may cast this face down as a 2/2 creature for {3}. You may pay %s at any time to turn it face up."),
|
||||
Multikicker(KeywordWithCost.class, true, "You may pay an additional %s any number of times as you cast this spell."),
|
||||
Ninjutsu(KeywordWithCost.class, true, "%s, Reveal this card from your hand, Return an unblocked attacking creature you control to its owner's hand: Put this card onto the battlefield from your hand tapped and attacking."),
|
||||
Offering(KeywordWithType.class, true, "You may cast this card any time you could cast an instant by sacrificing a %s. If you do, the total cost to cast this card is reduced by the mana cost of the sacrificed %s."),
|
||||
Persist(SimpleKeyword.class, false, "When this permanent is put into a graveyard from the battlefield, if it had no -1/-1 counters on it, return it to the battlefield under its owner's control with a -1/-1 counter on it."),
|
||||
Phasing(SimpleKeyword.class, false, "This phases in or out before you untap during each of your untap steps. While it's phased out, it's treated as though it doesn't exist."),
|
||||
Poisonous(KeywordWithAmount.class, true, "Whenever this creature deals combat damage to a player, that player gets %d poison counters."),
|
||||
Protection(Protection.class, true, "This creature can't be blocked, targeted, dealt damage, or equipped/enchanted by %s."),
|
||||
Provoke(SimpleKeyword.class, true, "Whenever this creature attacks, you may choose to have target creature defending player controls block this creature this combat if able. If you do, untap that creature."),
|
||||
Prowl(KeywordWithCost.class, true, "You may cast this card by paying %s rather than paying its mana cost if you dealt combat damage to a player this turn with a creature that shares any of this spell's creature types."),
|
||||
Rampage(KeywordWithAmount.class, true, "Whenever this creature becomes blocked, it gets +%d/+%d until end of turn for each creature blocking it beyond the first."),
|
||||
Reach(SimpleKeyword.class, false, "This creature can block creatures with flying."),
|
||||
Rebound(SimpleKeyword.class, false, "If you cast this spell from your hand, exile it as it resolves. At the beginning of your next upkeep, you may cast this card from exile without paying its mana cost."),
|
||||
Recover(KeywordWithCost.class, true, "When a creature is put into your graveyard from the battlefield, you may pay %s. If you do, return this card from your graveyard to your hand. Otherwise, exile this card."),
|
||||
Reinforce(KeywordWithCostAndAmount.class, true, "%s, Discard this card: Put %d +1/+1 counters on target creature."),
|
||||
Replicate(KeywordWithCost.class, true, "As an additional cost to cast this spell, you may pay %s any number of times. If you do, copy it that many times. You may choose new targets for the copies."),
|
||||
Retrace(SimpleKeyword.class, false, "You may cast this card from your graveyard by discarding a land card in addition to paying its other costs."),
|
||||
Ripple(KeywordWithAmount.class, true, "When you cast this spell, you may reveal the top %d cards of your library. You may cast any of those cards with the same name as this spell without paying their mana costs. Put the rest on the bottom of your library in any order."),
|
||||
Shroud(SimpleKeyword.class, false, "This can't be the target of spells or abilities."),
|
||||
Soulshift(KeywordWithAmount.class, true, "When this permanent is put into a graveyard from the battlefield, you may return target Spirit card with converted mana cost %d or less from your graveyard to your hand."),
|
||||
Splice(KeywordWithCostAndType.class, true, "You may reveal this card from your hand as you cast a %s spell. If you do, copy this card's text box onto that spell and pay %s as an additional cost to cast that spell."),
|
||||
SplitSecond(SimpleKeyword.class, false, "As long as this spell is on the stack, players can't play other spells or abilities that aren't mana abilities."),
|
||||
Storm(SimpleKeyword.class, true, "When you cast this spell, copy it for each other spell that was cast before it this turn. You may choose new targets for the copies."),
|
||||
Sunburst(SimpleKeyword.class, true, "This enters the battlefield with either a +1/+1 or charge counter on it for each color of mana spent to cast it based on whether it's a creature."),
|
||||
Suspend(KeywordWithCostAndAmount.class, true, "Rather than cast this card from your hand, you may pay %s and exile it with %d time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost."),
|
||||
TotemArmor(SimpleKeyword.class, false, "If enchanted permanent would be destroyed, instead remove all damage marked on it and destroy this Aura."),
|
||||
Trample(SimpleKeyword.class, false, "If this creature would assign enough damage to its blockers to destroy them, you may have it assign the rest of its damage to defending player or planeswalker."),
|
||||
Transfigure(KeywordWithCost.class, true, "%s, Sacrifice this permanent: Search your library for a creature card with the same converted mana cost as this permanent and put it onto the battlefield. Then shuffle your library. Activate this ability only any time you could cast a sorcery."),
|
||||
Transmute(KeywordWithCost.class, true, "%s, Discard this card: Search your library for a card with the same converted mana cost as the discarded card, reveal that card, and put it into your hand. Then shuffle your library. Activate this ability only any time you could cast a sorcery."),
|
||||
Unearth(KeywordWithCost.class, true, "%s: Return this card from your graveyard to the battlefield. It gains haste. Exile it at the beginning of the next end step. If it would leave the battlefield, exile it instead of putting it anywhere else. Activate this ability only any time you could cast a sorcery."),
|
||||
Vanishing(KeywordWithAmount.class, true, "This permanent enters the battlefield with %d time counters on it. At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it."),
|
||||
Vigilance(SimpleKeyword.class, false, "Attacking doesn't cause this creature to tap."),
|
||||
Wither(SimpleKeyword.class, false, "This creature deals damage to creatures in the form of -1/-1 counters.");
|
||||
|
||||
final Class<? extends KeywordInstance<?>> type;
|
||||
final boolean allowMultiple;
|
||||
final String reminderText;
|
||||
|
||||
private Keyword(Class<? extends KeywordInstance<?>> type0, boolean allowMultiple0, String reminderText0) {
|
||||
type = type0;
|
||||
allowMultiple = allowMultiple0;
|
||||
reminderText = reminderText0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
public class KeywordCollection {
|
||||
private final EnumMap<Keyword, List<KeywordInstance<?>>> keywords = new EnumMap<Keyword, List<KeywordInstance<?>>>(Keyword.class);
|
||||
|
||||
public boolean contains(Keyword keyword) {
|
||||
return keywords.containsKey(keyword);
|
||||
}
|
||||
|
||||
public int getAmount(Keyword keyword) {
|
||||
int amount = 0;
|
||||
List<KeywordInstance<?>> instances = keywords.get(keyword);
|
||||
if (instances != null) {
|
||||
for (KeywordInstance<?> inst : instances) {
|
||||
amount += inst.getAmount();
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
public abstract class KeywordInstance<T extends KeywordInstance<?>> {
|
||||
public int getAmount() {
|
||||
return 1;
|
||||
}
|
||||
protected abstract void parse(String details);
|
||||
protected abstract String formatReminderText(String reminderText);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
public class KeywordWithAmount extends KeywordInstance<KeywordWithAmount> {
|
||||
private int amount;
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
return String.format(reminderText, amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
import forge.game.cost.Cost;
|
||||
|
||||
public class KeywordWithCost extends KeywordInstance<KeywordWithCost> {
|
||||
private Cost cost;
|
||||
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
return String.format(reminderText, cost.toSimpleString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
import forge.game.cost.Cost;
|
||||
|
||||
public class KeywordWithCostAndAmount extends KeywordInstance<KeywordWithCostAndAmount> {
|
||||
private Cost cost;
|
||||
private int amount;
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
return String.format(reminderText, cost.toSimpleString(), amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
import forge.game.cost.Cost;
|
||||
|
||||
public class KeywordWithCostAndType extends KeywordInstance<KeywordWithCostAndType> {
|
||||
private Cost cost;
|
||||
private String type;
|
||||
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
return String.format(reminderText, cost.toSimpleString(), type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
public class KeywordWithType extends KeywordInstance<KeywordWithType> {
|
||||
private String type;
|
||||
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
return String.format(reminderText, type);
|
||||
}
|
||||
}
|
||||
@@ -1,89 +1,89 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Card_Keywords class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class KeywordsChange {
|
||||
private final List<String> keywords;
|
||||
private final List<String> removeKeywords;
|
||||
private final boolean removeAllKeywords;
|
||||
|
||||
/**
|
||||
*
|
||||
* Construct a new {@link KeywordsChange}.
|
||||
*
|
||||
* @param keywordList the list of keywords to add.
|
||||
* @param removeKeywordList the list of keywords to remove.
|
||||
* @param removeAll whether to remove all keywords.
|
||||
*/
|
||||
public KeywordsChange(final List<String> keywordList, final List<String> removeKeywordList, final boolean removeAll) {
|
||||
this.keywords = keywordList == null ? Lists.<String>newArrayList() : Lists.newArrayList(keywordList);
|
||||
this.removeKeywords = removeKeywordList == null ? Lists.<String>newArrayList() : Lists.newArrayList(removeKeywordList);
|
||||
this.removeAllKeywords = removeAll;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* getKeywords.
|
||||
*
|
||||
* @return ArrayList<String>
|
||||
*/
|
||||
public final List<String> getKeywords() {
|
||||
return this.keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* getRemoveKeywords.
|
||||
*
|
||||
* @return ArrayList<String>
|
||||
*/
|
||||
public final List<String> getRemoveKeywords() {
|
||||
return this.removeKeywords;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* isRemoveAllKeywords.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isRemoveAllKeywords() {
|
||||
return this.removeAllKeywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this KeywordsChange doesn't have any effect.
|
||||
*/
|
||||
public final boolean isEmpty() {
|
||||
return !this.removeAllKeywords
|
||||
&& this.keywords.isEmpty()
|
||||
&& this.removeKeywords.isEmpty();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.keyword;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Card_Keywords class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id: KeywordsChange.java 27095 2014-08-17 07:32:24Z elcnesh $
|
||||
*/
|
||||
public class KeywordsChange {
|
||||
private final List<String> keywords;
|
||||
private final List<String> removeKeywords;
|
||||
private final boolean removeAllKeywords;
|
||||
|
||||
/**
|
||||
*
|
||||
* Construct a new {@link KeywordsChange}.
|
||||
*
|
||||
* @param keywordList the list of keywords to add.
|
||||
* @param removeKeywordList the list of keywords to remove.
|
||||
* @param removeAll whether to remove all keywords.
|
||||
*/
|
||||
public KeywordsChange(final List<String> keywordList, final List<String> removeKeywordList, final boolean removeAll) {
|
||||
this.keywords = keywordList == null ? Lists.<String>newArrayList() : Lists.newArrayList(keywordList);
|
||||
this.removeKeywords = removeKeywordList == null ? Lists.<String>newArrayList() : Lists.newArrayList(removeKeywordList);
|
||||
this.removeAllKeywords = removeAll;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* getKeywords.
|
||||
*
|
||||
* @return ArrayList<String>
|
||||
*/
|
||||
public final List<String> getKeywords() {
|
||||
return this.keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* getRemoveKeywords.
|
||||
*
|
||||
* @return ArrayList<String>
|
||||
*/
|
||||
public final List<String> getRemoveKeywords() {
|
||||
return this.removeKeywords;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* isRemoveAllKeywords.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isRemoveAllKeywords() {
|
||||
return this.removeAllKeywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this KeywordsChange doesn't have any effect.
|
||||
*/
|
||||
public final boolean isEmpty() {
|
||||
return !this.removeAllKeywords
|
||||
&& this.keywords.isEmpty()
|
||||
&& this.removeKeywords.isEmpty();
|
||||
}
|
||||
}
|
||||
14
forge-game/src/main/java/forge/game/keyword/Protection.java
Normal file
14
forge-game/src/main/java/forge/game/keyword/Protection.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
public class Protection extends KeywordInstance<Protection> {
|
||||
private String fromWhat;
|
||||
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
return String.format(reminderText, fromWhat);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package forge.game.keyword;
|
||||
|
||||
public class SimpleKeyword extends KeywordInstance<SimpleKeyword> {
|
||||
@Override
|
||||
protected void parse(String details) {
|
||||
//don't need to merge details for simple keywords
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatReminderText(String reminderText) {
|
||||
return reminderText;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user