EX10_045.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. //Tuwarmon
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_045 : 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 Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Damemon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Digixros
  24. if (timing == EffectTiming.None)
  25. {
  26. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  27. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  28. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  29. addDigiXrosConditionClass.SetNotShowUI(true);
  30. cardEffects.Add(addDigiXrosConditionClass);
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return true;
  34. }
  35. DigiXrosCondition GetDigiXros(CardSource cardSource)
  36. {
  37. if (cardSource == card)
  38. {
  39. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Damemon");
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. if (cardSource != null)
  43. {
  44. if (cardSource.Owner == card.Owner)
  45. {
  46. if (cardSource.IsDigimon)
  47. {
  48. if (cardSource.CardNames_DigiXros.Contains("Damemon"))
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "ChuuChuumon");
  58. bool CanSelectCardCondition1(CardSource cardSource)
  59. {
  60. if (cardSource != null)
  61. {
  62. if (cardSource.Owner == card.Owner)
  63. {
  64. if (cardSource.IsDigimon)
  65. {
  66. if (cardSource.CardNames_DigiXros.Contains("ChuuChuumon"))
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. }
  73. return false;
  74. }
  75. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  76. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  77. return digiXrosCondition;
  78. }
  79. return null;
  80. }
  81. }
  82. #endregion
  83. #region Collision
  84. if (timing == EffectTiming.OnCounterTiming)
  85. {
  86. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  87. }
  88. #endregion
  89. #region Rush
  90. if (timing == EffectTiming.None)
  91. {
  92. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  93. }
  94. #endregion
  95. #endregion
  96. #region OP/WD/WA Shared
  97. string SharedEffectDiscription(string tag)
  98. {
  99. return $"[{tag}] [Once Per Turn] By trashing any 1 digivolution card of your [Bagra Army] trait Digimon, 1 of your [Bagra Army] trait Digimon gains <Blocker> and <Retaliation> until your opponent's turn ends.";
  100. }
  101. bool CanActivateConditionShared(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  104. }
  105. bool CanSelectPermanent(Permanent permanent)
  106. {
  107. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  108. permanent.TopCard.CardTraits.Contains("Bagra Army");
  109. }
  110. bool CanSelectPermamentTrashDigivolution(Permanent permanent)
  111. {
  112. return CanSelectPermanent(permanent)
  113. && permanent.DigivolutionCards.Count > 0;
  114. }
  115. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  116. {
  117. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentTrashDigivolution))
  118. {
  119. #region Select Permanent to trash Digivolution Cards
  120. Permanent selectedPermanment = null;
  121. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermamentTrashDigivolution));
  122. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  123. selectPermanentEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectPermamentTrashDigivolution,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount,
  129. canNoSelect: false,
  130. canEndNotMax: false,
  131. selectPermanentCoroutine: SelectPermanentCoroutine,
  132. afterSelectPermanentCoroutine: null,
  133. mode: SelectPermanentEffect.Mode.Custom,
  134. cardEffect: activateClass);
  135. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  136. {
  137. selectedPermanment = permanent;
  138. yield return null;
  139. }
  140. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon trash digivolution card", "The opponent is selecting 1 Digimon trash digivolution card");
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. #endregion
  143. if (selectedPermanment != null)
  144. {
  145. #region Select Digivolution Card to trash
  146. CardSource selectedCard = null;
  147. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  148. selectCardEffect.SetUp(
  149. canTargetCondition: x => true,
  150. canTargetCondition_ByPreSelecetedList: null,
  151. canEndSelectCondition: null,
  152. canNoSelect: () => false,
  153. selectCardCoroutine: SelectCardCoroutine,
  154. afterSelectCardCoroutine: null,
  155. message: "Select 1 digivolution card to discard.",
  156. maxCount: 1,
  157. canEndNotMax: false,
  158. isShowOpponent: true,
  159. mode: SelectCardEffect.Mode.Custom,
  160. root: SelectCardEffect.Root.Custom,
  161. customRootCardList: selectedPermanment.DigivolutionCards,
  162. canLookReverseCard: true,
  163. selectPlayer: card.Owner,
  164. cardEffect: null);
  165. IEnumerator SelectCardCoroutine(CardSource cardSource)
  166. {
  167. selectedCard = cardSource;
  168. yield return null;
  169. }
  170. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to discard.", "The opponent is selecting 1 digivolution card to discard.");
  171. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  172. #endregion
  173. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  174. targetPermanent: selectedPermanment,
  175. targetDigivolutionCards: new List<CardSource>() { selectedCard },
  176. activateClass: activateClass,
  177. successProcess: SuccessProcess,
  178. failureProcess: null));
  179. IEnumerator SuccessProcess(List<CardSource> cardSources)
  180. {
  181. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanent))
  182. {
  183. #region Select Permanent to gain effects
  184. Permanent selectedPermanment1 = null;
  185. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanent));
  186. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  187. selectPermanentEffect1.SetUp(
  188. selectPlayer: card.Owner,
  189. canTargetCondition: CanSelectPermanent,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. maxCount: maxCount1,
  193. canNoSelect: false,
  194. canEndNotMax: false,
  195. selectPermanentCoroutine: SelectPermanentCoroutine,
  196. afterSelectPermanentCoroutine: null,
  197. mode: SelectPermanentEffect.Mode.Custom,
  198. cardEffect: activateClass);
  199. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  200. {
  201. selectedPermanment1 = permanent;
  202. yield return null;
  203. }
  204. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon to gain <Blocker> & <Retaliation>", "The opponent is selecting 1 Digimon to gain <Blocker> & <Retaliation>");
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  206. #endregion
  207. if (selectedPermanment1 != null)
  208. {
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  210. targetPermanent: selectedPermanment1,
  211. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  212. activateClass: activateClass));
  213. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRetaliation(
  214. targetPermanent: selectedPermanment1,
  215. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  216. activateClass: activateClass));
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. #endregion
  224. #region On Play
  225. if (timing == EffectTiming.OnEnterFieldAnyone)
  226. {
  227. ActivateClass activateClass = new ActivateClass();
  228. activateClass.SetUpICardEffect("By trashing 1 source, 1 digimon gains Blocker, Retaliation", CanUseCondition, card);
  229. activateClass.SetUpActivateClass(CanActivateConditionShared, hashtable => SharedActivateCoroutine(hashtable, activateClass), 1, true, SharedEffectDiscription("On Play"));
  230. activateClass.SetHashString("OPWDWA_EX10_045");
  231. cardEffects.Add(activateClass);
  232. bool CanUseCondition(Hashtable hashtable)
  233. {
  234. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  235. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  236. }
  237. }
  238. #endregion
  239. #region When Digivolving
  240. if (timing == EffectTiming.OnEnterFieldAnyone)
  241. {
  242. ActivateClass activateClass = new ActivateClass();
  243. activateClass.SetUpICardEffect("By trashing 1 source, 1 digimon gains Blocker, Retaliation", CanUseCondition, card);
  244. activateClass.SetUpActivateClass(CanActivateConditionShared, hashtable => SharedActivateCoroutine(hashtable, activateClass), 1, true, SharedEffectDiscription("When Digivolving"));
  245. activateClass.SetHashString("OPWDWA_EX10_045");
  246. cardEffects.Add(activateClass);
  247. bool CanUseCondition(Hashtable hashtable)
  248. {
  249. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  250. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  251. }
  252. }
  253. #endregion
  254. #region When Attacking
  255. if (timing == EffectTiming.OnAllyAttack)
  256. {
  257. ActivateClass activateClass = new ActivateClass();
  258. activateClass.SetUpICardEffect("By trashing 1 source, 1 digimon gains Blocker, Retaliation", CanUseCondition, card);
  259. activateClass.SetUpActivateClass(CanActivateConditionShared, hashtable => SharedActivateCoroutine(hashtable, activateClass), 1, true, SharedEffectDiscription("When Attacking"));
  260. activateClass.SetHashString("OPWDWA_EX10_045");
  261. cardEffects.Add(activateClass);
  262. bool CanUseCondition(Hashtable hashtable)
  263. {
  264. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  265. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  266. }
  267. }
  268. #endregion
  269. #region Save
  270. if (timing == EffectTiming.OnDestroyedAnyone)
  271. {
  272. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  273. }
  274. #endregion
  275. #region ESS
  276. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  277. {
  278. ActivateClass activateClass = new ActivateClass();
  279. activateClass.SetUpICardEffect("<Draw 1>", CanUseCondition, card);
  280. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  281. activateClass.SetIsInheritedEffect(true);
  282. cardEffects.Add(activateClass);
  283. string EffectDiscription()
  284. {
  285. return "When effects trash this card from a [Bagra Army] trait Digimon's digivolution cards, <Draw 1>";
  286. }
  287. bool CanUseCondition(Hashtable hashtable)
  288. {
  289. Permanent trashedPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  290. return trashedPermanent.TopCard.EqualsTraits("Bagra Army") &&
  291. CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card);
  292. }
  293. bool CanActivateCondition(Hashtable hashtable)
  294. {
  295. return CardEffectCommons.IsExistOnTrash(card);
  296. }
  297. IEnumerator ActivateCoroutine(Hashtable hashtable)
  298. {
  299. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  300. }
  301. }
  302. #endregion
  303. return cardEffects;
  304. }
  305. }
  306. }