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
by 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.
Does anyone anticipate any problems with any of this?
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 (...)
Does anyone anticipate any problems with any of this?
-
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
by 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.
Assuming that you tested what you posted and it works, the code looks fine to me.
Re: AI Fix for Hero of Leina Tower
by 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.
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.
-
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
by 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.
Re: AI Fix for Hero of Leina Tower
by 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.
EDIT: Went ahead and committed this, so it's live now.
-
rikimbo - Posts: 52
- Joined: 25 Mar 2014, 14:15
- Location: Winnipeg
- Has thanked: 10 times
- Been thanked: 7 times
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 18 guests