BT7_055.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 BT7_055 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Suspend 1 Digimon and gain Memory", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, gain 1 memory for each of your opponent's suspended Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  36. {
  37. return true;
  38. }
  39. if (card.Owner.CanAddMemory(activateClass))
  40. {
  41. int count = card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => permanent.IsSuspended);
  42. if (count >= 1)
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  53. {
  54. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  55. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  56. selectPermanentEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectPermanentCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: maxCount,
  62. canNoSelect: false,
  63. canEndNotMax: false,
  64. selectPermanentCoroutine: null,
  65. afterSelectPermanentCoroutine: null,
  66. mode: SelectPermanentEffect.Mode.Tap,
  67. cardEffect: activateClass);
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. }
  70. int count = card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => permanent.IsSuspended);
  71. if (count >= 1)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(count, activateClass));
  74. }
  75. }
  76. }
  77. if (timing == EffectTiming.None)
  78. {
  79. AddSkillClass addSkillClass = new AddSkillClass();
  80. addSkillClass.SetUpICardEffect("Opponent's Digimon can't unsuspend unless opponent trash a card from hand", CanUseCondition, card);
  81. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  82. cardEffects.Add(addSkillClass);
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. if (CardEffectCommons.IsExistOnBattleArea(card))
  86. {
  87. if (CardEffectCommons.IsOpponentTurn(card))
  88. {
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94. bool PermanentCondition(Permanent permanent)
  95. {
  96. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  97. {
  98. if (!permanent.TopCard.CanNotBeAffected(addSkillClass))
  99. {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. bool CardSourceCondition(CardSource cardSource)
  106. {
  107. if (CardEffectCommons.IsExistOnBattleArea(cardSource))
  108. {
  109. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  110. {
  111. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. return false;
  118. }
  119. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  120. {
  121. if (_timing == EffectTiming.WhenUntapAnyone)
  122. {
  123. ActivateClass activateClass1 = new ActivateClass();
  124. activateClass1.SetUpICardEffect("Trash 1 card from hand or this Digimon can't unsuspend", CanUseCondition1, cardSource);
  125. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription());
  126. activateClass1.SetRootCardEffect(addSkillClass);
  127. cardEffects.Add(activateClass1);
  128. string EffectDiscription()
  129. {
  130. return "[Your Turn] You must trash 1 card in your hand to unsuspend this Digimon.";
  131. }
  132. bool CanUseCondition1(Hashtable hashtable)
  133. {
  134. if (CardEffectCommons.IsOwnerTurn(cardSource))
  135. {
  136. if (CardSourceCondition(cardSource))
  137. {
  138. return true;
  139. }
  140. }
  141. return false;
  142. }
  143. bool CanActivateCondition1(Hashtable hashtable)
  144. {
  145. if (CardSourceCondition(cardSource))
  146. {
  147. if (cardSource.PermanentOfThisCard().IsSuspended)
  148. {
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154. IEnumerator ActivateCoroutine1(Hashtable _hashtable)
  155. {
  156. if (CardSourceCondition(cardSource))
  157. {
  158. if (cardSource.Owner.GetBattleAreaDigimons().Contains(cardSource.PermanentOfThisCard()))
  159. {
  160. bool discarded = false;
  161. if (cardSource.Owner.HandCards.Count >= 1)
  162. {
  163. int discardCount = 1;
  164. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  165. selectHandEffect.SetUp(
  166. selectPlayer: cardSource.Owner,
  167. canTargetCondition: (cardSource) => true,
  168. canTargetCondition_ByPreSelecetedList: null,
  169. canEndSelectCondition: null,
  170. maxCount: discardCount,
  171. canNoSelect: true,
  172. canEndNotMax: false,
  173. isShowOpponent: true,
  174. selectCardCoroutine: null,
  175. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  176. mode: SelectHandEffect.Mode.Discard,
  177. cardEffect: activateClass1);
  178. yield return StartCoroutine(selectHandEffect.Activate());
  179. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  180. {
  181. if (cardSources.Count >= 1)
  182. {
  183. discarded = true;
  184. yield return null;
  185. }
  186. }
  187. }
  188. if (!discarded)
  189. {
  190. Permanent selectedPermanent = cardSource.PermanentOfThisCard();
  191. if (selectedPermanent != null)
  192. {
  193. string effectName = "This Digimon can't unsuspend.";
  194. bool CanUseCondition2()
  195. {
  196. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  197. }
  198. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  199. targetPermanent: selectedPermanent,
  200. effectDuration: EffectDuration.UntilNextUntap,
  201. activateClass: activateClass1,
  202. condition: CanUseCondition2,
  203. effectName: effectName
  204. ));
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. return cardEffects;
  212. }
  213. }
  214. return cardEffects;
  215. }
  216. }