BT24_048.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Deramon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_048 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Blocker
  13. if (timing == EffectTiming.None)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  16. isInheritedEffect: false,
  17. card: card,
  18. condition: null));
  19. }
  20. #endregion
  21. #region Shared OP/WD
  22. string SharedEffectName = "May hatch, may digivolve in breeding";
  23. string SharedEffectDescription(string tag) => $"[{tag}] You may hatch in your breeding area. Then, 1 of your Digimon with [Avian] or [Bird] in any of its traits in the breeding area may digivolve into a level 5 or lower Digimon card with [Avian] or [Bird] in any of its traits in the hand without paying the cost.";
  24. bool SharedCanActivateCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  27. }
  28. bool DigivolveFromPermanentCondition(Permanent permanent)
  29. {
  30. return CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card)
  31. && (permanent.TopCard.ContainsTraits("Avian")
  32. || permanent.TopCard.ContainsTraits("Bird"));
  33. }
  34. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  35. {
  36. bool DigivolveToCardCondition(CardSource cardSource)
  37. {
  38. return cardSource.IsDigimon
  39. && cardSource.HasLevel
  40. && cardSource.Level <= 5
  41. && (cardSource.ContainsTraits("Avian")
  42. || cardSource.ContainsTraits("Bird"))
  43. && cardSource.CanPlayCardTargetFrame(
  44. frame: card.Owner.GetBreedingAreaPermanents()[0].PermanentFrame,
  45. PayCost: false,
  46. cardEffect: activateClass,
  47. root: SelectCardEffect.Root.Hand,
  48. isBreedingArea: true);
  49. }
  50. if (card.Owner.CanHatch)
  51. {
  52. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  53. {
  54. new SelectionElement<bool>(message: $"Hatch", value : true, spriteIndex: 0),
  55. new SelectionElement<bool>(message: $"Not hatch", value : false, spriteIndex: 1),
  56. };
  57. string selectPlayerMessage = "Will you hatch in Breeding Area?";
  58. string notSelectPlayerMessage = "The opponent is selecting whether to hatch in Breeding Area.";
  59. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  60. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  61. bool doHatch = GManager.instance.userSelectionManager.SelectedBoolValue;
  62. if (doHatch)
  63. {
  64. yield return ContinuousController.instance.StartCoroutine(new HatchDigiEggClass(player: card.Owner, hashtable: CardEffectCommons.CardEffectHashtable(activateClass)).Hatch());
  65. }
  66. }
  67. if (card.Owner.GetBreedingAreaPermanents().Count(DigivolveFromPermanentCondition) >= 1)
  68. {
  69. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  70. {
  71. new(message: "Digivolve in the breeding area", value: true, spriteIndex: 0),
  72. new(message: "Do not digivolve", value: false, spriteIndex: 1),
  73. };
  74. string selectPlayerMessage = "Digivolve into [Avian] or [Bird] in any of its traits in breeding area?";
  75. string notSelectPlayerMessage = "The opponent is choosing whether to digivolve in the breeding area or not.";
  76. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  77. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  78. notSelectPlayerMessage: notSelectPlayerMessage);
  79. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  80. .WaitForEndSelect());
  81. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  82. {
  83. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  84. targetPermanent: card.Owner.GetBreedingAreaPermanents()[0],
  85. cardCondition: DigivolveToCardCondition,
  86. payCost: false,
  87. reduceCostTuple: null,
  88. fixedCostTuple: null,
  89. ignoreDigivolutionRequirementFixedCost: -1,
  90. isHand: true,
  91. activateClass: activateClass,
  92. successProcess: null));
  93. }
  94. }
  95. }
  96. #endregion
  97. #region On Play
  98. if (timing == EffectTiming.OnEnterFieldAnyone)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  102. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  103. cardEffects.Add(activateClass);
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  107. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  108. }
  109. }
  110. #endregion
  111. #region When Digivolving
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  116. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  117. cardEffects.Add(activateClass);
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  121. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  122. }
  123. }
  124. #endregion
  125. #region All Turns - ESS
  126. if (timing == EffectTiming.OnDestroyedAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  131. activateClass.SetHashString("BT24_048_Inherited");
  132. activateClass.SetIsInheritedEffect(true);
  133. cardEffects.Add(activateClass);
  134. string EffectDiscription()
  135. {
  136. return "[All Turns] [Once Per Turn] When this Digimon deletes an opponent's Digimon in battle, it may unsuspend.";
  137. }
  138. bool PermanentCondition(Permanent permanent)
  139. {
  140. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  141. }
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  145. {
  146. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  147. {
  148. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  149. bool WinnerRealCondition(Permanent permanent)
  150. {
  151. return true;
  152. }
  153. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  154. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable, winnerCondition: WinnerCondition, winnerRealCondition: WinnerRealCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false))
  155. {
  156. return true;
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanActivateCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  165. }
  166. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  167. {
  168. Permanent selectedPermanent = card.PermanentOfThisCard();
  169. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  170. }
  171. }
  172. #endregion
  173. return cardEffects;
  174. }
  175. }
  176. }