IceYGO / windbot

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

Special Summoning Monster from Deck due to Card effect #179

Open jdistro07 opened 7 months ago

jdistro07 commented 7 months ago

Hi. I am making a bot that uses Spirit Charmers Structure Deck. I can't figure out how to Special Summon Awakening of the Possessed - Nefariouser Archfiend from the deck by tributing 1 spellcaster and 1 level 4 or lower Earth monster on the bot's field.

I have this code currently and it seems SpSummon doesn't seem to work:

[Deck("SpiritCharmers", "AI_SDSpiritCharmers")]
public class SpiritCharmers : DefaultExecutor
{
    public SpiritCharmers(GameAI ai, Duel duel)
    : base(ai, duel)
        {
        ...
                AddExecutor(ExecutorType.SpSummon, CardId.AwakeningNefariouserArch, AwakeningNefariouserArch_Effect);
        ...
    }

    public bool AwakeningNefariouserArch_Effect()
    {
        if (ActivateDescription == Util.GetStringId(CardId.AwakeningNefariouserArch, 0))
        {
            AI.SelectCard(CardId.AwakeningNefariouserArch);
            return true;
        }

        return false;
    }
}

The bot special summons but only if Awakening of the Possessed - Nefariouser Archfiend is on the hand which is not really productive. Any help would be appreciated.

Thanks!

Wind2009-Louse commented 7 months ago
        private void OnSelectIdleCmd(BinaryReader packet)
        {
            packet.ReadByte(); // player

            _duel.MainPhase = new MainPhase();
            MainPhase main = _duel.MainPhase;
            int count;
            for (int k = 0; k < 5; k++)
            {
                count = packet.ReadByte();
                for (int i = 0; i < count; ++i)
                {
                    packet.ReadInt32(); // card id
                    int con = GetLocalPlayer(packet.ReadByte());
                    CardLocation loc = (CardLocation)packet.ReadByte();
                    int seq = packet.ReadByte();
                    ClientCard card = _duel.GetCard(con, loc, seq);
                    if (card == null) continue;

Seems that calling _duel.GetCard() to get cards in deck will return null, so Bot won't try to special summon monsters from deck directly.

jdistro07 commented 7 months ago
        private void OnSelectIdleCmd(BinaryReader packet)
        {
            packet.ReadByte(); // player

            _duel.MainPhase = new MainPhase();
            MainPhase main = _duel.MainPhase;
            int count;
            for (int k = 0; k < 5; k++)
            {
                count = packet.ReadByte();
                for (int i = 0; i < count; ++i)
                {
                    packet.ReadInt32(); // card id
                    int con = GetLocalPlayer(packet.ReadByte());
                    CardLocation loc = (CardLocation)packet.ReadByte();
                    int seq = packet.ReadByte();
                    ClientCard card = _duel.GetCard(con, loc, seq);
                    if (card == null) continue;

Seems that calling _duel.GetCard() to get cards in deck will return null, so Bot won't try to special summon monsters from deck directly.

So it's a current issue on the bot? But it's odd the "Feelin' Lucky" executor can Special Summon from deck like immediately in Main Phase 1. Where can I see the implementation of "Feelin' Lucky" executor?

Wind2009-Louse commented 7 months ago

Maybe you can try to catch Card from Executor(.SpSummon, Func), to find out why it can't be special summoned by Executor(.SpSummon, int, Func).

jdistro07 commented 6 months ago

I just saw AI.SelectMaterials(). And I think I should use that instead of AI.SelectCard(). And the SpSummon executor type seems to be working fine. But since it's some sort of a tribute summon I need to use AI.SelectMaterials(). I think that's where the problem is. I am gonna to test this out to see if I am correct. Then close the issue.