Beispiel #1
0
        public override List <WrappedCard> GetViewAsCards(TrustedAI ai, string pattern, Player player)
        {
            Room               room    = ai.Room;
            Player             jiaozhu = ai.FindPlayerBySkill("hongfa");
            List <WrappedCard> result  = new List <WrappedCard>();

            if (jiaozhu != null && RoomLogic.WillBeFriendWith(room, player, jiaozhu) && pattern == Slash.ClassName)
            {
                foreach (int id in jiaozhu.GetPile("heavenly_army"))
                {
                    WrappedCard hongfa = new WrappedCard("HongfaCard")
                    {
                        Skill = "hongfa"
                    };
                    hongfa.AddSubCard(id);

                    WrappedCard slash = new WrappedCard(Slash.ClassName)
                    {
                        Skill = "hongfa"
                    };
                    slash.AddSubCard(id);
                    slash            = RoomLogic.ParseUseCard(room, slash);
                    slash.UserString = RoomLogic.CardToString(room, hongfa);
                    result.Add(slash);
                }
            }

            return(result);
        }
Beispiel #2
0
        public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player)
        {
            Room       room = ai.Room;
            List <int> ids  = player.GetCards("he");

            ids.AddRange(player.GetHandPile());

            foreach (int id in ids)
            {
                WrappedCard card = ai.Room.GetCard(id);
                if (WrappedCard.IsRed(card.Suit))
                {
                    WrappedCard slash = new WrappedCard(Slash.ClassName)
                    {
                        Skill     = Name,
                        ShowSkill = Name
                    };
                    slash.AddSubCard(card);
                    slash = RoomLogic.ParseUseCard(room, slash);
                    return(new List <WrappedCard> {
                        slash
                    });
                }
            }
            return(null);
        }
Beispiel #3
0
        public override WrappedCard ViewAs(Room room, WrappedCard card, Player player)
        {
            WrappedCard ox = new WrappedCard(ClassicWoodenOxCard.ClassName);

            ox.AddSubCard(card);
            ox.Skill = Name;
            return(ox);
        }
Beispiel #4
0
        public override bool TargetFilter(Room room, List <Player> targets, Player to_select, Player Self, WrappedCard card)
        {
            WrappedCard ba = new WrappedCard(card.UserString);

            ba.AddSubCard(card);
            ba = RoomLogic.ParseUseCard(room, ba);
            FunctionCard bcard = Engine.GetFunctionCard(card.UserString);

            return(bcard.TargetFilter(room, targets, to_select, Self, ba));
        }
        public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player)
        {
            Room       room = ai.Room;
            List <int> ids  = player.GetCards("h");

            ids.AddRange(player.GetHandPile());
            List <int> spades = new List <int>();

            foreach (int id in ids)
            {
                if (room.GetCard(id).Suit == WrappedCard.CardSuit.Spade)
                {
                    spades.Add(id);
                }
            }

            List <WrappedCard> result = new List <WrappedCard>();

            if (spades.Count > 0)
            {
                ai.SortByUseValue(ref spades, false);
                WrappedCard card = new WrappedCard(GuishuCard.ClassName)
                {
                    Skill     = Name,
                    ShowSkill = Name
                };
                card.AddSubCard(spades[0]);

                if (player.GetMark(Name) == 0 || player.GetMark(Name) == 1)
                {
                    card.UserString = BefriendAttacking.ClassName;
                    WrappedCard ba = new WrappedCard(BefriendAttacking.ClassName)
                    {
                        Skill     = Name,
                        ShowSkill = Name,
                    };
                    ba.AddSubCard(card);
                    ba            = RoomLogic.ParseUseCard(room, ba);
                    ba.UserString = RoomLogic.CardToString(room, card);
                    result.Add(ba);
                }
                else if (spades.Count > 1)
                {
                    card.UserString = KnownBoth.ClassName;
                    result.Add(card);
                }
            }
            return(result);
        }
Beispiel #6
0
        public override WrappedCard ViewAs(Room room, List <WrappedCard> cards, Player player)
        {
            if (cards.Count == 1 && RoomLogic.IsVirtualCard(room, cards[0]))
            {
                WrappedCard gs = new WrappedCard(GuishuCard.ClassName)
                {
                    Skill      = Name,
                    ShowSkill  = Name,
                    UserString = cards[0].Name
                };
                gs.AddSubCard(cards[0]);
                return(gs);
            }

            return(null);
        }
Beispiel #7
0
        public override List <WrappedCard> GetViewAsCards(TrustedAI ai, string pattern, Player player)
        {
            List <WrappedCard> cards = new List <WrappedCard>();

            if (pattern == Snatch.ClassName && player.GetPile("field").Count > 0)
            {
                foreach (int id in player.GetPile("field"))
                {
                    WrappedCard shun = new WrappedCard(Snatch.ClassName)
                    {
                        Skill     = Name,
                        ShowSkill = Name
                    };
                    shun.AddSubCard(id);
                    shun = RoomLogic.ParseUseCard(ai.Room, shun);
                    cards.Add(shun);
                }
            }

            return(cards);
        }
Beispiel #8
0
        public override WrappedCard ViewAs(TrustedAI ai, Player player, int id, bool current, Player.Place place)
        {
            Room        room = ai.Room;
            WrappedCard card = room.GetCard(id);

            if (card.HasFlag("using"))
            {
                return(null);
            }
            if (WrappedCard.IsRed(card.Suit))
            {
                WrappedCard slash = new WrappedCard(Slash.ClassName)
                {
                    Skill     = Name,
                    ShowSkill = Name
                };
                slash.AddSubCard(card);
                slash = RoomLogic.ParseUseCard(room, slash);
                return(slash);
            }

            return(null);
        }
        public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
        {
            if (player.GetMark("guishu") == 2)
            {
                WrappedCard kb = new WrappedCard(KnownBoth.ClassName)
                {
                    Skill     = Name,
                    ShowSkill = Name,
                };
                kb.AddSubCard(card);
                kb = RoomLogic.ParseUseCard(ai.Room, kb);

                UseCard e = Engine.GetCardUsage(KnownBoth.ClassName);
                if (e != null)
                {
                    CardUseStruct dummy = new CardUseStruct(null, player, new List <Player>())
                    {
                        IsDummy = true
                    };
                    e.Use(ai, player, ref dummy, kb);
                    if (dummy.Card == kb && dummy.To.Count > 0)
                    {
                        use.Card = card;
                        use.To   = dummy.To;
                        return;
                    }
                }

                Room          room    = ai.Room;
                List <Player> targets = ai.Exclude(room.GetOtherPlayers(player), kb);
                if (targets.Count > 0)
                {
                    use.Card = card;
                    use.To.Add(targets[0]);
                }
            }
        }
Beispiel #10
0
        public override CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data)
        {
            List <int>    ids = new List <int>(player.HandCards);
            CardUseStruct use = new CardUseStruct(null, player, new List <Player>());
            KeyValuePair <Player, int> key = ai.GetCardNeedPlayer(ids);

            if (key.Key != null && key.Value >= 0 && ai.Room.Current == key.Key)
            {
                WrappedCard wrapped = new WrappedCard(YijiJCard.ClassName)
                {
                    Skill = Name
                };
                wrapped.AddSubCard(key.Value);
                use.Card = wrapped;
                use.To.Add(key.Key);
                return(use);
            }
            if (player.HandcardNum <= 2)
            {
                return(use);
            }

            if (key.Key != null && key.Value >= 0)
            {
                WrappedCard wrapped = new WrappedCard(YijiJCard.ClassName)
                {
                    Skill = Name
                };
                wrapped.AddSubCard(key.Value);
                use.Card = wrapped;
                use.To.Add(key.Key);
                return(use);
            }

            return(use);
        }
Beispiel #11
0
        public override WrappedCard Validate(Room room, CardUseStruct use)
        {
            Player      player = use.From;
            WrappedCard ba     = new WrappedCard(use.Card.UserString)
            {
                Skill         = "guishu",
                ShowSkill     = "guishu",
                SkillPosition = use.Card.SkillPosition
            };

            ba.AddSubCard(use.Card);
            ba = RoomLogic.ParseUseCard(room, ba);

            if (ba.Name == BefriendAttacking.ClassName)
            {
                player.SetMark("guishu", 2);
            }
            else
            {
                player.SetMark("guishu", 1);
            }

            return(ba);
        }
Beispiel #12
0
        public override bool Effect(TriggerEvent triggerEvent, Room room, Player player, ref object data, Player target, TriggerStruct trigger_info)
        {
            if (room.SkipGameRule)
            {
                room.SkipGameRule = false;
                return(false);
            }

            // Handle global events
            if (player == null)
            {
                if (triggerEvent == TriggerEvent.GameStart)
                {
                    OnGameStart(room, ref data);
                }

                if (triggerEvent != TriggerEvent.BeforeCardsMove && triggerEvent != TriggerEvent.CardsMoveOneTime)
                {
                    return(false);
                }
            }

            switch (triggerEvent)
            {
            case TriggerEvent.TurnStart:
                OnTurnStart(room, player, ref data);
                break;

            case TriggerEvent.EventPhaseProceeding:
                OnPhaseProceed(room, player, ref data);
                break;

            case TriggerEvent.EventPhaseEnd:
                OnPhaseEnd(room, player, ref data);
                break;

            case TriggerEvent.EventPhaseChanging:
                OnPhaseChanging(room, player, ref data);
                break;

            case TriggerEvent.PreCardUsed:
                OnPreCardUsed(room, player, ref data);
                break;

            case TriggerEvent.CardUsed:
                OnCardUsed(room, player, ref data);
                break;

            case TriggerEvent.CardFinished:
                CardUseStruct use = (CardUseStruct)data;
                //room.ClearCardFlag(use.Card);
                use.Card.ClearFlags();                      //RoomCard会在其移动后自动清除flag
                room.RemoveSubCards(use.Card);

                //以askforcard形式使用的卡牌没有onUse的trigger,但有finish
                if (use.Reason != CardUseStruct.CardUseReason.CARD_USE_REASON_RESPONSE)
                {
                    room.RemoveUseOnFinish();
                }

                if (Engine.GetFunctionCard(use.Card.Name).IsNDTrick())
                {
                    room.RemoveHegNullification(use.Card);
                }

                foreach (Client p in room.Clients)
                {
                    room.DoNotify(p, CommandType.S_COMMAND_NULLIFICATION_ASKED, new List <string> {
                        "."
                    });
                }

                break;

            case TriggerEvent.EventAcquireSkill:
            case TriggerEvent.EventLoseSkill:
                InfoStruct info       = (InfoStruct)data;
                string     skill_name = info.Info;
                Skill      skill      = Engine.GetSkill(skill_name);
                bool       refilter   = skill is FilterSkill;

                if (!refilter && skill is TriggerSkill)
                {
                    TriggerSkill trigger = (TriggerSkill)skill;
                    ViewAsSkill  vsskill = trigger.ViewAsSkill;
                    if (vsskill != null && (vsskill is FilterSkill))
                    {
                        refilter = true;
                    }
                }

                if (refilter)
                {
                    room.FilterCards(player, player.GetCards("he"), triggerEvent == TriggerEvent.EventLoseSkill);
                }

                CheckBigKingdoms(room);
                break;

            case TriggerEvent.PostHpReduced:
                if (player.Hp > 0 || player.HasFlag("Global_Dying"))     // newest GameRule -- a player cannot enter dying when it is dying.
                {
                    break;
                }
                if (data is DamageStruct damage)
                {
                    room.EnterDying(player, damage);
                }
                else
                {
                    room.EnterDying(player, new DamageStruct());
                }

                break;

            case TriggerEvent.AskForPeaches:
                OnAskforPeach(room, player, ref data);
                break;

            case TriggerEvent.AskForPeachesDone:
            {
                if (player.Hp <= 0 && player.Alive)
                {
                    DyingStruct dying = (DyingStruct)data;
                    room.KillPlayer(player, dying.Damage);
                }

                break;
            }

            case TriggerEvent.ConfirmDamage:
            {
                break;
            }

            case TriggerEvent.DamageDone:
            {
                damage = (DamageStruct)data;
                if (damage.From != null && !damage.From.Alive)
                {
                    damage.From = null;
                }
                room.SendDamageLog(damage);

                if (damage.Nature != DamageNature.Normal && player.Chained && !damage.Chain && !damage.ChainStarter)
                {
                    damage.ChainStarter = true;
                }

                data = damage;

                bool reduce = !room.ApplyDamage(player, damage);

                if (reduce)
                {
                    room.RoomThread.Trigger(TriggerEvent.PostHpReduced, room, player, ref data);
                }

                break;
            }

            case TriggerEvent.DamageComplete:
            {
                damage = (DamageStruct)data;
                if (damage.Prevented)
                {
                    return(false);
                }

                /*
                 * if (damage.Nature != DamageNature.Normal && player.Chained)
                 * {
                 *  room.ChainedRemoveOnDamageDone(player, damage);
                 * }
                 */
                if (damage.Nature != DamageNature.Normal && !damage.Chain && damage.ChainStarter)              // iron chain effect
                {
                    List <Player> chained_players = new List <Player>();
                    if (!room.Current.Alive)
                    {
                        chained_players = room.GetOtherPlayers(room.Current);
                    }
                    else
                    {
                        chained_players = room.GetAllPlayers();
                    }
                    chained_players.Remove(damage.To);
                    foreach (Player chained_player in chained_players)
                    {
                        if (chained_player.Chained)
                        {
                            Thread.Sleep(500);
                            LogMessage log = new LogMessage
                            {
                                Type = "#IronChainDamage",
                                From = chained_player.Name
                            };
                            room.SendLog(log);

                            DamageStruct chain_damage = damage;
                            chain_damage.To             = chained_player;
                            chain_damage.Chain          = true;
                            chain_damage.Transfer       = false;
                            chain_damage.TransferReason = null;

                            room.Damage(chain_damage);
                        }
                    }
                }

                foreach (Player p in room.GetAllPlayers())
                {
                    if (p.HasFlag("Global_DFDebut"))
                    {
                        p.SetFlags("-Global_DFDebut");
                        room.RoomThread.Trigger(TriggerEvent.DFDebut, room, p);
                    }
                }
                break;
            }

            case TriggerEvent.CardEffect:
            {
                if (data is CardEffectStruct effect)
                {
                    if (Engine.GetFunctionCard(effect.Card.Name) is DelayedTrick)
                    {
                        CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_DELAYTRICK_EFFECT,
                                                                   effect.To.Name, effect.Card.Skill, effect.Card.Name)
                        {
                            Card = effect.Card
                        };

                        room.MoveCardTo(effect.Card, effect.To, Place.PlaceTable, reason, true);
                        Thread.Sleep(500);
                    }
                }
                break;
            }

            case TriggerEvent.CardEffected:
            {
                if (data is CardEffectStruct effect)
                {
                    FunctionCard fcard = Engine.GetFunctionCard(effect.Card.Name);
                    if (!(fcard is Slash) && effect.BasicEffect.Nullified)
                    {
                        LogMessage log = new LogMessage
                        {
                            Type = "#Cardnullified",
                            From = effect.To.Name,
                            Arg  = effect.Card.Name
                        };
                        room.SendLog(log);

                        return(true);
                    }
                    else if (fcard.TypeID == CardType.TypeTrick && room.IsCanceled(effect))
                    {
                        effect.To.SetFlags("Global_NonSkillnullify");
                        return(true);
                    }
                    object _effect = effect;
                    room.RoomThread.Trigger(TriggerEvent.CardEffectConfirmed, room, effect.To, ref _effect);

                    if (effect.To.Alive || fcard is Slash)
                    {
                        fcard.OnEffect(room, effect);
                    }
                }

                break;
            }

            case TriggerEvent.SlashEffected:
            {
                SlashEffectStruct effect = (SlashEffectStruct)data;
                if (effect.Nullified)
                {
                    LogMessage log = new LogMessage
                    {
                        Type = "#Cardnullified",
                        From = effect.To.Name,
                        Arg  = effect.Slash.Name
                    };
                    room.SendLog(log);

                    return(true);
                }

                if (effect.Jink_num > 0)
                {
                    room.RoomThread.Trigger(TriggerEvent.SlashProceed, room, effect.From, ref data);
                }
                else
                {
                    room.SlashResult(effect, null);
                }
                break;
            }

            case TriggerEvent.SlashProceed:
            {
                SlashEffectStruct effect  = (SlashEffectStruct)data;
                string            slasher = effect.From.Name;
                if (!effect.To.Alive)
                {
                    break;
                }
                if (effect.Jink_num == 1)
                {
                    CardResponseStruct resp = room.AskForCard(effect.To, Slash.ClassName, Jink.ClassName, string.Format("slash-jink:{0}::{1}", slasher, effect.Slash.Name),
                                                              data, HandlingMethod.MethodUse, null, effect.From, false, false);
                    room.SlashResult(effect, room.IsJinkEffected(effect.To, resp) ? resp.Card : null);
                }
                else
                {
                    WrappedCard jink = new WrappedCard(DummyCard.ClassName);
                    for (int i = effect.Jink_num; i > 0; i--)
                    {
                        string             prompt = string.Format("@multi-jink{0}:{1}::{2}:{3}", i == effect.Jink_num ? "-start" : string.Empty, slasher, i, effect.Slash.Name);
                        CardResponseStruct resp   = room.AskForCard(effect.To, Slash.ClassName, Jink.ClassName, prompt, data, HandlingMethod.MethodUse, null, effect.From, false, false);

                        if (!room.IsJinkEffected(effect.To, resp))
                        {
                            //delete jink;
                            room.SlashResult(effect, null);
                            return(false);
                        }
                        else
                        {
                            jink.AddSubCard(resp.Card);
                        }
                    }
                    room.SlashResult(effect, jink);
                }

                break;
            }

            case TriggerEvent.SlashHit:
            {
                SlashEffectStruct effect = (SlashEffectStruct)data;
                if (effect.Drank > 0)
                {
                    LogMessage log = new LogMessage
                    {
                        Type = "#AnalepticBuff",
                        From = effect.From.Name,
                        To   = new List <string> {
                            effect.To.Name
                        },
                        Arg  = (1 + effect.ExDamage).ToString(),
                        Arg2 = (1 + effect.ExDamage + effect.Drank).ToString()
                    };

                    room.SendLog(log);
                }
                DamageStruct slash_damage = new DamageStruct(effect.Slash, effect.From, effect.To, 1 + effect.ExDamage + effect.Drank, effect.Nature)
                {
                    Drank = effect.Drank > 0
                };
                room.Damage(slash_damage);
                break;
            }

            case TriggerEvent.BeforeGameOverJudge:
            {
                if (!player.General1Showed)
                {
                    room.ShowGeneral(player, true, false, false);
                }
                if (!player.General2Showed)
                {
                    room.ShowGeneral(player, false, false, false);
                }
                break;
            }

            case TriggerEvent.GameOverJudge:
            {
                string winner = GetWinner(room);
                if (!string.IsNullOrEmpty(winner))
                {
                    room.GameOver(winner);
                    return(true);
                }

                break;
            }

            case TriggerEvent.BuryVictim:
            {
                OnBuryVictim(room, player, ref data);
                break;
            }

            case TriggerEvent.StartJudge:
            {
                int         card_id      = room.GetNCards(1)[0];
                JudgeStruct judge_struct = (JudgeStruct)data;
                judge_struct.Card = room.GetCard(card_id);

                LogMessage log = new LogMessage
                {
                    Type     = "$InitialJudge",
                    From     = judge_struct.Who.Name,
                    Card_str = card_id.ToString()
                };
                room.SendLog(log);

                room.MoveCardTo(judge_struct.Card, null, judge_struct.Who, Place.PlaceJudge,
                                new CardMoveReason(MoveReason.S_REASON_JUDGE, judge_struct.Who.Name, null, null, judge_struct.Reason), true);

                Thread.Sleep(500);
                bool effected = judge_struct.Good == Engine.MatchExpPattern(room, judge_struct.Pattern, judge_struct.Who, judge_struct.Card);
                judge_struct.UpdateResult(effected);
                data = judge_struct;
                break;
            }

            case TriggerEvent.JudgeResult:
            {
                JudgeStruct judge = (JudgeStruct)data;
                LogMessage  log   = new LogMessage
                {
                    Type     = "$JudgeResult",
                    From     = player.Name,
                    Card_str = RoomLogic.CardToString(room, judge.Card)
                };
                room.SendLog(log);

                //Thread.Sleep(500);
                if (judge.PlayAnimation)
                {
                    room.SendJudgeResult(judge);
                    Thread.Sleep(800);
                }

                break;
            }

            case TriggerEvent.FinishJudge:
            {
                JudgeStruct judge = (JudgeStruct)data;

                if (room.GetCardPlace(judge.Card.Id) == Place.PlaceJudge)
                {
                    CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_JUDGEDONE, judge.Who.Name, null, judge.Reason);
                    room.MoveCardTo(judge.Card, judge.Who, null, Place.DiscardPile, reason, true);
                }

                break;
            }

            case TriggerEvent.ChoiceMade:
            {
                foreach (Player p in room.GetAlivePlayers())
                {
                    List <string> flags = new List <string>(p.Flags);
                    foreach (string flag in flags)
                    {
                        if (flag.StartsWith("Global_") && flag.EndsWith("Failed"))
                        {
                            p.SetFlags("-" + flag);
                        }
                    }
                }
                break;
            }

            case TriggerEvent.GeneralShown:
            {
                string winner = GetWinner(room);
                if (!string.IsNullOrEmpty(winner))
                {
                    room.GameOver(winner);         // if all hasShownGenreal, and they are all friend, game over.
                    return(true);
                }
                if (!room.ContainsTag("TheFirstToShowRewarded"))
                {
                    room.SetTag("TheFirstToShowRewarded", true);
                    room.SetPlayerMark(player, "@pioneer", 1);
                    room.AttachSkillToPlayer(player, "pioneer");
                }
                if (player.Alive && player.HasShownAllGenerals())
                {
                    if (player.GetMark("CompanionEffect") > 0)
                    {
                        room.RemovePlayerMark(player, "CompanionEffect");
                        room.DoSuperLightbox(player, string.Empty, "companion");
                        room.SetPlayerMark(player, "@companion", 1);
                        room.AttachSkillToPlayer(player, "companion");
                    }
                    if (player.GetMark("HalfMaxHpLeft") > 0)
                    {
                        room.RemovePlayerMark(player, "HalfMaxHpLeft");
                        room.SetPlayerMark(player, "@megatama", 1);
                        room.AttachSkillToPlayer(player, "megatama");
                    }
                }
                CheckBigKingdoms(room);
                break;
            }

            case TriggerEvent.BeforeCardsMove:
            {
                if (data is CardsMoveOneTimeStruct move)
                {
                    bool should_find_io = false;
                    if (move.To_place == Place.DiscardPile)
                    {
                        if (move.Reason.Reason != MoveReason.S_REASON_USE)
                        {
                            should_find_io = true;         // not use
                        }
                        else if (move.Card_ids.Count > 1)
                        {
                            should_find_io = true;         // use card isn't IO
                        }
                        else
                        {
                            WrappedCard card = room.GetCard(move.Card_ids[0]);
                            if (card.Name == Edict.ClassName && !card.HasFlag("edict_normal_use"))
                            {
                                should_find_io = true;         // use card isn't IO
                            }
                        }
                    }
                    if (should_find_io)
                    {
                        foreach (int id in move.Card_ids)
                        {
                            WrappedCard card = room.GetCard(id);
                            if (card.Name == Edict.ClassName)
                            {
                                room.MoveCardTo(card, null, Place.PlaceTable, true);
                                room.AddToPile(room.Players[0], "#edict", card, false);
                                LogMessage log = new LogMessage
                                {
                                    Type = "#RemoveEdict",
                                    Arg  = Edict.ClassName
                                };
                                room.SendLog(log);
                                room.SetTag("EdictInvoke", true);
                                room.SetTag("EdictCard", card);
                                int i = move.Card_ids.IndexOf(id);
                                move.From_places.RemoveAt(i);
                                move.Open.RemoveAt(i);
                                move.From_pile_names.RemoveAt(i);
                                move.Card_ids.Remove(id);
                                data = move;
                                break;
                            }
                        }
                    }
                }
                break;
            }

            case TriggerEvent.Death:
            {
                OnDeath(room, player, ref data);
                break;
            }

            case TriggerEvent.CardsMoveOneTime:
            {
                if (data is CardsMoveOneTimeStruct move)
                {
                    if (move.From != null && move.From_places.Contains(Place.PlaceEquip))
                    {
                        foreach (int id in move.Card_ids)
                        {
                            WrappedCard card = room.GetCard(id);
                            if (card.Name == JadeSeal.ClassName)
                            {
                                CheckBigKingdoms(room);
                                break;
                            }
                        }
                    }

                    if (move.To != null && move.To_place == Place.PlaceEquip)
                    {
                        foreach (int id in move.Card_ids)
                        {
                            WrappedCard card = room.GetCard(id);
                            if (card.Name == JadeSeal.ClassName)
                            {
                                CheckBigKingdoms(room);
                                break;
                            }
                        }
                    }
                }

                break;
            }

            default:
                break;
            }

            return(false);
        }
Beispiel #13
0
        public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
        {
            List <int> slashes = new List <int>();
            Room       room    = ai.Room;

            foreach (int id in player.GetCards("h"))
            {
                WrappedCard wrapped = room.GetCard(id);
                if (wrapped.Name.Contains(Slash.ClassName))
                {
                    slashes.Add(id);
                }
            }

            if (slashes.Count > 0)
            {
                List <Player> friends = ai.FriendNoSelf;
                room.SortByActionOrder(ref friends);
                foreach (int id in slashes)
                {
                    WrappedCard slash = room.GetCard(id);
                    if (WrappedCard.IsRed(slash.Suit) && slash.Name != Slash.ClassName)
                    {
                        foreach (Player p in friends)
                        {
                            if (p.IsWounded() && !ai.HasSkill("zishu", p) && !ai.WillSkipPlayPhase(player))
                            {
                                card.AddSubCard(id);

                                use.Card = card;
                                use.To.Add(p);
                                return;
                            }
                        }
                    }
                }

                foreach (int id in slashes)
                {
                    WrappedCard slash = room.GetCard(id);
                    if (!WrappedCard.IsRed(slash.Suit) && slash.Name != Slash.ClassName)
                    {
                        foreach (Player p in friends)
                        {
                            if (!ai.HasSkill("zishu", p) && !ai.WillSkipPlayPhase(player))
                            {
                                card.AddSubCard(id);
                                use.Card = card;
                                use.To.Add(p);
                                return;
                            }
                        }
                    }
                }

                foreach (int id in slashes)
                {
                    WrappedCard slash = room.GetCard(id);
                    if (WrappedCard.IsRed(slash.Suit))
                    {
                        foreach (Player p in friends)
                        {
                            if (p.IsWounded() && !ai.HasSkill("zishu", p))
                            {
                                card.AddSubCard(id);
                                use.Card = card;
                                use.To.Add(p);
                                return;
                            }
                        }
                    }
                }

                ai.SortByUseValue(ref slashes, false);
                {
                    foreach (Player p in friends)
                    {
                        if (!ai.HasSkill("zishu", p) && !ai.WillSkipPlayPhase(player))
                        {
                            card.AddSubCard(slashes[0]);

                            use.Card = card;
                            use.To.Add(p);
                            return;
                        }
                    }
                }
            }
        }
Beispiel #14
0
        public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player)
        {
            if (!player.HasUsed(WendaoCard.ClassName) && !player.IsNude())
            {
                Room room = ai.Room;
                int  pp   = -1;
                foreach (int id in room.DiscardPile)
                {
                    WrappedCard card = room.GetCard(id);
                    if (card.Name == PeaceSpell.ClassName)
                    {
                        pp = id;
                        break;
                    }
                }
                if (pp == -1)
                {
                    foreach (Player p in room.GetAlivePlayers())
                    {
                        foreach (int id in p.GetEquips())
                        {
                            WrappedCard card = room.GetCard(id);
                            if (card.Name == PeaceSpell.ClassName)
                            {
                                pp = id;
                                break;
                            }
                        }
                        if (pp != -1)
                        {
                            break;
                        }
                    }
                }

                if (pp > -1)
                {
                    WrappedCard wd = new WrappedCard(WendaoCard.ClassName)
                    {
                        ShowSkill = Name,
                        Skill     = Name
                    };
                    List <int> ids = player.GetCards("he");
                    ai.SortByKeepValue(ref ids, false);
                    foreach (int id in ids)
                    {
                        WrappedCard card = room.GetCard(id);
                        if (WrappedCard.IsRed(card.Suit) && card.Name != PeaceSpell.ClassName && ai.GetKeepValue(id, player) < 0)
                        {
                            wd.AddSubCard(id);
                            return(new List <WrappedCard> {
                                wd
                            });
                        }
                    }

                    ai.SortByUseValue(ref ids, false);
                    foreach (int id in ids)
                    {
                        WrappedCard card = room.GetCard(id);
                        if (WrappedCard.IsRed(card.Suit) && card.Name != PeaceSpell.ClassName)
                        {
                            wd.AddSubCard(id);
                            return(new List <WrappedCard> {
                                wd
                            });
                        }
                    }
                }
            }

            return(new List <WrappedCard>());
        }
        public override List <WrappedCard> GetTurnUse(TrustedAI ai, Player player)
        {
            Room room = ai.Room;

            ai.Target[Name] = null;
            if (player.HasUsed(ClassicWoodenOxCard.ClassName) || player.IsKongcheng() || player.GetPile("wooden_ox").Count >= 5)
            {
                return(null);
            }
            List <int> cards = player.GetCards("h");

            int sub = -1;

            foreach (int id in cards)
            {
                WrappedCard card = room.GetCard(id);
                if (card.Name == DragonPhoenix.ClassName)
                {
                    Player target = null;
                    foreach (Player p in room.GetOtherPlayers(player))
                    {
                        if (ai.HasSkill("zhangwu", p))
                        {
                            target = p;
                            break;
                        }
                    }

                    if (target != null && !ai.IsFriend(target, player) || !ai.HasSkill(TrustedAI.LoseEquipSkill, player))
                    {
                        sub = id;
                        break;
                    }
                }
                else if (card.Name == PeaceSpell.ClassName)
                {
                    Player target = null;
                    foreach (Player p in room.GetOtherPlayers(player))
                    {
                        if (ai.HasSkill("wendao", p))
                        {
                            target = p;
                            break;
                        }
                    }

                    if (target != null && !ai.IsFriend(target, player))
                    {
                        sub = id;
                        break;
                    }
                }
                else if (card.Name == LuminouSpearl.ClassName)
                {
                    Player target = null;
                    foreach (Player p in room.GetOtherPlayers(player))
                    {
                        if (ai.HasSkill("jubao", p))
                        {
                            target = p;
                            break;
                        }
                    }

                    if (target != null && !ai.IsFriend(target, player))
                    {
                        sub = id;
                        break;
                    }
                }
            }

            ai.SortByUseValue(ref cards);
            bool keep = false;

            if (ai.HasSkill("jijiu"))
            {
                foreach (Player p in ai.GetFriends(player))
                {
                    if (ai.IsWeak(p))
                    {
                        keep = true;
                        break;
                    }
                }
            }

            if (!keep)
            {
                List <Player> targets = new List <Player>();
                foreach (Player p in ai.FriendNoSelf)
                {
                    if (RoomLogic.CanPutEquip(p, room.GetCard(player.Treasure.Key)) && ai.GetSameEquip(room.GetCard(player.Treasure.Key), p) == null)
                    {
                        targets.Add(p);
                    }
                }

                Player next = null;
                room.SortByActionOrder(ref targets);
                foreach (Player p in targets)
                {
                    if (!ai.WillSkipPlayPhase(p))
                    {
                        next = p;
                        break;
                    }
                }
                if (next != null)
                {
                    if (sub != -1)
                    {
                        ai.Target[Name] = next;
                        WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(sub);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                    else
                    {
                        KeyValuePair <Player, int> result = ai.GetCardNeedPlayer(cards, new List <Player> {
                            next
                        });
                        if (result.Key != null)
                        {
                            ai.Target[Name] = next;
                            WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                            {
                                Skill = Name
                            };
                            card.AddSubCard(result.Value);
                            return(new List <WrappedCard> {
                                card
                            });
                        }
                    }
                }
                else if (ai.HasSkill(TrustedAI.LoseEquipSkill) && targets.Count > 0)
                {
                    if (sub != -1)
                    {
                        ai.Target[Name] = targets[0];
                        WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(sub);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                    else
                    {
                        ai.Target[Name] = targets[0];
                        ai.SortByUseValue(ref cards, false);
                        WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(cards[0]);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                }
                else if (targets.Count > 0)
                {
                    List <Player> weaks = new List <Player>();
                    foreach (Player p in targets)
                    {
                        if (ai.IsWeak(p))
                        {
                            weaks.Add(p);
                        }
                    }

                    if (sub != -1 && weaks.Count > 0)
                    {
                        ai.SortByDefense(ref weaks, false);
                        ai.Target[Name] = weaks[0]; WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(sub);
                        return(new List <WrappedCard> {
                            card
                        });
                    }

                    KeyValuePair <Player, int> result = ai.GetCardNeedPlayer(cards, weaks);
                    if (result.Key != null)
                    {
                        ai.Target[Name] = result.Key;
                        WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                        {
                            Skill = Name
                        };
                        card.AddSubCard(result.Value);
                        return(new List <WrappedCard> {
                            card
                        });
                    }
                }
            }

            if (ai.GetOverflow(player) > 0)
            {
                WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                {
                    Skill = Name
                };
                if (sub != -1)
                {
                    card.AddSubCard(sub);
                }
                else
                {
                    ai.SortByKeepValue(ref cards, false);
                    card.AddSubCard(cards[ai.GetOverflow(player) - 1]);
                }
                return(new List <WrappedCard> {
                    card
                });
            }

            if (player.HandcardNum == 1 && ai.HasSkill("kongcheng|kongcheng_jx"))
            {
                WrappedCard card = new WrappedCard(ClassicWoodenOxCard.ClassName)
                {
                    Skill = Name
                };
                card.AddSubCards(player.GetCards("h"));
                return(new List <WrappedCard> {
                    card
                });
            }

            return(null);
        }
Beispiel #16
0
        public override CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data)
        {
            CardUseStruct result = new CardUseStruct
            {
                From = player,
                To   = new List <Player>()
            };
            Room room = ai.Room;
            int  sub  = -1;

            foreach (int id in player.GetPile("sorcery"))
            {
                WrappedCard card = room.GetCard(id);
                if (card.Suit == WrappedCard.CardSuit.Club || card.Suit == WrappedCard.CardSuit.Spade)
                {
                    sub = id;
                    break;
                }
            }
            if (sub == -1)
            {
                sub = player.GetPile("sorcery")[0];
            }
            WrappedCard qianhuan = new WrappedCard("QianhuanCard")
            {
                Mute  = true,
                Skill = Name
            };

            qianhuan.AddSubCard(sub);

            if (room.ContainsTag("qianhuan_data") && room.GetTag("qianhuan_data") is CardUseStruct use)
            {
                if (ai.IsCancelTarget(use.Card, use.To[0], use.From) || !ai.IsCardEffect(use.Card, use.To[0], use.From))
                {
                    return(result);
                }

                if (use.Card.Name == SupplyShortage.ClassName || use.Card.Name == Indulgence.ClassName || use.Card.Name == Snatch.ClassName)
                {
                    if (use.From != null && ai.IsEnemy(use.From))
                    {
                        result.Card = qianhuan;
                        return(result);
                    }
                }
                else if (use.Card.Name == BurningCamps.ClassName)
                {
                    DamageStruct damage = new DamageStruct(use.Card, use.From, use.To[0], 1, DamageStruct.DamageNature.Fire);
                    if (player.GetPile("sorcery").Count >= 3 && ai.GetDamageScore(damage).Score < 0 || ai.GetDamageScore(damage).Score < -5)
                    {
                        result.Card = qianhuan;
                        return(result);
                    }
                }
                else if (use.Card.Name.Contains(Slash.ClassName))
                {
                    DamageStruct damage = new DamageStruct(use.Card, use.From, use.To[0], 1 + use.Drank);
                    if (use.Card.Name == FireSlash.ClassName)
                    {
                        damage.Nature = DamageStruct.DamageNature.Fire;
                    }
                    else if (use.Card.Name == ThunderSlash.ClassName)
                    {
                        damage.Nature = DamageStruct.DamageNature.Thunder;
                    }
                    double value = ai.GetDamageScore(damage).Score;
                    if (value < -5 || (ai.IsWeak(use.To[0]) && value < 0) || (value < 0 && player.GetPile("sorcery").Count >= 3))
                    {
                        result.Card = qianhuan;
                        return(result);
                    }
                }
                else if (use.Card.Name == ArcheryAttack.ClassName)
                {
                    DamageStruct damage = new DamageStruct(use.Card, use.From, use.To[0]);
                    double       value  = ai.GetDamageScore(damage).Score;
                    if ((value < -5 || (ai.IsWeak(use.To[0]) && value < 0)) && player != use.To[0] ? ai.IsLackCard(use.To[0], Jink.ClassName) : ai.GetKnownCardsNums(Jink.ClassName, "he", use.To[0]) == 0)
                    {
                        result.Card = qianhuan;
                        return(result);
                    }
                }
                else if (use.Card.Name == SavageAssault.ClassName)
                {
                    Player       menghuo = ai.FindPlayerBySkill("huoshou");
                    DamageStruct damage  = new DamageStruct(use.Card, menghuo ?? use.From, use.To[0]);
                    double       value   = ai.GetDamageScore(damage).Score;
                    if ((value < -5 || (ai.IsWeak(use.To[0]) && value < 0)) && (player != use.To[0] ? ai.IsLackCard(use.To[0], Slash.ClassName)
                        : ai.GetKnownCardsNums(Slash.ClassName, "he", use.To[0]) == 0 || RoomLogic.IsHandCardLimited(room, use.To[0], HandlingMethod.MethodResponse)))
                    {
                        result.Card = qianhuan;
                        return(result);
                    }
                }
                else if (use.Card.Name == Duel.ClassName)
                {
                    DamageStruct damage = new DamageStruct(use.Card, use.From, use.To[0]);
                    double       value  = ai.GetDamageScore(damage).Score;
                    if (value < -5 || ((ai.IsWeak(use.To[0]) || player.GetPile("sorcery").Count >= 3) && value < 0))
                    {
                        result.Card = qianhuan;
                        return(result);
                    }
                }
            }

            return(result);
        }