Flashback + keyword (Deep Analysis)
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Flashback + keyword (Deep Analysis)
by Chris H. » 11 Sep 2009, 17:27
With the new 08-28 version I noticed that the spell Deep Analysis is still hard coded. I thought that I would try to remove some of the code and turn it into a keyword + code type of card.
Deep Analysis looked like this in cards.txt:
Deep Analysis
3 U
Sorcery
no text
and the CardFactory.java code looked like this:
Deep Analysis
3 U
Sorcery
Target player draws two cards.
spDrawCardsTgt:2
and I changed the CardFactory.java code to look like this:
Granted, the code is now just a shell for the flashback code. There is no serialVersionUID but I am not sure if one is required.
I noticed that when the flashback is executed, I am not asked to pick a target player. Just an observation.
Does anything need to be added to the limited code above? Or is this OK?
Deep Analysis looked like this in cards.txt:
Deep Analysis
3 U
Sorcery
no text
and the CardFactory.java code looked like this:
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Deep Analysis"))
{
SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = 6317660847906461825L;
public void resolve()
{
AllZone.GameAction.drawCard(card.getController());
AllZone.GameAction.drawCard(card.getController());
}
public boolean canPlayAI()
{
return AllZone.Computer_Hand.getCards().length <= 6;
}
};
spell.setDescription("Target player draws two cards.");
spell.setStackDescription(card.getName() + " - " + card.getController() + " draws two cards.");
card.clearSpellAbility();
card.addSpellAbility(spell);
card.addSpellAbility(CardFactoryUtil.ability_Flashback(card, "1 U", "3"));
card.setFlashback(true);
}//*************** END ************ END **************************
Deep Analysis
3 U
Sorcery
Target player draws two cards.
spDrawCardsTgt:2
and I changed the CardFactory.java code to look like this:
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Deep Analysis"))
{
card.addSpellAbility(CardFactoryUtil.ability_Flashback(card, "1 U", "3"));
card.setFlashback(true);
}//*************** END ************ END **************************
Granted, the code is now just a shell for the flashback code. There is no serialVersionUID but I am not sure if one is required.
I noticed that when the flashback is executed, I am not asked to pick a target player. Just an observation.
Does anything need to be added to the limited code above? Or is this OK?
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Flashback + keyword (Deep Analysis)
by DennisBergkamp » 11 Sep 2009, 20:03
Chris,
If it works, then it should be fine!
I'll add the serial version #, it's not needed, but we always include it to shut up Eclipse with its annoying warning messages
If it works, then it should be fine!
I'll add the serial version #, it's not needed, but we always include it to shut up Eclipse with its annoying warning messages
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Flashback + keyword (Deep Analysis)
by Chris H. » 11 Sep 2009, 21:09
There are a few new spells that are keyword + Flashback that I would like to add to this code block. For example:DennisBergkamp wrote:Chris,
If it works, then it should be fine!
I'll add the serial version #, it's not needed, but we always include it to shut up Eclipse with its annoying warning messages
Ancient Grudge
Bash to Bits
Defy Gravity
Earth Rift
Ray of Distortion
Ray of Revelation
Reckless Charge
Scorching Missile
Sylvan Might
Think Twice
Thrill of the Hunt
I would also like to remove the code for Firebolt and I will add Firebolt to this block. Currently the Firebolt spell in Forge is missing Flashback.
I will give it my best, but I'm sure that the code will look like a mess.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Flashback + keyword (Deep Analysis)
by DennisBergkamp » 11 Sep 2009, 21:27
I'm not sure if they will work for flashback... this might be because they're targeted. I can't remember
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Flashback + keyword (Deep Analysis)
by Chris H. » 11 Sep 2009, 22:56
There is something strange going on with the flashback code. I think that when the computer uses flashback with Deep Analysis that I will draw the cards, not the computerDennisBergkamp wrote:I'm not sure if they will work for flashback... this might be because they're targeted. I can't remember
Firebolt is missing Flashback for some time. I tried to add it and ouch. The game froze with a exception when the computer attempted to use flashback with Firebolt.
- Code: Select all
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: GameAction : getPlayerLife() invalid player string
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Flashback + keyword (Deep Analysis)
by Chris H. » 12 Sep 2009, 00:34
We can skip the changes to Deep Analysis and Firebolt.
The spell Think Twice can be added. I will skip the other spells as they all are targeted. I could not figure out how to add the "private static final long serialVersionUID =" and the other sections
At least it is one new card. It is time for me to find something a wee bit easier to do.
Think Twice
1 U
Instant
Draw a card.
spDrawCards:1
The spell Think Twice can be added. I will skip the other spells as they all are targeted. I could not figure out how to add the "private static final long serialVersionUID =" and the other sections
At least it is one new card. It is time for me to find something a wee bit easier to do.
Think Twice
1 U
Instant
Draw a card.
spDrawCards:1
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Think Twice"))
{
card.addSpellAbility(CardFactoryUtil.ability_Flashback(card, "2 U", "0"));
card.setFlashback(true);
}//*************** END ************ END **************************
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Flashback + keyword (Deep Analysis)
by nantuko84 » 14 Sep 2009, 09:40
As you don't develop remote application, there is no need for serializationID.
And if it is annoying for you in Eclipse, then you can do one of these:
1. Press on Warning icon on the left in Eclipse, it will show you menu with suggestions "Add default serial version ID" (that is 1 by default), "Add generated serial version ID"
2. Add @SuppressWarning("serial") to the method where ID is required or to the whole class
Hope this helps
And if it is annoying for you in Eclipse, then you can do one of these:
1. Press on Warning icon on the left in Eclipse, it will show you menu with suggestions "Add default serial version ID" (that is 1 by default), "Add generated serial version ID"
2. Add @SuppressWarning("serial") to the method where ID is required or to the whole class
- Code: Select all
@SuppressWarnings("serial")
public class CardFactory {
Hope this helps
Re: Flashback + keyword (Deep Analysis)
by Rob Cashwalker » 14 Sep 2009, 11:27
Having Eclipse insert the @SuppressWarning at every warning along the way is just as many clicks as having Eclipse generate the ID. And who knows when one day the ID may be useful.
Some other warnings it generates, like object type matching end up needing the @SuppressWarnings, because trying to force some object types ends up breaking the code. Specifically Eclipse wants us to use ArrayList<ObjectType>.
Some other warnings it generates, like object type matching end up needing the @SuppressWarnings, because trying to force some object types ends up breaking the code. Specifically Eclipse wants us to use ArrayList<ObjectType>.
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: Flashback + keyword (Deep Analysis)
by nantuko84 » 14 Sep 2009, 14:51
One comment: as I said, you may put one SuppressWarning per class not per warning. E.g. as your CardFactory is too big, one click will replace hundrends (thousands?) of lines.
And if you need them, you'll add them in the future no need to do unnecessary work
And if you need them, you'll add them in the future no need to do unnecessary work
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 88 guests