BT24_102.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_102 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of your Main
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Gain 1 Memory. If 5+ Memory, suspend and Draw 1.", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Start of Your Main Phase] Gain 1 memory. Then, if you have 5 or more memory, suspend this Tamer and <Draw 1>.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.IsExistOnBattleArea(card) &&
  26. CardEffectCommons.IsOwnerTurn(card);
  27. }
  28. bool CanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleArea(card);
  31. }
  32. IEnumerator ActivateCoroutine(Hashtable hashtable)
  33. {
  34. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  35. if (card.Owner.MemoryForPlayer >= 5)
  36. {
  37. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  38. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  39. }
  40. }
  41. }
  42. #endregion
  43. #region All turns
  44. if (timing == EffectTiming.None)
  45. {
  46. string EffectDiscription()
  47. {
  48. return "[All Turns] All of your [TS] trait Digimon get +1000 DP.";
  49. }
  50. bool Condition()
  51. {
  52. return CardEffectCommons.IsExistOnBattleArea(card);
  53. }
  54. bool PermanentCondition(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  57. permanent.TopCard.HasTSTraits;
  58. }
  59. cardEffects.Add(CardEffectFactory.ChangeDPStaticEffect(
  60. permanentCondition: PermanentCondition,
  61. changeValue: 1000,
  62. isInheritedEffect: false,
  63. card: card,
  64. condition: Condition,
  65. effectName: EffectDiscription));
  66. }
  67. #endregion
  68. #region End of your turn
  69. if (timing == EffectTiming.OnEndTurn)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Suspend this tamer to use an On Play or When Digivolving", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  74. cardEffects.Add(activateClass);
  75. string EffectDiscription()
  76. {
  77. return "[End of Your Turn] By suspending this Tamer, you may activate 1 [On Play] or [When Digivolving] effect of 1 of your [Olympos XII] trait Digimon.";
  78. }
  79. bool CanSelectPermanentCondition(Permanent permanent)
  80. {
  81. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  82. permanent.TopCard.EqualsTraits("Olympos XII") &&
  83. permanent.EffectList(EffectTiming.OnEnterFieldAnyone).Any(CanBeEffectCandidate);
  84. }
  85. bool CanBeEffectCandidate(ICardEffect cardEffect)
  86. {
  87. if (cardEffect != null &&
  88. cardEffect is ActivateICardEffect &&
  89. !cardEffect.IsSecurityEffect)
  90. {
  91. if (cardEffect.IsOnPlay)
  92. {
  93. Hashtable onPlayHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(cardEffect.EffectSourceCard);
  94. return cardEffect.CanUse(onPlayHashtable);
  95. }
  96. if (cardEffect.IsWhenDigivolving)
  97. {
  98. Hashtable digivolvingHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(cardEffect.EffectSourceCard);
  99. return cardEffect.CanUse(digivolvingHashtable);
  100. }
  101. }
  102. return false;
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleArea(card) &&
  107. CardEffectCommons.IsOwnerTurn(card);
  108. }
  109. bool CanActivateCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.IsExistOnBattleArea(card) &&
  112. CardEffectCommons.CanActivateSuspendCostEffect(card);
  113. }
  114. IEnumerator ActivateCoroutine(Hashtable hashtable)
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  117. Permanent selectedPermanent = null;
  118. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  119. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectPermanentCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount,
  126. canNoSelect: true,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: SelectCardCoroutine,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Custom,
  131. cardEffect: activateClass);
  132. selectPermanentEffect.SetUpCustomMessage("Select 1 of your [Olympos XII] digimon to use their effect.", "Your opponent is selecting an effect to use.");
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator SelectCardCoroutine(Permanent permanent)
  135. {
  136. selectedPermanent = permanent;
  137. yield return null;
  138. }
  139. if (selectedPermanent != null)
  140. {
  141. List<ICardEffect> candidateEffects = selectedPermanent.EffectList(EffectTiming.OnEnterFieldAnyone)
  142. .Clone()
  143. .Filter(CanBeEffectCandidate);
  144. if (candidateEffects.Count >= 1)
  145. {
  146. ICardEffect selectedEffect = null;
  147. if (candidateEffects.Count == 1)
  148. {
  149. selectedEffect = candidateEffects[0];
  150. }
  151. else
  152. {
  153. List<SkillInfo> skillInfos = new List<SkillInfo>();
  154. foreach (ICardEffect effect in candidateEffects)
  155. {
  156. ICardEffect cardEffect = new ChangeBaseDPClass();
  157. cardEffect.SetUpICardEffect((effect.IsOnPlay ? "On Play: " : "When Digivolving: ") + effect.EffectName, null, effect.EffectSourceCard);
  158. skillInfos.Add(new SkillInfo(cardEffect, null, EffectTiming.None));
  159. }
  160. List<CardSource> cardSources = candidateEffects
  161. .Map(cardEffect => cardEffect.EffectSourceCard);
  162. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  163. selectCardEffect.SetUp(
  164. canTargetCondition: (cardSource) => true,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. canNoSelect: () => false,
  168. selectCardCoroutine: null,
  169. afterSelectCardCoroutine: null,
  170. message: "Select 1 effect to activate.",
  171. maxCount: 1,
  172. canEndNotMax: false,
  173. isShowOpponent: false,
  174. mode: SelectCardEffect.Mode.Custom,
  175. root: SelectCardEffect.Root.Custom,
  176. customRootCardList: cardSources,
  177. canLookReverseCard: true,
  178. selectPlayer: card.Owner,
  179. cardEffect: activateClass);
  180. selectCardEffect.SetNotShowCard();
  181. selectCardEffect.SetUpSkillInfos(skillInfos);
  182. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  183. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  184. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  185. {
  186. if (selectedIndexes.Count == 1)
  187. {
  188. selectedEffect = candidateEffects[selectedIndexes[0]];
  189. yield return null;
  190. }
  191. }
  192. }
  193. if (selectedEffect != null)
  194. {
  195. if (selectedEffect.EffectSourceCard != null)
  196. {
  197. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  198. {
  199. selectedEffect.SetIsDigimonEffect(true);
  200. Hashtable onPlayHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  201. Hashtable digivolvingHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  202. if (selectedEffect.CanUse(digivolvingHashtable))
  203. {
  204. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(digivolvingHashtable));
  205. }
  206. else if (selectedEffect.CanUse(onPlayHashtable))
  207. {
  208. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(onPlayHashtable));
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. #endregion
  218. #region Security
  219. if (timing == EffectTiming.SecuritySkill)
  220. {
  221. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  222. }
  223. #endregion
  224. return cardEffects;
  225. }
  226. }
  227. }