EX8_014.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_014 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. if (targetPermanent.TopCard.ContainsTraits("Dinosaur"))
  17. {
  18. if (targetPermanent.TopCard.HasLevel)
  19. {
  20. if (targetPermanent.Level == 4)
  21. {
  22. return true;
  23. }
  24. }
  25. }
  26. return false;
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  29. }
  30. #endregion
  31. #region Fortitude
  32. if (timing == EffectTiming.OnDestroyedAnyone)
  33. {
  34. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. #endregion
  37. #region On Play
  38. if (timing == EffectTiming.OnEnterFieldAnyone)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("Suspend and delete an opponent's Digimon", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  43. cardEffects.Add(activateClass);
  44. string EffectDiscription()
  45. {
  46. return "[On Play] You may suspend 1 Digimon. Then, if this Digimon is suspended, delete 1 of your opponent's Digimon with 8000 DP or less.";
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  51. }
  52. bool PermanentCondition(Permanent permanent)
  53. {
  54. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) || CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  55. {
  56. return true;
  57. }
  58. return false;
  59. }
  60. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  61. {
  62. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  63. {
  64. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  65. {
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. bool CanActivateCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable hashtable)
  76. {
  77. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  78. {
  79. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  80. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  81. };
  82. string selectPlayerMessage = "Will you suspend 1 Digimon?";
  83. string notSelectPlayerMessage = "The opponent is choosing whether or not to suspend a Digimon.";
  84. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  85. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  86. bool willSuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  87. if (willSuspend)
  88. {
  89. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  90. {
  91. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  92. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  93. selectPermanentEffect.SetUp(
  94. selectPlayer: card.Owner,
  95. canTargetCondition: PermanentCondition,
  96. canTargetCondition_ByPreSelecetedList: null,
  97. canEndSelectCondition: null,
  98. maxCount: maxCount,
  99. canNoSelect: false,
  100. canEndNotMax: false,
  101. selectPermanentCoroutine: null,
  102. afterSelectPermanentCoroutine: null,
  103. mode: SelectPermanentEffect.Mode.Tap,
  104. cardEffect: activateClass);
  105. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  106. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  107. }
  108. }
  109. if(card.PermanentOfThisCard().IsSuspended && CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  110. {
  111. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  112. int maxCount = Math.Min(1,
  113. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  114. SelectPermanentEffect selectPermanentEffect =
  115. GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: CanSelectOpponentPermanentCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: maxCount,
  122. canNoSelect: false,
  123. canEndNotMax: false,
  124. selectPermanentCoroutine: null,
  125. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  126. mode: SelectPermanentEffect.Mode.Custom,
  127. cardEffect: activateClass);
  128. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  129. "The opponent is selecting 1 Digimon to delete.");
  130. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  131. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  132. {
  133. deleteTargetPermanents = permanents.Clone();
  134. yield return null;
  135. }
  136. yield return ContinuousController.instance.StartCoroutine(
  137. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  138. targetPermanents: deleteTargetPermanents, activateClass: activateClass,
  139. successProcess: null, failureProcess: null));
  140. }
  141. }
  142. }
  143. #endregion
  144. #region When Digivolving
  145. if (timing == EffectTiming.OnEnterFieldAnyone)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Suspend and delete an opponent's Digimon", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  150. cardEffects.Add(activateClass);
  151. string EffectDiscription()
  152. {
  153. return "[When Digivolving] You may suspend 1 Digimon. Then, if this Digimon is suspended, delete 1 of your opponent's Digimon with 8000 DP or less.";
  154. }
  155. bool CanUseCondition(Hashtable hashtable)
  156. {
  157. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  158. {
  159. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  160. {
  161. return true;
  162. }
  163. }
  164. return false;
  165. }
  166. bool PermanentCondition(Permanent permanent)
  167. {
  168. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) || CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  169. {
  170. return true;
  171. }
  172. return false;
  173. }
  174. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  175. {
  176. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  177. {
  178. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  179. {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  188. {
  189. return true;
  190. }
  191. return false;
  192. }
  193. IEnumerator ActivateCoroutine(Hashtable hashtable)
  194. {
  195. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  196. {
  197. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  198. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  199. };
  200. string selectPlayerMessage = "Will you suspend 1 Digimon?";
  201. string notSelectPlayerMessage = "The opponent is choosing whether or not to suspend a Digimon.";
  202. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  203. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  204. bool willSuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  205. if (willSuspend)
  206. {
  207. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  208. {
  209. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  210. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  211. selectPermanentEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: PermanentCondition,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: maxCount,
  217. canNoSelect: false,
  218. canEndNotMax: false,
  219. selectPermanentCoroutine: null,
  220. afterSelectPermanentCoroutine: null,
  221. mode: SelectPermanentEffect.Mode.Tap,
  222. cardEffect: activateClass);
  223. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  224. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  225. }
  226. }
  227. if (card.PermanentOfThisCard().IsSuspended && CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  228. {
  229. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  230. int maxCount = Math.Min(1,
  231. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  232. SelectPermanentEffect selectPermanentEffect =
  233. GManager.instance.GetComponent<SelectPermanentEffect>();
  234. selectPermanentEffect.SetUp(
  235. selectPlayer: card.Owner,
  236. canTargetCondition: CanSelectOpponentPermanentCondition,
  237. canTargetCondition_ByPreSelecetedList: null,
  238. canEndSelectCondition: null,
  239. maxCount: maxCount,
  240. canNoSelect: false,
  241. canEndNotMax: false,
  242. selectPermanentCoroutine: null,
  243. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  244. mode: SelectPermanentEffect.Mode.Custom,
  245. cardEffect: activateClass);
  246. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  247. "The opponent is selecting 1 Digimon to delete.");
  248. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  249. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  250. {
  251. deleteTargetPermanents = permanents.Clone();
  252. yield return null;
  253. }
  254. yield return ContinuousController.instance.StartCoroutine(
  255. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  256. targetPermanents: deleteTargetPermanents, activateClass: activateClass,
  257. successProcess: null, failureProcess: null));
  258. }
  259. }
  260. }
  261. #endregion
  262. #region Inherit
  263. if (timing == EffectTiming.None)
  264. {
  265. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
  266. }
  267. #endregion
  268. return cardEffects;
  269. }
  270. }
  271. }