P_182.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // WarGreymon
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_182 : 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.IsLevel5)
  20. {
  21. if (targetPermanent.TopCard.ContainsCardName("MetalGreymon") || targetPermanent.TopCard.EqualsTraits("ADVENTURE"))
  22. {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  29. permanentCondition: PermanentCondition,
  30. digivolutionCost: 3,
  31. ignoreDigivolutionRequirement: false,
  32. card: card,
  33. condition: null)
  34. );
  35. }
  36. #endregion
  37. #region Sec +1
  38. if (timing == EffectTiming.None)
  39. {
  40. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  41. changeValue: 1,
  42. isInheritedEffect: false,
  43. card: card,
  44. condition: null));
  45. }
  46. #endregion
  47. #region Blocker
  48. if (timing == EffectTiming.None)
  49. {
  50. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  51. isInheritedEffect: false,
  52. card: card,
  53. condition: null));
  54. }
  55. #endregion
  56. #endregion
  57. #region When Digivolving
  58. if (timing == EffectTiming.OnEnterFieldAnyone)
  59. {
  60. ActivateClass activateClass = new ActivateClass();
  61. activateClass.SetUpICardEffect("Delete 1 digimon", CanUseCondition, card);
  62. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  63. cardEffects.Add(activateClass);
  64. string EffectDiscription()
  65. {
  66. return "[When Digivolving] Delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  67. }
  68. bool CanUseCondition(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  71. {
  72. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  73. {
  74. return true;
  75. }
  76. }
  77. return false;
  78. }
  79. bool CanActivateCondition(Hashtable hashtable)
  80. {
  81. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  82. {
  83. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  84. {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. bool CanSelectPermanentCondition(Permanent permanent)
  91. {
  92. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  93. {
  94. if (permanent.DP <= card.PermanentOfThisCard().DP)
  95. {
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. IEnumerator ActivateCoroutine(Hashtable hashtable)
  102. {
  103. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  104. {
  105. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanSelectPermanentCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: maxCount,
  113. canNoSelect: false,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: null,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Destroy,
  118. cardEffect: activateClass);
  119. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  120. }
  121. }
  122. }
  123. #endregion
  124. #region All Turns
  125. if (timing == EffectTiming.OnEnterFieldAnyone || timing == EffectTiming.AfterEffectsActivate)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  128. {
  129. Permanent thisPermanent = card.PermanentOfThisCard();
  130. if(Condition())
  131. thisPermanent.AddBoost(new Permanent.DPBoost("P_182", count(), Condition));
  132. else
  133. thisPermanent.RemoveBoost("P_182");
  134. }
  135. int count()
  136. {
  137. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  138. {
  139. List<CardSource> cards = card.Owner.GetBattleAreaPermanents()
  140. .Concat(card.Owner.Enemy.GetBattleAreaPermanents()).ToList()
  141. .Map(card => card.TopCard)
  142. .Where(x => x.IsDigimon || x.IsTamer).ToList();
  143. var colourCount = Combinations.GetDifferenetColorCardCount(cards);
  144. var newDP = colourCount * 1000;
  145. return newDP;
  146. }
  147. return 0;
  148. }
  149. bool Condition()
  150. {
  151. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  152. }
  153. /*bool PermanentCondition(Permanent permanent)
  154. {
  155. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  156. {
  157. if (permanent == card.PermanentOfThisCard())
  158. {
  159. return true;
  160. }
  161. }
  162. return false;
  163. }
  164. cardEffects.Add(CardEffectFactory.ChangeDPStaticEffect(
  165. permanentCondition: PermanentCondition,
  166. changeValue: count(),
  167. isInheritedEffect: false,
  168. card: card,
  169. condition: Condition,
  170. effectName: EffectDiscription));
  171. string EffectDiscription()
  172. {
  173. return "[All Turns] This Digimon gets +1000 DP for each color Digimon and Tamers have.";
  174. }*/
  175. }
  176. #endregion
  177. return cardEffects;
  178. }
  179. }
  180. }