It is currently 17 Apr 2021, 04:38
   
Text Size

Card Development Questions

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, friarsol, Blacksmith, KrazyTheFox, Agetian, CCGHQ Admins

Re: Card Development Questions

Postby drdev » 17 Feb 2014, 23:01

Max mtg wrote:
drdev wrote:
Max mtg wrote:That's the weird autoplay, that attempts to pay mana with the same instances as used for real payment,
I always told this autopay feature should not be there.
If auto-payment is broken, then so is AI mana payment, since they use the exact same logic. Instead of contemplating removing the Auto button, can we just fix the AI logic?

You may not find the Auto button useful, but I know for a fact that many do. It's also a nice way to test the AI logic.
AI mana payment is not broken, not when it has no spare mana in pool. Just put a breakpoint at ManaPool.java, line 332 and see when it gets hit:
1. AI is paying for an ability (ai does not reach this place when it choses which spells it can afford)
2. Human pays for a spell or ability.
3. "Autoplay" feature checks if it can pay for the spell with mana form pool.

Without autoplay it would work properly.

Probably, some people might like autopay, but it's poorly implemented and stands on the way of adding new cards.
I remember your words that code should not stand on the way of new features. Let's apply this principle here!
I'm not opposed to the implementation of the "auto-pay" logic being changed. I admit I did it without fully understanding the corner cases that wouldn't play nice with it. I'm just strongly requesting the feature not be removed completely.
drdev
Programmer
 
Posts: 1958
Joined: 27 Jul 2013, 02:07
Has thanked: 189 times
Been thanked: 565 times

Re: Card Development Questions

Postby Max mtg » 17 Feb 2014, 23:15

Don't worry about it, the autopayment will remain in a single piece. Just a bit of refactoring and it'll work as intended
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Card Development Questions

Postby Max mtg » 18 Feb 2014, 01:17

swordshiine, sa.getPayingMana() is the method you should use to learn the mana spent
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Card Development Questions

Postby swordshine » 18 Feb 2014, 01:50

Max mtg wrote:swordshiine, sa.getPayingMana() is the method you should use to learn the mana spent
Yes, I've tried that method. It seems working.
Another bug: when I tried to activate an ability with colorless activation cost (e.g. Voltaic Key) and tap a dual land to pay the cost (e.g. Bayou), I was not able to choose the color. It automatically activated the first mana ability of the land.
swordshine
 
Posts: 682
Joined: 11 Jul 2010, 02:37
Has thanked: 116 times
Been thanked: 87 times

Re: Card Development Questions

Postby friarsol » 18 Feb 2014, 02:10

swordshine wrote:Another bug: when I tried to activate an ability with colorless activation cost (e.g. Voltaic Key) and tap a dual land to pay the cost (e.g. Bayou), I was not able to choose the color. It automatically activated the first mana ability of the land.
I'm not sure that's a bug. We have a specific express mana payment feature to speed up mana payment when it doesn't matter (like in the case of colorless mana). Express mana is skipped for things like Sunburst, we'd need a way to do that for Jeweled Amulet.
friarsol
Global Moderator
 
Posts: 7566
Joined: 15 May 2010, 04:20
Has thanked: 242 times
Been thanked: 954 times

Re: Card Development Questions

Postby swordshine » 18 Feb 2014, 02:22

friarsol wrote:I'm not sure that's a bug. We have a specific express mana payment feature to speed up mana payment when it doesn't matter (like in the case of colorless mana). Express mana is skipped for things like Sunburst, we'd need a way to do that for Jeweled Amulet.
Gotcha, forge.game.spellability.SpellAbility.tracksManaSpent().
swordshine
 
Posts: 682
Joined: 11 Jul 2010, 02:37
Has thanked: 116 times
Been thanked: 87 times

Re: Card Development Questions

Postby swordshine » 18 Feb 2014, 15:06

I have an idea to script Leonin Arbiter. I'm not sure if this is the best way to implement ignore effects.
The static ability creates a temporary AbilityStatic to ignore the effect on that card. You may click the card to pay the cost of that temporary ability and exclude you from the static effect.
Code: Select all
### Eclipse Workspace Patch 1.0
#P Forge
Index: forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java
===================================================================
--- forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java   (revision 24896)
+++ forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java   (working copy)
@@ -18,6 +18,8 @@
 package forge.game.staticability;
 
 import com.google.common.collect.Lists;
+
+import forge.GameCommand;
 import forge.card.CardType;
 import forge.card.ColorSet;
 import forge.card.mana.ManaCostShard;
@@ -28,10 +30,12 @@
 import forge.game.card.CardFactoryUtil;
 import forge.game.card.CardLists;
 import forge.game.card.CardUtil;
+import forge.game.cost.Cost;
 import forge.game.player.Player;
 import forge.game.replacement.ReplacementEffect;
 import forge.game.replacement.ReplacementHandler;
 import forge.game.spellability.AbilityActivated;
+import forge.game.spellability.AbilityStatic;
 import forge.game.spellability.SpellAbility;
 import forge.game.trigger.Trigger;
 import forge.game.trigger.TriggerHandler;
@@ -308,6 +312,11 @@
             }
         }
 
+        if (params.containsKey("IgnoreEffectCost")) {
+            String cost = params.get("IgnoreEffectCost");
+            buildIgnorEffectAbility(stAb, cost, affectedPlayers, affectedCards);
+        }
+
         // modify players
         for (final Player p : affectedPlayers) {
 
@@ -516,6 +525,44 @@
         return affectedCards;
     }
 
+    private static void buildIgnorEffectAbility(final StaticAbility stAb, final String costString, final List<Player> players, final List<Card> cards) {
+        final List<Player> validActivator = new ArrayList<Player>(players);
+        for (final Card c : cards) {
+            validActivator.add(c.getController());
+        }
+        final Card sourceCard = stAb.getHostCard();
+        Cost cost = new Cost(costString, true);
+        final AbilityStatic addIgnore = new AbilityStatic(sourceCard, cost, null) {
+
+            @Override
+            public void resolve() {
+                stAb.addIgnoreEffectPlayers(this.getActivatingPlayer());
+                stAb.setIgnoreEffectCards(cards);
+            }
+
+            @Override
+            public boolean canPlay() {
+                return validActivator.contains(this.getActivatingPlayer())
+                        && sourceCard.isInPlay();
+            }
+
+        };
+        addIgnore.setTemporary(true);
+        addIgnore.setIntrinsic(false);
+        addIgnore.setDescription(cost + " Ignore the effect until end of turn.");
+        sourceCard.addSpellAbility(addIgnore);
+
+        final GameCommand removeIgnore = new GameCommand() {
+            private static final long serialVersionUID = -5415775215053216360L;
+            @Override
+            public void run() {
+                stAb.clearIgnoreEffects();
+            }
+        };
+        sourceCard.getGame().getEndOfTurn().addUntil(removeIgnore);
+        sourceCard.addLeavesPlayCommand(removeIgnore);
+    }
+
     private static ArrayList<Player> getAffectedPlayers(final StaticAbility stAb) {
         final Map<String, String> params = stAb.getMapParams();
         final Card hostCard = stAb.getHostCard();
@@ -534,6 +581,7 @@
                 players.add(p);
             }
         }
+        players.removeAll(stAb.getIgnoreEffectPlayers());
 
         return players;
     }
@@ -573,7 +621,7 @@
         if (params.containsKey("Affected")) {
             affectedCards = CardLists.getValidCards(affectedCards, params.get("Affected").split(","), controller, hostCard);
         }
-
+        affectedCards.removeAll(stAb.getIgnoreEffectCards());
         return affectedCards;
     }
 
Index: forge-game/src/main/java/forge/game/staticability/StaticAbility.java
===================================================================
--- forge-game/src/main/java/forge/game/staticability/StaticAbility.java   (revision 24896)
+++ forge-game/src/main/java/forge/game/staticability/StaticAbility.java   (working copy)
@@ -30,6 +30,7 @@
 import forge.game.zone.ZoneType;
 import forge.util.Expressions;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -40,6 +41,8 @@
 public class StaticAbility extends CardTraitBase {
 
     private int layer = 0;
+    private List<Card> ignoreEffectCards = new ArrayList<Card>();
+    private List<Player> ignoreEffectPlayers = new ArrayList<Player>();
 
     // *******************************************************
 
@@ -568,8 +571,40 @@
         return true;
     }
 
+    /**
+     * @return the ignoreEffectCards
+     */
+    public List<Card> getIgnoreEffectCards() {
+        return ignoreEffectCards;
+    }
 
     /**
+     * @param c the ignoreEffectCards to add
+     */
+    public void setIgnoreEffectCards(List<Card> cards) {
+        this.ignoreEffectCards = cards;
+    }
+
+    /**
+     * @return the ignoreEffectPlayers
+     */
+    public List<Player> getIgnoreEffectPlayers() {
+        return ignoreEffectPlayers;
+    }
+
+    /**
+     * @param p the ignoreEffectPlayers to add
+     */
+    public void addIgnoreEffectPlayers(Player p) {
+        this.ignoreEffectPlayers.add(p);
+    }
+
+    public void clearIgnoreEffects() {
+        this.ignoreEffectPlayers.clear();
+        this.ignoreEffectCards.clear();
+    }
+
+    /**
      * @return the layer
      */
     public int getLayer() {
Index: forge-game/src/main/java/forge/game/StaticEffects.java
===================================================================
--- forge-game/src/main/java/forge/game/StaticEffects.java   (revision 24896)
+++ forge-game/src/main/java/forge/game/StaticEffects.java   (working copy)
@@ -21,6 +21,7 @@
 import forge.game.card.CardUtil;
 import forge.game.player.Player;
 import forge.game.replacement.ReplacementEffect;
+import forge.game.spellability.AbilityStatic;
 import forge.game.spellability.SpellAbility;
 import forge.game.staticability.StaticAbility;
 
@@ -149,7 +150,13 @@
                 addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(" & "))));
             }
         }
-
+        if (params.containsKey("IgnoreEffectCost")) {
+            for (final SpellAbility s : se.getSource().getSpellAbilities()) {
+                if (s instanceof AbilityStatic && s.isTemporary()) {
+                    se.getSource().removeSpellAbility(s);
+                }
+            }
+        }
         // modify players
         for (final Player p : affectedPlayers) {
             p.setUnlimitedHandSize(false);
Index: forge-gui/res/cardsfolder/l/leonin_arbiter.txt
===================================================================
--- forge-gui/res/cardsfolder/l/leonin_arbiter.txt   (revision 0)
+++ forge-gui/res/cardsfolder/l/leonin_arbiter.txt   (working copy)
@@ -0,0 +1,7 @@
+Name:Leonin Arbiter
+ManaCost:1 W
+Types:Creature Cat Cleric
+PT:2/2
+S:Mode$ Continuous | Affected$ Player | AddKeyword$ CantSearchLibrary | IgnoreEffectCost$ 2 | Description$ Players can't search libraries. Any player may pay {2} for that player to ignore this effect until end of turn.
+SVar:Picture:http://www.wizards.com/global/images/magic/general/leonin_arbiter.jpg
+Oracle:Players can't search libraries. Any player may pay {2} for that player to ignore this effect until end of turn.

swordshine
 
Posts: 682
Joined: 11 Jul 2010, 02:37
Has thanked: 116 times
Been thanked: 87 times

Re: Card Development Questions

Postby friarsol » 18 Feb 2014, 15:32

swordshine wrote:I have an idea to script Leonin Arbiter. I'm not sure if this is the best way to implement ignore effects.
The static ability creates a temporary AbilityStatic to ignore the effect on that card. You may click the card to pay the cost of that temporary ability and exclude you from the static effect.
Yea this is basically how I always pictured these cards would work. It looks like there are 4 of these right now. http://magiccards.info/query?q=o%3Aigno ... rd&s=cname

Two things to make sure to test, which I believe will work in this scenario:

1/1/2011: Paying {2} to ignore Leonin Arbiter's effect is a special action. Any player may take this special action any time he or she has priority. It doesn't use the stack and can't be responded to.
1/1/2011: If there are multiple Leonin Arbiters on the battlefield, a player must pay {2} for each one before being able to search libraries that turn.
friarsol
Global Moderator
 
Posts: 7566
Joined: 15 May 2010, 04:20
Has thanked: 242 times
Been thanked: 954 times

Re: Card Development Questions

Postby Max mtg » 20 Feb 2014, 18:03

Congratulations, Scars of Mirroding block is now 100% scripted... as well as the currently released sets from Theros block are.

The remaning 210 cards | Open
Born of the Gods (165 cards) ... 100%
Theros (249 cards) ... 100%
Magic 2014 (249 cards) ... 100%
Modern Masters (229 cards) ... 100%
Dragon's Maze (156 cards) ... 99.35% (a card missing: Trait Doctoring )
Gatecrash (249 cards) ... 100%
Return to Ravnica (274 cards) ... 100%
Magic 2013 (249 cards) ... 100%
Avacyn Restored (244 cards) ... 99.59% (a card missing: Divine Deflection )
Dark Ascension (158 cards) ... 100%
Innistrad (264 cards) ... 100%
Magic 2012 (249 cards) ... 100%
New Phyrexia (175 cards) ... 100%
Mirrodin Besieged (155 cards) ... 100%
Scars of Mirrodin (249 cards) ... 100%
Magic 2011 (249 cards) ... 100%
Rise of the Eldrazi (248 cards) ... 99.59% (a card missing: World at War )
Worldwake (145 cards) ... 99.31% (a card missing: Refraction Trap )
Zendikar (269 cards) ... 100%
Magic 2010 (249 cards) ... 99.59% (a card missing: Harm's Way )
Alara Reborn (145 cards) ... 100%
Conflux (145 cards) ... 100%
Shards of Alara (249 cards) ... 100%
Eventide (180 cards) ... 99.44% (a card missing: Glamerdye )
Shadowmoor (301 cards) ... 99.66% (a card missing: Plague of Vermin )
Morningtide (150 cards) ... 100%
Lorwyn (301 cards) ... 100%
Tenth Edition (383 cards) ... 99.73% (a card missing: Mind Bend )
Future Sight (180 cards) ... 97.77% (4 cards missing: Grave Scrabbler | Nacatl War-Pride | Nix | Shah of Naar Isle )
Planar Chaos (165 cards) ... 98.18% (3 cards missing: Kor Dirge | Magus of the Arena | Shrouded Lore )
Time Spiral (301 cards) ... 99.33% (2 cards missing: Evangelize | Thick-Skinned Goblin )
Time Spiral "Timeshifted" (121 cards) ... 96.69% (4 cards missing: Arena | Giant Oyster | Grinning Totem | Honorable Passage )
Coldsnap (155 cards) ... 96.77% (5 cards missing: Balduvian Fallen | Balduvian Warlord | Cover of Winter | Lightning Storm | Panglacial Wurm )
Dissension (180 cards) ... 98.33% (3 cards missing: War's Toll | Flash Foliage | Street Savvy )
Guildpact (165 cards) ... 100%
Ravnica: City of Guilds (306 cards) ... 99.67% (a card missing: Razia, Boros Archangel )
Ninth Edition (359 cards) ... 99.72% (a card missing: Mind Bend )
Saviors of Kamigawa (165 cards) ... 97.57% (4 cards missing: Burning-Eye Zubera | Choice of Damnations | Pain's Reward | Rushing-Tide Zubera )
Betrayers of Kamigawa (165 cards) ... 99.39% (a card missing: Shining Shoal )
Champions of Kamigawa (307 cards) ... 99.67% (a card missing: Swirl the Mists )
Fifth Dawn (165 cards) ... 98.78% (2 cards missing: Reversal of Fortune | Spectral Shift )
Darksteel (165 cards) ... 99.39% (a card missing: Well of Lost Dreams )
Mirrodin (306 cards) ... 98.36% (5 cards missing: Confusion in the Ranks | Fatespinner | Mindstorm Crown | Quicksilver Elemental | Shared Fate )
Eighth Edition (357 cards) ... 99.43% (2 cards missing: Mind Bend | Okk )
Scourge (143 cards) ... 98.60% (2 cards missing: Lethal Vapors | Parallel Thoughts )
Legions (145 cards) ... 100%
Onslaught (350 cards) ... 96.85% (11 cards missing: Artificial Evolution | Aven Soulgazer | Butcher Orgg | Chain of Acid | Chain of Silence | Chain of Smog | Meddle | Menacing Ogre | Risky Move | Spy Network | Trade Secrets )
Judgment (143 cards) ... 97.90% (3 cards missing: Lost in Thought | Shaman's Trance | Shieldmage Advocate )
Torment (143 cards) ... 98.60% (2 cards missing: Alter Reality | Flaming Gambit )
Odyssey (350 cards) ... 99.42% (2 cards missing: Cultural Exchange | Price of Glory )
Apocalypse (143 cards) ... 94.40% (8 cards missing: Captain's Maneuver | Coalition Flag | Coalition Honor Guard | Dead Ringers | Emblazoned Golem | Ice Cave | Standard Bearer | Tahngarth's Glare )
Seventh Edition (350 cards) ... 99.71% (a card missing: Okk )
Planeshift (146 cards) ... 99.31% (a card missing: Goblin Game )
Invasion (350 cards) ... 98.28% (6 cards missing: Crystal Spray | Mages' Contest | Psychic Battle | Samite Ministration | Scarred Puma | Stand or Fall )
Prophecy (143 cards) ... 97.20% (4 cards missing: Brutal Suppression | Celestial Convergence | Hollow Warrior | Psychic Theft )
Nemesis (143 cards) ... 98.60% (2 cards missing: Harvest Mage | Mana Cache )
Mercadian Masques (350 cards) ... 99.14% (3 cards missing: Barbed Wire | Crooked Scales | Wishmonger )
Urza's Destiny (143 cards) ... 100%
Classic Sixth Edition (350 cards) ... 99.42% (2 cards missing: Grinning Totem | Illicit Auction )
Urza's Legacy (143 cards) ... 98.60% (2 cards missing: Damping Engine | Viashino Bey )
Urza's Saga (350 cards) ... 99.14% (3 cards missing: Okk | Soul Sculptor | Veiled Crocodile )
Exodus (143 cards) ... 97.90% (3 cards missing: Fade Away | Kor Chant | Mogg Assassin )
Stronghold (143 cards) ... 98.60% (2 cards missing: Hidden Retreat | Volrath's Shapeshifter )
Tempest (350 cards) ... 98.00% (7 cards missing: Echo Chamber | Ertai's Meddling | Legerdemain | Magnetic Web | Oracle en-Vec | Volrath's Curse | Whim of Volrath )
Weatherlight (167 cards) ... 98.20% (3 cards missing: Bosium Strip | Liege of the Hollows | Mana Web )
Fifth Edition (449 cards) ... 98.21% (8 cards missing: Drain Power | Game of Chaos | Gauntlets of Chaos | Magical Hack | Mind Bomb | Orcish Conscripts | Seraph | Sleight of Mind )
Visions (167 cards) ... 92.81% (12 cards missing: Desolation | Dream Tides | Elkin Lair | Equipoise | Forbidden Ritual | Honorable Passage | Ogre Enforcer | Peace Talks | Pillar Tombs of Aku | Pygmy Hippo | Teferi's Realm | Three Wishes )
Mirage (350 cards) ... 96.57% (12 cards missing: Ekundu Cyclops | Emberwilde Djinn | Grinning Totem | Illicit Auction | Mangara's Tome | Meddle | Mind Bend | Preferred Selection | Reflect Damage | Shadowbane | Soul Echo | Torrent of Lava )
Alliances (199 cards) ... 97.48% (5 cards missing: Martyrdom | Martyrdom | Primitive Justice | Taste of Paradise | Taste of Paradise )
Homelands (140 cards) ... 95.71% (6 cards missing: Autumn Willow | Giant Albatross | Giant Albatross | Giant Oyster | Hazduhr the Abbot | Timmerian Fiends )
Chronicles (125 cards) ... 96.80% (4 cards missing: Cuombajj Witches | Gauntlets of Chaos | Goblin Artisans | Wall of Shadows )
Ice Age (383 cards) ... 93.99% (23 cards missing: Adarkar Unicorn | Arcum's Whistle | Balduvian Shaman | Barbarian Guides | Drought | Errant Minion | Forgotten Lore | Game of Chaos | General Jarkeld | Ghostly Flame | Ice Cauldron | Illusionary Terrain | Infernal Denizen | Krovikan Vampire | Lava Burst | Lim-Dul's Hex | Mercenaries | Mudslide | Orcish Conscripts | Seraph | Sleight of Mind | Snowfall | Winter's Chill )
Fourth Edition (378 cards) ... 97.35% (10 cards missing: Bronze Tablet | Drain Power | Erosion | Magical Hack | Magnetic Mountain | Mind Bomb | Power Leak | Rebirth | Sleight of Mind | Tempest Efreet )
Fallen Empires (187 cards) ... 96.79% (6 cards missing: Merseine | Merseine | Merseine | Merseine | Raiding Party | Thelon's Curse )
The Dark (119 cards) ... 93.27% (8 cards missing: Erosion | Fasting | Mind Bomb | Preacher | Season of the Witch | Sorrow's Path | Whippoorwill | Worms of the Earth )
Legends (310 cards) ... 93.22% (21 cards missing: Arboria | Backdraft | Divine Intervention | Equinox | Falling Star | Firestorm Phoenix | Gauntlets of Chaos | Glyph of Delusion | Glyph of Reincarnation | Halfdane | Hammerheim | Imprison | Infinite Authority | North Star | Nova Pentacle | Quarum Trench Gnomes | Rebirth | Reverberation | Silhouette | Tempest Efreet | Wall of Shadows )
Revised Edition (306 cards) ... 98.03% (6 cards missing: Drain Power | Magical Hack | Magnetic Mountain | Power Leak | Rock Hydra | Sleight of Mind )
Antiquities (100 cards) ... 96.00% (4 cards missing: Bronze Tablet | Goblin Artisans | Tawnos's Coffin | Urza's Miter )
Arabian Nights (92 cards) ... 93.47% (6 cards missing: Cuombajj Witches | Guardian Beast | Magnetic Mountain | Pyramids | Shahrazad | Ydwen Efreet )
Unlimited Edition (302 cards) ... 96.35% (11 cards missing: Camouflage | Chaos Orb | Drain Power | False Orders | Illusionary Mask | Magical Hack | Power Leak | Raging River | Rock Hydra | Sleight of Mind | Word of Command )
Limited Edition Beta (302 cards) ... 96.35% (11 cards missing: Camouflage | Chaos Orb | Drain Power | False Orders | Illusionary Mask | Magical Hack | Power Leak | Raging River | Rock Hydra | Sleight of Mind | Word of Command )
Limited Edition Alpha (295 cards) ... 96.27% (11 cards missing: Camouflage | Chaos Orb | Drain Power | False Orders | Illusionary Mask | Magical Hack | Power Leak | Raging River | Rock Hydra | Sleight of Mind | Word of Command )
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Card Development Questions

Postby swordshine » 24 Feb 2014, 11:35

Veiled Crocodile has a simple Always trigger.
FAQ says "It can trigger even if a player's hand is empty momentarily during the middle of the resolution of a spell or ability.", which doesn't work in the current version.

Tethered Griffin "10/4/2004: The ability will trigger if you don't control an enchantment, even for a brief moment during the resolution of another spell or ability."
I played Thassa's Emissary and Tethered Griffin, then cast Cloudshift targeting Thassa's Emissary. This should trigger Tethered Griffin.
We shouldn't run Always triggers in checkStateEffects.

Progress: Veiled Crocodile is scripted. Windfall fires the trigger.
Remaining bugs: Cast the last card in your hand and then roll back it fires the trigger, not sure if we should suppress some trigger in HumanPlaySpellAbility (forge.game.GameAction.changeZone(Zone, Zone, Card, Integer) checks static abilities.)
swordshine
 
Posts: 682
Joined: 11 Jul 2010, 02:37
Has thanked: 116 times
Been thanked: 87 times

Re: Card Development Questions

Postby swordshine » 25 Feb 2014, 14:05

How to add canPlayAI to hardcoded abilities? I scripted Lost in Thought and Volrath's Curse a week ago, both cannot be handled by AI.
swordshine
 
Posts: 682
Joined: 11 Jul 2010, 02:37
Has thanked: 116 times
Been thanked: 87 times

Re: Card Development Questions

Postby Max mtg » 25 Feb 2014, 14:57

@swordshine, you can not add AI specific methods to hardcoded abilities.
Game must not be aware of AI, so it's no longer possible.

Find another ways through. You may want to identify and intercept the given ability somewhere in forge-ai module.
Some rare exceptions (like Haunt) add their own API types - this seems reasonable for common ability types, like when they are keyworded.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Card Development Questions

Postby swordshine » 26 Feb 2014, 08:18

Someone reported that Suppression Field is totally broken. It seems cost adjustment is not in the correct place. It's not able to adjust activated abilities without mana cost (and it affected replacement effects scripted starting with "AB"). We also have two cards with non-mana cost adjustment, Brutal Suppression and Drought. Maybe it's time to rework this cost adjustment method.
swordshine
 
Posts: 682
Joined: 11 Jul 2010, 02:37
Has thanked: 116 times
Been thanked: 87 times

Re: Card Development Questions

Postby swordshine » 11 Mar 2014, 09:51

Join Forces cards are popular in Commander games. I tried to script these cards using RepeatEach->ChooseNumber(the mana will be paid)->StoreSVar(UnlessCost: the chosen number and UnlessSwitched)->Join Forces effect.
Sample:
Code: Select all
Name:Minds Aglow
ManaCost:U
Types:Sorcery
A:SP$ RepeatEach | Cost$ U | RepeatPlayers$ Player | StartingWithActivator$ True | RepeatSubAbility$ DBPay | SubAbility$ DBDraw | StackDescription$ SpellDescription | SpellDescription$ Join forces - Starting with you, each player may pay any amount of mana. Each player draws X cards, where X is the total amount of mana paid this way.
SVar:DBPay:DB$ ChooseNumber | Defined$ Player.IsRemembered | ChooseAnyNumber$ True | SubAbility$ DBStore
SVar:DBStore:DB$ StoreSVar | SVar$ JoinForcesAmount | Type$ CountSVar | Expression$ JoinForcesAmount/Plus.X | UnlessCost$ X | UnlessPayer$ Player.IsRemembered | UnlessSwitched$ True | UnlessAI$ OnlyOwn | References$ X,JoinForcesAmount
SVar:DBDraw:DB$ Draw | Defined$ Each | NumCards$ JoinForcesAmount | SubAbility$ DBReset | References$ JoinForcesAmount | StackDescription$ None
SVar:DBReset:DB$ StoreSVar | SVar$ JoinForcesAmount | Type$ Number | Expression$ 0 | References$ JoinForcesAmount
SVar:X:Count$ChosenNumber
SVar:JoinForcesAmount:Number$0
SVar:Picture:http://www.wizards.com/global/images/magic/general/minds_aglow.jpg
Any suggestions?
swordshine
 
Posts: 682
Joined: 11 Jul 2010, 02:37
Has thanked: 116 times
Been thanked: 87 times

Re: Card Development Questions

Postby friarsol » 11 Mar 2014, 12:22

swordshine wrote:Join Forces cards are popular in Commander games. I tried to script these cards using RepeatEach->ChooseNumber(the mana will be paid)->StoreSVar(UnlessCost: the chosen number and UnlessSwitched)->Join Forces effect.
Sample:
Any suggestions?
Seems functional, but hackish. Does it work ok in practice?
friarsol
Global Moderator
 
Posts: 7566
Joined: 15 May 2010, 04:20
Has thanked: 242 times
Been thanked: 954 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 29 guests


Who is online

In total there are 29 users online :: 0 registered, 0 hidden and 29 guests (based on users active over the past 10 minutes)
Most users ever online was 1371 on 09 Feb 2020, 16:22

Users browsing this forum: No registered users and 29 guests

Login Form