protected override bool DoTransformSideEffect(CompositeCard card, object arg, List<Player> targets) { ICard result = null; List<Player> toProcess = new List<Player>(Game.CurrentGame.AlivePlayers); toProcess.Remove(Owner); Game.CurrentGame.SortByOrderOfComputation(Owner, toProcess); bool noAnswer = true; foreach (var player in toProcess) { if (player.Hero.Allegiance == Core.Heroes.Allegiance.Shu) { bool failToRespond = false; while (true) { IUiProxy ui = Game.CurrentGame.UiProxies[player]; SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is Sha; }, false); ISkill skill; List<Player> p; List<Card> cards; if (!ui.AskForCardUsage(new CardUsagePrompt("JiJiang", Owner), v1, out skill, out cards, out p)) { failToRespond = true; break; } if (!Game.CurrentGame.CommitCardTransform(player, skill, cards, out result, targets)) { continue; } noAnswer = false; Trace.TraceInformation("Player {0} Responded JiJiang with SHA, ", player.Id); break; } if (failToRespond) { continue; } break; } } if (noAnswer) { return false; } Trace.Assert(result != null); card.Subcards = new List<Card>(); if (result is CompositeCard) { card.Subcards.AddRange(((CompositeCard)result).Subcards); card.Type = ((CompositeCard)result).Type; } else { Trace.Assert(result is Card); card.Subcards.Add((Card)result); card.Type = ((Card)result).Type; } return true; }
public override void Run(GameEvent gameEvent, GameEventArgs eventArgs) { if (eventArgs.ReadonlyCard == null) { return; } if (!(eventArgs.ReadonlyCard.Type is Sha)) { return; } Player source = eventArgs.Source; Player dest = eventArgs.Targets[0]; ICard card = eventArgs.Card; List<Player> sourceList = new List<Player>() { source }; GameEventArgs args = new GameEventArgs(); Game.CurrentGame.Emit(PlayerShaTargetShanModifier, eventArgs); // this number is 0 for normal Sha/Shan. Lv Bu would like this to be 1 int numberOfShanRequired = eventArgs.ReadonlyCard[ShaCancellationCount] = eventArgs.ReadonlyCard[CardAttribute.TargetRequireTwoResponses[dest]] + 1; bool cannotUseShan = (eventArgs.ReadonlyCard[CannotProvideShan[dest]] & 1) == 1; eventArgs.ReadonlyCard[CannotProvideShan[dest]] >>= 1; bool cannotProvideShan = false; while (numberOfShanRequired > 0 && !cannotUseShan) { args.Source = dest; args.Targets = sourceList; args.Card = new CompositeCard(); args.Card.Type = new Shan(); args.ReadonlyCard = eventArgs.ReadonlyCard; try { Game.CurrentGame.Emit(GameEvent.PlayerRequireCard, args); } catch (TriggerResultException e) { if (e.Status == TriggerResult.Success) { GameEventArgs arg = new GameEventArgs(); arg.Source = dest; arg.Targets = sourceList; arg.Skill = args.Skill; arg.Cards = args.Cards; arg.InResponseTo = eventArgs; Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, arg); #if SB_FAQ numberOfShanRequired--; #else numberOfShanRequired = eventArgs.ReadonlyCard[ShaCancellationCount]; #endif continue; } } while (true) { IUiProxy ui = Game.CurrentGame.UiProxies[dest]; SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is Shan; }, true); ISkill skill; List<Player> p; List<Card> cards; if (!ui.AskForCardUsage(new CardUsagePrompt("Sha.Shan", source), v1, out skill, out cards, out p)) { cannotProvideShan = true; break; } try { GameEventArgs arg = new GameEventArgs(); arg.Source = dest; arg.Targets = sourceList; arg.Skill = skill; arg.Cards = cards; arg.InResponseTo = eventArgs; Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, arg); } catch (TriggerResultException e) { Trace.Assert(e.Status == TriggerResult.Retry); continue; } break; } if (cannotProvideShan) { break; } #if SB_FAQ numberOfShanRequired--; #else numberOfShanRequired = eventArgs.ReadonlyCard[ShaCancellationCount]; #endif } if (cannotUseShan || #if SB_FAQ eventArgs.ReadonlyCard[ShaCancellationCount] > 0 #else numberOfShanRequired > 0 #endif ) return; Trace.TraceInformation("Successfully dodged"); args = new GameEventArgs(); args.Source = source; args.Targets = new List<Player>(); args.Targets.Add(dest); args.Card = card; args.ReadonlyCard = eventArgs.ReadonlyCard; try { Game.CurrentGame.Emit(PlayerShaTargetDodged, args); } catch (TriggerResultException) { Trace.Assert(false); } throw new TriggerResultException(TriggerResult.End); }
public WanJianQiFa() { ResponseCardVerifier = new SingleCardUsageVerifier((c) => { return c.Type is Shan; }, false); }
void CallOfShan(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs) { ICard result = null; List<Player> toProcess = new List<Player>(Game.CurrentGame.AlivePlayers); toProcess.Remove(Owner); bool noAnswer = true; foreach (var player in toProcess) { if (player.Allegiance == Core.Heroes.Allegiance.Wei) { bool failToRespond = false; GameEventArgs args = new GameEventArgs(); args.Source = player; args.Targets = eventArgs.Targets; args.Card = new CompositeCard(); args.Card.Type = new Shan(); args.ReadonlyCard = eventArgs.ReadonlyCard; try { Game.CurrentGame.Emit(GameEvent.PlayerRequireCard, args); } catch (TriggerResultException e) { if (e.Status == TriggerResult.Success) { eventArgs.Skill = args.Skill; eventArgs.Cards = new List<Card>(args.Cards); throw new TriggerResultException(TriggerResult.Success); } } while (true) { IUiProxy ui = Game.CurrentGame.UiProxies[player]; SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is Shan; }, false); ISkill skill; List<Player> p; List<Card> cards; if (!ui.AskForCardUsage(new CardUsagePrompt("HuJia", Owner), v1, out skill, out cards, out p)) { failToRespond = true; break; } if (!Game.CurrentGame.CommitCardTransform(player, skill, cards, out result, eventArgs.Targets)) { continue; } if (result is CompositeCard) { eventArgs.Cards = new List<Card>((result as CompositeCard).Subcards); eventArgs.Skill = new CardWrapper(Owner, new Shan()); } else { eventArgs.Cards = new List<Card>() { result as Card }; eventArgs.Skill = null; } noAnswer = false; Trace.TraceInformation("Player {0} Responded HuJia with SHAN, ", player.Id); break; } if (failToRespond) { continue; } break; } } if (noAnswer) { return; } Trace.Assert(result != null); eventArgs.Cards = new List<Card>(); if (result is CompositeCard) { eventArgs.Cards.AddRange(((CompositeCard)result).Subcards); } else { Trace.Assert(result is Card); eventArgs.Cards.Add((Card)result); } throw new TriggerResultException(TriggerResult.Success); }
public override void Run(GameEvent gameEvent, GameEventArgs eventArgs) { ReadOnlyCard card = eventArgs.ReadonlyCard; SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is WuXieKeJi; }, true, new WuXieKeJi()); List<Card> cards; List<Player> players; ISkill skill; Player responder; bool WuXieSuccess = false; Trace.Assert(eventArgs.Targets.Count == 1); Player promptPlayer = eventArgs.Targets[0]; ICard promptCard = eventArgs.ReadonlyCard; if (card != null && CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Tool) && card[WuXieKeJi.CannotBeCountered] == 0) { bool askWuXie = false; foreach (var p in Game.CurrentGame.AlivePlayers) { foreach (var c in Game.CurrentGame.Decks[p, DeckType.Hand]) { if (c.Type is WuXieKeJi) { askWuXie = true; break; } } foreach (var sk in p.ActionableSkills) { CardTransformSkill cts = sk as CardTransformSkill; if (cts != null) { if (cts.PossibleResults == null) { askWuXie = true; break; } foreach (var pr in cts.PossibleResults) { if (pr is WuXieKeJi) { askWuXie = true; break; } } } } if (askWuXie) break; } Game.CurrentGame.SyncConfirmationStatus(ref askWuXie); if (!askWuXie) return; while (true) { Prompt prompt = new CardUsagePrompt("WuXieKeJi", promptPlayer, promptCard); if (Game.CurrentGame.GlobalProxy.AskForCardUsage( prompt, v1, out skill, out cards, out players, out responder)) { try { GameEventArgs args = new GameEventArgs(); args.Source = responder; args.Targets = players; args.Skill = skill; args.Cards = cards; Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args); } catch (TriggerResultException e) { Trace.Assert(e.Status == TriggerResult.Retry); continue; } promptPlayer = responder; promptCard = new CompositeCard(); promptCard.Type = new WuXieKeJi(); (promptCard as CompositeCard).Subcards = null; WuXieSuccess = !WuXieSuccess; } else { break; } } } if (WuXieSuccess) { throw new TriggerResultException(TriggerResult.End); } }
protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard) { Player current = dest; bool firstTime = true; while (true) { List<Player> sourceList = new List<Player>(); if (current == dest) { sourceList.Add(source); } else { sourceList.Add(dest); } IUiProxy ui = Game.CurrentGame.UiProxies[current]; SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is Sha; }, false); ISkill skill; List<Player> p; List<Card> cards; CardUsagePrompt prompt; if (current.IsDead) return; if (firstTime) { prompt = new CardUsagePrompt("JueDou", source);; } else { prompt = new CardUsagePrompt("JueDou2", current == dest ? source : dest); firstTime = false; } int numberOfShaRequired = current == dest ? readonlyCard[CardAttribute.TargetRequireTwoResponses] + 1 : readonlyCard[CardAttribute.SourceRequireTwoResponses] + 1; bool cannotProvideSha = false; while (numberOfShaRequired > 0) { if (!ui.AskForCardUsage(prompt, v1, out skill, out cards, out p)) { Trace.TraceInformation("Player {0} Invalid answer", current); cannotProvideSha = true; break; } if (!Game.CurrentGame.HandleCardPlay(current, skill, cards, sourceList)) { continue; } numberOfShaRequired--; } if (cannotProvideSha) break; Trace.TraceInformation("Player {0} SHA, ", current.Id); if (current == dest) { current = source; } else { current = dest; } } Player won = current == dest ? source : dest; Game.CurrentGame.DoDamage(won, current, 1, DamageElement.None, card, readonlyCard); }
public override void Run(GameEvent gameEvent, GameEventArgs eventArgs) { if (eventArgs.ReadonlyCard == null) { return; } if (!(eventArgs.ReadonlyCard.Type is Sha)) { return; } Player source = eventArgs.Source; Player dest = eventArgs.Targets[0]; ICard card = eventArgs.Card; List<Player> sourceList = new List<Player>() { source }; GameEventArgs args = new GameEventArgs(); Game.CurrentGame.Emit(PlayerShaTargetShanModifier, args); int numberOfShanRequired = eventArgs.ReadonlyCard[CardAttribute.TargetRequireTwoResponses] + 1; bool cannotUseShan = eventArgs.ReadonlyCard[CannotProvideShan] == 1 ? true : false; bool cannotProvideShan = false; while (numberOfShanRequired > 0 && !cannotUseShan) { args.Source = dest; args.Targets = sourceList; args.Card = new CompositeCard(); args.Card.Type = new Shan(); args.ReadonlyCard = eventArgs.ReadonlyCard; try { Game.CurrentGame.Emit(GameEvent.PlayerRequireCard, args); } catch (TriggerResultException e) { if (e.Status == TriggerResult.Success) { Game.CurrentGame.HandleCardPlay(dest, new CardWrapper(dest, new Shan()), args.Cards, sourceList); numberOfShanRequired--; continue; } } while (true) { IUiProxy ui = Game.CurrentGame.UiProxies[dest]; SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is Shan; }, true); ISkill skill; List<Player> p; List<Card> cards; if (!ui.AskForCardUsage(new CardUsagePrompt("Sha.Shan", source), v1, out skill, out cards, out p)) { cannotProvideShan = true; break; } try { GameEventArgs arg = new GameEventArgs(); arg.Source = dest; arg.Targets = sourceList; arg.Skill = skill; arg.Cards = cards; Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, arg); } catch (TriggerResultException e) { Trace.Assert(e.Status == TriggerResult.Retry); continue; } break; } if (cannotProvideShan) { break; } numberOfShanRequired--; } if (cannotUseShan || numberOfShanRequired > 0) return; Trace.TraceInformation("Successfully dodged"); args = new GameEventArgs(); args.Source = source; args.Targets = new List<Player>(); args.Targets.Add(dest); args.Card = card; args.ReadonlyCard = eventArgs.ReadonlyCard; try { Game.CurrentGame.Emit(PlayerShaTargetDodged, args); } catch (TriggerResultException) { Trace.Assert(false); } throw new TriggerResultException(TriggerResult.End); }
protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs) { ISkill skill; List<Card> cards; List<Player> players; while (ParentEquipment.ParentCard.Place.DeckType == DeckType.Equipment) { if (!Game.CurrentGame.PlayerCanBeTargeted(Owner, new List<Player>() { eventArgs.Targets[0] }, new CompositeCard() { Type = new Sha() })) { return; } var v = new SingleCardUsageVerifier((c) => { return c.Type is Sha; }, true, new Sha()); Game.CurrentGame.Emit(GameEvent.PlayerIsAboutToUseCard, new PlayerIsAboutToUseOrPlayCardEventArgs() { Source = Owner, Verifier = v }); if (Game.CurrentGame.UiProxies[Owner].AskForCardUsage(new CardUsagePrompt("QingLongYanYueDao"), new SingleCardUsageVerifier((c) => { return c.Type is Sha; }, true), out skill, out cards, out players)) { try { Owner[Sha.NumberOfShaUsed]--; GameEventArgs args = new GameEventArgs(); args.Source = eventArgs.Source; args.Targets = eventArgs.Targets; args.Skill = skill; args.Cards = cards; args.ReadonlyCard = new ReadOnlyCard(new Card() { Place = new DeckPlace(null, null) }); args.ReadonlyCard[QingLongSha] = 1; Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args); } catch (TriggerResultException e) { Trace.Assert(e.Status == TriggerResult.Retry); continue; } } break; } }
public NanManRuQin() { ResponseCardVerifier = new SingleCardUsageVerifier((c) => { return c.Type is Sha; }, false); }