mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
CardType: better handling for multiword types (#720)
This commit is contained in:
@@ -51,6 +51,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
|||||||
private static final long serialVersionUID = 4629853583167022151L;
|
private static final long serialVersionUID = 4629853583167022151L;
|
||||||
|
|
||||||
public static final CardTypeView EMPTY = new CardType(false);
|
public static final CardTypeView EMPTY = new CardType(false);
|
||||||
|
private static final Set<String> multiWordTypes = ImmutableSet.of("Serra's Realm", "Bolas's Meditation Realm", "Dungeon Master");
|
||||||
|
|
||||||
public enum CoreType {
|
public enum CoreType {
|
||||||
Artifact(true, "artifacts"),
|
Artifact(true, "artifacts"),
|
||||||
@@ -752,12 +753,14 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
|||||||
while (hasMoreTypes) {
|
while (hasMoreTypes) {
|
||||||
final String type = typeText.substring(iTypeStart, iSpace == -1 ? typeText.length() : iSpace);
|
final String type = typeText.substring(iTypeStart, iSpace == -1 ? typeText.length() : iSpace);
|
||||||
hasMoreTypes = iSpace != -1;
|
hasMoreTypes = iSpace != -1;
|
||||||
if (!isMultiwordType(type) || !hasMoreTypes) {
|
final String rest = typeText.substring(iTypeStart);
|
||||||
iTypeStart = iSpace + 1;
|
if (isMultiwordType(rest)) {
|
||||||
if (!"-".equals(type)) {
|
result.add(rest);
|
||||||
result.add(type);
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iTypeStart = iSpace + 1;
|
||||||
|
result.add(type);
|
||||||
iSpace = typeText.indexOf(space, iSpace + 1);
|
iSpace = typeText.indexOf(space, iSpace + 1);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -775,13 +778,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isMultiwordType(final String type) {
|
private static boolean isMultiwordType(final String type) {
|
||||||
final String[] multiWordTypes = { "Serra's Realm", "Bolas's Meditation Realm", "Dungeon Master" };
|
return multiWordTypes.contains(type);
|
||||||
for (int i = 0; i < multiWordTypes.length; ++i) {
|
|
||||||
if (multiWordTypes[i].startsWith(type) && !multiWordTypes[i].equals(type)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Constant {
|
public static class Constant {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import forge.game.trigger.WrappedAbility;
|
|||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
import forge.util.PredicateString.StringOp;
|
||||||
|
|
||||||
public class VentureEffect extends SpellAbilityEffect {
|
public class VentureEffect extends SpellAbilityEffect {
|
||||||
|
|
||||||
@@ -42,18 +43,21 @@ public class VentureEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Card dungeon = null;
|
List<PaperCard> dungeonCards = null;
|
||||||
if (sa.hasParam("Dungeon")) {
|
if (sa.hasParam("Dungeon")) {
|
||||||
dungeon = Card.fromPaperCard(StaticData.instance().getVariantCards().getUniqueByName(
|
dungeonCards = StaticData.instance().getVariantCards()
|
||||||
sa.getParam("Dungeon")), player);
|
.getAllCards(Predicates.compose(
|
||||||
|
Predicates.and(CardRulesPredicates.Presets.IS_DUNGEON,
|
||||||
|
CardRulesPredicates.subType(StringOp.EQUALS, sa.getParam("Dungeon"))),
|
||||||
|
PaperCard.FN_GET_RULES));
|
||||||
} else {
|
} else {
|
||||||
// Create a new dungeon card chosen by player in command zone.
|
// Create a new dungeon card chosen by player in command zone.
|
||||||
List<PaperCard> dungeonCards = StaticData.instance().getVariantCards().getAllCards(
|
dungeonCards = StaticData.instance().getVariantCards().getAllCards(
|
||||||
Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard.FN_GET_RULES));
|
Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard.FN_GET_RULES));
|
||||||
dungeonCards.removeIf(c -> !c.getRules().isEnterableDungeon());
|
dungeonCards.removeIf(c -> !c.getRules().isEnterableDungeon());
|
||||||
String message = Localizer.getInstance().getMessage("lblChooseDungeon");
|
|
||||||
dungeon = player.getController().chooseDungeon(player, dungeonCards, message);
|
|
||||||
}
|
}
|
||||||
|
String message = Localizer.getInstance().getMessage("lblChooseDungeon");
|
||||||
|
Card dungeon = player.getController().chooseDungeon(player, dungeonCards, message);
|
||||||
|
|
||||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||||
game.getAction().moveTo(ZoneType.Command, dungeon, sa, moveParams);
|
game.getAction().moveTo(ZoneType.Command, dungeon, sa, moveParams);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Name:Undercity
|
Name:Undercity
|
||||||
ManaCost:no cost
|
ManaCost:no cost
|
||||||
Types:Dungeon
|
Types:Dungeon Undercity
|
||||||
K:You can't enter this dungeon unless you "venture into Undercity".
|
K:You can't enter this dungeon unless you "venture into Undercity".
|
||||||
K:Dungeon:Entrance,Forge,Well,Trap,Arena,Stash,Archives,Catacombs,Throne
|
K:Dungeon:Entrance,Forge,Well,Trap,Arena,Stash,Archives,Catacombs,Throne
|
||||||
SVar:Entrance:DB$ ChangeZone | Origin$ Library | Destination$ Hand | ChangeType$ Land.Basic | RoomName$ Secret Entrance | NextRoom$ Forge,Well | SpellDescription$ Search your library for a basic land card, reveal it, put it into your hand, then shuffle.
|
SVar:Entrance:DB$ ChangeZone | Origin$ Library | Destination$ Hand | ChangeType$ Land.Basic | RoomName$ Secret Entrance | NextRoom$ Forge,Well | SpellDescription$ Search your library for a basic land card, reveal it, put it into your hand, then shuffle.
|
||||||
|
|||||||
Reference in New Issue
Block a user