Exemplo n.º 1
0
        public override List <int> OnDiscard(TrustedAI ai, Player player, List <int> cards, int min, int max, bool option)
        {
            if (!ai.WillShowForAttack())
            {
                return(new List <int>());
            }

            Room       room   = ai.Room;
            Player     target = room.Current;
            List <int> ids    = new List <int>();

            foreach (int id in player.HandCards)
            {
                if (RoomLogic.CanDiscard(room, player, player, id))
                {
                    ids.Add(id);
                }
            }
            ai.SortByKeepValue(ref ids, false);
            double value = ai.GetKeepValue(ids[0], player);

            if (ai.GetOverflow(player) > 1)
            {
                value /= 3;
            }
            DamageStruct damage = new DamageStruct(Name, player, target);

            if (ai.IsFriend(target))
            {
                bool range = false;
                foreach (Player p in room.GetOtherPlayers(target))
                {
                    if (ai.GetPrioEnemies().Contains(p) && RoomLogic.InMyAttackRange(room, target, p))
                    {
                        range = true;
                        break;
                    }
                }

                if (range && target.HandcardNum + target.GetPile("wooden_ox").Count > 3)
                {
                    if (ai.GetDamageScore(damage).Score < -3 && ai.HasSkill("wushuang|jianchu", target) && value < 3)
                    {
                        return new List <int> {
                                   ids[0]
                        }
                    }
                    ;
                }
            }
            else
            {
                if (ai.GetDamageScore(damage).Score > 7 && value < 7)
                {
                    return new List <int> {
                               ids[0]
                    }
                }
                ;
                else if (ai.GetDamageScore(damage).Score > 4 && value < 3)
                {
                    if (ai.IsLackCard(target, Slash.ClassName) || target.HandcardNum + target.GetPile("wooden_ox").Count < 3)
                    {
                        return(new List <int> {
                            ids[0]
                        });
                    }
                    else
                    {
                        bool range = false;
                        foreach (Player p in room.GetOtherPlayers(target))
                        {
                            if (ai.IsFriend(p) && RoomLogic.InMyAttackRange(room, target, p))
                            {
                                range = true;
                                break;
                            }
                        }

                        if (!range)
                        {
                            return new List <int> {
                                       ids[0]
                            }
                        }
                        ;
                    }
                }
            }

            return(new List <int>());
        }
    }
Exemplo n.º 2
0
        private static void OnUseCard(Room room, Player player, object data)
        {
            if (data is CardUseStruct use)
            {
                if (use.Card.Name == Analeptic.ClassName &&
                    (use.Reason == CardUseStruct.CardUseReason.CARD_USE_REASON_PLAY || room.GetRoomState().GetCurrentCardUsePattern(player) == "@@rende") &&
                    use.Card.Skill != "_zhendu")
                {
                    List <Client> ais = new List <Client>();
                    foreach (Player p in room.GetAlivePlayers())
                    {
                        Client client = room.GetClient(p);
                        if (p.ClientId < 0 && !ais.Contains(client) && RoomLogic.InMyAttackRange(room, player, p) && !RoomLogic.IsFriendWith(room, player, p) &&
                            room.GetClient(player) != client && Shuffle.random(1, 3))
                        {
                            ais.Add(client);
                        }
                    }

                    if (ais.Count == 0)
                    {
                        return;
                    }
                    foreach (Client client in ais)
                    {
                        bool speak = Shuffle.random(1, 2);
                        if (room.Setting.SpeakForbidden)
                        {
                            speak = false;
                        }

                        DataRow row = Engine.GetLines(client.Profile.NickName);
                        if (speak)
                        {
                            string message = row["other_drunk1"].ToString();
                            if (!string.IsNullOrEmpty(message))
                            {
                                message = message.Replace("%1", player.SceenName);
                                room.Speak(client, message);
                            }
                        }
                        else
                        {
                            string messages = row["other_drunk2"].ToString();
                            if (!string.IsNullOrEmpty(messages))
                            {
                                string[] ms = messages.Split('/');
                                room.Emotion(client, ms[0], ms[1]);
                            }
                        }
                    }
                }
                else if (player.ClientId < 0 && use.Card.Name.Contains(Slash.ClassName) &&
                         (use.Reason == CardUseStruct.CardUseReason.CARD_USE_REASON_PLAY || room.GetRoomState().GetCurrentCardUsePattern(player) == "@@rende") &&
                         use.To.Count == 1 && !RoomLogic.IsFriendWith(room, player, use.To[0]) && Shuffle.random(1, 3))
                {
                    Client client = room.GetClient(player);

                    bool speak = Shuffle.random(1, 2);
                    if (room.Setting.SpeakForbidden)
                    {
                        speak = false;
                    }

                    DataRow row = Engine.GetLines(client.Profile.NickName);
                    if (speak)
                    {
                        string message = row["slash_use1"].ToString();
                        if (!string.IsNullOrEmpty(message))
                        {
                            message = message.Replace("%1", use.To[0].SceenName);
                            room.Speak(client, message);
                        }
                    }
                    else
                    {
                        string messages = row["slash_use2"].ToString();
                        if (!string.IsNullOrEmpty(messages))
                        {
                            string[] ms = messages.Split('/');
                            room.Emotion(client, ms[0], ms[1]);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
        {
            Room room = ai.Room;
            List <ScoreStruct> scores = new List <ScoreStruct>();

            foreach (Player p in room.GetOtherPlayers(player))
            {
                if (!RoomLogic.InMyAttackRange(room, p, player) || p.IsNude())
                {
                    continue;
                }
                ScoreStruct score = ai.FindCards2Discard(player, p, "he", HandlingMethod.MethodDiscard);
                score.Players = new List <Player> {
                    p
                };
                if (ai.IsEnemy(p))
                {
                    if (p.HandcardNum + p.GetPile("wooden_ox").Count < 3 || ai.IsLackCard(p, Slash.ClassName))
                    {
                        score.Score += 3;
                    }
                    else
                    {
                        bool armor_ignore = false;
                        if (p.HasWeapon(QinggangSword.ClassName) || ai.HasSkill("jianchu", p))
                        {
                            armor_ignore = true;
                        }
                        else if (ai.HasSkill("paoxiao|paoxiao_fz", p))
                        {
                            Player lord = ai.FindPlayerBySkill("shouyue");
                            if (lord != null && RoomLogic.PlayerHasShownSkill(room, lord, "shouyue") && RoomLogic.WillBeFriendWith(room, p, lord))
                            {
                                armor_ignore = true;
                            }
                        }

                        if (!armor_ignore && ai.HasArmorEffect(player, RenwangShield.ClassName))
                        {
                            score.Score += 0.5;
                        }
                        if (!armor_ignore && ai.HasArmorEffect(player, EightDiagram.ClassName))
                        {
                            score.Score += 0.5;
                        }
                        if (ai.HasSkill("wushang", p))
                        {
                            score.Score -= 0.5;
                        }
                        if (p.HasWeapon(DragonPhoenix.ClassName))
                        {
                            score.Score -= 0.5;
                        }
                        if (ai.HasSkill("jianchu", p))
                        {
                            score.Score = -0.5;
                        }
                        if (ai.HasSkill("tieqi|tieqi_fz", p))
                        {
                            score.Score = 1;
                        }
                        if (ai.GetKnownCardsNums(Jink.ClassName, "he", player) == 0)
                        {
                            score.Score -= 2;
                        }
                    }
                }
                scores.Add(score);
            }

            if (scores.Count > 0)
            {
                ai.CompareByScore(ref scores);
                if (scores[0].Score > 2)
                {
                    use.Card = card;
                    use.To   = new List <Player>(scores[0].Players);
                }
            }
        }