Page 1 of 1

CommandArgs and ability.setChooseTargetAI

PostPosted: 25 Oct 2010, 00:44
by slapshot5
Hello,

I'm debugging Hedron Crab. After the conversion of Player to a class, it has exposed a NullPointerException. When the Landfall ability of Hedron Crab is resolved for the AI, you get the Exception. When it is resolved when under Human control, everything works fine.

The problem code is at the end of GameActionUtil.landfall_Hedron_Crab():
Code: Select all
else if(c.getController().equals(AllZone.ComputerPlayer)) {
         System.out.print("Setting target player: ");
         ability.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
         System.out.println("getTargetPlayer(): "+ability.getTargetPlayer());
         //AllZone.Stack.add(ability);

      }
This prints: "Setting target player: null". Stack.add is commented to prevent the crash.

but, if I change it to this:
Code: Select all
else if(c.getController().equals(AllZone.ComputerPlayer)) {
         System.out.print("Setting target player: ");
         ability.setTargetPlayer(AllZone.HumanPlayer);
         System.out.println("getTargetPlayer(): "+ability.getTargetPlayer());
         AllZone.Stack.add(ability);

      }
it gives "Setting target player: Human" and resolves correctly (though the description is the generic targeting instead of Landfall - whatever.)

Does anyone know this code well enough to dig in?

-slapshot5

Re: CommandArgs and ability.setChooseTargetAI

PostPosted: 01 Nov 2010, 14:56
by Chris H.
Hmmm, I came across similar issues when attempting to fix Brain Freeze. I fixed Brain Freeze by adding the following to the SpellAbility:

Code: Select all
@Override
public void chooseTargetAI() {
   
    setTargetPlayer(AllZone.HumanPlayer);
   
}//chooseTargetAI()
`
and this is basically what you did for the Hedron Crab.

The old syle of card code would have the AI picking the target inside of the SpellAbility and the Human would usually have an input outside of the SpellAbility.

I am starting to realize that the setChooseTargetAI() is meant to allow the AI to set the tartget outside of the SpellAbility.

So, do we just go back to the old style since it still works or does someone feel competent enough to step in and get this working again?

Re: CommandArgs and ability.setChooseTargetAI

PostPosted: 01 Nov 2010, 19:11
by mtgrares
I am starting to realize that the setChooseTargetAI() is meant to allow the AI to set the target outside of the SpellAbility.
Yeah, sorry for the lack of documentation.