It is currently 23 May 2024, 16:27
   
Text Size

CommandArgs and ability.setChooseTargetAI

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

CommandArgs and ability.setChooseTargetAI

Postby slapshot5 » 25 Oct 2010, 00:44

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
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: CommandArgs and ability.setChooseTargetAI

Postby Chris H. » 01 Nov 2010, 14:56

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?
User avatar
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: CommandArgs and ability.setChooseTargetAI

Postby mtgrares » 01 Nov 2010, 19:11

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.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 50 guests


Who is online

In total there are 50 users online :: 0 registered, 0 hidden and 50 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 50 guests

Login Form