예제 #1
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;
            }
        }
예제 #2
0
 public override TriggerStruct Cost(TriggerEvent triggerEvent, Room room, Player player, ref object data, Player ask_who, TriggerStruct inf)
 {
     if (RoomLogic.PlayerHasSkill(room, player, skill_name) && player.Alive && data is InfoStruct info)
     {
         if (!player.HasShownSkill(skill_name, info.Head) && room.AskForSkillInvoke(player, name, null, inf.SkillPosition))
         {
             room.ShowSkill(player, skill_name, inf.SkillPosition);
             return(new TriggerStruct());
         }
         else if (player.HasShownSkill(skill_name, info.Head))
         {
             return(new TriggerStruct());
         }
     }
     return(inf);
 }
예제 #3
0
        protected virtual void OnPreCardUsed(Room room, Player player, ref object data)
        {
            if (data is CardUseStruct card_use)
            {
                if (card_use.From.HasFlag("Global_ForbidSurrender"))
                {
                    card_use.From.SetFlags("-Global_ForbidSurrender");
                    room.DoNotify(room.GetClient(card_use.From), CommandType.S_COMMAND_ENABLE_SURRENDER, new List <string> {
                        true.ToString()
                    });
                }

                room.BroadcastSkillInvoke(card_use.From, card_use.Card);
                if (!string.IsNullOrEmpty(card_use.Card.Skill) && card_use.Card.GetSkillName() == card_use.Card.Skill &&
                    card_use.IsOwnerUse && RoomLogic.PlayerHasSkill(room, card_use.From, card_use.Card.Skill))
                {
                    room.NotifySkillInvoked(card_use.From, card_use.Card.Skill);
                }
            }
        }
예제 #4
0
        public virtual bool IsAvailable(Room room, Player invoker, CardUseReason reason, string pattern, string position = null)
        {
            bool huashen = false;

            if (invoker.ContainsTag("Huashens"))
            {
                //List<string> huashens = (List<string>)(invoker.GetTag("Huashens"));                 //for huashen
                //foreach (string general in huashens) {
                //    if (Engine.GetHuashenSkills(general).contains(Name))
                //    {
                //        huashen = true;
                //        break;
                //    }
                //}
            }

            if (!RoomLogic.PlayerHasSkill(room, invoker, Name) && !huashen)
            {
                return(false);
            }

            if (reason == CardUseReason.CARD_USE_REASON_RESPONSE_USE && pattern == Nullification.ClassName)
            {
                return(IsEnabledAtNullification(room, invoker));
            }

            switch (reason)
            {
            case CardUseReason.CARD_USE_REASON_PLAY:
                return(IsEnabledAtPlay(room, invoker));

            case CardUseReason.CARD_USE_REASON_RESPONSE:
            case CardUseReason.CARD_USE_REASON_RESPONSE_USE:
                return(IsEnabledAtResponse(room, invoker, pattern));

            default:
                return(false);
            }
        }
예제 #5
0
 public virtual bool Triggerable(Player target, Room room)
 {
     return(target != null && target.Alive && RoomLogic.PlayerHasSkill(room, target, Name));
 }
예제 #6
0
        public virtual void DoRecast(Room room, CardUseStruct use)
        {
            WrappedCard    card   = use.Card;
            CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_RECAST, use.From.Name)
            {
                SkillName = card.Skill
            };

            room.MoveCardTo(card, null, Place.PlaceTable, reason, true);
            if (!string.IsNullOrEmpty(reason.SkillName))
            {
                room.BroadcastSkillInvoke(use.From, use.Card);
            }
            else
            {
                room.BroadcastSkillInvoke("@recast", use.From.IsMale() ? "male" : "female", -1);
            }

            if (!string.IsNullOrEmpty(card.Skill) && !card.Skill.StartsWith("-") && use.IsOwnerUse && RoomLogic.PlayerHasSkill(room, use.From, card.Skill))
            {
                room.NotifySkillInvoked(use.From, card.Skill);
            }

            LogMessage log = new LogMessage("#Card_Recast")
            {
                From     = use.From.Name,
                Card_str = RoomLogic.CardToString(room, card)
            };

            room.SendLog(log);

            List <int> table_cardids = room.GetCardIdsOnTable(card);

            if (table_cardids.Count > 0)
            {
                CardsMoveStruct move = new CardsMoveStruct(table_cardids, use.From, null, Place.PlaceTable, Place.DiscardPile, reason);
                room.MoveCardsAtomic(new List <CardsMoveStruct>()
                {
                    move
                }, true);
            }

            room.DrawCards(use.From, 1, "recast");
        }