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

How do I choose a target for a flipped monster? #203

Open
orwasaker opened this issue Sep 23, 2024 · 3 comments
Open

How do I choose a target for a flipped monster? #203

orwasaker opened this issue Sep 23, 2024 · 3 comments

Comments

@orwasaker
Copy link

Currently I use this for Man eater Bug and Hane Hane:

public bool EaterHaneactivate()
{
ClientCard mystrongest = Enemy.MonsterZone.GetHighestAttackMonster();
AI.SelectCard(mystrongest);
return true;
}

But it doesn't work, since I use the Executor "Activate" and I don't think that controls how the AI uses its flip effects

AddExecutor(ExecutorType.Activate, CardId.ManEaterBug, EaterHaneactivate);

@mercury233
Copy link
Collaborator

The mandatory effects don't use Executor to decide whether to activate. You need to override OnSelectCard to do the select.

@orwasaker
Copy link
Author

I tried to find instances of OnSelectCard in the solution to see if maybe I can get the hang of it on my own...but I don't really get how that works

Can you show me how to do it in this case? the effect is very simple, the AI literally just has to select the highest attack monster on my field...but I don't know how to connect the OnSelectCard with Eater's effect

I would really appreciate it since I can then use it as a basis for other flip or mandatory effects

@Wind2009-Louse
Copy link
Contributor

Wind2009-Louse commented Oct 27, 2024

Here's an example(not checked):

        public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
        {
            // other script

            // not in chain solving, meaning it's chaining
            if (Duel.GetCurrentSolvingChainCard() == null)
            {
                ClientCard lastChainCard = Util.GetLastChainCard();
                // selecting target for Man-eating bug
                if (lastChainCard != null && lastChainCard.Controller == 0 && lastChainCard.IsCode(CardId.ManEaterBug))
                {
                    // whether can destroy enemy's best monster
                    List<ClientCard> enemyTargets = _cards.Where(c => c.Controller == 1).OrderByDescending(c => c.Attack).ToList();
                    if (enemyTargets.Count > 0)
                    {
                        return Util.CheckSelectCount(enemyTargets, _cards, min, max);
                    }
                    // select worst monster(usually bot's monster) to destroy
                    return Util.CheckSelectCount(_cards.OrderBy(c => c.Attack).ToList(), _cards, min, max);
                }
            }

            // other script
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants