EX6_041.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX6
  5. {
  6. public class EX6_041 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete 1 [Diaboromon], Digivolve into a [Diaboromon]", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] By deleting 1 of your Digimon with [Diaboromon] in its name, this Digimon may digivolve into [Diaboromon] in your hand without paying the cost.";
  21. }
  22. bool HasDiaboromonInNameField(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  25. {
  26. if (permanent.TopCard.ContainsCardName("Diaboromon"))
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool IsDiaboromon(CardSource cardSource)
  34. {
  35. return cardSource.EqualsCardName("Diaboromon");
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  44. {
  45. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasDiaboromonInNameField);
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable hashtable)
  50. {
  51. bool deleted = false;
  52. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  53. selectPermanentEffect.SetUp(
  54. selectPlayer: card.Owner,
  55. canTargetCondition: HasDiaboromonInNameField,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. maxCount: 1,
  59. canNoSelect: true,
  60. canEndNotMax: false,
  61. selectPermanentCoroutine: SelectPermanentCoroutine,
  62. afterSelectPermanentCoroutine: null,
  63. mode: SelectPermanentEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  66. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  67. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  70. IEnumerator SuccessProcess()
  71. {
  72. deleted = true;
  73. yield return null;
  74. }
  75. }
  76. if (deleted)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  79. targetPermanent: card.PermanentOfThisCard(),
  80. cardCondition: IsDiaboromon,
  81. payCost: false,
  82. reduceCostTuple: null,
  83. fixedCostTuple: null,
  84. ignoreDigivolutionRequirementFixedCost: -1,
  85. isHand: true,
  86. activateClass: activateClass,
  87. successProcess: null));
  88. }
  89. yield return null;
  90. }
  91. }
  92. #endregion
  93. #region When Digivolving
  94. if (timing == EffectTiming.OnEnterFieldAnyone)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("Delete 1 [Diaboromon], Digivolve into a [Diaboromon]", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  99. cardEffects.Add(activateClass);
  100. string EffectDiscription()
  101. {
  102. return "[When Digivolving] By deleting 1 of your Digimon with [Diaboromon] in its name, this Digimon may digivolve into [Diaboromon] in your hand without paying the cost.";
  103. }
  104. bool HasDiaboromonInNameField(Permanent permanent)
  105. {
  106. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  107. {
  108. if (permanent.TopCard.ContainsCardName("Diaboromon"))
  109. {
  110. return true;
  111. }
  112. }
  113. return false;
  114. }
  115. bool IsDiaboromon(CardSource cardSource)
  116. {
  117. return cardSource.EqualsCardName("Diaboromon");
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  126. {
  127. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasDiaboromonInNameField);
  128. }
  129. return false;
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable hashtable)
  132. {
  133. bool deleted = false;
  134. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  135. selectPermanentEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: HasDiaboromonInNameField,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: 1,
  141. canNoSelect: true,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: SelectPermanentCoroutine,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  148. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  149. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  150. {
  151. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  152. IEnumerator SuccessProcess()
  153. {
  154. deleted = true;
  155. yield return null;
  156. }
  157. }
  158. if (deleted)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  161. targetPermanent: card.PermanentOfThisCard(),
  162. cardCondition: IsDiaboromon,
  163. payCost: false,
  164. reduceCostTuple: null,
  165. fixedCostTuple: null,
  166. ignoreDigivolutionRequirementFixedCost: -1,
  167. isHand: true,
  168. activateClass: activateClass,
  169. successProcess: null));
  170. }
  171. yield return null;
  172. }
  173. }
  174. #endregion
  175. #region All Turns - ESS
  176. if (timing == EffectTiming.OnEnterFieldAnyone)
  177. {
  178. ActivateClass activateClass = new ActivateClass();
  179. activateClass.SetUpICardEffect("<De-Digivolve 1> 1 of your opponent's Digimon", CanUseCondition, card);
  180. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  181. activateClass.SetHashString("DeDigivolve_EX6_041");
  182. activateClass.SetIsInheritedEffect(true);
  183. cardEffects.Add(activateClass);
  184. string EffectDiscription()
  185. {
  186. return "[All Turns] [Once Per Turn] When one of your other Digimon with [Diaboromon] in its name is played, <De-Digivolve 1> 1 of your opponent's Digimon.";
  187. }
  188. bool HasDiaboromonInName(Permanent permanent)
  189. {
  190. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  191. {
  192. return permanent.TopCard.ContainsCardName("Diaboromon");
  193. }
  194. return false;
  195. }
  196. bool CanTargetCondtion(Permanent permanent)
  197. {
  198. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  199. }
  200. bool CanUseCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, HasDiaboromonInName);
  203. }
  204. bool CanActivateCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  207. }
  208. IEnumerator ActivateCoroutine(Hashtable hashtable)
  209. {
  210. if (CardEffectCommons.HasMatchConditionPermanent(CanTargetCondtion))
  211. {
  212. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanTargetCondtion));
  213. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  214. selectPermanentEffect.SetUp(
  215. selectPlayer: card.Owner,
  216. canTargetCondition: CanTargetCondtion,
  217. canTargetCondition_ByPreSelecetedList: null,
  218. canEndSelectCondition: null,
  219. maxCount: maxCount,
  220. canNoSelect: false,
  221. canEndNotMax: false,
  222. selectPermanentCoroutine: SelectPermanentCoroutine,
  223. afterSelectPermanentCoroutine: null,
  224. mode: SelectPermanentEffect.Mode.Custom,
  225. cardEffect: activateClass);
  226. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  227. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  228. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  229. {
  230. Permanent selectedPermanent = permanent;
  231. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  232. }
  233. }
  234. }
  235. }
  236. #endregion
  237. return cardEffects;
  238. }
  239. }
  240. }