IceYGO / windbot

A C# bot for ygopro, compatible with the ygosharp server.
MIT License
80 stars 103 forks source link

How Can I Program WindBot to Surrender? #188

Closed choco55933 closed 3 months ago

choco55933 commented 5 months ago

I'm working on programming a bot for an Exodia FTK strategy. I want the bot to surrender right away if any of the Exodia pieces are sent to its graveyard. Is it feasible to incorporate this feature?

TheSeventhOne commented 4 months ago

You can call AI.Game.Connection.Send(CtosMessage.Surrender) inside the Executor to make the bot surrender. I think this is useful.

choco55933 commented 4 months ago

Hello, I'm trying to use AI.Game.Connection.Send(CtosMessage.Surrender) to make the bot surrender, but I'm facing a CS1061 error and it's not working. Could you please provide detailed instructions on how to make the bot surrender using AI.Game.Connection.Send(CtosMessage.Surrender)?

Here is the code I've used:

private bool CheckForExodia()
{
    if (Bot.HasInGraveyardOrInBanished(CardId.ExodiatheForbiddenOne))
    {
        AI.Game.Connection.Send(CtosMessage.Surrender);
        return true;
    }

    return false;
}

Thank you!

mercury233 commented 3 months ago

https://github.com/IceYGO/windbot/commit/d18e943d45031e3e622e0f6c42eba8557ffd1a67

Now you can use AddExecutor(ExecutorType.Surrender, your_check_function); to let the bot surrender.