Page 1 of 1

AI Fix for Hero of Leina Tower

PostPosted: 10 Jun 2014, 22:26
by rikimbo
(Until I get more comfortable adding to the code, I'll put changes I made here for review, just to make sure I don't break anything or do anything sloppily.)

I added some logic to CountersPutAi.doTriggerAINoCost so that the AI will be able to play Hero of Leina Tower's ability. With this fix, dumps all of its available mana into the ability when it triggers. I tried to do it the same way as DamageDealAi.doTriggerAINoCost.

Code: Select all
if (abTgt == null) {
   (...)
   if (amountStr.equals("X") && ((sa.hasParam(amountStr) && sa.getSVar(amountStr).equals("Count$xPaid")) || source.getSVar(amountStr).equals("Count$xPaid") )) {
      // Spend all remaining mana to add X counters (eg. Hero of Leina Tower)
      source.setSVar("PayX", Integer.toString(ComputerUtilMana.determineLeftoverMana(sa, ai)));
   }
   (...)
} else (...)
(I had to look at both the ability's SVar and the source card's SVar for X, since for Hero of Leina Tower, it is found on the source card, and is not present in the ability.)

Does anyone anticipate any problems with any of this?

Re: AI Fix for Hero of Leina Tower

PostPosted: 11 Jun 2014, 03:38
by excessum
You should put your proposed changes as a patch for easier comparison and testing. For single card fixes, it is probably better to add a new AiLogic or SVar for the card since you never know what existing cards might stumble into the same conditional.

Assuming that you tested what you posted and it works, the code looks fine to me.

Re: AI Fix for Hero of Leina Tower

PostPosted: 11 Jun 2014, 12:21
by rikimbo
As a patch, do you mean post the source file that I changed?

I thought about it being a card-specific thing, because right now Hero of Leina tower is the only card that does this. But the branch of logic that I put in essentially affects only triggered abilities that add X counters, where X is a mana cost paid. Right now there is only one card that uses that template (I think), but I think dumping leftover mana to get counters from a triggered ability like that is a reasonable general solution.

Re: AI Fix for Hero of Leina Tower

PostPosted: 11 Jun 2014, 12:41
by excessum
Eclipse or whatever IDE you are using should have an option somewhere to create a patch which is essentially a diff of your local repository and whatever revision you are comparing with. The logic might be sound for Hero of Leina Tower but who knows what ancient card somewhere that might trigger that and make a mess so it is safer to just trap it in a conditional.

Re: AI Fix for Hero of Leina Tower

PostPosted: 11 Jun 2014, 13:28
by rikimbo
I do use Eclipse for Forge, so I'll give that patch thing a try next time. :)

EDIT: Went ahead and committed this, so it's live now.