It is currently 23 Apr 2024, 23:46
   
Text Size

AI Fix for Hero of Leina Tower

Post MTG Forge Related Programming Questions Here

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

AI Fix for Hero of Leina Tower

Postby rikimbo » 10 Jun 2014, 22:26

(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?
User avatar
rikimbo
 
Posts: 52
Joined: 25 Mar 2014, 14:15
Location: Winnipeg
Has thanked: 10 times
Been thanked: 7 times

Re: AI Fix for Hero of Leina Tower

Postby excessum » 11 Jun 2014, 03:38

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.
excessum
 
Posts: 177
Joined: 21 Oct 2013, 02:30
Has thanked: 0 time
Been thanked: 19 times

Re: AI Fix for Hero of Leina Tower

Postby rikimbo » 11 Jun 2014, 12:21

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.
User avatar
rikimbo
 
Posts: 52
Joined: 25 Mar 2014, 14:15
Location: Winnipeg
Has thanked: 10 times
Been thanked: 7 times

Re: AI Fix for Hero of Leina Tower

Postby excessum » 11 Jun 2014, 12:41

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.
excessum
 
Posts: 177
Joined: 21 Oct 2013, 02:30
Has thanked: 0 time
Been thanked: 19 times

Re: AI Fix for Hero of Leina Tower

Postby rikimbo » 11 Jun 2014, 13:28

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.
User avatar
rikimbo
 
Posts: 52
Joined: 25 Mar 2014, 14:15
Location: Winnipeg
Has thanked: 10 times
Been thanked: 7 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 34 guests


Who is online

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

Login Form