public override void Use(Room room, CardUseStruct card_use) { List <Player> targets = card_use.To; string str = RoomLogic.CardToString(room, card_use.Card); if (targets.Count == 0 || RoomLogic.PlayerContainsTrick(room, targets[0], Name)) { /* * if (movable) * { * OnNullified(room, card_use.From, card_use.Card); * if (room.GetCardOwner(card_use.Card.GetEffectiveId()) != card_use.From) return; * } */ CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_USE, card_use.From.Name, null, card_use.Card.Skill, null) { Card = card_use.Card }; room.MoveCardTo(card_use.Card, null, Place.DiscardPile, reason, true); return; } if (room.GetCardIdsOnTable(room.GetSubCards(card_use.Card)).Count == 0) { return; } CardMoveReason reason2 = new CardMoveReason(MoveReason.S_REASON_USE, card_use.From.Name, targets[0].Name, card_use.Card.Skill, null) { Card = card_use.Card }; room.MoveCardTo(card_use.Card, null, targets[0], Place.PlaceDelayedTrick, reason2, true); }
public override void Use(Room room, CardUseStruct card_use) { List <Player> targets = card_use.To; string str = RoomLogic.CardToString(room, card_use.Card); List <string> nullified_list = room.ContainsTag("CardUseNullifiedList") ? (List <string>)room.GetTag("CardUseNullifiedList") : new List <string>(); bool all_nullified = nullified_list.Contains("_ALL_TARGETS"); if (all_nullified || targets.Count == 0 || RoomLogic.PlayerContainsTrick(room, targets[0], Name)) { if (movable) { OnNullified(room, card_use.From, card_use.Card); if (room.GetCardOwner(card_use.Card.GetEffectiveId()) != card_use.From) { return; } } CardMoveReason reason = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_USE, card_use.From.Name, null, card_use.Card.Skill, null) { CardString = str }; room.MoveCardTo(card_use.Card, null, Place.DiscardPile, reason, true); return; } if (room.GetCardIdsOnTable(card_use.Card).Count == 0) { return; } CardMoveReason reason2 = new CardMoveReason(CardMoveReason.MoveReason.S_REASON_USE, card_use.From.Name, targets[0].Name, card_use.Card.Skill, null) { CardString = str }; room.MoveCardTo(card_use.Card, null, targets[0], Place.PlaceDelayedTrick, reason2, true); }
public override WrappedCard AskForNullification(WrappedCard trick, Player from, Player to, bool positive) { Choice[HegNullification.ClassName] = null; if (!to.Alive) { return(null); } List <WrappedCard> nullcards = GetCards(Nullification.ClassName, self); if (nullcards.Count == 0) { return(null); } int null_num = nullcards.Count; SortByUseValue(ref nullcards); WrappedCard null_card = null; foreach (WrappedCard c in nullcards) { if (!RoomLogic.IsCardLimited(room, self, c, HandlingMethod.MethodUse)) { null_card = c; } } if (null_card == null) { return(null); } if (null_num > 1) { foreach (WrappedCard card in nullcards) { if (card.Name != HegNullification.ClassName && !RoomLogic.IsCardLimited(room, self, card, HandlingMethod.MethodUse)) { null_card = card; break; } } } if (RoomLogic.IsCardLimited(room, self, null_card, FunctionCard.HandlingMethod.MethodUse)) { return(null); } if (null_num == 1 && HasSkill("kanpo") && self.Phase == Player.PlayerPhase.NotActive && self.IsLastHandCard(null_card)) { foreach (Player p in GetFriends(self)) { if (HasSkill("shouchen", p)) { null_num = 2; break; } } } bool keep = false; if (null_num == 1) { bool only = true; foreach (Player p in FriendNoSelf) { if (GetKnownCardsNums(Nullification.ClassName, "he", p, self) > 0) { only = false; break; } } if (only) { foreach (Player p in GetFriends(self)) { if (RoomLogic.PlayerContainsTrick(room, p, Indulgence.ClassName) && !HasSkill("guanxing|yizhi|shensu|qiaobian") && p.HandcardNum >= p.Hp && (trick.Name != Indulgence.ClassName) || p.Name != to.Name) { keep = true; break; } } } } UseCard use = Engine.GetCardUsage(trick.Name); if (use != null) { UseCard.NulliResult result = use.OnNullification(this, from, to, trick, positive, keep); if (result.Null) { if (result.Heg) { foreach (WrappedCard card in nullcards) { if (card.Name == HegNullification.ClassName && !RoomLogic.IsCardLimited(room, self, card, HandlingMethod.MethodUse)) { Choice[HegNullification.ClassName] = "all"; null_card = card; break; } } } return(null_card); } } return(null); }
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); } }
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); } }
public override bool TargetFilter(Room room, List <Player> targets, Player to_select, Player Self, WrappedCard card) { return(!RoomLogic.PlayerContainsTrick(room, to_select, Name) && base.TargetFilter(room, targets, to_select, Self, card) && to_select.JudgingAreaAvailable); }