BT15_074.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT15
  4. {
  5. public class BT15_074 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  13. }
  14. #region On Play/When Digivolving Shared
  15. bool CanSelectCardCondition(CardSource cardSource)
  16. {
  17. if (cardSource.Owner == card.Owner.Enemy)
  18. {
  19. if (cardSource.IsDigimon)
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. #endregion
  27. #region On Play
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("Opponent trashes 1 Digimon card, or you gain Memory +1", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectSharedDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectSharedDiscription()
  35. {
  36. return "[On Play] Your opponent may trash 1 Digimon card in their hand. If they don't, gain 1 memory.";
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (card.Owner.Enemy.HandCards.Count >= 1)
  47. {
  48. return true;
  49. }
  50. if (card.Owner.CanAddMemory(activateClass))
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. bool discarded = false;
  60. if (card.Owner.Enemy.HandCards.Count >= 1)
  61. {
  62. int discardCount = 1;
  63. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  64. selectHandEffect.SetUp(
  65. selectPlayer: card.Owner.Enemy,
  66. canTargetCondition: CanSelectCardCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: discardCount,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. selectCardCoroutine: null,
  74. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  75. mode: SelectHandEffect.Mode.Discard,
  76. cardEffect: activateClass);
  77. yield return StartCoroutine(selectHandEffect.Activate());
  78. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  79. {
  80. if (cardSources.Count >= 1)
  81. {
  82. discarded = true;
  83. yield return null;
  84. }
  85. }
  86. }
  87. if (!discarded)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  90. }
  91. }
  92. }
  93. #endregion
  94. #region When Digivolving
  95. if (timing == EffectTiming.OnEnterFieldAnyone)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect("Opponent trashes 1 Digimon card, or you gain Memory +1", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectSharedDiscription());
  100. cardEffects.Add(activateClass);
  101. string EffectSharedDiscription()
  102. {
  103. return "[When Digivolving] Your opponent may trash 1 Digimon card in their hand. If they don't, gain 1 memory.";
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  108. }
  109. bool CanActivateCondition(Hashtable hashtable)
  110. {
  111. if (CardEffectCommons.IsExistOnBattleArea(card))
  112. {
  113. if (card.Owner.Enemy.HandCards.Count >= 1)
  114. {
  115. return true;
  116. }
  117. if (card.Owner.CanAddMemory(activateClass))
  118. {
  119. return true;
  120. }
  121. }
  122. return false;
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  125. {
  126. bool discarded = false;
  127. if (card.Owner.Enemy.HandCards.Count >= 1)
  128. {
  129. int discardCount = 1;
  130. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  131. selectHandEffect.SetUp(
  132. selectPlayer: card.Owner.Enemy,
  133. canTargetCondition: CanSelectCardCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: discardCount,
  137. canNoSelect: true,
  138. canEndNotMax: false,
  139. isShowOpponent: true,
  140. selectCardCoroutine: null,
  141. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  142. mode: SelectHandEffect.Mode.Discard,
  143. cardEffect: activateClass);
  144. yield return StartCoroutine(selectHandEffect.Activate());
  145. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  146. {
  147. if (cardSources.Count >= 1)
  148. {
  149. discarded = true;
  150. yield return null;
  151. }
  152. }
  153. }
  154. if (!discarded)
  155. {
  156. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  157. }
  158. }
  159. }
  160. #endregion
  161. #region All Turns - Can't Attack
  162. if (timing == EffectTiming.None)
  163. {
  164. bool Condition()
  165. {
  166. return CardEffectCommons.IsOwnerTurn(card) && card.Owner.Enemy.GetBattleAreaDigimons().Count == 0;
  167. }
  168. cardEffects.Add(CardEffectFactory.CanNotAttackSelfStaticEffect(
  169. defenderCondition: null,
  170. isInheritedEffect: false,
  171. card: card,
  172. condition: Condition,
  173. effectName: "Can't Attack"));
  174. }
  175. #endregion
  176. #region All Turns - Inherited Effect
  177. if (timing == EffectTiming.OnEnterFieldAnyone)
  178. {
  179. ActivateClass activateClass = new ActivateClass();
  180. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  181. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  182. activateClass.SetHashString("Memory1_BT15_074");
  183. activateClass.SetIsInheritedEffect(true);
  184. cardEffects.Add(activateClass);
  185. string EffectDiscription()
  186. {
  187. return "[All Turns] [Once Per Turn] When an effect plays an opponent's Digimon, gain 1 memory.";
  188. }
  189. bool PermanentCondition(Permanent permanent)
  190. {
  191. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  192. }
  193. bool CanUseCondition(Hashtable hashtable)
  194. {
  195. if (CardEffectCommons.IsExistOnBattleArea(card))
  196. {
  197. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  198. {
  199. if (CardEffectCommons.IsByEffect(hashtable, null))
  200. {
  201. return true;
  202. }
  203. }
  204. }
  205. return false;
  206. }
  207. bool CanActivateCondition(Hashtable hashtable)
  208. {
  209. if (CardEffectCommons.IsExistOnBattleArea(card))
  210. {
  211. return true;
  212. }
  213. return false;
  214. }
  215. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  216. {
  217. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  218. }
  219. }
  220. #endregion
  221. return cardEffects;
  222. }
  223. }
  224. }