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);
        }
 public override bool Effect(TriggerEvent triggerEvent, Room room, Player player, ref object data, Player ask_who, TriggerStruct info)
 {
     if (triggerEvent == TriggerEvent.EventPhaseStart)
     {
         GeneralSkin gsk = RoomLogic.GetGeneralSkin(room, player, Name, info.SkillPosition);
         room.SendCompulsoryTriggerLog(ask_who, Name, true);
         room.BroadcastSkillInvoke(Name, "male", 1, gsk.General, gsk.SkinId);
         room.DrawCards(ask_who, 2, Name);
     }
     else
     {
         room.AskForDiscard(ask_who, Name, 1, 1, false, true, "@moqu", false, info.SkillPosition);
         GeneralSkin gsk = RoomLogic.GetGeneralSkin(room, player, Name, info.SkillPosition);
         room.BroadcastSkillInvoke(Name, "male", 2, gsk.General, gsk.SkinId);
         room.SendCompulsoryTriggerLog(ask_who, Name, true);
     }
     return(false);
 }
        public override void OnUse(Room room, CardUseStruct card_use)
        {
            GeneralSkin gsk = RoomLogic.GetGeneralSkin(room, card_use.From, "shefu", card_use.Card.SkillPosition);

            room.BroadcastSkillInvoke("shefu", "male", 1, gsk.General, gsk.SkinId);

            int    id        = card_use.Card.GetEffectiveId();
            string card_name = card_use.Card.UserString;

            room.AddToPile(card_use.From, "ambush", id, false);
            card_use.From.SetTag(string.Format("shefu_{0}", card_name), id);

            LogMessage log = new LogMessage
            {
                Type     = "$ShefuRecord",
                From     = card_use.From.Name,
                Card_str = id.ToString(),
                Arg      = card_name
            };

            room.SendLog(log, card_use.From);
        }
        public override void OnUse(Room room, CardUseStruct use)
        {
            string str = RoomLogic.CardToString(room, use.Card);

            object     data   = use;
            RoomThread thread = room.RoomThread;

            thread.Trigger(TriggerEvent.PreCardUsed, room, use.From, ref data);

            CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_USE, use.From.Name, use.To[0].Name, use.Card.Skill, null)
            {
                CardString = str,
                General    = RoomLogic.GetGeneralSkin(room, use.From, use.Card.Skill, use.Card.SkillPosition)
            };

            room.MoveCardTo(use.Card, use.From, Place.PlaceTable, reason, true);

            LogMessage log = new LogMessage
            {
                From     = use.From.Name,
                To       = new List <string>(),
                Type     = "#DelayedTrick",
                Card_str = str
            };

            foreach (Player to in use.To)
            {
                log.To.Add(to.Name);
            }
            room.SendLog(log);

            Thread.Sleep(300);
            room.RoomThread.Trigger(TriggerEvent.CardUsedAnnounced, room, use.From, ref data);
            room.RoomThread.Trigger(TriggerEvent.CardTargetAnnounced, room, use.From, ref data);
            thread.Trigger(TriggerEvent.CardUsed, room, use.From, ref data);
            thread.Trigger(TriggerEvent.CardFinished, room, use.From, ref data);
        }
Exemple #5
0
        public override void OnUse(Room room, CardUseStruct card_use)
        {
            if (card_use.To.Count == 0)
            {
                DoRecast(room, card_use);
            }
            else
            {
                Player        player  = card_use.From;
                CardUseStruct use     = new CardUseStruct(card_use.Card, player, new List <Player>());
                List <Player> targets = new List <Player>();
                Game3v3Camp   camp    = card_use.To[0].Camp;
                foreach (Player p in room.GetAlivePlayers())
                {
                    if (player.Camp == camp && p.Camp == camp && p.Chained)
                    {
                        targets.Add(p);
                    }
                    else if (player.Camp != camp && p.Camp == camp && !p.Chained)
                    {
                        targets.Add(p);
                    }
                }

                foreach (Player p in targets)
                {
                    Skill skill = Engine.IsProhibited(room, player, p, card_use.Card);
                    if (skill != null)
                    {
                        skill = Engine.GetMainSkill(skill.Name);
                        LogMessage log = new LogMessage
                        {
                            Type = "#SkillAvoid",
                            From = p.Name,
                            Arg  = skill.Name,
                            Arg2 = Name
                        };
                        room.SendLog(log);
                        if (RoomLogic.PlayerHasShownSkill(room, p, skill))
                        {
                            room.NotifySkillInvoked(p, skill.Name);
                            GeneralSkin gsk        = RoomLogic.GetGeneralSkin(room, p, skill.Name);
                            string      genral     = gsk.General;
                            int         skin_id    = gsk.SkinId;
                            string      skill_name = skill.Name;
                            int         audio      = -1;
                            skill.GetEffectIndex(room, p, 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
                    {
                        use.To.Add(p);
                    }
                }

                room.SortByActionOrder(ref use);
                base.OnUse(room, use);
            }
        }
        public virtual void OnUse(Room room, CardUseStruct card_use)
        {
            Player player = card_use.From;

            room.SortByActionOrder(ref card_use);
            List <Player> targets = card_use.To;

            bool       hidden = (TypeID == CardType.TypeSkill && !WillThrow);
            LogMessage log    = new LogMessage("#UseCard")
            {
                From     = player.Name,
                To       = new List <string>(),
                Card_str = RoomLogic.CardToString(room, card_use.Card)
            };

            if (!TargetFixed(card_use.Card) || card_use.To.Count > 1 || !card_use.To.Contains(card_use.From))
            {
                log.SetTos(card_use.To);
            }


            List <int>             used_cards = new List <int>();
            List <CardsMoveStruct> moves      = new List <CardsMoveStruct>();

            used_cards.AddRange(card_use.Card.SubCards);

            RoomThread thread = room.RoomThread;
            object     data   = card_use;

            thread.Trigger(TriggerEvent.PreCardUsed, room, player, ref data);

            card_use = (CardUseStruct)data;

            if (TypeID != CardType.TypeSkill)
            {
                CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_USE, player.Name, null, card_use.Card.Skill, null)
                {
                    CardString = RoomLogic.CardToString(room, card_use.Card),
                    General    = RoomLogic.GetGeneralSkin(room, player, card_use.Card.Skill, card_use.Card.SkillPosition)
                };
                if (card_use.To.Count == 1)
                {
                    reason.TargetId = card_use.To[0].Name;
                }

                foreach (int id in used_cards)
                {
                    CardsMoveStruct move = new CardsMoveStruct(id, null, Place.PlaceTable, reason);
                    moves.Add(move);
                }
                room.MoveCardsAtomic(moves, true);
                if (used_cards.Count == 0)
                {                                                                                 //show virtual card on table
                    CardsMoveStruct move = new CardsMoveStruct(-1, player, Place.PlaceTable, reason)
                    {
                        From_place       = Place.PlaceUnknown,
                        From             = player.Name,
                        Is_last_handcard = false,
                    };
                    room.NotifyUsingVirtualCard(RoomLogic.CardToString(room, card_use.Card), move);
                }

                room.SendLog(log);
                if (this is Collateral)
                { // put it here for I don't wanna repeat these codes in Card::onUse
                    Player victim = room.FindPlayer((string)card_use.To[0].GetTag("collateralVictim"), true);
                    if (victim != null)
                    {
                        log = new LogMessage("#CollateralSlash")
                        {
                            From = card_use.From.Name,
                            To   = new List <string> {
                                victim.Name
                            },
                        };
                        room.SendLog(log);
                        room.DoAnimate(AnimateType.S_ANIMATE_INDICATE, card_use.To[0].Name, victim.Name);
                    }
                }
            }
            else
            {
                CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_THROW, card_use.From.Name, null,
                                                           card_use.Card.Skill, null)
                {
                    CardString = RoomLogic.CardToString(room, card_use.Card),
                    General    = RoomLogic.GetGeneralSkin(room, player, card_use.Card.Skill, card_use.Card.SkillPosition)
                };

                FunctionCard card = Engine.GetFunctionCard(card_use.Card.Name);
                if (card is SkillCard && WillThrow)
                {
                    room.MoveCardTo(card_use.Card, card_use.From, null, Place.PlaceTable, reason, true);
                }
                room.SendLog(log);

                if (WillThrow)
                {
                    List <int> table_cardids = room.GetCardIdsOnTable(card_use.Card);
                    if (table_cardids.Count > 0)
                    {
                        CardsMoveStruct move = new CardsMoveStruct(table_cardids, player, null, Place.PlaceTable, Place.DiscardPile, reason);
                        room.MoveCardsAtomic(new List <CardsMoveStruct> {
                            move
                        }, true);
                    }
                }
            }
            room.RoomThread.Trigger(TriggerEvent.CardUsedAnnounced, room, player, ref data);
            room.RoomThread.Trigger(TriggerEvent.CardTargetAnnounced, room, player, ref data);

            room.RoomThread.Trigger(TriggerEvent.CardUsed, room, player, ref data);
            room.RoomThread.Trigger(TriggerEvent.CardFinished, room, player, ref data);
        }
        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);
            }
        }