protected virtual void OnCardUsed(Room room, Player player, ref object data) { if (data is CardUseStruct card_use) { RoomThread thread = room.RoomThread; FunctionCard fcard = Engine.GetFunctionCard(card_use.Card.Name); WrappedCard card = card_use.Card; if (fcard.HasPreact) { fcard.DoPreAction(room, player, card); data = card_use; } room.AddUseList(card_use); card_use.EffectCount = new List <CardBasicEffect>(); foreach (Player p in card_use.To) { card_use.EffectCount.Add(fcard.FillCardBasicEffct(room, p)); } data = card_use; if (card_use.From != null) { thread.Trigger(TriggerEvent.TargetChoosing, room, card_use.From, ref data); CardUseStruct new_use = (CardUseStruct)data; } card_use = (CardUseStruct)data; if (card_use.From != null && card_use.To.Count > 0) { foreach (CardBasicEffect effect in card_use.EffectCount) { effect.Triggered = false; } while (card_use.EffectCount.Count > 0) { bool check = true; int count = card_use.EffectCount.Count; for (int i = 0; i < count; i++) { CardBasicEffect effect = card_use.EffectCount[i]; if (!effect.Triggered) { check = false; thread.Trigger(TriggerEvent.TargetConfirming, room, effect.To, ref data); effect.Triggered = true; break; } } if (check) { break; } card_use = (CardUseStruct)data; } } card_use = (CardUseStruct)data; if (card_use.From != null && card_use.To.Count > 0) { thread.Trigger(TriggerEvent.TargetChosen, room, card_use.From, ref data); for (int i = 0; i < card_use.EffectCount.Count; i++) { CardBasicEffect effect = card_use.EffectCount[i]; effect.Triggered = false; thread.Trigger(TriggerEvent.TargetConfirmed, room, effect.To, ref data); effect.Triggered = true; } } card_use = (CardUseStruct)data; fcard.Use(room, card_use); } }
protected virtual void OnCardUsed(Room room, Player player, ref object data) { if (data is CardUseStruct card_use) { RoomThread thread = room.RoomThread; FunctionCard fcard = Engine.GetFunctionCard(card_use.Card.Name); WrappedCard card = card_use.Card; if (fcard.HasPreact) { fcard.DoPreAction(room, player, card); data = card_use; } List <Player> targets = card_use.To; List <CardUseStruct> use_list = room.ContainsTag("card_proceeing") ? (List <CardUseStruct>)room.GetTag("card_proceeing") : new List <CardUseStruct>(); //for serval purpose, such as AI use_list.Add(card_use); room.SetTag("card_proceeing", use_list); if (card_use.From != null) { thread.Trigger(TriggerEvent.TargetChoosing, room, card_use.From, ref data); CardUseStruct new_use = (CardUseStruct)data; targets = new_use.To; } if (card_use.From != null && targets.Count > 0) { List <Player> targets_copy = new List <Player>(targets); foreach (Player to in targets_copy) { if (targets.Contains(to)) { thread.Trigger(TriggerEvent.TargetConfirming, room, to, ref data); CardUseStruct new_use = (CardUseStruct)data; targets = new_use.To; if (targets.Count == 0) { break; } } } } card_use = (CardUseStruct)data; if (card_use.From != null && card_use.To.Count > 0) { thread.Trigger(TriggerEvent.TargetChosen, room, card_use.From, ref data); foreach (Player p in card_use.To) { thread.Trigger(TriggerEvent.TargetConfirmed, room, p, ref data); } } card_use = (CardUseStruct)data; if (card_use.NullifiedList != null) { room.SetTag("CardUseNullifiedList", card_use.NullifiedList); } fcard.Use(room, card_use); } }