Page 1 of 1

Flashback + keyword (Deep Analysis)

PostPosted: 11 Sep 2009, 17:27
by Chris H.
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:

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 **************************
I changed the cards.txt entry to look 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:

Code: Select all
    //*************** START *********** START **************************
    if(cardName.equals("Deep Analysis"))
    {
     
      card.addSpellAbility(CardFactoryUtil.ability_Flashback(card, "1 U", "3"));
      card.setFlashback(true);
    }//*************** END ************ END **************************
And it works! =D>

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?

Re: Flashback + keyword (Deep Analysis)

PostPosted: 11 Sep 2009, 20:03
by DennisBergkamp
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 :)

Re: Flashback + keyword (Deep Analysis)

PostPosted: 11 Sep 2009, 21:09
by Chris H.
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 :)
There are a few new spells that are keyword + Flashback that I would like to add to this code block. For example:

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. :roll:

Re: Flashback + keyword (Deep Analysis)

PostPosted: 11 Sep 2009, 21:27
by DennisBergkamp
I'm not sure if they will work for flashback... this might be because they're targeted. I can't remember :(

Re: Flashback + keyword (Deep Analysis)

PostPosted: 11 Sep 2009, 22:56
by Chris H.
DennisBergkamp wrote:I'm not sure if they will work for flashback... this might be because they're targeted. I can't remember :(
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 computer

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
I will try Think Twice since it is the only one without targeting.

Re: Flashback + keyword (Deep Analysis)

PostPosted: 12 Sep 2009, 00:34
by Chris H.
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. :rolleyes:


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 **************************

Re: Flashback + keyword (Deep Analysis)

PostPosted: 14 Sep 2009, 09:40
by nantuko84
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

Code: Select all
@SuppressWarnings("serial")
public class CardFactory {
As for me, I choose the second one as it takes less lines of code
Hope this helps

Re: Flashback + keyword (Deep Analysis)

PostPosted: 14 Sep 2009, 11:27
by Rob Cashwalker
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>.

Re: Flashback + keyword (Deep Analysis)

PostPosted: 14 Sep 2009, 14:51
by nantuko84
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 ;)