Cantrip keyword and milling
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Cantrip keyword and milling
by Rob Cashwalker » 04 Jun 2009, 04:49
First post in the new forum!
I thought I had once posted some code that might allow cantrips to be handled as a keyword. (Cantrips are spells or permanents, which also draw a card on resolution, such as Accelrate or Carven Caryatid)
I figured out where in the code any given SpellAbility's Resolve method is called.
I thought I had once posted some code that might allow cantrips to be handled as a keyword. (Cantrips are spells or permanents, which also draw a card on resolution, such as Accelrate or Carven Caryatid)
I figured out where in the code any given SpellAbility's Resolve method is called.
- Code: Select all
C:\MTGForge0517\source\ComputerUtil.java (1 hits)
Line 61: sa.resolve();
C:\MTGForge0517\source\Input_StackNotEmpty.java (1 hits)
Line 31: sa.resolve();
- Code: Select all
If (sa.getSourceCard().getKeywords().Contains("Cantrip"))
GameAction.drawCard(sa.getSourceCard().getController());
- Code: Select all
if(card.getKeyword().contains("When this card comes into play, draw a card."))
{
card.setComesIntoPlay(new Command()
{
private static final long serialVersionUID = 203335252453049234L;
public void execute()
{
GameAction.drawCard(card.getController());
}
});
}//if "Comes into play tapped."
- Code: Select all
if(library.size() != 0)
{
Card c = library.get(0);
library.remove(0);
hand.add(c);
GameActionUtil.executeDrawCardTriggeredEffects(player);
}
else
{
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
life.setLife(0);
}
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Cantrip keyword and milling
by DennisBergkamp » 04 Jun 2009, 16:56
Cool stuff, Rob
I'll add the cantrip (and comes into play) code to the next version. I'll hold off on the milling part (I've done something similar in GameActionUtil by the way - and I also stole the setLife(0) part from Battle of Wits ), but I never really liked this enabled because it makes testing cards so difficult ( I like to test cards by creating decks that consist of 7 - 8 cards). But I'll add some button in the GUI somewhere that could enable and disable milling as a win/loss condition.
I'll add the cantrip (and comes into play) code to the next version. I'll hold off on the milling part (I've done something similar in GameActionUtil by the way - and I also stole the setLife(0) part from Battle of Wits ), but I never really liked this enabled because it makes testing cards so difficult ( I like to test cards by creating decks that consist of 7 - 8 cards). But I'll add some button in the GUI somewhere that could enable and disable milling as a win/loss condition.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Cantrip keyword and milling
by mtgrares » 04 Jun 2009, 18:07
Sounds good. Card.getKeyword() has been very useful since more and more stuff can be added to it.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: Cantrip keyword and milling
by Rob Cashwalker » 04 Jun 2009, 18:09
I'd suggest making the enable/disable similar to how the quest decks can be edited - the presence or lack of a file. It's the sort of thing that 99% of the time should be enabled.... I usually make test decks a full 40 cards... but 8 or 10 copies of the card to be tested.DennisBergkamp wrote:Cool stuff, Rob
I'll add the cantrip (and comes into play) code to the next version. I'll hold off on the milling part (I've done something similar in GameActionUtil by the way - and I also stole the setLife(0) part from Battle of Wits ), but I never really liked this enabled because it makes testing cards so difficult ( I like to test cards by creating decks that consist of 7 - 8 cards). But I'll add some button in the GUI somewhere that could enable and disable milling as a win/loss condition.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Cantrip keyword and milling
by frwololo » 15 Jun 2009, 10:43
I have forgotten Java, but this could probably be improved to draw as many cards as you want, with the following (sorry, pseudo code):Rob Cashwalker wrote:
- Code: Select all
if(card.getKeyword().contains("When this card comes into play, draw a card."))
{
card.setComesIntoPlay(new Command()
{
private static final long serialVersionUID = 203335252453049234L;
public void execute()
{
GameAction.drawCard(card.getController());
}
});
}//if "Comes into play tapped."
- Code: Select all
if(card.getKeyword().contains("When this card comes into play, draw:"))
{
Integer nbCards = card.getKeyword().everythingAfter(":").toInteger;
card.setComesIntoPlay(new Command()
{
private static final long serialVersionUID = 203335252453049234L;
public void execute()
{
for (i=1 to nbCards) {
GameAction.drawCard(card.getController());
}
}
});
}//if "Comes into play tapped."
Re: Cantrip keyword and milling
by Rob Cashwalker » 15 Jun 2009, 15:36
There are currently only two cards that draw more than 1 card when they come into play - Flight of Fancy and Mulldrifter.
Not that this should prevent us from allowing the keyword form you're suggesting... just that it's not needed... yet.
No doubt though, that there will be a spDrawCards:# keyword for spells that specifically just draw cards.
Not that this should prevent us from allowing the keyword form you're suggesting... just that it's not needed... yet.
No doubt though, that there will be a spDrawCards:# keyword for spells that specifically just draw cards.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Cantrip keyword and milling
by Rob Cashwalker » 20 Jun 2009, 03:15
Dennis-
I see the Cantrip check was added. But the comes into play draw ability wasn't. Oversight or didn't work? Did Cantrip work as expected?
I see the Cantrip check was added. But the comes into play draw ability wasn't. Oversight or didn't work? Did Cantrip work as expected?
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Cantrip keyword and milling
by DennisBergkamp » 20 Jun 2009, 03:32
Oh, haven't tested either actually. I guess I must've forgotten to add in the Comes into play cantrip... I'll try to add it in next.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 108 guests