Fix for hex.
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Fix for hex.
by jpb » 09 Jan 2009, 22:32
With Hex you can target the same creature twice. This should not be allowed. Here is the fix so that you must target 6 unique creatures. Insert this fix in place of the current Hex card in CardFactory.java
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Hex"))
{
final Card[] target = new Card[6];
final int[] index = new int[1];
final SpellAbility spell = new Spell(card)
{
public boolean canPlayAI()
{
CardList human = CardFactoryUtil.AI_getHumanCreature();
CardListUtil.sortAttack(human);
CardListUtil.sortFlying(human);
if(6 <= human.size())
{
for(int i = 0; i < 6; i++) //should check to make sure none of these creatures have protection or cannot be the target of spells.
target[i] = human.get(i);
}
return 6 <= human.size();
}
public void resolve()
{
for(int i = 0; i < target.length; i++)
if(AllZone.GameAction.isCardInPlay(target[i]))
AllZone.GameAction.destroy(target[i]);
}//resolve()
};//SpellAbility
final Input input = new Input()
{
public void showMessage()
{
int count = 6 - index[0];
AllZone.Display.showMessage("Select target " + count +" creatures to destroy");
ButtonUtil.enableOnlyCancel();
}
public void selectButtonCancel() {stop();}
public void selectCard(Card c, PlayerZone zone)
{
for(int i=0;i<index[0];i++){
if(c.equals(target[i])){
AllZone.Display.showMessage("You have already selected this target. You must select unique targets for each of the 6 creatures to destroy.");
return; //cannot target the same creature twice.
}
}
if(c.isCreature() && zone.is(Constant.Zone.Play))
{
target[index[0]] = c;
index[0]++;
showMessage();
if(index[0] == target.length)
stopSetNext(new Input_PayManaCost(spell));
}
}//selectCard()
};//Input
Input runtime = new Input()
{
public void showMessage()
{
index[0] = 0;
stopSetNext(input);
}
};//Input
card.clearSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(runtime);
}//*************** END ************ END **************************
- jpb
- Posts: 132
- Joined: 05 Sep 2008, 13:12
- Has thanked: 0 time
- Been thanked: 0 time
Re: Fix for hex.
by DennisBergkamp » 10 Jan 2009, 04:07
Did you mean to post this code here?
Anyway, thanks a lot I'll add the fix
Anyway, thanks a lot I'll add the fix

-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 30 guests