P_185.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //EmperorGreymon
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_185 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Alternative Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. if (targetPermanent.TopCard.IsTamer)
  20. {
  21. if (targetPermanent.TopCard.EqualsCardName("Takuya Kanbara"))
  22. {
  23. if (targetPermanent.cardSources.Filter(x => x.EqualsTraits("Hybrid")).Count >= 5)
  24. {
  25. return true;
  26. }
  27. }
  28. }
  29. return false;
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  32. permanentCondition: PermanentCondition,
  33. digivolutionCost: 4,
  34. ignoreDigivolutionRequirement: false,
  35. card: card,
  36. condition: null)
  37. );
  38. }
  39. #endregion
  40. #region Blocker
  41. if (timing == EffectTiming.None)
  42. {
  43. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  44. isInheritedEffect: false,
  45. card: card,
  46. condition: null));
  47. }
  48. #endregion
  49. #endregion
  50. #region When Digivolving
  51. if (timing == EffectTiming.OnEnterFieldAnyone)
  52. {
  53. ActivateClass activateClass = new ActivateClass();
  54. activateClass.SetUpICardEffect("Delete 1 digimon", CanUseCondition, card);
  55. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  56. cardEffects.Add(activateClass);
  57. string EffectDiscription()
  58. {
  59. return "[When Digivolving] Delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  64. {
  65. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. bool CanActivateCondition(Hashtable hashtable)
  73. {
  74. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  75. {
  76. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. bool CanSelectPermanentCondition(Permanent permanent)
  84. {
  85. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  86. {
  87. if (permanent.DP <= card.PermanentOfThisCard().DP)
  88. {
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94. IEnumerator ActivateCoroutine(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  97. {
  98. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  99. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  100. selectPermanentEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: CanSelectPermanentCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: maxCount,
  106. canNoSelect: false,
  107. canEndNotMax: false,
  108. selectPermanentCoroutine: null,
  109. afterSelectPermanentCoroutine: null,
  110. mode: SelectPermanentEffect.Mode.Destroy,
  111. cardEffect: activateClass);
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. }
  114. }
  115. }
  116. #endregion
  117. #region All Turns
  118. if (timing == EffectTiming.None)
  119. {
  120. int count()
  121. {
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. return card.PermanentOfThisCard().DigivolutionCardsColors.Count;
  125. }
  126. return 0;
  127. }
  128. bool Condition()
  129. {
  130. if (CardEffectCommons.IsExistOnBattleArea(card))
  131. {
  132. if (count() >= 1)
  133. {
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(changeValue: () => 1000 * count(), isInheritedEffect: false, card: card, condition: Condition));
  140. }
  141. #endregion
  142. #region End of your turn OPT
  143. if (timing == EffectTiming.OnEndTurn)
  144. {
  145. ActivateClass activateClass = new ActivateClass();
  146. activateClass.SetUpICardEffect("", CanUseCondition, card);
  147. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  148. activateClass.SetHashString("Unsuspend_P_185");
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. {
  152. return "[End of Your Turn] [Once Per Turn] This Digimon unsuspends.";
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  157. {
  158. if (CardEffectCommons.IsOwnerTurn(card))
  159. {
  160. return true;
  161. }
  162. }
  163. return false;
  164. }
  165. bool CanActivateCondition(Hashtable hashtable)
  166. {
  167. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  168. {
  169. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  170. {
  171. return true;
  172. }
  173. }
  174. return false;
  175. }
  176. IEnumerator ActivateCoroutine(Hashtable hashtable)
  177. {
  178. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent> { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  179. }
  180. }
  181. #endregion
  182. return cardEffects;
  183. }
  184. }
  185. }