AD1_016.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  72. if (doPlay)
  73. {
  74. List<CardSource> selectedCards = new List<CardSource>();
  75. if (fromHand)
  76. {
  77. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: IsMarcusDamonCard,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: true,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: null,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.PlayForFree,
  90. cardEffect: activateClass);
  91. yield return StartCoroutine(selectHandEffect.Activate());
  92. }
  93. else
  94. {
  95. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  96. selectCardEffect.SetUp(
  97. canTargetCondition: IsMarcusDamonCard,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. canNoSelect: () => true,
  101. selectCardCoroutine: null,
  102. afterSelectCardCoroutine: null,
  103. message: "Select 1 card to play.",
  104. maxCount: 1,
  105. canEndNotMax: false,
  106. isShowOpponent: true,
  107. mode: SelectCardEffect.Mode.PlayForFree,
  108. root: SelectCardEffect.Root.Trash,
  109. customRootCardList: null,
  110. canLookReverseCard: true,
  111. selectPlayer: card.Owner,
  112. cardEffect: activateClass);
  113. yield return StartCoroutine(selectCardEffect.Activate());
  114. }
  115. }
  116. }
  117. if (card.Owner.Enemy.GetBattleAreaDigimons().Any())
  118. {
  119. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: IsOpponentsDigimon,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: 1,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: SelectPermanentCoroutine,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Custom,
  131. cardEffect: activateClass);
  132. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  133. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  134. {
  135. int changeAmount = -3000 * card.Owner.GetBattleAreaPermanents().Count(IsDigimonOrTamerPermanent);
  136. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: changeAmount, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  137. }
  138. }
  139. }
  140. #endregion
  141. #region When Digivolving
  142. if (timing == EffectTiming.OnEnterFieldAnyone)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  146. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  147. activateClass.SetHashString(SharedHashString);
  148. cardEffects.Add(activateClass);
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  152. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  153. }
  154. }
  155. #endregion
  156. #region When Attacking
  157. if (timing == EffectTiming.OnAllyAttack)
  158. {
  159. ActivateClass activateClass = new ActivateClass();
  160. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  161. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  162. activateClass.SetHashString(SharedHashString);
  163. cardEffects.Add(activateClass);
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.CanTriggerOnAttack(hashtable, card) &&
  167. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  168. }
  169. }
  170. #endregion
  171. #region All Turns
  172. string AllTurnsHashString = "AD1_016_AT";
  173. string AllTurnsEffectName = "Delete 1 enemy Digimon with s much or Less DP as this";
  174. string AllTurnsEffectDescription()
  175. => "[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.";
  176. bool IsYourMarcusDamon(Permanent permanent)
  177. {
  178. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  179. && permanent.TopCard.EqualsCardName("Marcus Damon");
  180. }
  181. bool IsWeakerEnemyDigimon(Permanent permanent)
  182. {
  183. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  184. && permanent.HasDP
  185. && permanent.DP <= card.PermanentOfThisCard().DP;
  186. }
  187. bool AllTurnsCanActivateCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.IsExistOnBattleArea(card)
  190. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerEnemyDigimon);
  191. }
  192. IEnumerator AllTurnsActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  193. {
  194. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  195. selectPermanentEffect.SetUp(
  196. selectPlayer: card.Owner,
  197. canTargetCondition: IsWeakerEnemyDigimon,
  198. canTargetCondition_ByPreSelecetedList: null,
  199. canEndSelectCondition: null,
  200. maxCount: 1,
  201. canNoSelect: false,
  202. canEndNotMax: false,
  203. selectPermanentCoroutine: null,
  204. afterSelectPermanentCoroutine: null,
  205. mode: SelectPermanentEffect.Mode.Destroy,
  206. cardEffect: activateClass);
  207. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  208. }
  209. if (timing == EffectTiming.OnEnterFieldAnyone)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  213. activateClass.SetUpActivateClass(AllTurnsCanActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, true, AllTurnsEffectDescription());
  214. activateClass.SetHashString(AllTurnsHashString);
  215. cardEffects.Add(activateClass);
  216. bool CanUseCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleArea(card)
  219. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsYourMarcusDamon);
  220. }
  221. }
  222. if (timing == EffectTiming.OnTappedAnyone)
  223. {
  224. ActivateClass activateClass = new ActivateClass();
  225. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  226. activateClass.SetUpActivateClass(AllTurnsCanActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, true, AllTurnsEffectDescription());
  227. activateClass.SetHashString(AllTurnsHashString);
  228. cardEffects.Add(activateClass);
  229. bool CanUseCondition(Hashtable hashtable)
  230. {
  231. return CardEffectCommons.IsExistOnBattleArea(card)
  232. && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, IsYourMarcusDamon);
  233. }
  234. }
  235. #endregion
  236. return cardEffects;
  237. }
  238. }
  239. }