BT15_049.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT15
  5. {
  6. public class BT15_049 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. //Blast Digivolve
  12. if (timing == EffectTiming.OnCounterTiming)
  13. {
  14. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  15. }
  16. #region On Play/When Digivolving Shared
  17. bool CanSelectPermanentCondition(Permanent permanent)
  18. {
  19. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  20. }
  21. bool CanActivateCondition(Hashtable hashtable)
  22. {
  23. if (CardEffectCommons.IsExistOnBattleArea(card))
  24. {
  25. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  26. {
  27. return true;
  28. }
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  30. {
  31. if (GManager.instance.attackProcess.IsAttacking)
  32. {
  33. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. #endregion
  43. #region On Play
  44. if (timing == EffectTiming.OnEnterFieldAnyone)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("Your 1 Digimon gains DP +3000 and switch attack target", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[On Play] 1 of your Digimon gets +3000 DP until the end of your opponent's turn. Then, if one of their Digimon is attacking, you may switch the target of attack to this Digimon.";
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage(
  77. "Select 1 Digimon that will get DP +3000.",
  78. "The opponent is selecting 1 Digimon that will get DP +3000.");
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  81. {
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  83. targetPermanent: permanent,
  84. changeValue: 3000,
  85. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  86. activateClass: activateClass));
  87. }
  88. }
  89. if (CardEffectCommons.IsExistOnBattleArea(card))
  90. {
  91. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  92. {
  93. if (GManager.instance.attackProcess.IsAttacking)
  94. {
  95. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  96. {
  97. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  98. {
  99. new SelectionElement<bool>(message: $"Switch", value : true, spriteIndex: 0),
  100. new SelectionElement<bool>(message: $"Not switch", value : false, spriteIndex: 1),
  101. };
  102. string selectPlayerMessage = "Will you switch the attack target?";
  103. string notSelectPlayerMessage = "The opponent is selecting whether to switch the attack target.";
  104. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  105. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  106. bool doSwitch = GManager.instance.userSelectionManager.SelectedBoolValue;
  107. if (doSwitch)
  108. {
  109. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  110. activateClass,
  111. false,
  112. card.PermanentOfThisCard()));
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. #endregion
  121. #region When Digivolving
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect("Your 1 Digimon gains DP +3000 and switch attack target", CanUseCondition, card);
  126. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  127. cardEffects.Add(activateClass);
  128. string EffectDiscription()
  129. {
  130. return "[When Digivolving] 1 of your Digimon gets +3000 DP until the end of your opponent's turn. Then, if one of their Digimon is attacking, you may switch the target of attack to this Digimon.";
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  139. {
  140. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  141. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  142. selectPermanentEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: CanSelectPermanentCondition,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: maxCount,
  148. canNoSelect: false,
  149. canEndNotMax: false,
  150. selectPermanentCoroutine: SelectPermanentCoroutine,
  151. afterSelectPermanentCoroutine: null,
  152. mode: SelectPermanentEffect.Mode.Custom,
  153. cardEffect: activateClass);
  154. selectPermanentEffect.SetUpCustomMessage(
  155. "Select 1 Digimon that will get DP +3000.",
  156. "The opponent is selecting 1 Digimon that will get DP +3000.");
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  161. targetPermanent: permanent,
  162. changeValue: 3000,
  163. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  164. activateClass: activateClass));
  165. }
  166. }
  167. if (CardEffectCommons.IsExistOnBattleArea(card))
  168. {
  169. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  170. {
  171. if (GManager.instance.attackProcess.IsAttacking)
  172. {
  173. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  174. {
  175. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  176. {
  177. new SelectionElement<bool>(message: $"Switch", value : true, spriteIndex: 0),
  178. new SelectionElement<bool>(message: $"Not switch", value : false, spriteIndex: 1),
  179. };
  180. string selectPlayerMessage = "Will you switch the attack target?";
  181. string notSelectPlayerMessage = "The opponent is selecting whether to switch the attack target.";
  182. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  183. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  184. bool doSwitch = GManager.instance.userSelectionManager.SelectedBoolValue;
  185. if (doSwitch)
  186. {
  187. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  188. activateClass,
  189. false,
  190. card.PermanentOfThisCard()));
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. #endregion
  199. #region All Turns
  200. if (timing == EffectTiming.None)
  201. {
  202. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  203. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseCondition, card);
  204. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  205. cardEffects.Add(canNotAffectedClass);
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleArea(card))
  209. {
  210. if (card.PermanentOfThisCard().IsSuspended)
  211. {
  212. return true;
  213. }
  214. }
  215. return false;
  216. }
  217. bool CardCondition(CardSource cardSource)
  218. {
  219. if (cardSource == card)
  220. {
  221. if (CardEffectCommons.IsExistOnBattleArea(card))
  222. {
  223. if (cardSource == card.PermanentOfThisCard().TopCard)
  224. {
  225. return true;
  226. }
  227. }
  228. }
  229. return false;
  230. }
  231. bool SkillCondition(ICardEffect cardEffect)
  232. {
  233. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  234. {
  235. if (cardEffect.IsDigimonEffect)
  236. {
  237. return true;
  238. }
  239. }
  240. return false;
  241. }
  242. }
  243. #endregion
  244. return cardEffects;
  245. }
  246. }
  247. }