예제 #1
0
        public override void OnUse(Room room, CardUseStruct card_use)
        {
            Player        source  = card_use.From;
            List <Player> targets = new List <Player>();

            if (card_use.To.Count == 0)
            {
                List <Player> all_players = room.GetOtherPlayers(card_use.From);
                foreach (Player player in all_players)
                {
                    Skill skill = RoomLogic.IsProhibited(room, source, player, card_use.Card);
                    if (skill != null)
                    {
                        skill = Engine.GetMainSkill(skill.Name);
                        LogMessage log = new LogMessage
                        {
                            Type = "#SkillAvoid",
                            From = player.Name,
                            Arg  = skill.Name,
                            Arg2 = Name
                        };
                        room.SendLog(log);
                        if (RoomLogic.PlayerHasShownSkill(room, player, skill))
                        {
                            room.NotifySkillInvoked(player, skill.Name);
                            GeneralSkin gsk        = RoomLogic.GetGeneralSkin(room, player, skill.Name);
                            string      genral     = gsk.General;
                            int         skin_id    = gsk.SkinId;
                            string      skill_name = skill.Name;
                            int         audio      = -1;
                            skill.GetEffectIndex(room, player, card_use.Card, ref audio, ref skill_name, ref genral, ref skin_id);
                            if (audio >= -1)
                            {
                                room.BroadcastSkillInvoke(skill_name, "male", audio, genral, skin_id);
                            }
                        }
                        else
                        {
                            int    audio      = -1;
                            string skill_name = skill.Name;
                            string genral     = string.Empty;
                            int    skin_id    = 0;
                            skill.GetEffectIndex(room, null, card_use.Card, ref audio, ref skill_name, ref genral, ref skin_id);
                        }
                    }
                    else
                    {
                        targets.Add(player);
                    }
                }
            }
            else
            {
                targets = card_use.To;
            }

            card_use.To = targets;

            base.OnUse(room, card_use);
        }
예제 #2
0
 public override bool IsAvailable(Room room, Player player, WrappedCard card)
 {
     if (room.GetCardPlace(card.Id) == Place.PlaceEquip)
     {
         return(false);
     }
     return(RoomLogic.IsProhibited(room, player, player, card) == null &&
            RoomLogic.CanPutEquip(player, card) && base.IsAvailable(room, player, card));
 }
예제 #3
0
        public override bool IsAvailable(Room room, Player player, WrappedCard card)
        {
            bool          canUse  = false;
            List <Player> players = room.GetOtherPlayers(player);

            foreach (Player p in players)
            {
                if (RoomLogic.IsProhibited(room, player, p, card) != null)
                {
                    continue;
                }

                canUse = true;
                break;
            }

            return(canUse && base.IsAvailable(room, player, card));
        }
예제 #4
0
        public override void OnUse(Room room, CardUseStruct card_use)
        {
            Player        source  = card_use.From;
            List <Player> targets = new List <Player>();

            if (card_use.To.Count == 0)
            {
                List <Player> all_players = room.GetOtherPlayers(card_use.From);
                foreach (Player player in all_players)
                {
                    Skill skill = RoomLogic.IsProhibited(room, source, player, card_use.Card);
                    if (skill != null)
                    {
                        skill = Engine.GetMainSkill(skill.Name);
                        LogMessage log = new LogMessage
                        {
                            Type = "#SkillAvoid",
                            From = player.Name,
                            Arg  = skill.Name,
                            Arg2 = Name
                        };
                        room.SendLog(log);
                        if (RoomLogic.PlayerHasShownSkill(room, player, skill))
                        {
                            room.BroadcastSkillInvoke(skill.Name, player);
                            room.NotifySkillInvoked(player, skill.Name);
                        }
                    }
                    else
                    {
                        targets.Add(player);
                    }
                }
            }
            else
            {
                targets = card_use.To;
            }

            card_use.To = targets;

            base.OnUse(room, card_use);
        }
예제 #5
0
        public override void OnNullified(Room room, Player target, WrappedCard card)
        {
            RoomThread thread = room.RoomThread;

            string card_str = RoomLogic.CardToString(room, card);
            bool   move     = false;
            Player p        = null;

            if (movable)
            {
                List <Player> players       = new List <Player>();
                List <Player> count_players = new List <Player>(room.Players);
                Player        starter       = target;
                int           index         = count_players.IndexOf(starter);
                for (int i = index + 1; i < count_players.Count; i++)
                {
                    if (count_players[i].Alive)
                    {
                        players.Add(count_players[i]);
                    }
                }

                for (int i = 0; i <= index; i++)
                {
                    if (count_players[i].Alive)
                    {
                        players.Add(count_players[i]);
                    }
                }

                foreach (Player player in players)
                {
                    if (RoomLogic.PlayerContainsTrick(room, player, Name))
                    {
                        continue;
                    }

                    Skill skill = RoomLogic.IsProhibited(room, null, player, card);
                    if (skill != null)
                    {
                        skill = Engine.GetMainSkill(skill.Name);
                        LogMessage log = new LogMessage
                        {
                            Type = "#SkillAvoid",
                            From = player.Name,
                            Arg  = skill.Name,
                            Arg2 = Name
                        };
                        room.SendLog(log);

                        room.BroadcastSkillInvoke(skill.Name, player);
                        continue;
                    }
                    if (player.HasFlag(card_str + "_delay_trick_cancel"))
                    {
                        continue;
                    }

                    CardUseStruct use  = new CardUseStruct(room.GetCard(card.GetEffectiveId()), null, player);
                    object        data = use;
                    thread.Trigger(TriggerEvent.TargetConfirming, room, player, ref data);
                    CardUseStruct new_use = (CardUseStruct)data;
                    if (new_use.To.Count == 0)
                    {
                        p = player;
                        player.SetFlags(card_str + "_delay_trick_cancel");
                        break;
                    }

                    CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_TRANSFER, string.Empty)
                    {
                        CardString = RoomLogic.CardToString(room, card)
                    };
                    room.MoveCardTo(card, null, player, Place.PlaceDelayedTrick, reason, true);
                    move = true;

                    foreach (Player p2 in room.GetAllPlayers())
                    {
                        thread.Trigger(TriggerEvent.TargetChosen, room, p2, ref data);
                    }
                    foreach (Player p2 in room.GetAllPlayers())
                    {
                        thread.Trigger(TriggerEvent.TargetConfirmed, room, p2, ref data);
                    }
                    break;
                }
            }

            if (p != null)
            {
                OnNullified(room, p, card);
            }
            else if (!move)
            {
                foreach (Player player in room.GetAllPlayers())
                {
                    if (player.HasFlag(RoomLogic.CardToString(room, card) + "_delay_trick_cancel"))
                    {
                        player.SetFlags(string.Format("-{0}{1}", card_str, "_delay_trick_cancel"));
                    }
                }

                CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_NATURAL_ENTER, string.Empty);
                room.MoveCardTo(card, null, Place.DiscardPile, reason, true);
            }
        }
예제 #6
0
        public override void OnNullified(Room room, Player target, WrappedCard card)
        {
            RoomThread thread = room.RoomThread;

            string card_str = RoomLogic.CardToString(room, card);
            bool   move     = false;
            Player p        = null;

            if (movable)
            {
                List <Player> players       = new List <Player>();
                List <Player> count_players = new List <Player>(room.Players);
                Player        starter       = target;
                int           index         = count_players.IndexOf(starter);
                for (int i = index + 1; i < count_players.Count; i++)
                {
                    if (count_players[i].Alive)
                    {
                        players.Add(count_players[i]);
                    }
                }

                for (int i = 0; i <= index; i++)
                {
                    if (count_players[i].Alive)
                    {
                        players.Add(count_players[i]);
                    }
                }

                foreach (Player player in players)
                {
                    if (RoomLogic.PlayerContainsTrick(room, player, Name) || !player.JudgingAreaAvailable)
                    {
                        continue;
                    }

                    Skill skill = RoomLogic.IsProhibited(room, null, player, card);
                    if (skill != null)
                    {
                        skill = Engine.GetMainSkill(skill.Name);
                        LogMessage log = new LogMessage
                        {
                            Type = "#SkillAvoid",
                            From = player.Name,
                            Arg  = skill.Name,
                            Arg2 = Name
                        };
                        room.SendLog(log);
                        if (RoomLogic.PlayerHasShownSkill(room, player, skill))
                        {
                            room.NotifySkillInvoked(player, skill.Name);
                            GeneralSkin gsk        = RoomLogic.GetGeneralSkin(room, player, skill.Name);
                            string      genral     = gsk.General;
                            int         skin_id    = gsk.SkinId;
                            string      skill_name = skill.Name;
                            int         audio      = -1;
                            skill.GetEffectIndex(room, player, card, ref audio, ref skill_name, ref genral, ref skin_id);
                            if (audio >= -1)
                            {
                                room.BroadcastSkillInvoke(skill_name, "male", audio, genral, skin_id);
                            }
                        }
                        continue;
                    }
                    //if (player.HasFlag(card_str + "_delay_trick_cancel")) continue;

                    /*
                     * CardUseStruct use = new CardUseStruct(room.GetCard(card.GetEffectiveId()), null, player)
                     * {
                     *  EffectCount = new List<CardBasicEffect> { FillCardBasicEffct(room, player) }
                     * };
                     * object data = use;
                     * thread.Trigger(TriggerEvent.TargetConfirming, room, player, ref data);
                     * CardUseStruct new_use = (CardUseStruct)data;
                     * if (new_use.To.Count == 0)
                     * {
                     *  p = player;
                     *  player.SetFlags(card_str + "_delay_trick_cancel");
                     *  break;
                     * }
                     *
                     * thread.Trigger(TriggerEvent.TargetChosen, room, null, ref data);
                     * thread.Trigger(TriggerEvent.TargetConfirmed, room, player, ref data);
                     */
                    CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_TRANSFER, string.Empty)
                    {
                        Card = card
                    };
                    room.MoveCardTo(card, null, player, Place.PlaceDelayedTrick, reason, true);
                    move = true;

                    break;
                }
            }

            if (p != null)
            {
                OnNullified(room, p, card);
            }
            else if (!move)
            {
                //foreach (Player player in room.GetAllPlayers())
                //if (player.HasFlag(RoomLogic.CardToString(room, card) + "_delay_trick_cancel"))
                //player.SetFlags(string.Format("-{0}{1}", card_str, "_delay_trick_cancel"));

                CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_NATURAL_ENTER, string.Empty);
                room.MoveCardTo(card, null, Place.DiscardPile, reason, true);
            }
        }
예제 #7
0
        public override bool OnSkillInvoke(TrustedAI ai, Player player, object data)
        {
            Room room  = ai.Room;
            int  count = 0;
            List <WrappedCard> analeptics = ai.GetCards(Analeptic.ClassName, player, true);

            analeptics.AddRange(ai.GetCards(Peach.ClassName, player, true));
            foreach (WrappedCard card in analeptics)
            {
                if (!RoomLogic.IsCardLimited(room, player, card, HandlingMethod.MethodUse) && RoomLogic.IsProhibited(room, player, player, card) == null)
                {
                    count++;
                }
            }

            if (count >= 1 - player.Hp)
            {
                return(false);
            }

            return(true);
        }