RB1_025.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class RB1_025 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. if (timing == EffectTiming.OnEnterFieldAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Suspend 1 Digimon and gain Memory +1", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  22. cardEffects.Add(activateClass);
  23. string EffectDiscription()
  24. {
  25. return "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, if your opponent has no unsuspended Digimon, gain 1 memory.";
  26. }
  27. bool CanSelectPermanentCondition(Permanent permanent)
  28. {
  29. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  40. {
  41. return true;
  42. }
  43. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => !permanent.IsSuspended) == 0)
  44. {
  45. if (card.Owner.CanAddMemory(activateClass))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  54. {
  55. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: null,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Tap,
  68. cardEffect: activateClass);
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => !permanent.IsSuspended) == 0)
  71. {
  72. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  73. }
  74. }
  75. }
  76. if (timing == EffectTiming.OnAllyAttack)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Suspend 1 Digimon and gain Memory +1", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  81. cardEffects.Add(activateClass);
  82. string EffectDiscription()
  83. {
  84. return "[When Attacking] Suspend 1 of your opponent's Digimon. Then, if your opponent has no unsuspended Digimon, gain 1 memory.";
  85. }
  86. bool CanSelectPermanentCondition(Permanent permanent)
  87. {
  88. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  89. }
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  93. }
  94. bool CanActivateCondition(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleArea(card))
  97. {
  98. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  99. {
  100. return true;
  101. }
  102. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => !permanent.IsSuspended) == 0)
  103. {
  104. if (card.Owner.CanAddMemory(activateClass))
  105. {
  106. return true;
  107. }
  108. }
  109. }
  110. return false;
  111. }
  112. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  113. {
  114. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  115. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: CanSelectPermanentCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: maxCount,
  122. canNoSelect: false,
  123. canEndNotMax: false,
  124. selectPermanentCoroutine: null,
  125. afterSelectPermanentCoroutine: null,
  126. mode: SelectPermanentEffect.Mode.Tap,
  127. cardEffect: activateClass);
  128. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  129. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => !permanent.IsSuspended) == 0)
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  132. }
  133. }
  134. }
  135. if (timing == EffectTiming.OnEndTurn)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect("1 Digimon with [Angoramon] in text attacks", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  140. cardEffects.Add(activateClass);
  141. string EffectDiscription()
  142. {
  143. return "[End of Your Turn] 1 of your Digimon with [Angoramon] in its text may attack an opponent's Digimon.";
  144. }
  145. bool CanSelectPermanentCondition1(Permanent permanent)
  146. {
  147. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  148. {
  149. if (permanent.TopCard.HasText("Angoramon"))
  150. {
  151. if (permanent.CanAttack(activateClass))
  152. {
  153. if (card.Owner.Enemy.GetBattleAreaDigimons().Count(enemyPermanent => permanent.CanAttackTargetDigimon(enemyPermanent, activateClass)) >= 1)
  154. {
  155. return true;
  156. }
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. if (CardEffectCommons.IsExistOnBattleArea(card))
  165. {
  166. if (CardEffectCommons.IsOwnerTurn(card))
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. bool CanActivateCondition(Hashtable hashtable)
  174. {
  175. if (CardEffectCommons.IsExistOnBattleArea(card))
  176. {
  177. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  178. {
  179. return true;
  180. }
  181. }
  182. return false;
  183. }
  184. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  185. {
  186. Permanent selectedPermanent = null;
  187. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  188. {
  189. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  190. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  191. selectPermanentEffect.SetUp(
  192. selectPlayer: card.Owner,
  193. canTargetCondition: CanSelectPermanentCondition1,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. maxCount: maxCount,
  197. canNoSelect: true,
  198. canEndNotMax: false,
  199. selectPermanentCoroutine: SelectPermanentCoroutine,
  200. afterSelectPermanentCoroutine: null,
  201. mode: SelectPermanentEffect.Mode.Custom,
  202. cardEffect: activateClass);
  203. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack.");
  204. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  205. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  206. {
  207. selectedPermanent = permanent;
  208. yield return null;
  209. }
  210. if (selectedPermanent != null)
  211. {
  212. if (selectedPermanent.CanAttack(activateClass))
  213. {
  214. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) => permanent.IsDigimon && selectedPermanent.CanAttackTargetDigimon(permanent, activateClass)))
  215. {
  216. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  217. selectAttackEffect.SetUp(
  218. attacker: selectedPermanent,
  219. canAttackPlayerCondition: () => false,
  220. defenderCondition: (permanent) => true,
  221. cardEffect: activateClass);
  222. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  223. }
  224. }
  225. }
  226. }
  227. }
  228. }
  229. return cardEffects;
  230. }
  231. }