Advertisement
LittleSallyDigby

What's Wrong With This DestroyAttempted?

Apr 14th, 2021
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.47 KB | None | 0 0
  1. using Handelabra;
  2. using Handelabra.Sentinels.Engine.Controller;
  3. using Handelabra.Sentinels.Engine.Model;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9.  
  10. namespace Jp.ParahumansOfTheWormverse.TheMerchants
  11. {
  12. class SkidmarkCharacterCardController : VillainCharacterCardController
  13. {
  14. public SkidmarkCharacterCardController(Card card, TurnTakerController turnTakerController) : base(card, turnTakerController)
  15. {
  16. ThugDeck = base.Card.UnderLocation;
  17. SpecialStringMaker.ShowNumberOfCardsAtLocation(ThugDeck);
  18. }
  19.  
  20. public Location ThugDeck
  21. {
  22. get;
  23. private set;
  24. }
  25.  
  26. public const string HeroesCannotWinMessage = "HeroesCannotWinMessage";
  27.  
  28. public override void AddSideTriggers()
  29. {
  30. base.AddSideTriggers();
  31. if (!base.Card.IsFlipped)
  32. {
  33. // Superpowered Drug Lord
  34. // "At the start of the villain turn, if the Thug deck is empty, the Merchants have grown out of control. [b]GAME OVER.[/b]"
  35. AddStartOfTurnTrigger((TurnTaker tt) => tt == base.TurnTaker, GameOverResponse, TriggerType.GameOver, additionalCriteria: (PhaseChangeAction pca) => !ThugDeck.HasCards);
  36. // "At the end of the villain turn, play the top {H - 1} cards of the Thug deck."
  37. AddEndOfTurnTrigger((TurnTaker tt) => tt == base.TurnTaker, (PhaseChangeAction pca) => base.GameController.PlayTopCardOfLocation(base.TurnTakerController, ThugDeck, numberOfCards: H - 1, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource()), TriggerType.PlayCard);
  38. if (IsGameAdvanced)
  39. {
  40. // "Reduce damage dealt to villain targets by 1."
  41. base.AddSideTrigger(AddReduceDamageTrigger((Card c) => c.IsVillain, 1));
  42. }
  43. }
  44. else
  45. {
  46. // Defeated Drug Lord
  47. // "[b]The heroes cannot win the game as long as there is a villain target in play.[/b]"
  48. base.AddSideTrigger(AddTrigger((GameOverAction goa) => goa.ResultIsVictory && base.GameController.FindCardsWhere(new LinqCardCriteria((Card c) => c.IsVillain && c.IsTarget && c.IsInPlayAndHasGameText), visibleToCard: GetCardSource()).Any(), CancelVictoryResponse, TriggerType.CancelAction, TriggerTiming.Before));
  49. // "At the start of the villain turn, if the Thug deck is empty, the Merchants have grown out of control. [b]GAME OVER.[/b]"
  50. base.AddSideTrigger(AddStartOfTurnTrigger((TurnTaker tt) => tt == base.TurnTaker, GameOverResponse, TriggerType.GameOver, additionalCriteria: (PhaseChangeAction pca) => !ThugDeck.HasCards));
  51. // "At the end of the villain turn, play the top card of the Thug deck."
  52. base.AddSideTrigger(AddEndOfTurnTrigger((TurnTaker tt) => tt == base.TurnTaker, (PhaseChangeAction pca) => base.GameController.PlayTopCardOfLocation(base.TurnTakerController, ThugDeck, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource()), TriggerType.PlayCard));
  53. }
  54. AddDefeatedIfMovedOutOfGameTriggers();
  55. ThugDeck.OverrideIsInPlay = false;
  56. }
  57.  
  58. public override IEnumerator DestroyAttempted(DestroyCardAction destroyCard)
  59. {
  60. // "When {SkidmarkCharacter} would be destroyed, flip {SkidmarkCharacter}'s villain character cards instead."
  61. Log.Debug("SkidmarkCharacterCardController.DestroyAttempted activated...");
  62. if (!base.Card.IsFlipped)
  63. {
  64. Log.Debug("Flipping " + base.Card.Title + " instead of destroying him...");
  65. IEnumerator flipCoroutine = base.GameController.FlipCard(this, treatAsPlayed: false, treatAsPutIntoPlay: false, destroyCard.ActionSource, cardSource: GetCardSource());
  66. if (base.UseUnityCoroutines)
  67. {
  68. yield return base.GameController.StartCoroutine(flipCoroutine);
  69. }
  70. else
  71. {
  72. base.GameController.ExhaustCoroutine(flipCoroutine);
  73. }
  74. }
  75. yield break;
  76. }
  77.  
  78. public IEnumerator GameOverResponse(GameAction ga)
  79. {
  80. // "... the Merchants have grown out of control. [b]GAME OVER.[/b]"
  81. string ending = "The Thug deck is empty! The Merchants have become too numerous for the heroes to contain!";
  82. IEnumerator endCoroutine = base.GameController.GameOver(EndingResult.AlternateDefeat, ending, showEndingTextAsMessage: true, actionSource: ga, cardSource: GetCardSource());
  83. if (base.UseUnityCoroutines)
  84. {
  85. yield return base.GameController.StartCoroutine(endCoroutine);
  86. }
  87. else
  88. {
  89. base.GameController.ExhaustCoroutine(endCoroutine);
  90. }
  91. yield break;
  92. }
  93.  
  94. public IEnumerator CancelVictoryResponse(GameOverAction goa)
  95. {
  96. // "[b]The heroes cannot win the game as long as there is a villain target in play.[/b]"
  97. if (!HasBeenSetToTrueThisGame(nameof(HeroesCannotWinMessage)))
  98. {
  99. IEnumerator messageCoroutine = base.GameController.SendMessageAction(base.Card.Title + " has been defeated, but his followers continue to rampage as long as there is a villain target in play!", Priority.Critical, GetCardSource(), base.GameController.FindCardsWhere(new LinqCardCriteria((Card c) => c.IsTarget && c.IsVillain && c.IsInPlayAndHasGameText), visibleToCard: GetCardSource()), showCardSource: true);
  100. if (base.UseUnityCoroutines)
  101. {
  102. yield return base.GameController.StartCoroutine(messageCoroutine);
  103. }
  104. else
  105. {
  106. base.GameController.ExhaustCoroutine(messageCoroutine);
  107. }
  108. SetCardPropertyToTrueIfRealAction(nameof(HeroesCannotWinMessage));
  109. }
  110. IEnumerator cancelCoroutine = CancelAction(goa);
  111. if (base.UseUnityCoroutines)
  112. {
  113. yield return base.GameController.StartCoroutine(cancelCoroutine);
  114. }
  115. else
  116. {
  117. base.GameController.ExhaustCoroutine(cancelCoroutine);
  118. }
  119. yield break;
  120. }
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement