AD1_003.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Unity.Mathematics;
  5. // Wargrowlmon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_003 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.ContainsCardName("Growlmon")
  19. || targetPermanent.TopCard.EqualsTraits("Hero");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Raid
  25. if (timing == EffectTiming.OnAllyAttack)
  26. {
  27. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Shared OP / WD
  31. string SharedEffectName = "Play 1 [Takato Matsuki] from hand or trash for free, then may delete 1 opponent's Digimon w/ 6000 DP or less";
  32. string SharedEffectDescription(string tag) => $"[{tag}] You may play 1 [Takato Matsuki] from your hand or trash without paying the cost. Then, you may delete 1 of your opponent's Digimon with 6000 DP or less.";
  33. bool SharedCanActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  34. {
  35. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  36. && (CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCardCondition(cardSource, activateClass))
  37. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCardCondition(cardSource, activateClass))
  38. || CardEffectCommons.HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, activateClass)));
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource, ActivateClass activateClass)
  41. {
  42. return cardSource.EqualsCardName("Takato Matsuki")
  43. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent, ActivateClass activateClass)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  48. && permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass);
  49. }
  50. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  51. {
  52. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCardCondition(cardSource, activateClass));
  53. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCardCondition(cardSource, activateClass));
  54. if (canSelectHand || canSelectTrash)
  55. {
  56. #region Setup Location Selection
  57. if (canSelectHand && canSelectTrash)
  58. {
  59. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  60. {
  61. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  62. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  63. };
  64. string selectPlayerMessage = "From which area do you select a card?";
  65. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  66. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  67. }
  68. else
  69. {
  70. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  71. }
  72. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  73. #endregion
  74. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  75. CardSource selectedCard = null;
  76. IEnumerator SelectCardCoroutine(CardSource cardSource)
  77. {
  78. selectedCard = cardSource;
  79. yield return null;
  80. }
  81. #region Hand/Trash Card Selection & Play
  82. if (fromHand)
  83. {
  84. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  85. selectHandEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: cardSource => CanSelectCardCondition(cardSource, activateClass),
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: 1,
  91. canNoSelect: true,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. selectCardCoroutine: SelectCardCoroutine,
  95. afterSelectCardCoroutine: null,
  96. mode: SelectHandEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. selectHandEffect.SetUpCustomMessage("Select 1 [Takato Matsuki] to play.", "The opponent is selecting 1 [Takato Matsuki] to play.");
  99. yield return StartCoroutine(selectHandEffect.Activate());
  100. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  101. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Hand, true));
  102. }
  103. else
  104. {
  105. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  106. selectCardEffect.SetUp(
  107. canTargetCondition: cardSource => CanSelectCardCondition(cardSource, activateClass),
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. canNoSelect: () => true,
  111. selectCardCoroutine: SelectCardCoroutine,
  112. afterSelectCardCoroutine: null,
  113. message: "Select 1 [Takato Matsuki] to play.",
  114. maxCount: 1,
  115. canEndNotMax: false,
  116. isShowOpponent: true,
  117. mode: SelectCardEffect.Mode.Custom,
  118. root: SelectCardEffect.Root.Trash,
  119. customRootCardList: null,
  120. canLookReverseCard: true,
  121. selectPlayer: card.Owner,
  122. cardEffect: activateClass);
  123. selectCardEffect.SetUpCustomMessage("Select 1 [Takato Matsuki] to play.", "The opponent is selecting 1 [Takato Matsuki] to play.");
  124. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  125. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  126. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Trash, true));
  127. }
  128. #endregion
  129. }
  130. if(CardEffectCommons.HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, activateClass)))
  131. {
  132. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: permanent => CanSelectPermanentCondition(permanent, activateClass),
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: 1,
  139. canNoSelect: true,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: null,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.Destroy,
  144. cardEffect: activateClass);
  145. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  146. }
  147. }
  148. #endregion
  149. #region On Play
  150. if (timing == EffectTiming.OnEnterFieldAnyone)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  154. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  155. cardEffects.Add(activateClass);
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  159. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  160. }
  161. }
  162. #endregion
  163. #region When Digivolving
  164. if (timing == EffectTiming.OnEnterFieldAnyone)
  165. {
  166. ActivateClass activateClass = new ActivateClass();
  167. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  168. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  169. cardEffects.Add(activateClass);
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  173. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  174. }
  175. }
  176. #endregion
  177. #region All Turns
  178. if (timing == EffectTiming.WhenRemoveField)
  179. {
  180. ActivateClass activateClass = new ActivateClass();
  181. activateClass.SetUpICardEffect("Play 1 [Takato Matsuki] and [Guilmon] from source without paying the cost", CanUseCondition, card);
  182. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  183. activateClass.SetIsInheritedEffect(true);
  184. cardEffects.Add(activateClass);
  185. string EffectDiscription()
  186. {
  187. return "[All Turns] When this Digimon with [Gallantmon] in its name would leave the battle area other than by your effects, you may play 1 each of [Takato Matsuki] and [Guilmon] from its digivolution cards without paying the cost.";
  188. }
  189. bool CanSelectSourceCardCondition(CardSource cardSource)
  190. {
  191. return cardSource.EqualsCardName("Takato Matsuki") &&
  192. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  193. }
  194. bool CanSelectSourceCardCondition1(CardSource cardSource)
  195. {
  196. return cardSource.EqualsCardName("Guilmon") &&
  197. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  198. }
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  202. && card.PermanentOfThisCard().TopCard.ContainsCardName("Gallantmon")
  203. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  204. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  209. && (card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition)
  210. || card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition1));
  211. }
  212. IEnumerator ActivateCoroutine(Hashtable hashtable)
  213. {
  214. List<CardSource> selectedCards = new List<CardSource>();
  215. int maxCount = math.min(1, card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCardCondition));
  216. int maxCount1 = math.min(1, card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCardCondition1));
  217. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  218. selectCardEffect.SetUp(
  219. canTargetCondition: CanSelectSourceCardCondition,
  220. canTargetCondition_ByPreSelecetedList: null,
  221. canEndSelectCondition: null,
  222. canNoSelect: () => true,
  223. selectCardCoroutine: SelectCardCoroutine,
  224. afterSelectCardCoroutine: null,
  225. message: "Select 1 [Takato Matsuki] card to play.",
  226. maxCount: maxCount,
  227. canEndNotMax: false,
  228. isShowOpponent: true,
  229. mode: SelectCardEffect.Mode.Custom,
  230. root: SelectCardEffect.Root.DigivolutionCards,
  231. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  232. canLookReverseCard: true,
  233. selectPlayer: card.Owner,
  234. cardEffect: activateClass);
  235. selectCardEffect.SetUpCustomMessage(
  236. "Select 1 [Takato Matsuki] card to play.",
  237. "The opponent is selecting 1 [Takato Matsuki] card to play.");
  238. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  239. yield return StartCoroutine(selectCardEffect.Activate());
  240. SelectCardEffect selectCardEffect1 = GManager.instance.GetComponent<SelectCardEffect>();
  241. selectCardEffect1.SetUp(
  242. canTargetCondition: CanSelectSourceCardCondition1,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. canNoSelect: () => true,
  246. selectCardCoroutine: SelectCardCoroutine,
  247. afterSelectCardCoroutine: null,
  248. message: "Select 1 [Guilmon] card to play.",
  249. maxCount: maxCount1,
  250. canEndNotMax: false,
  251. isShowOpponent: true,
  252. mode: SelectCardEffect.Mode.Custom,
  253. root: SelectCardEffect.Root.DigivolutionCards,
  254. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  255. canLookReverseCard: true,
  256. selectPlayer: card.Owner,
  257. cardEffect: activateClass);
  258. selectCardEffect1.SetUpCustomMessage(
  259. "Select 1 [Guilmon] card to play.",
  260. "The opponent is selecting 1 [Guilmon] card to play.");
  261. selectCardEffect1.SetUpCustomMessage_ShowCard("Played Card");
  262. yield return StartCoroutine(selectCardEffect1.Activate());
  263. IEnumerator SelectCardCoroutine(CardSource cardSource)
  264. {
  265. selectedCards.Add(cardSource);
  266. yield return null;
  267. }
  268. yield return ContinuousController.instance.StartCoroutine(
  269. CardEffectCommons.PlayPermanentCards(
  270. cardSources: selectedCards,
  271. activateClass: activateClass,
  272. payCost: false,
  273. isTapped: false,
  274. root: SelectCardEffect.Root.DigivolutionCards,
  275. activateETB: true));
  276. }
  277. }
  278. #endregion
  279. return cardEffects;
  280. }
  281. }
  282. }