EX10_030.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //EX10 Cometmon
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_030 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region App Fusion (Warpmon, Weatherdramon)
  14. if (timing == EffectTiming.None)
  15. {
  16. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Warpmon", "Weatherdramon" }, card));
  17. }
  18. #endregion
  19. #region Alternative Digivolution Condition
  20. if (timing == EffectTiming.None)
  21. {
  22. bool PermanentCondition(Permanent targetPermanent)
  23. {
  24. return targetPermanent.TopCard.HasSuperAppTraits;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Link Condition
  30. if (timing == EffectTiming.None)
  31. {
  32. static bool PermanentCondition(Permanent targetPermanent)
  33. {
  34. return targetPermanent.TopCard.HasAppmonTraits;
  35. }
  36. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  37. }
  38. #endregion
  39. #region Link
  40. if (timing == EffectTiming.OnDeclaration)
  41. {
  42. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  43. }
  44. #endregion
  45. #region Collision
  46. if (timing == EffectTiming.OnCounterTiming)
  47. {
  48. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  49. }
  50. #endregion
  51. #endregion
  52. #region On Play/When Digivolving shared
  53. bool CanActivateConditionShared(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  56. (card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardConditionShared(x)).Count > 0 ||
  57. card.Owner.HandCards.Count > 0);
  58. }
  59. bool CanSelectCardConditionShared(CardSource source)
  60. {
  61. if (source.IsDigimon)
  62. {
  63. if (source.HasLevel && source.Level <= 4)
  64. {
  65. if (source.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  74. {
  75. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared);
  76. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardConditionShared(x)).Count > 0;
  77. if (canSelectHand || canSelectSources)
  78. {
  79. if (canSelectHand && canSelectSources)
  80. {
  81. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  82. {
  83. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  84. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  85. };
  86. string selectPlayerMessage = "From which area do you select a card?";
  87. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  88. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  89. }
  90. else
  91. {
  92. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  93. }
  94. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  95. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  96. CardSource selectedCard = null;
  97. if (fromHand)
  98. {
  99. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardConditionShared));
  100. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  101. selectHandEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanSelectCardConditionShared,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: maxCount,
  107. canNoSelect: true,
  108. canEndNotMax: false,
  109. isShowOpponent: true,
  110. selectCardCoroutine: SelectCardCoroutine,
  111. afterSelectCardCoroutine: null,
  112. mode: SelectHandEffect.Mode.Custom,
  113. cardEffect: activateClass);
  114. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  115. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  116. yield return StartCoroutine(selectHandEffect.Activate());
  117. }
  118. else
  119. {
  120. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  121. selectCardEffect.SetUp(
  122. canTargetCondition: CanSelectCardConditionShared,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. canNoSelect: () => true,
  126. selectCardCoroutine: SelectCardCoroutine,
  127. afterSelectCardCoroutine: null,
  128. message: "Select 1 card to add as source.",
  129. maxCount: 1,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. mode: SelectCardEffect.Mode.Custom,
  133. root: SelectCardEffect.Root.DigivolutionCards,
  134. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  135. canLookReverseCard: true,
  136. selectPlayer: card.Owner,
  137. cardEffect: activateClass);
  138. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  139. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  140. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  141. }
  142. IEnumerator SelectCardCoroutine(CardSource cardSource)
  143. {
  144. selectedCard = cardSource;
  145. yield return null;
  146. }
  147. if (selectedCard != null)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCard, activateClass));
  150. }
  151. }
  152. }
  153. #endregion
  154. #region On Play
  155. if (timing == EffectTiming.OnEnterFieldAnyone)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("You may Link 1 level 4 or lower digimon", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateConditionShared, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDescription());
  160. cardEffects.Add(activateClass);
  161. string EffectDescription()
  162. {
  163. return "[On Play] You may link 1 level 4 or lower Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  168. {
  169. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  170. {
  171. return true;
  172. }
  173. }
  174. return false;
  175. }
  176. }
  177. #endregion
  178. #region When Digivolving
  179. if (timing == EffectTiming.OnEnterFieldAnyone)
  180. {
  181. ActivateClass activateClass = new ActivateClass();
  182. activateClass.SetUpICardEffect("You may Link 1 level 4 or lower digimon", CanUseCondition, card);
  183. activateClass.SetUpActivateClass(CanActivateConditionShared, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDescription());
  184. cardEffects.Add(activateClass);
  185. string EffectDescription()
  186. {
  187. return "[When Digivolving] You may link 1 level 4 or lower Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  188. }
  189. bool CanUseCondition(Hashtable hashtable)
  190. {
  191. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  192. {
  193. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. }
  201. #endregion
  202. #region All turns when link trash
  203. if (timing == EffectTiming.OnLinkCardDiscarded)
  204. {
  205. ActivateClass activateClass = new ActivateClass();
  206. activateClass.SetUpICardEffect("-8k opposing digimon", CanUseCondition, card);
  207. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  208. activateClass.SetHashString("MinusEX10_030");
  209. cardEffects.Add(activateClass);
  210. string EffectDescription()
  211. {
  212. return "[All Turns] [Once Per Turn] When effects trash any of this Digimon's link cards, 1 of your opponent's Digimon gets -8000 DP for the turn.";
  213. }
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  217. CardEffectCommons.CanTriggerOnTrashLinkedCard(hashtable, perm => perm == card.PermanentOfThisCard(), cardEffect => cardEffect != null, source => source != null);
  218. }
  219. bool CanActivateCondition(Hashtable hashtable)
  220. {
  221. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  222. }
  223. bool IsOpponentsDigimon(Permanent permanent)
  224. {
  225. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable hashtable)
  228. {
  229. Permanent selectedPermament = null;
  230. #region Select Opponent Digimon
  231. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentsDigimon));
  232. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  233. selectPermanentEffect.SetUp(
  234. selectPlayer: card.Owner,
  235. canTargetCondition: IsOpponentsDigimon,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. maxCount: maxCount,
  239. canNoSelect: false,
  240. canEndNotMax: false,
  241. selectPermanentCoroutine: SelectPermanentCoroutine,
  242. afterSelectPermanentCoroutine: null,
  243. mode: SelectPermanentEffect.Mode.Custom,
  244. cardEffect: activateClass);
  245. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  246. {
  247. selectedPermament = permanent;
  248. yield return null;
  249. }
  250. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to get -6k DP", "The opponent is selecting 1 Digimon to get -6k DP");
  251. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  252. #endregion
  253. if (selectedPermament != null)
  254. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  255. targetPermanent: selectedPermament,
  256. changeValue: -8000,
  257. effectDuration: EffectDuration.UntilEachTurnEnd,
  258. activateClass: activateClass));
  259. }
  260. }
  261. #endregion
  262. #region Link effect
  263. if (timing == EffectTiming.WhenRemoveField)
  264. {
  265. ActivateClass activateClass = new ActivateClass();
  266. activateClass.SetUpICardEffect("Trash a linked card to prevent this digimon from leaving", CanUseCondition, card);
  267. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  268. activateClass.SetIsInheritedEffect(true);
  269. activateClass.SetHashString("Protection_EX10-030");
  270. cardEffects.Add(activateClass);
  271. string EffectDescription()
  272. {
  273. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area, by trashing 1 of this Digimon's link cards, it doesn't leave.";
  274. }
  275. bool CanUseCondition(Hashtable hashtable)
  276. {
  277. return CardEffectCommons.IsExistLinked(card) &&
  278. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  279. }
  280. bool CanActivateCondition(Hashtable hashtable)
  281. {
  282. return CardEffectCommons.IsExistLinked(card) &&
  283. !card.PermanentOfThisCard().HasNoLinkCards;
  284. }
  285. IEnumerator ActivateCoroutine(Hashtable hashtable)
  286. {
  287. Permanent thisPermanent = card.PermanentOfThisCard();
  288. CardSource selectedCard = null;
  289. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  290. selectCardEffect.SetUp(
  291. canTargetCondition: _ => true,
  292. canTargetCondition_ByPreSelecetedList: null,
  293. canEndSelectCondition: null,
  294. canNoSelect: () => true,
  295. selectCardCoroutine: SelectCardCoroutine,
  296. afterSelectCardCoroutine: null,
  297. message: "Select 1 link card to trash.",
  298. maxCount: 1,
  299. canEndNotMax: false,
  300. isShowOpponent: true,
  301. mode: SelectCardEffect.Mode.Custom,
  302. root: SelectCardEffect.Root.Custom,
  303. customRootCardList: card.PermanentOfThisCard().LinkedCards,
  304. canLookReverseCard: true,
  305. selectPlayer: card.Owner,
  306. cardEffect: activateClass);
  307. IEnumerator SelectCardCoroutine(CardSource cardSource)
  308. {
  309. selectedCard = cardSource;
  310. yield return null;
  311. }
  312. selectCardEffect.SetUpCustomMessage("Select 1 link card to trash.", "The opponent is selecting 1 link card to trash.");
  313. yield return StartCoroutine(selectCardEffect.Activate());
  314. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  315. targetPermanent: thisPermanent,
  316. targetLinkCards: new List<CardSource>() { selectedCard },
  317. activateClass: activateClass,
  318. successProcess: SuccessProcess,
  319. failureProcess: null));
  320. IEnumerator SuccessProcess(List<CardSource> cardSources)
  321. {
  322. thisPermanent.willBeRemoveField = false;
  323. thisPermanent.HideHandBounceEffect();
  324. thisPermanent.HideDeckBounceEffect();
  325. thisPermanent.HideWillRemoveFieldEffect();
  326. thisPermanent.HideDeleteEffect();
  327. yield return null;
  328. }
  329. }
  330. }
  331. #endregion
  332. return cardEffects;
  333. }
  334. }
  335. }