EX5_054.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX5
  6. {
  7. public class EX5_054 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return (targetPermanent.TopCard.ContainsCardName("Etemon") || targetPermanent.TopCard.ContainsCardName("Sukamon"))
  17. && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Delete 1 Digimon or Tamer", canUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[On Play] Delete 1 of your opponent's play cost 3 or lower Digimon or Tamers. For each card with [Etemon]/[Sukamon] in its name in your trash, add 1 to the maximum play cost this effect can choose.";
  30. }
  31. int maxCost()
  32. {
  33. int maxCost = 3;
  34. maxCost += card.Owner.TrashCards.Count(cardSource => cardSource.ContainsCardName("Etemon") || cardSource.ContainsCardName("Sukamon"));
  35. return maxCost;
  36. }
  37. bool CanSelectPermanentCondition(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  40. {
  41. if (permanent.IsDigimon || permanent.IsTamer)
  42. {
  43. if (permanent.TopCard.GetCostItself <= maxCost())
  44. {
  45. if (permanent.TopCard.HasPlayCost)
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool canUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: null,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Destroy,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. }
  89. }
  90. }
  91. if (timing == EffectTiming.OnEnterFieldAnyone)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect("Delete 1 Digimon or Tamer", canUseCondition, card);
  95. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  96. cardEffects.Add(activateClass);
  97. string EffectDiscription()
  98. {
  99. return "[When Digivolving] Delete 1 of your opponent's play cost 3 or lower Digimon or Tamers. For each card with [Etemon]/[Sukamon] in its name in your trash, add 1 to the maximum play cost this effect can choose.";
  100. }
  101. int maxCost()
  102. {
  103. int maxCost = 3;
  104. maxCost += card.Owner.TrashCards.Count(cardSource => cardSource.ContainsCardName("Etemon") || cardSource.ContainsCardName("Sukamon"));
  105. return maxCost;
  106. }
  107. bool CanSelectPermanentCondition(Permanent permanent)
  108. {
  109. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  110. {
  111. if (permanent.IsDigimon || permanent.IsTamer)
  112. {
  113. if (permanent.TopCard.GetCostItself <= maxCost())
  114. {
  115. if (permanent.TopCard.HasPlayCost)
  116. {
  117. return true;
  118. }
  119. }
  120. }
  121. }
  122. return false;
  123. }
  124. bool canUseCondition(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. if (CardEffectCommons.IsExistOnBattleArea(card))
  131. {
  132. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  133. {
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  140. {
  141. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  142. {
  143. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  144. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  145. selectPermanentEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectPermanentCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: maxCount,
  151. canNoSelect: false,
  152. canEndNotMax: false,
  153. selectPermanentCoroutine: null,
  154. afterSelectPermanentCoroutine: null,
  155. mode: SelectPermanentEffect.Mode.Destroy,
  156. cardEffect: activateClass);
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. }
  159. }
  160. }
  161. if (timing == EffectTiming.OnAllyAttack)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("Place 1 card from hand at the top of security to switch attack target", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  166. activateClass.SetHashString("AttackChange_EX5_054");
  167. cardEffects.Add(activateClass);
  168. string EffectDiscription()
  169. {
  170. return "[Opponent's Turn] [Once Per Turn] When an opponent's Digimon attacks, by placing 1 card with [Etemon]/[Sukamon] in its name from your hand on top of your security stack, you may switch the target of attack to this Digimon or the player.";
  171. }
  172. bool CanSelectCardCondition(CardSource cardSource)
  173. {
  174. return cardSource.ContainsCardName("Etemon") || cardSource.ContainsCardName("Sukamon");
  175. }
  176. bool PermanentCondition(Permanent permanent)
  177. {
  178. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. if (CardEffectCommons.IsExistOnBattleArea(card))
  183. {
  184. if (CardEffectCommons.IsOpponentTurn(card))
  185. {
  186. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  187. {
  188. return true;
  189. }
  190. }
  191. }
  192. return false;
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.IsExistOnBattleArea(card))
  197. {
  198. if (card.Owner.HandCards.Count >= 1)
  199. {
  200. if (card.Owner.CanAddSecurity(activateClass))
  201. {
  202. return true;
  203. }
  204. }
  205. }
  206. return false;
  207. }
  208. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  209. {
  210. bool added = false;
  211. if (card.Owner.CanAddSecurity(activateClass))
  212. {
  213. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  214. {
  215. List<CardSource> selectedCards = new List<CardSource>();
  216. int maxCount = 1;
  217. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  218. selectHandEffect.SetUp(
  219. selectPlayer: card.Owner,
  220. canTargetCondition: CanSelectCardCondition,
  221. canTargetCondition_ByPreSelecetedList: null,
  222. canEndSelectCondition: null,
  223. maxCount: maxCount,
  224. canNoSelect: true,
  225. canEndNotMax: false,
  226. isShowOpponent: true,
  227. selectCardCoroutine: SelectCardCoroutine1,
  228. afterSelectCardCoroutine: null,
  229. mode: SelectHandEffect.Mode.Custom,
  230. cardEffect: activateClass);
  231. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the top of security.", "The opponent is selecting 1 card to place at the top of security.");
  232. selectHandEffect.SetUpCustomMessage_ShowCard("Security Top Card");
  233. yield return StartCoroutine(selectHandEffect.Activate());
  234. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  235. {
  236. selectedCards.Add(cardSource);
  237. yield return null;
  238. }
  239. foreach (CardSource cardSource in selectedCards)
  240. {
  241. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: true));
  242. added = true;
  243. }
  244. }
  245. }
  246. if (added)
  247. {
  248. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  249. {
  250. new SelectionElement<int>(message: $"This Digimon", value : 0, spriteIndex: 0),
  251. new SelectionElement<int>(message: $"You", value : 1, spriteIndex: 0),
  252. new SelectionElement<int>(message: $"Not Switch", value : 2, spriteIndex: 1),
  253. };
  254. string selectPlayerMessage = "To which will you switch the attack target?";
  255. string notSelectPlayerMessage = "The opponent is choosing to which target to switch the attack target.";
  256. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  257. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  258. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  259. switch (actionID)
  260. {
  261. case 0:
  262. if (CardEffectCommons.IsExistOnBattleArea(card))
  263. {
  264. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  265. activateClass,
  266. false,
  267. card.PermanentOfThisCard()));
  268. }
  269. break;
  270. case 1:
  271. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  272. activateClass,
  273. false,
  274. null));
  275. break;
  276. }
  277. }
  278. }
  279. }
  280. return cardEffects;
  281. }
  282. }
  283. }