EX9_033.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Kaguyamon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_033 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Alternative Digivolution Cost
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.TopCard.IsLevel5)
  19. {
  20. if (targetPermanent.TopCard.EqualsTraits("Puppet"))
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  28. permanentCondition: PermanentCondition,
  29. digivolutionCost: 3,
  30. ignoreDigivolutionRequirement: false,
  31. card: card,
  32. condition: null)
  33. );
  34. }
  35. #endregion
  36. #region Give Alliance & Blocker
  37. bool SharedPermanentCondition(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  40. {
  41. if (permanent.IsToken || permanent.TopCard.EqualsTraits("Puppet"))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. if (timing == EffectTiming.None)
  49. {
  50. bool CanUseAllTurnsCondition()
  51. {
  52. return CardEffectCommons.IsExistOnBattleArea(card);
  53. }
  54. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
  55. permanentCondition: SharedPermanentCondition,
  56. isInheritedEffect: false,
  57. card: card,
  58. condition: CanUseAllTurnsCondition));
  59. AddSkillClass addSkillClass = new AddSkillClass();
  60. addSkillClass.SetUpICardEffect("Your Digimon gain Alliance", CanUseCondition, card);
  61. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  62. cardEffects.Add(addSkillClass);
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CanUseAllTurnsCondition();
  66. }
  67. bool CardSourceCondition(CardSource cardSource)
  68. {
  69. if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
  70. {
  71. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  72. {
  73. if (SharedPermanentCondition(cardSource.PermanentOfThisCard()))
  74. {
  75. return true;
  76. }
  77. }
  78. }
  79. return false;
  80. }
  81. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  82. {
  83. if (_timing == EffectTiming.OnAllyAttack)
  84. {
  85. bool Condition()
  86. {
  87. return CardSourceCondition(cardSource);
  88. }
  89. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(false, cardSource, Condition));
  90. }
  91. return cardEffects;
  92. }
  93. }
  94. #endregion
  95. #endregion
  96. #region All Turns
  97. if (timing == EffectTiming.OnDestroyedAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Delete 1 lowest level digimon", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  102. activateClass.SetHashString("EX9_033_Deletion");
  103. cardEffects.Add(activateClass);
  104. string EffectDiscription()
  105. {
  106. return "[All Turns] [Once Per Turn] When other Digimon are deleted, delete 1 of your opponent's lowest level Digimon.";
  107. }
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  111. CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, permanent => TriggerCondtion(permanent), activateClass);
  112. }
  113. bool TriggerCondtion(Permanent permanent)
  114. {
  115. return permanent != card.PermanentOfThisCard()
  116. && CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  117. }
  118. bool CanActivateCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  121. }
  122. bool CanSelectPermanentCondition(Permanent permanent)
  123. {
  124. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  125. {
  126. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  127. {
  128. return true;
  129. }
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable hashtable)
  134. {
  135. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  136. {
  137. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: false,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: null,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Destroy,
  150. cardEffect: activateClass);
  151. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  152. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  153. }
  154. }
  155. }
  156. #endregion
  157. #region End of Your Turn
  158. if (timing == EffectTiming.OnEndTurn)
  159. {
  160. ActivateClass activateClass = new ActivateClass();
  161. activateClass.SetUpICardEffect("Play 1 level 4 [Puppet] digimon from trash", CanUseCondition, card);
  162. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  163. activateClass.SetHashString("EX9_033_PlayPuppet");
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. {
  167. return "[End of Your Turn] [Once Per Turn] You may play 1 level 4 or lower [Puppet] trait Digimon card from your trash without paying the cost.";
  168. }
  169. bool CanUseCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  172. }
  173. bool CanActivateCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  176. && CardEffectCommons.IsOwnerTurn(card);
  177. }
  178. bool CanSelectCardCondition(CardSource cardSource)
  179. {
  180. return CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.Trash) &&
  181. cardSource.Level <= 4 && cardSource.EqualsTraits("Puppet");
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  186. {
  187. List<CardSource> selectedCards = new List<CardSource>();
  188. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  189. selectCardEffect.SetUp(
  190. canTargetCondition: CanSelectCardCondition,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. canNoSelect: () => true,
  194. selectCardCoroutine: SelectCardCoroutine,
  195. afterSelectCardCoroutine: null,
  196. message: "Select 1 card to play.",
  197. maxCount: 1,
  198. canEndNotMax: false,
  199. isShowOpponent: true,
  200. mode: SelectCardEffect.Mode.Custom,
  201. root: SelectCardEffect.Root.Trash,
  202. customRootCardList: null,
  203. canLookReverseCard: true,
  204. selectPlayer: card.Owner,
  205. cardEffect: activateClass);
  206. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  207. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  208. yield return StartCoroutine(selectCardEffect.Activate());
  209. IEnumerator SelectCardCoroutine(CardSource cardSource)
  210. {
  211. selectedCards.Add(cardSource);
  212. yield return null;
  213. }
  214. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  215. }
  216. }
  217. }
  218. #endregion
  219. return cardEffects;
  220. }
  221. }
  222. }