BT22_026.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // MetalGarurumon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_026 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel5
  18. && (targetPermanent.TopCard.ContainsCardName("Garurumon") || targetPermanent.TopCard.HasCSTraits);
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Hand Main
  24. if (timing == EffectTiming.OnDeclaration)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Digivolve 1 [Gabumon] into this card for 6", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[Hand] [Main] If you have [Nokia Shiramine], 1 of your [Gabumon] digivolves into this card for a digivolution cost of 6, ignoring digivolution requirements.";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.IsExistOnHand(card)
  37. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsNokiaShiramine)
  38. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsGabumon);
  39. }
  40. bool IsNokiaShiramine(Permanent permanent)
  41. {
  42. return permanent.IsTamer && permanent.TopCard.EqualsCardName("Nokia Shiramine");
  43. }
  44. bool IsGabumon(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  47. permanent.TopCard.EqualsCardName("Gabumon") &&
  48. card.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass, fixedCost: 6, ignore: CardEffectCommons.IgnoreRequirement.All);
  49. }
  50. bool IsMetalGarurumon(CardSource cardSource)
  51. {
  52. return cardSource == card;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsNokiaShiramine))
  57. {
  58. Permanent gabumon = null;
  59. #region Select Gabumon Permanent
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: IsGabumon,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: 1,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  74. {
  75. gabumon = permanent;
  76. yield return null;
  77. }
  78. selectPermanentEffect.SetUpCustomMessage("Select 1 [Gabumon] to digivolve", "The opponent is selecting 1 [Gabumon] to digivolve.");
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. #endregion
  81. if (gabumon != null)
  82. {
  83. #region Digivolve into MetalGarurumon
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  85. gabumon,
  86. IsMetalGarurumon,
  87. payCost: true,
  88. reduceCostTuple: null,
  89. fixedCostTuple: null,
  90. ignoreDigivolutionRequirementFixedCost: 6,
  91. isHand: true,
  92. activateClass: activateClass,
  93. successProcess: null,
  94. failedProcess: OnFail(),
  95. isOptional: false,
  96. ignoreRequirements: CardEffectCommons.IgnoreRequirement.All));
  97. IEnumerator OnFail()
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(card));
  100. }
  101. #endregion
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region When Digivolving
  108. if (timing == EffectTiming.OnEnterFieldAnyone)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("Digivolve 1 [Agumon] into [WarGreymon], or bounce lowest level digimon to hand", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[When Digivolving] Activate 1 of the effects below: 1 of your [Agumon] may digivolve into [WarGreymon] in the hand, ignoring digivolution requirements and without paying the cost. or Return 1 of your opponent's Digimon with the lowest level to the hand.";
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  125. }
  126. bool IsAgumon(Permanent permanent)
  127. {
  128. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  129. permanent.TopCard.EqualsCardName("Agumon");
  130. }
  131. bool IsWarGreymon(CardSource cardSource)
  132. {
  133. return CardEffectCommons.IsExistOnHand(cardSource) && cardSource.EqualsCardName("WarGreymon");
  134. }
  135. bool CanSelectOpponentDigimon(Permanent permanent)
  136. {
  137. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  138. && CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  139. }
  140. IEnumerator ActivateCoroutine(Hashtable hashtable)
  141. {
  142. bool canDigivolve = CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsAgumon) && CardEffectCommons.HasMatchConditionOwnersHand(card, IsWarGreymon);
  143. bool canBounce = CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentDigimon);
  144. #region Option Selection
  145. if (canBounce || canDigivolve)
  146. {
  147. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  148. {
  149. new(message: "Return 1 of your opponent's Digimon with the lowest level to the hand.", value: 0, spriteIndex: 0),
  150. new(message: "1 of your [Agumon] may digivolve into [WarGreymon] in the hand, ignoring digivolution requirements and without paying the cost.", value: 1, spriteIndex: 0),
  151. };
  152. string selectPlayerMessage = "Which effect will you activate?";
  153. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  154. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  155. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  156. notSelectPlayerMessage: notSelectPlayerMessage);
  157. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  158. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  159. #region Bounce digimon to hand
  160. if (actionID == 0 && canBounce)
  161. {
  162. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentDigimon));
  163. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  164. selectPermanentEffect.SetUp(
  165. selectPlayer: card.Owner,
  166. canTargetCondition: CanSelectOpponentDigimon,
  167. canTargetCondition_ByPreSelecetedList: null,
  168. canEndSelectCondition: null,
  169. maxCount: maxCount,
  170. canNoSelect: false,
  171. canEndNotMax: false,
  172. selectPermanentCoroutine: null,
  173. afterSelectPermanentCoroutine: null,
  174. mode: SelectPermanentEffect.Mode.Bounce,
  175. cardEffect: activateClass);
  176. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to bounce to hand.", "The opponent is selecting a digimon to bounce to hand..");
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. }
  179. #endregion
  180. #region Digivolve
  181. if (actionID == 1 && canDigivolve)
  182. {
  183. Permanent agumon = null;
  184. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsAgumon));
  185. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  186. selectPermanentEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: IsAgumon,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: maxCount,
  192. canNoSelect: false,
  193. canEndNotMax: false,
  194. selectPermanentCoroutine: SelectPermanentCoroutine,
  195. afterSelectPermanentCoroutine: null,
  196. mode: SelectPermanentEffect.Mode.Custom,
  197. cardEffect: activateClass);
  198. selectPermanentEffect.SetUpCustomMessage("Select 1 [Agumon] to digivolve.", "The opponent is selecting 1 [Agumon] to digivolve.");
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  201. {
  202. agumon = permanent;
  203. yield return null;
  204. }
  205. if (agumon != null)
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  208. targetPermanent: agumon,
  209. cardCondition: IsWarGreymon,
  210. payCost: false,
  211. reduceCostTuple: null,
  212. fixedCostTuple: null,
  213. ignoreDigivolutionRequirementFixedCost: -1,
  214. isHand: true,
  215. activateClass: activateClass,
  216. successProcess: null,
  217. ignoreRequirements: CardEffectCommons.IgnoreRequirement.All));
  218. }
  219. }
  220. #endregion
  221. }
  222. #endregion
  223. }
  224. }
  225. #endregion
  226. #region When Attacking
  227. if (timing == EffectTiming.OnAllyAttack)
  228. {
  229. ActivateClass activateClass = new ActivateClass();
  230. activateClass.SetUpICardEffect("Unsuspend this digimon", CanUseCondition, card);
  231. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  232. activateClass.SetHashString("BT22_026_Unsuspend");
  233. activateClass.SetIsInheritedEffect(true);
  234. cardEffects.Add(activateClass);
  235. string EffectDiscription()
  236. {
  237. return "[When Attacking] [Once Per Turn] If this Digimon has [Omnimon] in its name, it unsuspends.";
  238. }
  239. bool CanUseCondition(Hashtable hashtable)
  240. {
  241. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  242. }
  243. bool CanActivateCondition(Hashtable hashtable)
  244. {
  245. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  246. && card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon");
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable hashtable)
  249. {
  250. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard())) yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  251. }
  252. }
  253. #endregion
  254. return cardEffects;
  255. }
  256. }
  257. }