EX11_050.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Loudmon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_050 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel4
  18. && (targetPermanent.TopCard.EqualsTraits("Dark Dragon")
  19. || targetPermanent.TopCard.EqualsTraits("Evil Dragon"));
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Shared OP / WD
  25. string SharedEffectName() => "Discard 2, delete 1 opponent's digimon with less DP then a [Dark Dragon]/[Evil Dragon] trait digimon.";
  26. string SharedEffectDescription(string tag) => $"[{tag}] Trash 2 cards in your hand. Then, delete 1 of your opponent's Digimon with as much or less DP as 1 of your [Dark Dragon] or [Evil Dragon] trait Digimon.";
  27. bool SharedCanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  30. }
  31. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  32. {
  33. if (card.Owner.HandCards.Count >= 1)
  34. {
  35. int discardCount = Math.Min(2, card.Owner.HandCards.Count);
  36. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  37. selectHandEffect.SetUp(
  38. selectPlayer: card.Owner,
  39. canTargetCondition: (cardSource) => true,
  40. canTargetCondition_ByPreSelecetedList: null,
  41. canEndSelectCondition: null,
  42. maxCount: discardCount,
  43. canNoSelect: false,
  44. canEndNotMax: false,
  45. isShowOpponent: true,
  46. selectCardCoroutine: null,
  47. afterSelectCardCoroutine: null,
  48. mode: SelectHandEffect.Mode.Discard,
  49. cardEffect: activateClass);
  50. yield return StartCoroutine(selectHandEffect.Activate());
  51. }
  52. #region Delete Digimon Setup
  53. Permanent selectedOwnerDigimon = null;
  54. bool CanSelectOwnerDigimon(Permanent permanent)
  55. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  56. bool HasDigimonAbleToDelete()
  57. {
  58. return card.Owner.GetBattleAreaDigimons().Some(ownersPermanent => CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent => CanSelectOpponentDigimon(permanent, ownersPermanent)));
  59. }
  60. bool CanSelectOpponentDigimon(Permanent permanent, Permanent ownersPermanent)
  61. {
  62. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  63. permanent.DP <= ownersPermanent.DP;
  64. }
  65. #endregion
  66. #region Select Digimon to Compare
  67. if (HasDigimonAbleToDelete())
  68. {
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectOwnerDigimon,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: 1,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: SelectPermanentCoroutine,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectPermanentEffect.SetUpCustomMessage("Select 1 of your Digimon. You will next be deleting a Digimon with less DP than this to delete.", "The opponent is selecting 1 Digimon");
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. selectedOwnerDigimon = permanent;
  86. yield return null;
  87. }
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. }
  90. #endregion
  91. #region Select Digimon To Delete
  92. if (selectedOwnerDigimon != null && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent => CanSelectOpponentDigimon(permanent, selectedOwnerDigimon)))
  93. {
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. selectPermanentEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: permanent => CanSelectOpponentDigimon(permanent, selectedOwnerDigimon),
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: 1,
  101. canNoSelect: false,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: null,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Destroy,
  106. cardEffect: activateClass);
  107. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete");
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. }
  110. #endregion
  111. }
  112. #endregion
  113. #region On Play
  114. if (timing == EffectTiming.OnEnterFieldAnyone)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  118. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("On Play"));
  119. cardEffects.Add(activateClass);
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  123. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  124. }
  125. }
  126. #endregion
  127. #region When Digivolving
  128. if (timing == EffectTiming.OnEnterFieldAnyone)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  132. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  133. cardEffects.Add(activateClass);
  134. bool CanUseCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  137. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  138. }
  139. }
  140. #endregion
  141. #region All Turns
  142. if (timing == EffectTiming.None)
  143. {
  144. AddSkillClass addSkillClass = new AddSkillClass();
  145. addSkillClass.SetUpICardEffect("Your [Dark Dragon]/[Evil Dragon] trait Digimon gain Scapegoat", CanUseCondition, card);
  146. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  147. cardEffects.Add(addSkillClass);
  148. bool CanUseCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  151. && card.Owner.HandCards.Count <= 4;
  152. }
  153. bool PermanentCondition(Permanent permanent)
  154. {
  155. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  156. && (permanent.TopCard.EqualsTraits("Dark Dragon")
  157. || permanent.TopCard.EqualsTraits("Evil Dragon"));
  158. }
  159. bool CardSourceCondition(CardSource cardSource)
  160. {
  161. return CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource)
  162. && cardSource == cardSource.PermanentOfThisCard().TopCard
  163. && PermanentCondition(cardSource.PermanentOfThisCard());
  164. }
  165. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  166. {
  167. if (_timing == EffectTiming.WhenPermanentWouldBeDeleted)
  168. {
  169. bool Condition()
  170. {
  171. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(cardSource.PermanentOfThisCard(), card)
  172. && (cardSource.EqualsTraits("Dark Dragon")
  173. || cardSource.EqualsTraits("Evil Dragon"));
  174. }
  175. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: cardSource, condition: Condition, effectName: "<Scapegoat>", effectDiscription: null));
  176. }
  177. return cardEffects;
  178. }
  179. }
  180. #endregion
  181. #region Inherit
  182. if (timing == EffectTiming.None)
  183. {
  184. bool PermanentCondition(Permanent permanent)
  185. {
  186. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  187. && (permanent.TopCard.ContainsTraits("Dark Dragon")
  188. || permanent.TopCard.ContainsTraits("Evil Dragon"));
  189. }
  190. bool CanUseCondition()
  191. {
  192. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  193. && CardEffectCommons.IsOwnerTurn(card)
  194. && card.Owner.HandCards.Count <= 4;
  195. }
  196. cardEffects.Add(CardEffectFactory.ChangeSAttackStaticEffect(PermanentCondition, 1, true, card, CanUseCondition));
  197. }
  198. #endregion
  199. return cardEffects;
  200. }
  201. }
  202. }