Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aura Spells have internal Attach Spell for multiple Enchant Keywords #6996

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Hanmac
Copy link
Contributor

@Hanmac Hanmac commented Feb 10, 2025

Closes #169

I can't add the AI flags into the Keyword because of Tallowisp,
so i added Svars instead.

  • Updated Cards
  • Fixed GUI, i think?
  • AI still need to use filter the possible list via canBeAttached

@Hanmac Hanmac added Game Mechanics AI General AI tag labels Feb 10, 2025
@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 10, 2025

@tool4ever i don't know why " Incremental Growth " fails ... that isn't even an Aura?

Incremental Growth (8) - [Couldn't add to stack, failed to target] - Put a +1/+1 counter on target creature, two +1/+1 counters on another target creature, and three +1/+1 counters on a third target creature.[[Flying Men (1)], [Forest Bear (7)], []]

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 11, 2025

@Agetian can you look at the failing test case why the AI has problem with Incremental Growth?
i somehow can't see how this is related to this MR

@Hanmac Hanmac requested a review from Agetian February 11, 2025 12:03
@Agetian
Copy link
Contributor

Agetian commented Feb 11, 2025

Hmm, not sure about Incremental Growth (and why it isn't targeting correctly in one of the tests) yet, but the immediate failing test for me is testPlayingSorceryPumpSpellsBeforeBlocks, which fails at line 609 of SpellAbilityPickerSimulationTest. What's happening there is the AI is playing a Dwarven Trader and then tries to make the AI decide on playing Furor of the Bitten on it, which is what line 609 is asserting. Furor of the Bitten is indeed affected by this MR, since it uses the new AI SVar for the aura attach. Possibly the SVar isn't accounted for somewhere in the AI code yet? Please let me know if you're able to figure this one out, we can take a look at Incremental Growth next if that causes issues once this immediate test case is fixed.

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 11, 2025

Hmm, not sure about Incremental Growth (and why it isn't targeting correctly in one of the tests) yet, but the immediate failing test for me is testPlayingSorceryPumpSpellsBeforeBlocks, which fails at line 609 of SpellAbilityPickerSimulationTest. What's happening there is the AI is playing a Dwarven Trader and then tries to make the AI decide on playing Furor of the Bitten on it, which is what line 609 is asserting. Furor of the Bitten is indeed affected by this MR, since it uses the new AI SVar for the aura attach. Possibly the SVar isn't accounted for somewhere in the AI code yet? Please let me know if you're able to figure this one out, we can take a look at Incremental Growth next if that causes issues once this immediate test case is fixed.

AttachAILogic is just turned into AILogic by this, so that shouldn't be the problem.

                if (c.hasSVar("AttachAILogic")) {
                    extra += " | AILogic$ " + c.getSVar("AttachAILogic");
                }

I think the AI needs better logic what it can target with AttachAi.attachPreference
So if sa is a Spell of an Aura Card, it should check canAttach too instead of just tgt

@Agetian
Copy link
Contributor

Agetian commented Feb 11, 2025

Yeah, agree about the AI logic improvements, sounds like a good thing to implement 👍

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 12, 2025

tests are green, and i did some hard wire that canTarget does call canAttach for Aura Spells

@tool4ever
Copy link
Contributor

yea that's what I meant
but wouldn't adding CanBeEnchantedBy property to the ValidTgts$ be much cleaner? 🤔

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 12, 2025

yea that's what I meant but wouldn't adding CanBeEnchantedBy property to the ValidTgts$ be much cleaner? 🤔

I don't know? Like this? ValidTgts$ Card.CanBeEnchantedBy,Player.CanBeEnchantedBy

You can try it if you want?

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 12, 2025

@tool4ever can you check why the last change does break the tests again?

getAllCandidates there calls sa.canTarget which then should call tr.getValidTgts() ?

Found it!

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 13, 2025

@tool4ever the MR should be clean now?
@Agetian now that CanBeEnchantedBy is part of the ValidTgts, the AI should respect that?

@Agetian
Copy link
Contributor

Agetian commented Feb 13, 2025

@Agetian now that CanBeEnchantedBy is part of the ValidTgts, the AI should respect that?

Hopefully yes, but if you can tell me some test cases for that, I can give it a shot and test/trace it in action :)
Otherwise, looks good, yeah 👍

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 13, 2025

@Agetian it is mostly the problem that tgt.canTgtPlayer() doesn't work anymore
but i think the one place in AttachAi where that is used got updated

@@ -551,11 +552,7 @@ private static Card attachAIReanimatePreference(final SpellAbility sa, final Lis
final Player ai = sa.getActivatingPlayer();
final Card attachSourceLki = CardCopyService.getLKICopy(attachSource);
attachSourceLki.setLastKnownZone(ai.getZone(ZoneType.Battlefield));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this branch tested?
I have doubts it still works now...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It got tested by GameSimulationTest.testEpochrasite

Or should we do another Test case for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not how the tests work, they are only to check engine and won't use AI api for the most parts
this code wouldn't be reached and such changes need to be confirmed manually ingame

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why resolve when it's been broken? :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tool4ever you or @Agetian could try to add an extra Animate Dead Test that uses AI parts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have a precedent for that...? So we'd need to add some framework parts there first.
Anyway to fix the logic here I suggest you try using AnimateAi.becomeAnimated so the new Aura is able to pass the check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tool4ever i will need to look at Weekend how to change the new Aura

@Agetian
Copy link
Contributor

Agetian commented Feb 13, 2025

I agree that it's important to come up with some in-game board states that would be good to check how this works in practice, it's a bit difficult for me to figure out what would be good test cases tbh, but yeah, the automated tests won't help since they use the simulation AI which is a completely different thing in itself :)

@Hanmac
Copy link
Contributor Author

Hanmac commented Feb 13, 2025

@Agetian @tool4ever, something unrelated, that ticked me off before:


still shows this in the Log:

Incremental Growth (8) - [Couldn't add to stack, failed to target] - Put a +1/+1 counter on target creature, two +1/+1 counters on another target creature, and three +1/+1 counters on a third target creature.[[Flying Men (1)], [Forest Bear (7)], []]

i know the spell should not be able to cast, but the Stack Message should still not appear there?

@Agetian
Copy link
Contributor

Agetian commented Feb 13, 2025

Hmm yeah, not sure what's happening there, probably needs looking into, yes. I'll see if I can figure it out on the upcoming weekend.

@Hanmac Hanmac marked this pull request as ready for review February 13, 2025 09:39
@Hanmac Hanmac requested a review from tool4ever February 13, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI General AI tag Game Mechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Aura Spells + Enchant Keyword
3 participants