AD1_016.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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.IsLevel5
  19. && (targetPermanent.TopCard.ContainsCardName("RizeGreymon")
  20. || targetPermanent.TopCard.EqualsTraits("DATA SQUAD"));
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Alliance
  26. if (timing == EffectTiming.OnAllyAttack)
  27. {
  28. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  29. }
  30. #endregion
  31. #region Blocker
  32. if (timing == EffectTiming.None)
  33. {
  34. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. #endregion
  37. #region Shared WD / WA
  38. string SharedHashString = "AD1_016_WD_WA";
  39. 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";
  40. 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.";
  41. bool IsMarcusDamonCard(CardSource cardSource) => cardSource.EqualsCardName("Marcus Damon");
  42. bool IsDigimonOrTamerPermanent(Permanent permanent) => permanent.IsDigimon || permanent.IsTamer;
  43. bool IsOpponentsDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  44. bool SharedCanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleArea(card);
  47. }
  48. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  49. {
  50. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, IsMarcusDamonCard);
  51. bool validTrashCard = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsMarcusDamonCard);
  52. if (validHandCard || validTrashCard)
  53. {
  54. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  55. int index = 0;
  56. if (validHandCard)
  57. {
  58. selectionElements.Add(new (message: $"Play Marcus Damon from hand", value : 1, spriteIndex: 0));
  59. index++;
  60. }
  61. if (validTrashCard)
  62. {
  63. selectionElements.Add(new (message: $"Play Marcus Damon from trash", value : 2, spriteIndex: 0));
  64. index++;
  65. };
  66. selectionElements.Add( new (message: $"Don't play", value: 3, spriteIndex: 1));
  67. string selectPlayerMessage = "From where will you play a Marcus Damon?";
  68. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  69. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  70. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  71. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  72. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  73. if (doPlay)
  74. {
  75. List<CardSource> selectedCards = new List<CardSource>();
  76. if (fromHand)
  77. {
  78. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  79. selectHandEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: IsMarcusDamonCard,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: 1,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. isShowOpponent: true,
  88. selectCardCoroutine: null,
  89. afterSelectCardCoroutine: null,
  90. mode: SelectHandEffect.Mode.PlayForFree,
  91. cardEffect: activateClass);
  92. yield return StartCoroutine(selectHandEffect.Activate());
  93. }
  94. else
  95. {
  96. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  97. selectCardEffect.SetUp(
  98. canTargetCondition: IsMarcusDamonCard,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. canNoSelect: () => true,
  102. selectCardCoroutine: null,
  103. afterSelectCardCoroutine: null,
  104. message: "Select 1 card to play.",
  105. maxCount: 1,
  106. canEndNotMax: false,
  107. isShowOpponent: true,
  108. mode: SelectCardEffect.Mode.PlayForFree,
  109. root: SelectCardEffect.Root.Trash,
  110. customRootCardList: null,
  111. canLookReverseCard: true,
  112. selectPlayer: card.Owner,
  113. cardEffect: activateClass);
  114. yield return StartCoroutine(selectCardEffect.Activate());
  115. }
  116. }
  117. }
  118. if (card.Owner.Enemy.GetBattleAreaDigimons().Any())
  119. {
  120. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. selectPermanentEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition: IsOpponentsDigimon,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. maxCount: 1,
  127. canNoSelect: false,
  128. canEndNotMax: false,
  129. selectPermanentCoroutine: SelectPermanentCoroutine,
  130. afterSelectPermanentCoroutine: null,
  131. mode: SelectPermanentEffect.Mode.Custom,
  132. cardEffect: activateClass);
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  135. {
  136. int changeAmount = -3000 * card.Owner.GetBattleAreaPermanents().Count(IsDigimonOrTamerPermanent);
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: changeAmount, effectDuration: EffectDuration.UntilOwnerTurnEnd, activateClass: activateClass));
  138. }
  139. }
  140. }
  141. #endregion
  142. #region When Digivolving
  143. if (timing == EffectTiming.OnEnterFieldAnyone)
  144. {
  145. ActivateClass activateClass = new ActivateClass();
  146. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  147. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  148. activateClass.SetHashString(SharedHashString);
  149. cardEffects.Add(activateClass);
  150. bool CanUseCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  153. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  154. }
  155. }
  156. #endregion
  157. #region When Attacking
  158. if (timing == EffectTiming.OnAllyAttack)
  159. {
  160. ActivateClass activateClass = new ActivateClass();
  161. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  162. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  163. activateClass.SetHashString(SharedHashString);
  164. cardEffects.Add(activateClass);
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.CanTriggerOnAttack(hashtable, card) &&
  168. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  169. }
  170. }
  171. #endregion
  172. #region All Turns
  173. string AllTurnsHashString = "AD1_016_AT";
  174. string AllTurnsEffectName = "Delete 1 enemy Digimon with s much or Less DP as this";
  175. string AllTurnsEffectDescription()
  176. => "[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.";
  177. bool IsYourMarcusDamon(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  180. && permanent.TopCard.EqualsCardName("Marcus Damon");
  181. }
  182. bool IsWeakerEnemyDigimon(Permanent permanent)
  183. {
  184. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  185. && permanent.HasDP
  186. && permanent.DP <= card.PermanentOfThisCard().DP;
  187. }
  188. bool AllTurnsCanActivateCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.IsExistOnBattleArea(card)
  191. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerEnemyDigimon);
  192. }
  193. IEnumerator AllTurnsActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  194. {
  195. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: IsWeakerEnemyDigimon,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: 1,
  202. canNoSelect: false,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: null,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Destroy,
  207. cardEffect: activateClass);
  208. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  209. }
  210. if (timing == EffectTiming.OnEnterFieldAnyone)
  211. {
  212. ActivateClass activateClass = new ActivateClass();
  213. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  214. activateClass.SetUpActivateClass(AllTurnsCanActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, true, AllTurnsEffectDescription());
  215. activateClass.SetHashString(AllTurnsHashString);
  216. cardEffects.Add(activateClass);
  217. bool CanUseCondition(Hashtable hashtable)
  218. {
  219. return CardEffectCommons.IsExistOnBattleArea(card)
  220. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsYourMarcusDamon);
  221. }
  222. }
  223. if (timing == EffectTiming.OnTappedAnyone)
  224. {
  225. ActivateClass activateClass = new ActivateClass();
  226. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  227. activateClass.SetUpActivateClass(AllTurnsCanActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, true, AllTurnsEffectDescription());
  228. activateClass.SetHashString(AllTurnsHashString);
  229. cardEffects.Add(activateClass);
  230. bool CanUseCondition(Hashtable hashtable)
  231. {
  232. return CardEffectCommons.IsExistOnBattleArea(card)
  233. && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, IsYourMarcusDamon);
  234. }
  235. }
  236. #endregion
  237. return cardEffects;
  238. }
  239. }
  240. }