Exemplo n.º 1
0
        public override ScoreStruct GetDamageScore(TrustedAI ai, DamageStruct damage)
        {
            ScoreStruct score = new ScoreStruct
            {
                Score = 0
            };

            if (damage.To != null && ai.HasSkill(Name, damage.To) && damage.Card != null)
            {
                score.Score = 1.2;
                FunctionCard fcard = Engine.GetFunctionCard(damage.Card.Name);
                if (!(fcard is SkillCard))
                {
                    foreach (int id in damage.Card.SubCards)
                    {
                        double value = Math.Max(ai.GetUseValue(id, damage.To, Player.Place.PlaceHand), ai.GetKeepValue(id, damage.To, Player.Place.PlaceHand));
                        score.Score += value * 0.45;
                    }

                    if (ai.WillSkipPlayPhase(damage.To))
                    {
                        score.Score /= 3;
                    }

                    if (damage.Damage >= damage.To.Hp)
                    {
                        score.Score /= 2;
                    }

                    if (damage.From != null && damage.From == damage.To && score.Score > 0)
                    {
                        score.Score /= 4;
                    }
                }

                if (damage.Damage > 1)
                {
                    score.Score /= 1.5;
                }
                if (ai.WillSkipPlayPhase(damage.To))
                {
                    score.Score /= 1.5;
                }

                if (ai.IsEnemy(damage.To))
                {
                    score.Score = -score.Score;
                }
                else
                {
                    score.Score -= 1.5;
                }
            }

            return(score);
        }
Exemplo n.º 2
0
        public override List <int> OnExchange(TrustedAI ai, Player player, string pattern, int min, int max, string pile)
        {
            if (ai.WillShowForDefence())
            {
                Room room = ai.Room;
                //有君角在,不要用太平发动
                Player lord = RoomLogic.FindPlayerBySkillName(room, "wendao");

                List <int> ids = new List <int>();
                foreach (int id in player.HandCards)
                {
                    WrappedCard card = room.GetCard(id);
                    if (card.Name == PeaceSpell.ClassName && lord != null)
                    {
                        continue;
                    }
                    bool add = true;
                    foreach (int _id in player.GetPile("sorcery"))
                    {
                        if (room.GetCard(_id).Suit == card.Suit)
                        {
                            add = false;
                            break;
                        }
                    }
                    if (add)
                    {
                        ids.Add(id);
                    }
                }

                foreach (int id in player.GetEquips())
                {
                    WrappedCard card = room.GetCard(id);
                    if (card.Name == PeaceSpell.ClassName && lord != null)
                    {
                        continue;
                    }
                    bool add = true;
                    foreach (int _id in player.GetPile("sorcery"))
                    {
                        if (room.GetCard(_id).Suit == card.Suit)
                        {
                            add = false;
                            break;
                        }
                    }
                    if (add)
                    {
                        ids.Add(id);
                    }
                }

                if (ids.Count > 0)
                {
                    ai.SortByKeepValue(ref ids, false);
                    foreach (int id in ids)
                    {
                        double keep = ai.GetKeepValue(id, player);
                        double use  = ai.GetUseValue(id, player);
                        if (keep < 0 || (keep <= 5 && use <= 5))
                        {
                            return new List <int> {
                                       id
                            }
                        }
                        ;
                    }
                }
            }

            return(new List <int>());
        }
Exemplo n.º 3
0
        public override CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data)
        {
            CardUseStruct use = new CardUseStruct(null, player, new List <Player>());

            if (player.ContainsTag("ziliang_aidata") && player.GetTag("ziliang_aidata") is string player_name)
            {
                Room   room   = ai.Room;
                Player target = room.FindPlayer(player_name);
                if (target != null)
                {
                    double best_v = 0;
                    int    result = -1;
                    foreach (int id in player.GetPile("field"))
                    {
                        double value = Math.Max(ai.GetKeepValue(id, target, Player.Place.PlaceHand), ai.GetUseValue(id, target, Player.Place.PlaceHand));
                        if (value > best_v)
                        {
                            best_v = value;
                            result = id;
                        }

                        if (best_v > 2.5 && result >= 0)
                        {
                            use.Card = new WrappedCard("ZiliangCard")
                            {
                                Skill = Name, ShowSkill = Name
                            };
                            use.Card.AddSubCard(result);
                        }
                    }
                }
            }

            return(use);
        }