Exemplo n.º 1
0
        public override bool OnSkillInvoke(TrustedAI ai, Player player, object data)
        {
            double value = 0;
            Room   room  = ai.Room;

            foreach (Player p in room.GetAlivePlayers())
            {
                if (p.Chained && RoomLogic.CanDiscard(room, player, p, "he"))
                {
                    if (p == player)
                    {
                        List <int> ids = new List <int>();
                        foreach (int id in player.GetCards("he"))
                        {
                            if (RoomLogic.CanDiscard(room, player, player, id))
                            {
                                ids.Add(id);
                            }
                        }

                        ai.SortByKeepValue(ref ids, false);
                        value += ai.GetKeepValue(ids[0], player);
                    }
                    else
                    {
                        value += ai.FindCards2Discard(player, p, string.Empty, "he", HandlingMethod.MethodDiscard).Score;
                    }
                }
            }

            return(value > 3);
        }
Exemplo n.º 2
0
        public override List <TriggerStruct> Triggerable(TriggerEvent triggerEvent, Room room, Player player, ref object data)
        {
            List <TriggerStruct> triggers = new List <TriggerStruct>();

            if (triggerEvent == TriggerEvent.EventPhaseStart && player.Phase == PlayerPhase.Finish)
            {
                List <Player> hx = RoomLogic.FindPlayersBySkillName(room, Name);
                foreach (Player p in hx)
                {
                    if (p.HandcardNum < p.Hp)
                    {
                        triggers.Add(new TriggerStruct(Name, p));
                    }
                }
            }
            else if (triggerEvent == TriggerEvent.Damaged && player.Alive)
            {
                List <Player> hx = RoomLogic.FindPlayersBySkillName(room, Name);
                foreach (Player p in hx)
                {
                    if (p != player && p.Camp == player.Camp && !player.IsNude() && RoomLogic.CanDiscard(room, p, p, "he"))
                    {
                        triggers.Add(new TriggerStruct(Name, p));
                    }
                }
            }

            return(triggers);
        }
Exemplo n.º 3
0
        public override TriggerStruct Triggerable(TriggerEvent triggerEvent, Room room, Player player, ref object data, Player ask_who)
        {
            if (triggerEvent == TriggerEvent.TargetChosen && data is CardUseStruct use)
            {
                FunctionCard fcard = use.Card != null?Engine.GetFunctionCard(use.Card.Name) : null;

                if (base.Triggerable(player, room) && use.Card != null && fcard is Slash)
                {
                    List <Player> targets = new List <Player>();
                    foreach (Player to in use.To)
                    {
                        if (RoomLogic.CanDiscard(room, to, to, "he"))
                        {
                            targets.Add(to);
                        }
                    }
                    if (targets.Count > 0)
                    {
                        return(new TriggerStruct(Name, player, targets));
                    }
                }
            }
            else if (triggerEvent == TriggerEvent.Dying && data is DyingStruct dying && dying.Damage.Card != null && dying.Damage.Card.Name.Contains(Slash.ClassName) &&
                     !dying.Damage.Transfer && !dying.Damage.Chain &&
                     dying.Damage.From != null && dying.Damage.From.Alive && base.Triggerable(dying.Damage.From, room) && !player.IsKongcheng())
            {
                if (RoomLogic.CanGetCard(room, dying.Damage.From, player, "h"))
                {
                    return(new TriggerStruct(Name, dying.Damage.From));
                }
            }

            return(new TriggerStruct());
        }
Exemplo n.º 4
0
        public override CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data)
        {
            CardUseStruct use         = new CardUseStruct(null, player, new List <Player>());
            string        target_name = prompt.Split(':')[1];
            Room          room        = ai.Room;
            Player        target      = room.FindPlayer(target_name);

            if (target != null)
            {
                if (ai.IsFriend(target))
                {
                    foreach (int id in player.GetEquips())
                    {
                        if (ai.GetKeepValue(id, player) < 0 && RoomLogic.CanDiscard(room, target, player, id))
                        {
                            return(use);
                        }
                    }

                    //System.Diagnostics.Debug.Assert(room.GetAI(target) == null, "ai挑衅目标错误");
                }

                List <ScoreStruct> scores = ai.CaculateSlashIncome(player, null, new List <Player> {
                    target
                });

                if (scores.Count > 0 && scores[0].Score > -2 && scores[0].Card != null)
                {
                    use.Card = scores[0].Card;
                    use.To.Add(target);
                }
            }

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

            foreach (int id in player.GetEquips())
            {
                if (RoomLogic.CanDiscard(room, player, player, id))
                {
                    ids.Add(id);
                }
            }

            ai.SortByKeepValue(ref ids, false);
            use.Card = room.GetCard(ids[0]);
            return(use);
        }
Exemplo n.º 6
0
        public override List <int> OnExchange(TrustedAI ai, Player player, string pattern, int min, int max, string pile)
        {
            List <int> ids  = new List <int>();
            Room       room = ai.Room;

            foreach (int id in player.GetCards("he"))
            {
                if (RoomLogic.CanDiscard(room, player, player, id))
                {
                    ids.Add(id);
                }
            }

            ai.SortByKeepValue(ref ids, false);
            return(new List <int> {
                ids[0]
            });
        }
        public override List <int> OnExchange(TrustedAI ai, Player player, string pattern, int min, int max, string pile)
        {
            Room room = ai.Room;

            if (room.GetTag(Name) is DamageStruct damage)
            {
                ScoreStruct score = ai.GetDamageScore(damage);
                damage.Damage++;
                ScoreStruct _score = ai.GetDamageScore(damage);
                if (_score.Score - score.Score > 3)
                {
                    List <int> ids = new List <int>();
                    foreach (int id in player.GetCards("h"))
                    {
                        if (!RoomLogic.CanDiscard(room, player, player, id))
                        {
                            continue;
                        }
                        WrappedCard  card  = room.GetCard(id);
                        FunctionCard fcard = Engine.GetFunctionCard(card.Name);
                        if (fcard is Slash || fcard is Weapon)
                        {
                            ids.Add(id);
                        }
                    }

                    if (ids.Count > 0)
                    {
                        ai.SortByUseValue(ref ids, false);
                        return(new List <int> {
                            ids[0]
                        });
                    }
                }
            }

            return(new List <int>());
        }
Exemplo n.º 8
0
 public override bool IsEnabledAtPlay(Room room, Player player)
 {
     return(RoomLogic.CanDiscard(room, player, player, "he") && !player.HasUsed("ZhihengCard") &&
            !RoomLogic.PlayerHasShownSkill(room, player, "zhiheng"));
 }
Exemplo n.º 9
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>());
        }
    }