EX12_034.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Erlangmon
  4. namespace DCGO.CardEffects.EX12
  5. {
  6. public class EX12_034 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("Shambala");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 3,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null,
  24. level: 5)
  25. );
  26. }
  27. #endregion
  28. #region Shared OP/WD
  29. string SharedEffectName = "May play [Kotenken] Token";
  30. CardEffectFactory.ActivateClassesForSharedEffects
  31. (ref cardEffects, timing, card,
  32. SharedEffectName,
  33. SharedActivateCoroutine,
  34. SharedEffectDescription,
  35. optional: true,
  36. onPlay: true,
  37. whenDigivolving: true);
  38. string SharedEffectDescription(string tag)
  39. {
  40. return $"[{tag}] You may play 1 [Kotenken] Token. (Digimon/Black/9000 DP/<Blocker>)";
  41. }
  42. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  43. {
  44. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayKotenkenToken(activateClass));
  45. }
  46. #endregion
  47. #region All Turns 1
  48. if (timing == EffectTiming.OnEnterFieldAnyone)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("Return 1 enemy lowest level Digimon to bottom of deck", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  53. activateClass.SetHashString("EX12_034_AT_1");
  54. cardEffects.Add(activateClass);
  55. string EffectDescription()
  56. {
  57. return "[All Turns] [Once Per Turn] When any of your Digimon are played, return 1 of your opponent's lowest level Digimon to the bottom of the deck.";
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  62. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  67. }
  68. bool PermanentCondition(Permanent permanent)
  69. {
  70. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  71. }
  72. bool CanSelectPermanentCondition(Permanent permanent)
  73. {
  74. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. if(CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: 1,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: null,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  92. cardEffect: activateClass);
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. }
  95. }
  96. }
  97. #endregion
  98. #region All Turns 2
  99. if (timing == EffectTiming.WhenRemoveField)
  100. {
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect("May play 1 lvl 5 or lower [SW] from hand/this Digimon's sources for free", CanUseCondition, card);
  103. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  104. activateClass.SetIsSkippable(true);
  105. activateClass.SetHashString("EX12_034_AT_2");
  106. cardEffects.Add(activateClass);
  107. string EffectDescription()
  108. {
  109. return "[All Turns] [One Per Turn] When any of your Digimon would leave the battle area, you may play 1 level 5 or lower [SW] trait card from your hand or this Digimon's digivolution cards without paying the cost.";
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  114. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  115. }
  116. bool CanActivateCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  119. }
  120. bool PermanentCondition(Permanent permanent)
  121. {
  122. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  123. }
  124. bool CanSelectCardCondition(CardSource cardSource)
  125. {
  126. return cardSource.HasLevel
  127. && cardSource.Level <= 5
  128. && cardSource.EqualsTraits("SW")
  129. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable hashtable)
  132. {
  133. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  134. bool validDigivolutionCard = card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition);
  135. if (validHandCard || validDigivolutionCard)
  136. {
  137. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  138. if (validHandCard)
  139. {
  140. selectionElements.Add(new(message: $"Play from hand", value: 1, spriteIndex: 0));
  141. }
  142. if (validDigivolutionCard)
  143. {
  144. selectionElements.Add(new(message: $"Play from this Digimon's Digivolution Cards", value: 2, spriteIndex: 0));
  145. }
  146. ;
  147. selectionElements.Add(new(message: $"Don't play", value: 3, spriteIndex: 1));
  148. string selectPlayerMessage = "Will you play a card?";
  149. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  150. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  151. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  152. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  153. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedIntValue == 1 ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.DigivolutionCards;
  154. if (doPlay)
  155. {
  156. #region Hand/Trash Card Selection & Play
  157. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  158. canTargetCondition: CanSelectCardCondition,
  159. root,
  160. activateClass,
  161. payCost: false,
  162. targetPermanent: card.PermanentOfThisCard()
  163. ));
  164. #endregion
  165. }
  166. }
  167. }
  168. }
  169. #endregion
  170. return cardEffects;
  171. }
  172. }
  173. }