It is currently 16 Apr 2024, 11:21
   
Text Size

Fix for hex.

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

Fix for hex.

Postby 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.

Postby DennisBergkamp » 10 Jan 2009, 04:07

Did you mean to post this code here?
Anyway, thanks a lot I'll add the fix :)
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Fix for hex.

Postby Huggybaby » 11 Jan 2009, 02:42

Topic relocated.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times


Return to Forge

Who is online

Users browsing this forum: No registered users and 57 guests


Who is online

In total there are 57 users online :: 0 registered, 0 hidden and 57 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 57 guests

Login Form