public override double UsePriorityAdjust(TrustedAI ai, Player player, List <Player> targets, WrappedCard card)
        {
            if (ai.HasSkill(TrustedAI.LoseEquipSkill, player) && ai.GetFriends(player).Count > 1)
            {
                return(6);
            }

            if (player.GetMark("@luan") > 0 && ai.GetFriends(player).Count > 1)
            {
                return(6);
            }

            return(2);
        }
Exemplo n.º 2
0
        public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
        {
            int  self_count = 0, enemies = 0;
            Room room = ai.Room;

            foreach (Player p in ai.GetFriends(player))
            {
                if (p.Chained && GDFighttogether.Instance.TargetFilter(room, new List <Player>(), p, player, card))
                {
                    self_count++;
                }
            }

            List <Player> _enemies = ai.GetEnemies(player);
            bool          vine     = false;

            foreach (Player p in room.GetAlivePlayers())
            {
                if (p.HasArmor(Vine.ClassName) && (p.Chained || _enemies.Contains(p)) && !ai.HasSkill("gangzhi", p))
                {
                    vine = true;
                    break;
                }
            }

            foreach (Player p in _enemies)
            {
                if (!p.Chained && GDFighttogether.Instance.TargetFilter(room, new List <Player>(), p, player, card))
                {
                    enemies++;
                    if (RoomLogic.PlayerHasSkill(room, p, "gangzhi"))
                    {
                        enemies++;
                    }
                }
            }

            if (enemies > 0 && vine)
            {
                enemies++;
            }

            use.Card = card;
            if (self_count < enemies && _enemies.Count > 1)
            {
                use.To.Add(ai.GetEnemies(player)[0]);
            }
            else if (self_count > 1)
            {
                use.To.Add(player);
            }

            if (use.To.Count == 0 && !GDFighttogether.Instance.CanRecast(room, player, card))
            {
                use.Card = null;
            }
        }
        public override double CardValue(TrustedAI ai, Player player, bool use, WrappedCard card, Player.Place place)
        {
            double value = ai.AjustWeaponRangeValue(player, card);

            foreach (Player p in ai.GetFriends(player))
            {
                if (ai.HasSkill("guidao|guicai_jx|zhenyi", p))
                {
                    value += 5;
                }
            }

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

            if (damage.To != null && ai.HasSkill(Name, damage.To))
            {
                int n = ai.DamageEffect(damage, DamageStruct.DamageStep.Done);
                if (n < damage.To.Hp || damage.To.Removed)
                {
                    score.Score = 4 * damage.Damage;
                }

                double numerator = 0.6;
                if (!ai.WillSkipPlayPhase(damage.To))
                {
                    numerator += 0.3;
                }
                foreach (Player p in ai.GetFriends(damage.To))
                {
                    if (p != damage.To && !ai.WillSkipPlayPhase(p))
                    {
                        numerator += 0.1;
                    }
                }
                score.Score *= numerator;

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

            return(score);
        }
Exemplo n.º 5
0
        public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
        {
            List <Player> targets = new List <Player>();
            Room          room    = ai.Room;

            List <Player> friends = ai.GetFriends(player);

            ai.SortByDefense(ref friends, false);
            foreach (Player p in friends)
            {
                if (HoardUp.Instance.TargetFilter(room, targets, p, player, card))
                {
                    targets.Add(p);
                }
            }

            if (targets.Count > 0)
            {
                use.Card = card;
                use.To   = targets;
            }
        }
Exemplo n.º 6
0
        public override List <Player> OnPlayerChosen(TrustedAI ai, Player player, List <Player> targets, int min, int max)
        {
            List <Player> players = ai.FriendNoSelf;

            if (players.Count > 0)
            {
                ai.SortByDefense(ref players, false);
                foreach (Player p in players)
                {
                    if (p.IsWounded())
                    {
                        return new List <Player> {
                                   p
                        }
                    }
                }
                ;

                players = ai.GetFriends(player);
                Room room = ai.Room;
                room.SortByActionOrder(ref players);
                foreach (Player p in players)
                {
                    if (p == room.Current || !p.FaceUp)
                    {
                        continue;
                    }
                    return(new List <Player> {
                        p
                    });
                }
            }
            return(new List <Player> {
                player
            });
        }
        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);
        }