AD1_002.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Aldamon
  5. namespace DCGO.CardEffects.AD1
  6. {
  7. public class AD1_002 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Takuya Kanbara")
  18. && targetPermanent.DigivolutionCards.Count(cardSource => cardSource.EqualsTraits("Hybrid")) >= 2;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Rush
  30. if (timing == EffectTiming.None)
  31. {
  32. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region When Digivolving
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Delete 1 enemy digimon with equal or less DP", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  41. cardEffects.Add(activateClass);
  42. string EffectDescription()
  43. {
  44. return "[When Digivolving] Delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  49. && CardEffectCommons.IsExistOnBattleArea(card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnBattleArea(card);
  54. }
  55. bool ValidOpponentDigimon(Permanent permanent)
  56. {
  57. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  58. && permanent.HasDP
  59. && permanent.DP <= card.PermanentOfThisCard().DP;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.HasMatchConditionPermanent(ValidOpponentDigimon))
  64. {
  65. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  66. selectPermanentEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: ValidOpponentDigimon,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: 1,
  72. canNoSelect: false,
  73. canEndNotMax: false,
  74. selectPermanentCoroutine: null,
  75. afterSelectPermanentCoroutine: null,
  76. mode: SelectPermanentEffect.Mode.Destroy,
  77. cardEffect: activateClass);
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. }
  80. }
  81. }
  82. #endregion
  83. #region Shared EoA/OD
  84. string SharedEffectName = "May trash 1 [Hybrid]/[Ten Warriors] card, if so <Draw 2>, then may play 1 R/U/G tamer with inherits from hand or trash for free";
  85. CardEffectFactory.ActivateClassesForSharedEffects
  86. (ref cardEffects, timing, card,
  87. SharedEffectName,
  88. SharedActivateCoroutine,
  89. SharedEffectDescription,
  90. optional: false,
  91. endOfAttack: true,
  92. onDeletion: true);
  93. string SharedEffectDescription(string tag)
  94. {
  95. return $"[{tag}] You may trash 1 [Hybrid] or [Ten Warriors] trait card from your hand. If this effect trashed, <Draw 2>. Then, you may play 1 red, blue or green Tamer card with inherited effects from your hand or trash without paying the cost.";
  96. }
  97. bool CanSelectTrashCondition(CardSource cardSource)
  98. {
  99. return cardSource.EqualsTraits("Hybrid")
  100. || cardSource.EqualsTraits("Ten Warriors");
  101. }
  102. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  103. {
  104. bool discarded = false;
  105. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  106. selectHandEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectTrashCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: 1,
  112. canNoSelect: true,
  113. canEndNotMax: false,
  114. isShowOpponent: true,
  115. selectCardCoroutine: null,
  116. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  117. mode: SelectHandEffect.Mode.Discard,
  118. cardEffect: activateClass);
  119. selectHandEffect.SetUpCustomMessage("Select 1 Card to trash.", "The opponent is selecting 1 card to trash from their hand.");
  120. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  121. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  122. {
  123. if (cardSources.Count >= 1)
  124. {
  125. discarded = true;
  126. yield return null;
  127. }
  128. }
  129. if (discarded)
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  132. }
  133. bool CanSelectPlayCondition(CardSource cardSource)
  134. {
  135. return cardSource.IsTamer
  136. && (cardSource.HasCardColor(CardColor.Red)
  137. || cardSource.HasCardColor(CardColor.Blue)
  138. || cardSource.HasCardColor(CardColor.Green))
  139. && cardSource.HasInheritedEffect
  140. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  141. }
  142. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectPlayCondition);
  143. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectPlayCondition);
  144. if (canSelectHand || canSelectTrash)
  145. {
  146. #region Setup Location Selection
  147. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  148. if (canSelectHand)
  149. {
  150. selectionElements.Add(new(message: $"From hand", value: 1, spriteIndex: 0));
  151. }
  152. if (canSelectTrash)
  153. {
  154. selectionElements.Add(new(message: $"From trash", value: 2, spriteIndex: 0));
  155. }
  156. selectionElements.Add(new(message: $"Do not play", value: 3, spriteIndex: 1));
  157. string selectPlayerMessage = "From which area do you select a card?";
  158. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  159. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  160. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  161. #endregion
  162. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  163. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedIntValue == 1 ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  164. if (doPlay)
  165. {
  166. #region Hand/Trash Card Selection & Play
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  168. canTargetCondition: CanSelectPlayCondition,
  169. root,
  170. activateClass,
  171. payCost: false
  172. ));
  173. #endregion
  174. }
  175. }
  176. }
  177. #endregion
  178. #region Your Turn - ESS
  179. if (timing == EffectTiming.None)
  180. {
  181. bool Condition()
  182. {
  183. return CardEffectCommons.IsExistOnBattleArea(card) &&
  184. CardEffectCommons.IsOwnerTurn(card);
  185. }
  186. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 4000, isInheritedEffect: true,
  187. card: card, condition: Condition));
  188. }
  189. #endregion
  190. return cardEffects;
  191. }
  192. }
  193. }