BT16_045.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_045 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Suspend and gain DP", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] You may suspend 1 Digimon. Then, 1 of your Digimon gets +3000 DP until the end of your opponent's turn.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  25. }
  26. bool PermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) || CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. bool PermanentConditionForSecondEffect(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  37. {
  38. return true;
  39. }
  40. return false;
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. return true;
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable hashtable)
  51. {
  52. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  53. {
  54. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  55. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  56. };
  57. string selectPlayerMessage = "Will you suspend 1 Digimon?";
  58. string notSelectPlayerMessage = "The opponent is choosing whether or not to suspend a Digimon.";
  59. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  60. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  61. bool willSuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  62. if (willSuspend)
  63. {
  64. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  65. {
  66. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  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: maxCount,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: null,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Tap,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. }
  83. }
  84. if (CardEffectCommons.HasMatchConditionPermanent(PermanentConditionForSecondEffect))
  85. {
  86. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentConditionForSecondEffect));
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: PermanentConditionForSecondEffect,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: SelectPermanentCoroutine,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Custom,
  99. cardEffect: activateClass);
  100. selectPermanentEffect.SetUpCustomMessage(
  101. "Select 1 Digimon that will get DP +3000.",
  102. "The opponent is selecting 1 Digimon that will get DP +3000.");
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  107. targetPermanent: permanent,
  108. changeValue: 3000,
  109. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  110. activateClass: activateClass));
  111. }
  112. }
  113. }
  114. }
  115. #endregion
  116. #region When Digivolving
  117. if (timing == EffectTiming.OnEnterFieldAnyone)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect("Suspend and gain DP", CanUseCondition, card);
  121. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  122. cardEffects.Add(activateClass);
  123. string EffectDiscription()
  124. {
  125. return "[When Digivolving] You may suspend 1 Digimon. Then, 1 of your Digimon gets +3000 DP until the end of your opponent's turn.";
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  130. }
  131. bool PermanentCondition(Permanent permanent)
  132. {
  133. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) || CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  134. {
  135. return true;
  136. }
  137. return false;
  138. }
  139. bool PermanentConditionForSecondEffect(Permanent permanent)
  140. {
  141. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  142. {
  143. return true;
  144. }
  145. return false;
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. return true;
  152. }
  153. return false;
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable hashtable)
  156. {
  157. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  158. {
  159. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  160. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  161. };
  162. string selectPlayerMessage = "Will you suspend 1 Digimon?";
  163. string notSelectPlayerMessage = "The opponent is choosing whether or not to suspend a Digimon.";
  164. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  165. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  166. bool willSuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  167. if (willSuspend)
  168. {
  169. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  170. {
  171. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. selectPermanentEffect.SetUp(
  174. selectPlayer: card.Owner,
  175. canTargetCondition: PermanentCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. maxCount: maxCount,
  179. canNoSelect: false,
  180. canEndNotMax: false,
  181. selectPermanentCoroutine: null,
  182. afterSelectPermanentCoroutine: null,
  183. mode: SelectPermanentEffect.Mode.Tap,
  184. cardEffect: activateClass);
  185. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. }
  188. }
  189. if (CardEffectCommons.HasMatchConditionPermanent(PermanentConditionForSecondEffect))
  190. {
  191. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentConditionForSecondEffect));
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: PermanentConditionForSecondEffect,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: SelectPermanentCoroutine,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Custom,
  204. cardEffect: activateClass);
  205. selectPermanentEffect.SetUpCustomMessage(
  206. "Select 1 Digimon that will get DP +3000.",
  207. "The opponent is selecting 1 Digimon that will get DP +3000.");
  208. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  209. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  210. {
  211. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  212. targetPermanent: permanent,
  213. changeValue: 3000,
  214. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  215. activateClass: activateClass));
  216. }
  217. }
  218. }
  219. }
  220. #endregion
  221. #region Inherit
  222. if (timing == EffectTiming.OnAllyAttack)
  223. {
  224. ActivateClass activateClass = new ActivateClass();
  225. activateClass.SetUpICardEffect("Switch attack target", CanUseCondition, card);
  226. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  227. activateClass.SetHashString("SwitchTarget_BT16-045");
  228. activateClass.SetIsInheritedEffect(true);
  229. cardEffects.Add(activateClass);
  230. string EffectDiscription()
  231. {
  232. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may switch the target of attack to one of your suspended Digimon with the [Insectoid] trait.";
  233. }
  234. bool CanSelectPermanentCondition(Permanent permanent)
  235. {
  236. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent.TopCard.CardTraits.Contains("Insectoid") && permanent.IsSuspended;
  237. }
  238. bool PermanentCondition(Permanent permanent)
  239. {
  240. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  241. }
  242. bool CanUseCondition(Hashtable hashtable)
  243. {
  244. if (CardEffectCommons.IsExistOnBattleArea(card))
  245. {
  246. if (CardEffectCommons.IsOpponentTurn(card))
  247. {
  248. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  249. {
  250. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  251. {
  252. return true;
  253. }
  254. }
  255. }
  256. }
  257. return false;
  258. }
  259. bool CanActivateCondition(Hashtable hashtable)
  260. {
  261. if (CardEffectCommons.IsExistOnBattleArea(card))
  262. {
  263. if (GManager.instance.attackProcess.IsAttacking)
  264. {
  265. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  266. {
  267. return true;
  268. }
  269. }
  270. }
  271. return false;
  272. }
  273. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  274. {
  275. if (CardEffectCommons.IsExistOnBattleArea(card))
  276. {
  277. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  278. {
  279. if (GManager.instance.attackProcess.IsAttacking)
  280. {
  281. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  282. {
  283. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  284. {
  285. new SelectionElement<bool>(message: $"Switch", value : true, spriteIndex: 0),
  286. new SelectionElement<bool>(message: $"Not switch", value : false, spriteIndex: 1),
  287. };
  288. string selectPlayerMessage = "Will you switch the attack target?";
  289. string notSelectPlayerMessage = "The opponent is selecting whether to switch the attack target.";
  290. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  291. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  292. bool doSwitch = GManager.instance.userSelectionManager.SelectedBoolValue;
  293. if (doSwitch)
  294. {
  295. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  296. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  297. selectPermanentEffect.SetUp(
  298. selectPlayer: card.Owner,
  299. canTargetCondition: CanSelectPermanentCondition,
  300. canTargetCondition_ByPreSelecetedList: null,
  301. canEndSelectCondition: null,
  302. maxCount: maxCount,
  303. canNoSelect: false,
  304. canEndNotMax: false,
  305. selectPermanentCoroutine: SelectPermanentCoroutine,
  306. afterSelectPermanentCoroutine: null,
  307. mode: SelectPermanentEffect.Mode.Custom,
  308. cardEffect: activateClass);
  309. selectPermanentEffect.SetUpCustomMessage(
  310. "Select 1 Digimon to switch the attack to.",
  311. "The opponent is selecting 1 Digimon to switch the attack to.");
  312. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  313. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  314. {
  315. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  316. activateClass,
  317. false,
  318. permanent));
  319. }
  320. }
  321. }
  322. }
  323. }
  324. }
  325. }
  326. }
  327. #endregion
  328. return cardEffects;
  329. }
  330. }
  331. }