diff --git a/forge-game/src/main/java/forge/game/card/CardLists.java b/forge-game/src/main/java/forge/game/card/CardLists.java index 7308ae667c1..6b1bdf9db70 100644 --- a/forge-game/src/main/java/forge/game/card/CardLists.java +++ b/forge-game/src/main/java/forge/game/card/CardLists.java @@ -31,6 +31,7 @@ import forge.game.keyword.Keyword; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; +import forge.game.staticability.StaticAbilityCrewValue; import forge.util.MyRandom; import forge.util.collect.FCollectionView; @@ -455,8 +456,13 @@ public class CardLists { public static int getTotalPower(Iterable cardList, boolean ignoreNegativePower, boolean crew) { int total = 0; for (final Card crd : cardList) { - if (crew && crd.hasKeyword("CARDNAME crews Vehicles using its toughness rather than its power.")) { - total += ignoreNegativePower ? Math.max(0, crd.getNetToughness()) : crd.getNetToughness(); + if (crew && StaticAbilityCrewValue.hasAnyCrewValue(crd)) { + if (StaticAbilityCrewValue.crewsWithToughness(crd)) { + total += ignoreNegativePower ? Math.max(0, crd.getNetToughness()) : crd.getNetToughness(); + } else { + int m = StaticAbilityCrewValue.getCrewMod(crd); + total += ignoreNegativePower ? Math.max(0, crd.getNetPower() + m) : crd.getNetPower() + m; + } } else total += ignoreNegativePower ? Math.max(0, crd.getNetPower()) : crd.getNetPower(); } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCrewValue.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCrewValue.java new file mode 100644 index 00000000000..5467ba0f825 --- /dev/null +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCrewValue.java @@ -0,0 +1,64 @@ +package forge.game.staticability; + +import forge.game.Game; +import forge.game.card.Card; +import forge.game.zone.ZoneType; + +public class StaticAbilityCrewValue { + + static String MODE = "CrewValue"; + + public static boolean hasAnyCrewValue(final Card card) { + final Game game = card.getGame(); + for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { + for (final StaticAbility stAb : ca.getStaticAbilities()) { + if (!stAb.getParam("Mode").equals(MODE) || stAb.isSuppressed() || !stAb.checkConditions()) { + continue; + } + if (hasAnyCrewValue(stAb, card)) { + return true; + } + } + } + return false; + } + + public static boolean hasAnyCrewValue(final StaticAbility stAb, final Card card) { + return stAb.matchesValidParam("ValidCard", card); + } + + public static boolean crewsWithToughness(final Card card) { + final Game game = card.getGame(); + for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { + for (final StaticAbility stAb : ca.getStaticAbilities()) { + if (!stAb.getParam("Mode").equals(MODE) || stAb.isSuppressed() || !stAb.checkConditions()) { + continue; + } + if (crewsWithToughness(stAb, card)) { + return true; + } + } + } + return false; + } + + public static boolean crewsWithToughness(final StaticAbility stAb, final Card card) { + return stAb.getParam("Value").equals("Toughness") && stAb.matchesValidParam("ValidCard", card); + } + + public static int getCrewMod(final Card card) { + int i = 0; + final Game game = card.getGame(); + for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { + for (final StaticAbility stAb : ca.getStaticAbilities()) { + if (!stAb.getParam("Mode").equals(MODE) || stAb.isSuppressed() || !stAb.checkConditions()) { + continue; + } + int t = Integer.parseInt(stAb.getParam("Value")); + i = i + t; + } + } + return i; + } + +} diff --git a/forge-gui/res/cardsfolder/g/giant_ox.txt b/forge-gui/res/cardsfolder/g/giant_ox.txt index d0a70efff0c..4f2b3894a49 100644 --- a/forge-gui/res/cardsfolder/g/giant_ox.txt +++ b/forge-gui/res/cardsfolder/g/giant_ox.txt @@ -2,6 +2,6 @@ Name:Giant Ox ManaCost:1 W Types:Creature Ox PT:0/6 -K:CARDNAME crews Vehicles using its toughness rather than its power. +S:Mode$ CrewValue | Affected$ Card.Self | Value$ Toughness | Description$ CARDNAME crews Vehicles using its toughness rather than its power. DeckHints:Type$Vehicle Oracle:Giant Ox crews Vehicles using its toughness rather than its power. diff --git a/forge-gui/res/cardsfolder/upcoming/born_to_drive.txt b/forge-gui/res/cardsfolder/upcoming/born_to_drive.txt new file mode 100644 index 00000000000..d9c81bd298b --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/born_to_drive.txt @@ -0,0 +1,12 @@ +Name:Born to Drive +ManaCost:2 W +Types:Enchantment Aura +K:Enchant artifact or creature +A:SP$ Attach | ValidTgts$ Creature,Artifact | TgtPrompt$ Select target artifact or creature | AILogic$ Pump +S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddPower$ X | AddToughness$ X | Description$ As long as enchanted permanent is a creature, it gets +1/+1 for each creature and/or Vehicle you control. +SVar:X:Count$Valid Creature.YouCtrl,Vehicle.YouCtrl +A:AB$ Token | PrecostDesc$ Channel — | Cost$ 2 W Discard<1/CARDNAME> | TokenAmount$ 2 | TokenScript$ c_1_1_pilot_crewbuff | ActivationZone$ Hand | SpellDescription$ Create two 1/1 colorless Pilot creature tokens with "This creature crews Vehicles as though its power were 2 greater." +SVar:BuffedBy:Creature,Vehicle +DeckHints:Type$Creature|Vehicle +DeckHas:Ability$Token|Discard & Type$Pilot +Oracle:Enchant artifact or creature\nAs long as enchanted permanent is a creature, it gets +1/+1 for each creature and/or Vehicle you control.\nChannel — {2}{W}, Discard Born to Drive: Create two 1/1 colorless Pilot creature tokens with "This creature crews Vehicles as though its power were 2 greater." diff --git a/forge-gui/res/cardsfolder/upcoming/hotshot_mechanic.txt b/forge-gui/res/cardsfolder/upcoming/hotshot_mechanic.txt new file mode 100644 index 00000000000..757c0e5336f --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/hotshot_mechanic.txt @@ -0,0 +1,7 @@ +Name:Hotshot Mechanic +ManaCost:W +Types:Artifact Creature Fox Pilot +PT:2/1 +S:Mode$ CrewValue | Affected$ Card.Self | Value$ 2 | Description$ CARDNAME crews Vehicles as though its power were 2 greater. +DeckHints:Type$Vehicle +Oracle:Hotshot Mechanic crews Vehicles as though its power were 2 greater. diff --git a/forge-gui/res/cardsfolder/upcoming/prodigys_prototype.txt b/forge-gui/res/cardsfolder/upcoming/prodigys_prototype.txt new file mode 100644 index 00000000000..d3b5f7bec37 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/prodigys_prototype.txt @@ -0,0 +1,10 @@ +Name:Prodigy's Prototype +ManaCost:1 W U +Types:Artifact Vehicle +PT:3/4 +T:Mode$ AttackersDeclared | ValidAttackers$ Vehicle.YouCtrl | Execute$ TrigToken | TriggerZones$ Battlefield | TriggerDescription$ Whenever one or more Vehicles you control attack, create a 1/1 colorless Pilot creature token with "This creature crews Vehicles as though its power were 2 greater." +SVar:TrigToken:DB$ Token | TokenScript$ c_1_1_pilot_crewbuff +K:Crew:2 +DeckHints:Type$Vehicle +DeckHas:Ability$Token & Type$Pilot +Oracle:Whenever one or more Vehicles you control attack, create a 1/1 colorless Pilot creature token with "This creature crews Vehicles as though its power were 2 greater."\nCrew 2 (Tap any number of creatures you control with total power 2 or more: This Vehicle becomes an artifact creature until end of turn.) diff --git a/forge-gui/res/tokenscripts/c_1_1_pilot_crewbuff.txt b/forge-gui/res/tokenscripts/c_1_1_pilot_crewbuff.txt new file mode 100644 index 00000000000..5a63a40320a --- /dev/null +++ b/forge-gui/res/tokenscripts/c_1_1_pilot_crewbuff.txt @@ -0,0 +1,6 @@ +Name:Pilot Token +ManaCost:no cost +Types:Creature Pilot +PT:1/1 +S:Mode$ CrewValue | Affected$ Card.Self | Value$ 2 | Description$ This creature crews Vehicles as though its power were 2 greater. +Oracle:This creature crews Vehicles as though its power were 2 greater.