AD1_016.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // ShineGreymon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_016 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolve Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.ContainsCardName("RizeGreymon")
  19. || targetPermanent.TopCard.EqualsTraits("DATA SQUAD");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Alliance
  25. if (timing == EffectTiming.OnAllyAttack)
  26. {
  27. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Blocker
  31. if (timing == EffectTiming.None)
  32. {
  33. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. #endregion
  36. #region Shared WD / WA
  37. string SharedHashString = "AD1_016_WD_WA";
  38. string SharedEffectName = "You may play [Marcus Damon] from hand or trash for free. The 1 enemy gets -3k DP for each of your Digimon or Tamers";
  39. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] You may play 1 [Marcus Damon] from your hand or trash without paying the cost. Then, to 1 of your opponent's Digimon, give -3000 DP for each of your Digimon and Tamers until their turn ends.";
  40. bool IsMarcusDamonCard(CardSource cardSource) => cardSource.EqualsCardName("Marcus Damon");
  41. bool IsDigimonOrTamerPermanent(Permanent permanent) => permanent.IsDigimon || permanent.IsTamer;
  42. bool IsOpponentsDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  43. bool SharedCanActivateCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnBattleArea(card);
  46. }
  47. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  48. {
  49. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, IsMarcusDamonCard);
  50. bool validTrashCard = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsMarcusDamonCard);
  51. if (validHandCard || validTrashCard)
  52. {
  53. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  54. int index = 0;
  55. if (validHandCard)
  56. {
  57. selectionElements.Add(new (message: $"Play Marcus Damon from hand", value : 1, spriteIndex: 0));
  58. index++;
  59. }
  60. if (validTrashCard)
  61. {
  62. selectionElements.Add(new (message: $"Play Marcus Damon from trash", value : 2, spriteIndex: 0));
  63. index++;
  64. };
  65. selectionElements.Add( new (message: $"Don't play", value: 3, spriteIndex: 1));
  66. string selectPlayerMessage = "From where will you play a Marcus Damon?";
  67. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  68. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  69. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  70. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  71. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedIntValue == 1 ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  72. if (doPlay)
  73. {
  74. #region Hand/Trash Card Selection & Play
  75. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  76. canTargetCondition: IsMarcusDamonCard,
  77. root,
  78. activateClass,
  79. payCost: false
  80. ));
  81. #endregion
  82. }
  83. }
  84. if (card.Owner.Enemy.GetBattleAreaDigimons().Any())
  85. {
  86. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  87. selectPermanentEffect.SetUp(
  88. selectPlayer: card.Owner,
  89. canTargetCondition: IsOpponentsDigimon,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. maxCount: 1,
  93. canNoSelect: false,
  94. canEndNotMax: false,
  95. selectPermanentCoroutine: SelectPermanentCoroutine,
  96. afterSelectPermanentCoroutine: null,
  97. mode: SelectPermanentEffect.Mode.Custom,
  98. cardEffect: activateClass);
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  101. {
  102. int changeAmount = -3000 * card.Owner.GetBattleAreaPermanents().Count(IsDigimonOrTamerPermanent);
  103. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: changeAmount, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  104. }
  105. }
  106. }
  107. #endregion
  108. #region When Digivolving
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  113. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  114. activateClass.SetHashString(SharedHashString);
  115. cardEffects.Add(activateClass);
  116. bool CanUseCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  119. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  120. }
  121. }
  122. #endregion
  123. #region When Attacking
  124. if (timing == EffectTiming.OnAllyAttack)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  128. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  129. activateClass.SetHashString(SharedHashString);
  130. cardEffects.Add(activateClass);
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerOnAttack(hashtable, card) &&
  134. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  135. }
  136. }
  137. #endregion
  138. #region All Turns
  139. string AllTurnsHashString = "AD1_016_AT";
  140. string AllTurnsEffectName = "Delete 1 enemy Digimon with s much or Less DP as this";
  141. string AllTurnsEffectDescription()
  142. => "[All Turns] [Once Per Turn] When any of your [Marcus Damon]s are played or suspend, you may delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  143. bool IsYourMarcusDamon(Permanent permanent)
  144. {
  145. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  146. && permanent.TopCard.EqualsCardName("Marcus Damon");
  147. }
  148. bool IsWeakerEnemyDigimon(Permanent permanent)
  149. {
  150. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  151. && permanent.HasDP
  152. && permanent.DP <= card.PermanentOfThisCard().DP;
  153. }
  154. bool AllTurnsCanActivateCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.IsExistOnBattleArea(card)
  157. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerEnemyDigimon);
  158. }
  159. IEnumerator AllTurnsActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  160. {
  161. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  162. selectPermanentEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: IsWeakerEnemyDigimon,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: 1,
  168. canNoSelect: false,
  169. canEndNotMax: false,
  170. selectPermanentCoroutine: null,
  171. afterSelectPermanentCoroutine: null,
  172. mode: SelectPermanentEffect.Mode.Destroy,
  173. cardEffect: activateClass);
  174. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  175. }
  176. if (timing == EffectTiming.OnEnterFieldAnyone)
  177. {
  178. ActivateClass activateClass = new ActivateClass();
  179. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  180. activateClass.SetUpActivateClass(AllTurnsCanActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, true, AllTurnsEffectDescription());
  181. activateClass.SetHashString(AllTurnsHashString);
  182. cardEffects.Add(activateClass);
  183. bool CanUseCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.IsExistOnBattleArea(card)
  186. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsYourMarcusDamon);
  187. }
  188. }
  189. if (timing == EffectTiming.OnTappedAnyone)
  190. {
  191. ActivateClass activateClass = new ActivateClass();
  192. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  193. activateClass.SetUpActivateClass(AllTurnsCanActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, true, AllTurnsEffectDescription());
  194. activateClass.SetHashString(AllTurnsHashString);
  195. cardEffects.Add(activateClass);
  196. bool CanUseCondition(Hashtable hashtable)
  197. {
  198. return CardEffectCommons.IsExistOnBattleArea(card)
  199. && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, IsYourMarcusDamon);
  200. }
  201. }
  202. #endregion
  203. return cardEffects;
  204. }
  205. }
  206. }