ST21_06.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. cardEffects.Add(activateClass);
  42. string effectDescription()
  43. {
  44. 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.";
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  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. Player selectedOwner = permanent.TopCard.Owner;
  82. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(permanent, CardEffectCommons.CardEffectHashtable(activateClass), toTop: true).PutSecurity());
  83. }
  84. }
  85. }
  86. #endregion
  87. #region When Digivolving
  88. if (timing == EffectTiming.OnEnterFieldAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Place into security", canUseCondition, card);
  92. activateClass.SetUpActivateClass(canActivateCondition, activateCoroutine, -1, false, effectDescription());
  93. cardEffects.Add(activateClass);
  94. string effectDescription()
  95. {
  96. 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.";
  97. }
  98. bool CanSelectPermanentCondition(Permanent permanent)
  99. {
  100. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  101. && permanent.TopCard.Owner.CanAddSecurity(activateClass)
  102. && permanent.HasDP && permanent.DP <= 6000 + 2000 * TamerTwoColourCount();
  103. }
  104. bool canActivateCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  107. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  108. }
  109. bool canUseCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  112. }
  113. IEnumerator activateCoroutine(Hashtable hashtable)
  114. {
  115. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. canTargetCondition: CanSelectPermanentCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. canNoSelect: false,
  121. selectPermanentCoroutine: SelectPermanentCoroutine,
  122. afterSelectPermanentCoroutine: null,
  123. maxCount: 1,
  124. canEndNotMax: false,
  125. mode: SelectPermanentEffect.Mode.Custom,
  126. selectPlayer: card.Owner,
  127. cardEffect: null);
  128. selectPermanentEffect.SetUpCustomMessage(
  129. "Select 1 of the opponent's Digimon to place on top of security",
  130. "The opponent is selecting 1 of your Digimon to place on top of Security.");
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  133. {
  134. Player selectedOwner = permanent.TopCard.Owner;
  135. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(permanent, CardEffectCommons.CardEffectHashtable(activateClass), toTop: true).PutSecurity());
  136. }
  137. }
  138. }
  139. #endregion
  140. #region Your Turn
  141. if (timing == EffectTiming.OnEnterFieldAnyone)
  142. {
  143. ActivateClass activateClass = new ActivateClass();
  144. activateClass.SetUpICardEffect("Gain alliance then attack", CanUseCondition, card);
  145. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  146. activateClass.SetHashString("alliance-attack-ST21-06");
  147. cardEffects.Add(activateClass);
  148. string EffectDiscription()
  149. {
  150. 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.";
  151. }
  152. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  155. permanent != card.PermanentOfThisCard() &&
  156. permanent.TopCard.EqualsTraits("ADVENTURE");
  157. }
  158. bool MyDigimonPlayedDigid(Permanent permanent)
  159. {
  160. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  161. permanent != card.PermanentOfThisCard();
  162. }
  163. bool MyDigimonAlliance(Permanent permanent)
  164. {
  165. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  166. }
  167. bool MyDigimonAttacking(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  170. permanent.CanAttack(activateClass);
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  175. {
  176. if (CardEffectCommons.IsOwnerTurn(card))
  177. {
  178. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  179. return true;
  180. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. bool CanActivateCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. List<Permanent> etbPermanents = new List<Permanent>();
  193. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  194. if (hashtables != null)
  195. {
  196. foreach (Hashtable hashtable1 in hashtables)
  197. {
  198. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  199. if (permanent != null)
  200. etbPermanents.Add(permanent);
  201. }
  202. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  203. }
  204. if (etbPermanents.Count > 0)
  205. {
  206. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  207. {
  208. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  209. selectPermanentEffect.SetUp(
  210. selectPlayer: card.Owner,
  211. canTargetCondition: MyDigimonAlliance,
  212. canTargetCondition_ByPreSelecetedList: null,
  213. canEndSelectCondition: null,
  214. maxCount: 1,
  215. canNoSelect: false,
  216. canEndNotMax: false,
  217. selectPermanentCoroutine: SelectBoostedDigimon,
  218. afterSelectPermanentCoroutine: null,
  219. mode: SelectPermanentEffect.Mode.Custom,
  220. cardEffect: activateClass);
  221. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  222. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  223. IEnumerator SelectBoostedDigimon(Permanent target)
  224. {
  225. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  226. }
  227. }
  228. }
  229. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  230. {
  231. Permanent selectedPermanent = null;
  232. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  233. selectPermanentEffect.SetUp(
  234. selectPlayer: card.Owner,
  235. canTargetCondition: MyDigimonAttacking,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. maxCount: 1,
  239. canNoSelect: true,
  240. canEndNotMax: false,
  241. selectPermanentCoroutine: SelectPermanentCoroutine,
  242. afterSelectPermanentCoroutine: null,
  243. mode: SelectPermanentEffect.Mode.Custom,
  244. cardEffect: activateClass);
  245. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  246. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  247. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  248. {
  249. selectedPermanent = permanent;
  250. yield return null;
  251. }
  252. if (selectedPermanent.CanAttack(activateClass))
  253. {
  254. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  255. selectAttackEffect.SetUp(
  256. attacker: selectedPermanent,
  257. canAttackPlayerCondition: () => true,
  258. defenderCondition: _ => true,
  259. cardEffect: activateClass);
  260. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  261. }
  262. }
  263. }
  264. }
  265. #endregion
  266. #region Alliance Inherit
  267. if (timing == EffectTiming.OnAllyAttack)
  268. {
  269. bool Condition()
  270. {
  271. return CardEffectCommons.IsExistOnBattleArea(card);
  272. }
  273. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  274. }
  275. #endregion
  276. return cardEffects;
  277. }
  278. }
  279. }