P_182.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.None)
  126. {
  127. int count()
  128. {
  129. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  130. {
  131. List<CardSource> cards = card.Owner.GetBattleAreaPermanents()
  132. .Concat(card.Owner.Enemy.GetBattleAreaPermanents()).ToList()
  133. .Map(card => card.TopCard)
  134. .Where(x => x.IsDigimon || x.IsTamer).ToList();
  135. var colourCount = Combinations.GetDifferenetColorCardCount(cards);
  136. var newDP = colourCount * 1000;
  137. return newDP;
  138. }
  139. return 0;
  140. }
  141. bool Condition()
  142. {
  143. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  144. card.PermanentOfThisCard().TopCard == card;
  145. }
  146. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(
  147. changeValue: count,
  148. isInheritedEffect: false,
  149. card: card,
  150. condition: Condition));
  151. }
  152. #endregion
  153. return cardEffects;
  154. }
  155. }
  156. }