Skip to content

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

Merged
Hanmac merged 2 commits into
masterfrom
auraSpellRework
Apr 13, 2025
Merged

Aura Spells have internal Attach Spell for multiple Enchant Keywords#6996
Hanmac merged 2 commits into
masterfrom
auraSpellRework

Conversation

@Hanmac
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Agetian commented Feb 11, 2025

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

Comment thread forge-game/src/main/java/forge/game/card/CardFactory.java Outdated
@Hanmac
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

@Hanmac
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread forge-ai/src/main/java/forge/ai/ability/AttachAi.java
Comment thread forge-ai/src/main/java/forge/ai/ability/AttachAi.java Outdated
@Agetian
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@Hanmac Hanmac force-pushed the auraSpellRework branch from a936c9c to 48fa59b Compare April 7, 2025 05:30
@Hanmac
Copy link
Copy Markdown
Contributor Author

Hanmac commented Apr 7, 2025

Some things that might be done before this MR:

  • KeepTapped for Prison Spells could probably more abstracted so that the AttachAi logic can look for the CantHappen Replacement Effect, then no extra AiLogic needed.
  • I want to add THISTYPE similar to CARDNAME so it does create this aura in the description. (for this i need to look how it works for different languages)

Copy link
Copy Markdown
Contributor

@tool4ever tool4ever left a comment

Choose a reason for hiding this comment

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

I don't know about the final TODO but otherwise it's big enough :p

@Hanmac Hanmac merged commit 25900ee into master Apr 13, 2025
7 checks passed
@Hanmac Hanmac deleted the auraSpellRework branch April 13, 2025 11:36
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