ST21_06.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //ST21 Magnaangemon
  4. namespace DCGO.CardEffects.ST21
  5. {
  6. public class ST21_06 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasAdventureTraits && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play/When Digivolving shared
  22. int TamerTwoColourCount()
  23. {
  24. List<CardSource> tamerCards = new List<CardSource>();
  25. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  26. {
  27. if (permanent.IsTamer && permanent.TopCard.HasAdventureTraits)
  28. {
  29. tamerCards.Add(permanent.TopCard);
  30. }
  31. }
  32. return Combinations.GetDifferenetColorCardCount(tamerCards) / 2;
  33. }
  34. #endregion
  35. #region On Play
  36. if(timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Place into security", canUseCondition, card);
  40. activateClass.SetUpActivateClass(canActivateCondition, activateCoroutine, -1, false, effectDescription());
  41. string effectDescription()
  42. {
  43. return "[On Play] Place 1 of your opponent's 6000 DP or lower Digimon as the top security card. For every 2 colors your Tamers have, add 2000 to this effect's DP maximum.";
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  48. && permanent.TopCard.Owner.CanAddSecurity(activateClass)
  49. && permanent.HasDP && permanent.DP <= 6000 + 2000 * TamerTwoColourCount();
  50. }
  51. bool canActivateCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  54. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  55. }
  56. bool canUseCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  59. }
  60. IEnumerator activateCoroutine(Hashtable hashtable)
  61. {
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. canNoSelect: false,
  68. selectPermanentCoroutine: SelectPermanentCoroutine,
  69. afterSelectPermanentCoroutine: null,
  70. maxCount: 1,
  71. canEndNotMax: false,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. selectPlayer: card.Owner,
  74. cardEffect: null);
  75. selectPermanentEffect.SetUpCustomMessage(
  76. "Select 1 of the opponent's Digimon to place on top of security",
  77. "The opponent is selecting 1 of your Digimon to place on top of Security.");
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  80. {
  81. if (!permanent.IsToken)
  82. {
  83. Player selectedOwner = permanent.TopCard.Owner;
  84. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(permanent, CardEffectCommons.CardEffectHashtable(activateClass), toTop: true).PutSecurity());
  85. }
  86. yield return null;
  87. }
  88. }
  89. }
  90. #endregion
  91. #region When Digivolving
  92. if (timing == EffectTiming.OnEnterFieldAnyone)
  93. {
  94. ActivateClass activateClass = new ActivateClass();
  95. activateClass.SetUpICardEffect("Place into security", canUseCondition, card);
  96. activateClass.SetUpActivateClass(canActivateCondition, activateCoroutine, -1, false, effectDescription());
  97. string effectDescription()
  98. {
  99. return "[On Play] Place 1 of your opponent's 6000 DP or lower Digimon as the top security card. For every 2 colors your Tamers have, add 2000 to this effect's DP maximum.";
  100. }
  101. bool CanSelectPermanentCondition(Permanent permanent)
  102. {
  103. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  104. && permanent.TopCard.Owner.CanAddSecurity(activateClass)
  105. && permanent.HasDP && permanent.DP <= 6000 + 2000 * TamerTwoColourCount();
  106. }
  107. bool canActivateCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  110. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  111. }
  112. bool canUseCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  115. }
  116. IEnumerator activateCoroutine(Hashtable hashtable)
  117. {
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. canTargetCondition: CanSelectPermanentCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. canNoSelect: false,
  124. selectPermanentCoroutine: SelectPermanentCoroutine,
  125. afterSelectPermanentCoroutine: null,
  126. maxCount: 1,
  127. canEndNotMax: false,
  128. mode: SelectPermanentEffect.Mode.Custom,
  129. selectPlayer: card.Owner,
  130. cardEffect: null);
  131. selectPermanentEffect.SetUpCustomMessage(
  132. "Select 1 of the opponent's Digimon to place on top of security",
  133. "The opponent is selecting 1 of your Digimon to place on top of Security.");
  134. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  135. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  136. {
  137. if (!permanent.IsToken)
  138. {
  139. Player selectedOwner = permanent.TopCard.Owner;
  140. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(permanent, CardEffectCommons.CardEffectHashtable(activateClass), toTop: true).PutSecurity());
  141. }
  142. yield return null;
  143. }
  144. }
  145. }
  146. #endregion
  147. #region Your Turn
  148. if (timing == EffectTiming.OnEnterFieldAnyone)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Gain Alliance then attack", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  153. activateClass.SetHashString("alliance-attack-ST21-006");
  154. cardEffects.Add(activateClass);
  155. string EffectDiscription()
  156. {
  157. return "[Your Turn][Once Per Turn] When your other Digimon are played or digivolve, if any of them have the [ADVENTURE] trait, 1 of your Digimon gains <Alliance> for the turn. Then, 1 of your Digimon may attack.";
  158. }
  159. bool MyDigimonPlayedDigid(Permanent permanent)
  160. {
  161. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent != card.PermanentOfThisCard())
  162. {
  163. return permanent.TopCard.HasAdventureTraits;
  164. }
  165. return false;
  166. }
  167. bool MyDigimonAlliance(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  170. }
  171. bool MyDigimonAttacking(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  174. permanent.CanAttack(activateClass);
  175. }
  176. bool CanUseCondition(Hashtable hashtable)
  177. {
  178. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  179. {
  180. if (CardEffectCommons.IsOwnerTurn(card))
  181. {
  182. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  183. return true;
  184. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  185. return true;
  186. }
  187. }
  188. return false;
  189. }
  190. bool CanActivateCondition(Hashtable hashtable)
  191. {
  192. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  193. {
  194. return true;
  195. }
  196. return false;
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  201. {
  202. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  203. selectPermanentEffect.SetUp(
  204. selectPlayer: card.Owner,
  205. canTargetCondition: MyDigimonAlliance,
  206. canTargetCondition_ByPreSelecetedList: null,
  207. canEndSelectCondition: null,
  208. maxCount: 1,
  209. canNoSelect: false,
  210. canEndNotMax: false,
  211. selectPermanentCoroutine: SelectBoostedDigimon,
  212. afterSelectPermanentCoroutine: null,
  213. mode: SelectPermanentEffect.Mode.Custom,
  214. cardEffect: activateClass);
  215. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  216. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  217. IEnumerator SelectBoostedDigimon(Permanent target)
  218. {
  219. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  220. }
  221. }
  222. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  223. {
  224. Permanent selectedPermanent = null;
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: MyDigimonAttacking,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: SelectPermanentCoroutine,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Custom,
  237. cardEffect: activateClass);
  238. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  239. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  240. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  241. {
  242. selectedPermanent = permanent;
  243. yield return null;
  244. }
  245. if (selectedPermanent != null)
  246. {
  247. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  248. selectAttackEffect.SetUp(
  249. attacker: selectedPermanent,
  250. canAttackPlayerCondition: () => true,
  251. defenderCondition: _ => true,
  252. cardEffect: activateClass);
  253. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  254. }
  255. }
  256. }
  257. }
  258. #endregion
  259. #region Alliance Inherit
  260. if (timing == EffectTiming.OnAllyAttack)
  261. {
  262. bool Condition()
  263. {
  264. return CardEffectCommons.IsExistOnBattleArea(card);
  265. }
  266. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  267. }
  268. #endregion
  269. return cardEffects;
  270. }
  271. }
  272. }