BT22_013.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine.XR;
  5. //Wargreymon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_013 : 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
  14. //Level 5 CS trait/greymon in name
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.IsLevel5 &&
  20. (targetPermanent.TopCard.HasCSTraits || targetPermanent.TopCard.HasGreymonName);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 3,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null)
  28. );
  29. }
  30. #endregion
  31. #region Warp Effect
  32. //Warp from Agumon
  33. if (timing == EffectTiming.OnDeclaration)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("Digivolve for a cost of 6", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[Hand][Main] If you have [Nokia Shiramine], 1 of your [Agumon] digivolves into this card for a digivolution cost of 6, ignoring digivolution requirements.";
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnHand(card) &&
  46. CardEffectCommons.HasMatchConditionPermanent(HasNokia) &&
  47. CardEffectCommons.HasMatchConditionPermanent(PermanentCondition);
  48. }
  49. bool HasNokia(Permanent targetPermanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card) &&
  52. targetPermanent.TopCard.EqualsCardName("Nokia Shiramine");
  53. }
  54. bool PermanentCondition(Permanent targetPermanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card) &&
  57. targetPermanent.TopCard.EqualsCardName("Agumon") &&
  58. card.CanPlayCardTargetFrame(targetPermanent.PermanentFrame, true, activateClass, fixedCost: 6, ignore: CardEffectCommons.IgnoreRequirement.All);
  59. }
  60. bool CanSelectHandCardCondition(CardSource cardSource)
  61. {
  62. return cardSource == card;
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. Permanent selectedPermanent = null;
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: PermanentCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: 1,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  81. "The opponent is selecting 1 Digimon that will digivolve.");
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. selectedPermanent = permanent;
  86. yield return null;
  87. }
  88. if (selectedPermanent != null)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  91. targetPermanent: selectedPermanent,
  92. cardCondition: CanSelectHandCardCondition,
  93. payCost: true,
  94. reduceCostTuple: null,
  95. fixedCostTuple:null,
  96. ignoreDigivolutionRequirementFixedCost: 6,
  97. isHand: true,
  98. activateClass: activateClass,
  99. successProcess: null,
  100. failedProcess: OnFail(),
  101. isOptional: false,
  102. ignoreRequirements: CardEffectCommons.IgnoreRequirement.All));
  103. }
  104. IEnumerator OnFail()
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(card));
  107. }
  108. }
  109. }
  110. #endregion
  111. #region When Digivolving
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Choose 1 effect", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  117. cardEffects.Add(activateClass);
  118. string EffectDiscription()
  119. {
  120. return "[When Digivolving] Activate 1 of the effects below:\r\n・1 of your [Gabumon] may digivolve into [MetalGarurumon] in the hand, ignoring digivolution requirements and without paying the cost.\r\n・Delete 1 of your opponent's Digimon with the lowest DP.";
  121. }
  122. #region Evo Conditions
  123. bool CanSelectOwnPermanentCondition(Permanent permanent)
  124. {
  125. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  126. {
  127. if (permanent.TopCard.EqualsCardName("Gabumon"))
  128. {
  129. if(card.Owner.HandCards.Any(x => CanSelectHandCardCondition(x) && x.CanPlayCardTargetFrame(permanent.PermanentFrame,false,activateClass,ignore:CardEffectCommons.IgnoreRequirement.All)))
  130. return true;
  131. }
  132. }
  133. return false;
  134. }
  135. bool CanSelectHandCardCondition(CardSource cardSource)
  136. {
  137. return cardSource.IsDigimon && cardSource.EqualsCardName("MetalGarurumon");
  138. }
  139. #endregion
  140. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  141. {
  142. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  143. {
  144. if (CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy))
  145. {
  146. return true;
  147. }
  148. }
  149. return false;
  150. }
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable,card);
  154. }
  155. bool CanActivateCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  158. }
  159. IEnumerator ActivateCoroutine(Hashtable hashtable)
  160. {
  161. bool CanDelete = CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition);
  162. bool CanEvo = CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition);
  163. if(CanDelete || CanEvo)
  164. {
  165. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  166. {
  167. new(
  168. message: "1 of your [Gabumon] may digivolve into [MetalGarurumon] in your hand",
  169. value: 0, spriteIndex: 0),
  170. new(message: "Delete 1 of your opponent's Digimon with the lowest DP",
  171. value: 1, spriteIndex: 0),
  172. };
  173. string selectPlayerMessage = "Which effect will you activate?";
  174. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  175. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  176. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  177. notSelectPlayerMessage: notSelectPlayerMessage);
  178. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  179. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  180. switch (actionID)
  181. {
  182. case 0:
  183. {
  184. if (CanEvo)
  185. {
  186. Permanent selectedPermanent = null;
  187. SelectPermanentEffect selectPermanentEffect =
  188. GManager.instance.GetComponent<SelectPermanentEffect>();
  189. selectPermanentEffect.SetUp(
  190. selectPlayer: card.Owner,
  191. canTargetCondition: CanSelectOwnPermanentCondition,
  192. canTargetCondition_ByPreSelecetedList: null,
  193. canEndSelectCondition: null,
  194. maxCount: 1,
  195. canNoSelect: true,
  196. canEndNotMax: false,
  197. selectPermanentCoroutine: SelectPermanentCoroutine,
  198. afterSelectPermanentCoroutine: null,
  199. mode: SelectPermanentEffect.Mode.Custom,
  200. cardEffect: activateClass);
  201. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  202. "The opponent is selecting 1 Digimon that will digivolve.");
  203. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  204. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  205. {
  206. selectedPermanent = permanent;
  207. yield return null;
  208. }
  209. if (selectedPermanent != null)
  210. {
  211. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  212. targetPermanent: selectedPermanent,
  213. cardCondition: CanSelectHandCardCondition,
  214. payCost: false,
  215. reduceCostTuple: null,
  216. fixedCostTuple: null,
  217. ignoreDigivolutionRequirementFixedCost: 0,
  218. isHand: true,
  219. activateClass: activateClass,
  220. successProcess: null,
  221. ignoreRequirements: CardEffectCommons.IgnoreRequirement.All));
  222. }
  223. }
  224. break;
  225. }
  226. case 1:
  227. {
  228. if (CanDelete)
  229. {
  230. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  231. selectPermanentEffect.SetUp(
  232. selectPlayer: card.Owner,
  233. canTargetCondition: CanSelectOpponentPermanentCondition,
  234. canTargetCondition_ByPreSelecetedList: null,
  235. canEndSelectCondition: null,
  236. maxCount: 1,
  237. canNoSelect: false,
  238. canEndNotMax: false,
  239. selectPermanentCoroutine: null,
  240. afterSelectPermanentCoroutine: null,
  241. mode: SelectPermanentEffect.Mode.Destroy,
  242. cardEffect: activateClass);
  243. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  244. }
  245. break;
  246. }
  247. }
  248. }
  249. }
  250. }
  251. #endregion
  252. #region When Attacking - ESS
  253. if (timing == EffectTiming.OnAllyAttack)
  254. {
  255. ActivateClass activateClass = new ActivateClass();
  256. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  257. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  258. activateClass.SetIsInheritedEffect(true);
  259. activateClass.SetHashString("TrashSecurity_BT22_013");
  260. cardEffects.Add(activateClass);
  261. string EffectDiscription()
  262. {
  263. return "[When Attacking] [Once Per Turn] If this Digimon has [Omnimon] in its name, trash your opponent's top security card.";
  264. }
  265. bool CanUseCondition(Hashtable hashtable)
  266. {
  267. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  268. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  269. }
  270. bool CanActivateCondition(Hashtable hashtable)
  271. {
  272. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  273. card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon");
  274. }
  275. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  276. {
  277. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  278. player: card.Owner.Enemy,
  279. destroySecurityCount: 1,
  280. cardEffect: activateClass,
  281. fromTop: true).DestroySecurity());
  282. }
  283. }
  284. #endregion
  285. return cardEffects;
  286. }
  287. }
  288. }