mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Fix MultiwordType parsing
This commit is contained in:
@@ -753,20 +753,18 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
||||
final CardType result = new CardType(incomplete);
|
||||
|
||||
int iTypeStart = 0;
|
||||
int iSpace = typeText.indexOf(space);
|
||||
boolean hasMoreTypes = typeText.length() > 0;
|
||||
int max = typeText.length();
|
||||
boolean hasMoreTypes = max > 0;
|
||||
while (hasMoreTypes) {
|
||||
final String type = typeText.substring(iTypeStart, iSpace == -1 ? typeText.length() : iSpace);
|
||||
hasMoreTypes = iSpace != -1;
|
||||
final String rest = typeText.substring(iTypeStart);
|
||||
if (isMultiwordType(rest)) {
|
||||
result.add(rest);
|
||||
break;
|
||||
String type = getMultiwordType(rest);
|
||||
if (type == null) {
|
||||
int iSpace = typeText.indexOf(space, iTypeStart);
|
||||
type = typeText.substring(iTypeStart, iSpace == -1 ? max : iSpace);
|
||||
}
|
||||
|
||||
iTypeStart = iSpace + 1;
|
||||
result.add(type);
|
||||
iSpace = typeText.indexOf(space, iSpace + 1);
|
||||
iTypeStart += type.length() + 1;
|
||||
hasMoreTypes = iTypeStart < max;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -782,8 +780,13 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isMultiwordType(final String type) {
|
||||
return Constant.MultiwordTypes.contains(type);
|
||||
private static String getMultiwordType(final String type) {
|
||||
for (String multi : Constant.MultiwordTypes) {
|
||||
if (type.startsWith(multi)) {
|
||||
return multi;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Constant {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.StaticData;
|
||||
import forge.card.CardFacePredicates;
|
||||
import forge.card.CardRules;
|
||||
@@ -146,8 +145,7 @@ public class ChooseCardNameEffect extends SpellAbilityEffect {
|
||||
cpp = CardFacePredicates.valid(valid);
|
||||
}
|
||||
if (randomChoice) {
|
||||
final Iterable<ICardFace> cardsFromDb = StaticData.instance().getCommonCards().getAllFaces();
|
||||
final List<ICardFace> cards = Lists.newArrayList(Iterables.filter(cardsFromDb, cpp));
|
||||
final Iterable<ICardFace> cards = Iterables.filter(StaticData.instance().getCommonCards().getAllFaces(), cpp);
|
||||
chosen = Aggregates.random(cards).getName();
|
||||
} else {
|
||||
chosen = p.getController().chooseCardName(sa, cpp, valid, message);
|
||||
|
||||
@@ -7,7 +7,7 @@ SVar:TrigExile:DB$ Dig | Defined$ You | DigNum$ 1 | ChangeNum$ All | Destination
|
||||
SVar:DBEffect:DB$ Effect | Duration$ EndOfTurn | RememberObjects$ Remembered | StaticAbilities$ STPlay | SubAbility$ DBCleanup | ExileOnMoved$ Exile
|
||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||
SVar:STPlay:Mode$ Continuous | MayPlay$ True | EffectZone$ Command | Affected$ Card.IsRemembered | AffectedZone$ Exile | Description$ You may play the exiled card.
|
||||
A:AB$ DealDamage | Cost$ T | ValidTgts$ Any | NumDmg$ 1 | SpellDescription$ CARDNAME deals 1 damage to any target.
|
||||
A:AB$ DealDamage | Cost$ T | ValidTgts$ Any | NumDmg$ 1 | SpellDescription$ NICKNAME deals 1 damage to any target.
|
||||
SVar:NonCombatPriority:1
|
||||
DeckHints:Type$Instant|Sorcery
|
||||
Oracle:Whenever Syr Carah, the Bold or an instant or sorcery spell you control deals damage to a player, exile the top card of your library. You may play that card this turn.\n{T}: Syr Carah deals 1 damage to any target.
|
||||
|
||||
@@ -7,5 +7,5 @@ SVar:X:Count$InYourHand
|
||||
AI:RemoveDeck:All
|
||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigDraw | TriggerDescription$ When CARDNAME enters the battlefield, draw a card.
|
||||
SVar:TrigDraw:DB$ Draw | Defined$ You | NumCards$ 1
|
||||
S:Mode$ RaiseCost | ValidTarget$ Card.Self | Activator$ Player.Opponent | Type$ Spell | Amount$ 2 | Description$ Spells your opponents cast that target CARDNAME cost {2} more to cast.
|
||||
S:Mode$ RaiseCost | ValidTarget$ Card.Self | Activator$ Player.Opponent | Type$ Spell | Amount$ 2 | Description$ Spells your opponents cast that target NICKNAME cost {2} more to cast.
|
||||
Oracle:Syr Elenora, the Discerning's power is equal to the number of cards in your hand.\nWhen Syr Elenora enters the battlefield, draw a card.\nSpells your opponents cast that target Syr Elenora cost {2} more to cast.
|
||||
|
||||
@@ -2,7 +2,7 @@ Name:Syr Faren, the Hengehammer
|
||||
ManaCost:G G
|
||||
Types:Legendary Creature Human Knight
|
||||
PT:2/2
|
||||
T:Mode$ Attacks | ValidCard$ Card.Self | TriggerZones$ Battlefield | Execute$ TrigPump | TriggerDescription$ Whenever CARDNAME attacks, another target creature gets +X/+X until end of turn, where X is CARDNAME's power.
|
||||
T:Mode$ Attacks | ValidCard$ Card.Self | TriggerZones$ Battlefield | Execute$ TrigPump | TriggerDescription$ Whenever CARDNAME attacks, another target creature gets +X/+X until end of turn, where X is NICKNAME's power.
|
||||
SVar:TrigPump:DB$ Pump | ValidTgts$ Creature.attacking+Other | TgtPrompt$ Select another target attacking creature | NumAtt$ X | NumDef$ X
|
||||
SVar:X:Count$CardPower
|
||||
Oracle:Whenever Syr Faren, the Hengehammer attacks, another target attacking creature gets +X/+X until end of turn, where X is Syr Faren's power.
|
||||
|
||||
@@ -3,7 +3,7 @@ ManaCost:G G G
|
||||
Types:Legendary Creature Giant Noble
|
||||
PT:0/0
|
||||
K:etbCounter:P1P1:4
|
||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Creature.Other+YouCtrl+Green | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever another green creature enters the battlefield under your control, put a +1/+1 counter on CARDNAME. Then if that creature's power is greater than CARDNAME's power, put another +1/+1 counter on CARDNAME.
|
||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Creature.Other+YouCtrl+Green | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever another green creature enters the battlefield under your control, put a +1/+1 counter on NICKNAME. Then if that creature's power is greater than NICKNAME's power, put another +1/+1 counter on NICKNAME.
|
||||
SVar:TrigPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ DBPutCounter
|
||||
SVar:DBPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1 | ConditionCheckSVar$ X | ConditionSVarCompare$ GEY
|
||||
SVar:X:TriggeredCard$CardPower
|
||||
|
||||
Reference in New Issue
Block a user