Card Development Questions
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Card Development Questions
by Max mtg » 31 May 2013, 00:15
Priority is not a problem before the opponent (ai) passes in under a second. The rest really matters.
Then it is to become a static ability that changes game rules - there was something made in that way alreadt
Then it is to become a static ability that changes game rules - there was something made in that way alreadt
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
by Max mtg » 02 Jun 2013, 09:30
Is the second ability of Sovereigns of Lost Alara scriptable?
It could be triggered by DeclareAttackers, condition = SingleAttacker
(The current hardcoded implementation can be bugged: apply Turn to Frog, but the abillity will trigger anyway)
It could be triggered by DeclareAttackers, condition = SingleAttacker
(The current hardcoded implementation can be bugged: apply Turn to Frog, but the abillity will trigger anyway)
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
by friarsol » 02 Jun 2013, 11:23
It might be. The whole "could be enchanted by" is definitely tricky, but we have other cards that I believe are scripted that use similar verbiage.Max mtg wrote:Is the second ability of Sovereigns of Lost Alara scriptable?
It could be triggered by DeclareAttackers, condition = SingleAttacker
(The current hardcoded implementation can be bugged: apply Turn to Frog, but the abillity will trigger anyway)
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by Max mtg » 02 Jun 2013, 12:18
Others are:
Bruna, Light of Alabaster
Auratouched Mage
I would appreciate the script if anyone composes it.
Bruna, Light of Alabaster
Auratouched Mage
I would appreciate the script if anyone composes it.
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
by swordshine » 02 Jun 2013, 13:19
Update "CanEnchantSource" to handle situations that can enchant remembered card. Remember the triggered attacker first, then apply changezone effect.Max mtg wrote:Is the second ability of Sovereigns of Lost Alara scriptable?
- Sovereigns of Lost Alara | Open
- Code: Select all
### Eclipse Workspace Patch 1.0
#P trunk
Index: src/main/java/forge/game/phase/CombatUtil.java
===================================================================
--- src/main/java/forge/game/phase/CombatUtil.java (revision 21901)
+++ src/main/java/forge/game/phase/CombatUtil.java (working copy)
@@ -1300,62 +1300,6 @@
game.getStack().addSimultaneousStackEntry(ability);
}
-
- final Player phasingPlayer = c.getController();
-
- if (phasingPlayer.getCardsIn(ZoneType.Battlefield, "Sovereigns of Lost Alara").size() > 0) {
- for (int i = 0; i < phasingPlayer.getCardsIn(ZoneType.Battlefield, "Sovereigns of Lost Alara").size(); i++) {
- final Card attacker = c;
- final Ability ability4 = new Ability(c, ManaCost.ZERO) {
- @Override
- public void resolve() {
- List<Card> enchantments =
- CardLists.filter(attacker.getController().getCardsIn(ZoneType.Library), new Predicate<Card>() {
- @Override
- public boolean apply(final Card c) {
- if (attacker.hasKeyword("Protection from enchantments")
- || (attacker.hasKeyword("Protection from everything"))) {
- return false;
- }
- return (c.isEnchantment() && c.hasKeyword("Enchant creature") && !CardFactoryUtil
- .hasProtectionFrom(c, attacker));
- }
- });
- final Player player = attacker.getController();
- Card enchantment = null;
- if (player.isHuman()) {
- final Card[] target = new Card[enchantments.size()];
- for (int j = 0; j < enchantments.size(); j++) {
- final Card crd = enchantments.get(j);
- target[j] = crd;
- }
- final Object check = GuiChoose.oneOrNone(
- "Select enchantment to enchant exalted creature", target);
- if (check != null) {
- enchantment = ((Card) check);
- }
- } else {
- enchantment = ComputerUtilCard.getBestEnchantmentAI(enchantments, this, false);
- }
- if ((enchantment != null) && attacker.isInPlay()) {
- game.getAction().changeZone(game.getZoneOf(enchantment),
- enchantment.getOwner().getZone(ZoneType.Battlefield), enchantment, null);
- enchantment.enchantEntity(attacker);
- }
- attacker.getController().shuffle();
- } // resolve
- }; // ability4
-
- final StringBuilder sb4 = new StringBuilder();
- sb4.append(c).append(
- " - (Exalted) searches library for an Aura card that could enchant that creature, ");
- sb4.append("put it onto the battlefield attached to that creature, then shuffles library.");
- ability4.setDescription(sb4.toString());
- ability4.setStackDescription(sb4.toString());
-
- game.getStack().addSimultaneousStackEntry(ability4);
- } // For
- }
}
/**
Index: src/main/java/forge/Card.java
===================================================================
--- src/main/java/forge/Card.java (revision 21901)
+++ src/main/java/forge/Card.java (working copy)
@@ -5429,9 +5429,22 @@
if (!source.equals(this.enchanting)) {
return false;
}
- } else if (property.startsWith("CanEnchantSource")) {
- if (!source.canBeEnchantedBy(this)) {
+ } else if (property.startsWith("CanEnchant")) {
+ final String restriction = property.substring(10);
+ if (restriction.equals("Remembered")) {
+ for (final Object rem : source.getRemembered()) {
+ if (rem instanceof Card) {
+ final Card card = (Card) rem;
+ if (card.canBeEnchantedBy(this)) {
+ return true;
+ }
+ }
+ }
return false;
+ } else {//CanEnchantSource
+ if (!source.canBeEnchantedBy(this)) {
+ return false;
+ }
}
} else if (property.startsWith("CanBeEnchantedBy")) {
if (property.substring(16).equals("Targeted")) {
Index: res/cardsfolder/s/sovereigns_of_lost_alara.txt
===================================================================
--- res/cardsfolder/s/sovereigns_of_lost_alara.txt (revision 21901)
+++ res/cardsfolder/s/sovereigns_of_lost_alara.txt (working copy)
@@ -1,9 +1,11 @@
Name:Sovereigns of Lost Alara
ManaCost:4 W U
Types:Creature Spirit
-Text:Whenever a creature you control attacks alone, you may search your library for an Aura card that could enchant that creature, put it onto the battlefield attached to that creature, then shuffle your library.
PT:4/5
K:Exalted
+T:Mode$ Attacks | ValidCard$ Creature.YouCtrl | Alone$ True | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigSearch | TriggerDescription$ Whenever a creature you control attacks alone, you may search your library for an Aura card that could enchant that creature, put it onto the battlefield attached to that creature, then shuffle your library.
+SVar:TrigSearch:AB$ Pump | Cost$ 0 | RememberObjects$ TriggeredAttacker | SubAbility$ DBMoveAura
+SVar:DBMoveAura:DB$ ChangeZone | Origin$ Library | Destination$ Battlefield | ChangeType$ Aura.CanEnchantRemembered+YouCtrl | AttachedTo$ Remembered | ChangeNum$ 1 | Hidden$ True
SVar:RemRandomDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/sovereigns_of_lost_alara.jpg
Oracle:Exalted (Whenever a creature you control attacks alone, that creature gets +1/+1 until end of turn.)\nWhenever a creature you control attacks alone, you may search your library for an Aura card that could enchant that creature, put it onto the battlefield attached to that creature, then shuffle your library.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by Max mtg » 02 Jun 2013, 15:37
That's extactly what was needed! Thank you.swordshine wrote:Update "CanEnchantSource" to handle situations that can enchant remembered card. Remember the triggered attacker first, then apply changezone effect.Max mtg wrote:Is the second ability of Sovereigns of Lost Alara scriptable?
Now there'll be 1 less call to isHuman/isComputer and one less hardcoded ability
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
by Max mtg » 02 Jun 2013, 17:45
The following cards now have the effect that was missing to implement them:
Odric, Master Tactician
Master Warcraft
Melee
Feel free to write card scripts.
Sample card using the new effect
Odric, Master Tactician
Master Warcraft
Melee
Feel free to write card scripts.
Sample card using the new effect
- Code: Select all
Name:Aaaaa
ManaCost:U
Types:Instant
A:SP$ DeclareCombatants | Cost$ U | DeclareAttackers$ True | DeclareBlockers$ True
SVar:Picture:http://resources.wizards.com/magic/cards/2u/en-us/card692.jpg
Oracle:You decide who does what
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
by Sloth » 02 Jun 2013, 18:08
I miss a duration parameter in this ability, Odric, Master Tactician lasts only for one combat, Master Warcraft for a whole turn.Max mtg wrote:The following cards now have the effect that was missing to implement them:
Odric, Master Tactician
Master Warcraft
Melee
Feel free to write card scripts.
Sample card using the new effect
- Code: Select all
Name:Aaaaa
ManaCost:U
Types:Instant
A:SP$ DeclareCombatants | Cost$ U | DeclareAttackers$ True | DeclareBlockers$ True
SVar:Picture:http://resources.wizards.com/magic/cards/2u/en-us/card692.jpg
Oracle:You decide who does what
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Card Development Questions
by Max mtg » 02 Jun 2013, 18:27
Oh.. there's really a difference!
Ok then, r21915
PS: And of course change whatever you like about implementation if anything is wrong or missing. I've only set up a general path to implementation.
Ok then, r21915
PS: And of course change whatever you like about implementation if anything is wrong or missing. I've only set up a general path to implementation.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Card Development Questions
by mark » 05 Jun 2013, 09:56
Is Heat Wave forgable? Blue creatures can't block is probably no problem, I am not sure about the second part.
Re: Card Development Questions
by swordshine » 05 Jun 2013, 11:33
The second static ability might be scripted using "CantBlockUnless".mark wrote:Is Heat Wave forgable? Blue creatures can't block is probably no problem, I am not sure about the second part.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by swordshine » 05 Jun 2013, 12:23
I'm afraid one of our planeswalkers, Chandra, the Firebrand, is not perfectly scripted. Her second ability creates an effect with a delayed triggered ability that will copy the next instant or sorcery spell, then the effect will be removed after the trigger resolves. However, I could cast another instant spell before the trigger resolves that will fire the trigger again. A "TriggerLimit" parameter is very essential to fix this bug.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by Max mtg » 05 Jun 2013, 12:30
Are there are triggers with more than one intented 'triggers'? If not, there would come handy a self-destruct option. One the trigger has fired, it destroys its host, or detaches itself
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
by Max mtg » 05 Jun 2013, 20:44
Check the r21987
I wrote a small frament of code to trigger handler that removes the effect from command zone after it's ability went to stack
It is safe to do so? (I just wanted to remove the effect - fire no triggers, execute no change zones, etc.)
If it is, the last chancellor from NPH becomes scriptable
I wrote a small frament of code to trigger handler that removes the effect from command zone after it's ability went to stack
It is safe to do so? (I just wanted to remove the effect - fire no triggers, execute no change zones, etc.)
If it is, the last chancellor from NPH becomes scriptable
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Who is online
Users browsing this forum: No registered users and 12 guests