EX10_062.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //EX10 Yujin Ozora
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_062 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of Main Phase
  14. if (timing == EffectTiming.OnStartMainPhase)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Start of Your Main Phase] If your opponent has a Digimon, gain 1 memory.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. if (CardEffectCommons.IsOwnerTurn(card))
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1)
  40. {
  41. if (card.Owner.CanAddMemory(activateClass))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  52. }
  53. }
  54. #endregion
  55. #region All Turns
  56. if (timing == EffectTiming.OnLinkCardDiscarded)
  57. {
  58. ActivateClass activateClass = new ActivateClass();
  59. activateClass.SetUpICardEffect("Suspend to draw on trash", CanUseCondition, card);
  60. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  61. cardEffects.Add(activateClass);
  62. string EffectDescription() => "[All Turns] When effects trash any of your Digimon's link cards, by suspending this Tamer, <Draw 1>.";
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.IsExistOnField(card) &&
  66. CardEffectCommons.CanTriggerOnTrashLinkedCard(hashtable, perm => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(perm, card), cardEffect => cardEffect != null, source => source != null);
  67. }
  68. bool CanActivateCondition(Hashtable hashtable)
  69. {
  70. return CardEffectCommons.IsExistOnField(card)
  71. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable hashtable)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  76. new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  77. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  78. }
  79. }
  80. #endregion
  81. #region End of turn
  82. if (timing == EffectTiming.OnEndTurn)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("App fuse 1 digimon into digimon in hand", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  87. activateClass.SetHashString("EX10_062_AppFusion");
  88. activateClass.SetIsSkippable(true);
  89. cardEffects.Add(activateClass);
  90. string EffectDescription()
  91. {
  92. return "[End of Your Turn] [Once Per Turn] 1 of your Digimon may app fuse into a Digimon card in the hand.";
  93. }
  94. bool CanUseCondition(Hashtable hashtable)
  95. {
  96. return CardEffectCommons.IsExistOnBattleArea(card);
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.IsExistOnBattleArea(card)
  101. && CardEffectCommons.IsOwnerTurn(card);
  102. }
  103. bool CanSelectPermanent(Permanent permanent)
  104. {
  105. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  106. {
  107. foreach (CardSource hand in card.Owner.HandCards)
  108. {
  109. if (hand.appFusionCondition != null)
  110. {
  111. if (hand.CanAppFusionFromTargetPermanent(permanent, true))
  112. return true;
  113. }
  114. }
  115. }
  116. return false;
  117. }
  118. bool CanSelectCard(CardSource card, Permanent permanent)
  119. {
  120. if (CardEffectCommons.IsExistOnHand(card))
  121. {
  122. if (card.appFusionCondition != null)
  123. {
  124. if (card.CanAppFusionFromTargetPermanent(permanent, true))
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. IEnumerator ActivateCoroutine(Hashtable hashtable)
  131. {
  132. bool executed = false;
  133. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  134. {
  135. Permanent selectedPermanent = null;
  136. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  137. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  138. selectPermanentEffect.SetUp(
  139. selectPlayer: card.Owner,
  140. canTargetCondition: CanSelectPermanent,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. maxCount: maxCount,
  144. canNoSelect: true,
  145. canEndNotMax: false,
  146. selectPermanentCoroutine: SelectPermanentCoroutine,
  147. afterSelectPermanentCoroutine: null,
  148. mode: SelectPermanentEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to app fuse", "The opponent is selecting 1 digimon to app fuse");
  151. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  152. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  153. {
  154. selectedPermanent = permanent;
  155. yield return null;
  156. }
  157. if (selectedPermanent != null)
  158. {
  159. CardSource selectedCard = null;
  160. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, handCard => CanSelectCard(handCard, selectedPermanent)));
  161. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  162. selectHandEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: handCard => CanSelectCard(handCard, selectedPermanent),
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: maxCount1,
  168. canNoSelect: true,
  169. canEndNotMax: false,
  170. isShowOpponent: true,
  171. selectCardCoroutine: SelectCardCoroutine,
  172. afterSelectCardCoroutine: null,
  173. mode: SelectHandEffect.Mode.Custom,
  174. cardEffect: activateClass);
  175. selectHandEffect.SetUpCustomMessage("Select digimon to app fuse into.", "The opponent is selecting digimon to app fuse into.");
  176. selectHandEffect.SetUpCustomMessage_ShowCard("Selected digimon");
  177. yield return StartCoroutine(selectHandEffect.Activate());
  178. IEnumerator SelectCardCoroutine(CardSource cardSource)
  179. {
  180. selectedCard = cardSource;
  181. yield return null;
  182. }
  183. if (selectedCard != null && selectedCard.CanAppFusionFromTargetPermanent(selectedPermanent, true))
  184. {
  185. CardSource linkCard = selectedPermanent.LinkedCards.Where(x => selectedCard.appFusionCondition.linkedCondition(selectedPermanent, x)).First();
  186. PlayCardClass playCardClass = new PlayCardClass(new List<CardSource> { selectedCard }, hashtable, true, selectedPermanent, false, SelectCardEffect.Root.Hand, true);
  187. playCardClass.SetAppFusion(new int[] { selectedPermanent.PermanentFrame.FrameID, selectedPermanent.LinkedCards.IndexOf(linkCard) });
  188. executed = true;
  189. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  190. }
  191. }
  192. }
  193. if (!executed) activateClass.RemoveUse();
  194. }
  195. }
  196. #endregion
  197. #region Security Effect
  198. if (timing == EffectTiming.SecuritySkill)
  199. {
  200. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  201. }
  202. #endregion
  203. return cardEffects;
  204. }
  205. }
  206. }