ST21_06.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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)
  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, EffectDescription());
  146. activateClass.SetIsSkippableFunction(IsSkippable);
  147. activateClass.SetHashString("alliance-attack-ST21_06");
  148. cardEffects.Add(activateClass);
  149. string EffectDescription()
  150. {
  151. 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.";
  152. }
  153. bool IsSkippable(Hashtable hashtable)
  154. {
  155. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  156. if (hashtables != null)
  157. {
  158. foreach (Hashtable hashtable1 in hashtables)
  159. {
  160. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  161. if (permanent != null && MyDigimonAdventurePlayedDigid(permanent))
  162. return false;
  163. }
  164. }
  165. return true;
  166. }
  167. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  170. permanent != card.PermanentOfThisCard() &&
  171. permanent.TopCard.EqualsTraits("ADVENTURE");
  172. }
  173. bool MyDigimonPlayedDigid(Permanent permanent)
  174. {
  175. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  176. permanent != card.PermanentOfThisCard();
  177. }
  178. bool MyDigimonAlliance(Permanent permanent)
  179. {
  180. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  181. }
  182. bool MyDigimonAttacking(Permanent permanent)
  183. {
  184. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  185. permanent.CanAttack(activateClass);
  186. }
  187. bool CanUseCondition(Hashtable hashtable)
  188. {
  189. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  190. {
  191. if (CardEffectCommons.IsOwnerTurn(card))
  192. {
  193. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  194. return true;
  195. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. bool CanActivateCondition(Hashtable hashtable)
  202. {
  203. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  204. {
  205. return true;
  206. }
  207. return false;
  208. }
  209. IEnumerator ActivateCoroutine(Hashtable hashtable)
  210. {
  211. bool Used = false;
  212. List<Permanent> etbPermanents = new List<Permanent>();
  213. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  214. if (hashtables != null)
  215. {
  216. foreach (Hashtable hashtable1 in hashtables)
  217. {
  218. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  219. if (permanent != null)
  220. etbPermanents.Add(permanent);
  221. }
  222. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  223. }
  224. if (etbPermanents.Count > 0)
  225. {
  226. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  227. {
  228. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  229. selectPermanentEffect.SetUp(
  230. selectPlayer: card.Owner,
  231. canTargetCondition: MyDigimonAlliance,
  232. canTargetCondition_ByPreSelecetedList: null,
  233. canEndSelectCondition: null,
  234. maxCount: 1,
  235. canNoSelect: false,
  236. canEndNotMax: false,
  237. selectPermanentCoroutine: SelectBoostedDigimon,
  238. afterSelectPermanentCoroutine: null,
  239. mode: SelectPermanentEffect.Mode.Custom,
  240. cardEffect: activateClass);
  241. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  242. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  243. IEnumerator SelectBoostedDigimon(Permanent target)
  244. {
  245. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  246. }
  247. Used = true;
  248. }
  249. }
  250. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  251. {
  252. Permanent selectedPermanent = null;
  253. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  254. selectPermanentEffect.SetUp(
  255. selectPlayer: card.Owner,
  256. canTargetCondition: MyDigimonAttacking,
  257. canTargetCondition_ByPreSelecetedList: null,
  258. canEndSelectCondition: null,
  259. maxCount: 1,
  260. canNoSelect: true,
  261. canEndNotMax: false,
  262. selectPermanentCoroutine: SelectPermanentCoroutine,
  263. afterSelectPermanentCoroutine: null,
  264. mode: SelectPermanentEffect.Mode.Custom,
  265. cardEffect: activateClass);
  266. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  267. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  268. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  269. {
  270. selectedPermanent = permanent;
  271. yield return null;
  272. }
  273. if (selectedPermanent != null)
  274. {
  275. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  276. selectAttackEffect.SetUp(
  277. attacker: selectedPermanent,
  278. canAttackPlayerCondition: () => true,
  279. defenderCondition: _ => true,
  280. cardEffect: activateClass);
  281. selectAttackEffect.SetAfterOnAttackCoroutine(AfterOnAttackCoroutine);
  282. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  283. }
  284. IEnumerator AfterOnAttackCoroutine()
  285. {
  286. Used = true;
  287. yield return null;
  288. }
  289. }
  290. if (!Used)
  291. {
  292. activateClass.RemoveUse();
  293. }
  294. }
  295. }
  296. #endregion
  297. #region Alliance Inherit
  298. if (timing == EffectTiming.OnAllyAttack)
  299. {
  300. bool Condition()
  301. {
  302. return CardEffectCommons.IsExistOnBattleArea(card);
  303. }
  304. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  305. }
  306. #endregion
  307. return cardEffects;
  308. }
  309. }
  310. }