BT21_061.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT21
  4. {
  5. //MetalGreymon
  6. public class BT21_061 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Shared Conditions
  12. bool SelectableOpponentsDigimon(Permanent permanent)
  13. {
  14. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  15. }
  16. int OwnerTamerColorCountDividedBy2()
  17. {
  18. List<CardSource> tamerCards = new List<CardSource>();
  19. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  20. {
  21. if (permanent.IsTamer)
  22. {
  23. tamerCards.Add(permanent.TopCard);
  24. }
  25. }
  26. return Combinations.GetDifferenetColorCardCount(tamerCards) / 2;
  27. }
  28. #endregion
  29. #region Alternative Digivolve Condition
  30. if (timing == EffectTiming.None)
  31. {
  32. static bool PermanentCondition(Permanent targetPermanent)
  33. {
  34. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4 && (targetPermanent.TopCard.ContainsCardName("Greymon") || targetPermanent.TopCard.EqualsTraits("ADVENTURE"));
  35. }
  36. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  37. }
  38. #endregion
  39. #region On Play
  40. if (timing == EffectTiming.OnEnterFieldAnyone)
  41. {
  42. ActivateClass activateClass = new ActivateClass();
  43. activateClass.SetUpICardEffect("De-Digivolve 1 of your opponents digimon", CanUseCondition, card);
  44. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  45. cardEffects.Add(activateClass);
  46. string EffectDiscription()
  47. {
  48. return "[On Play] To 1 of your opponent's Digimon, <De-Digivolve 1> for every 2 of your Tamers' colors.";
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  57. CardEffectCommons.HasMatchConditionPermanent(SelectableOpponentsDigimon);
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: SelectableOpponentsDigimon,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: 1,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. for (int i = 0; i < OwnerTamerColorCountDividedBy2(); i++)
  79. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  80. }
  81. }
  82. }
  83. #endregion
  84. #region When Digivolving
  85. if (timing == EffectTiming.OnEnterFieldAnyone)
  86. {
  87. ActivateClass activateClass = new ActivateClass();
  88. activateClass.SetUpICardEffect("De-Digivolve 1 of your opponents digimon", CanUseCondition, card);
  89. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  90. cardEffects.Add(activateClass);
  91. string EffectDiscription()
  92. {
  93. return "[When Digivolving] To 1 of your opponent's Digimon, <De-Digivolve 1> for every 2 of your Tamers' colors.";
  94. }
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  102. CardEffectCommons.HasMatchConditionPermanent(SelectableOpponentsDigimon);
  103. }
  104. IEnumerator ActivateCoroutine(Hashtable hashtable)
  105. {
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: SelectableOpponentsDigimon,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: 1,
  113. canNoSelect: false,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  120. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  121. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  122. {
  123. for (int i = 0; i < OwnerTamerColorCountDividedBy2(); i++)
  124. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  125. }
  126. }
  127. }
  128. #endregion
  129. #region Your Turn
  130. if (timing == EffectTiming.OnEnterFieldAnyone)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Gain alliance then attack", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  135. activateClass.SetIsSkippableFunction(IsSkippable);
  136. activateClass.SetHashString("alliance-attack-BT21_061");
  137. cardEffects.Add(activateClass);
  138. string EffectDescription()
  139. {
  140. 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.";
  141. }
  142. bool IsSkippable(Hashtable hashtable)
  143. {
  144. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  145. if (hashtables != null)
  146. {
  147. foreach (Hashtable hashtable1 in hashtables)
  148. {
  149. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  150. if (permanent != null && MyDigimonAdventurePlayedDigid(permanent))
  151. return false;
  152. }
  153. }
  154. return true;
  155. }
  156. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  157. {
  158. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  159. permanent != card.PermanentOfThisCard() &&
  160. permanent.TopCard.EqualsTraits("ADVENTURE");
  161. }
  162. bool MyDigimonPlayedDigid(Permanent permanent)
  163. {
  164. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  165. permanent != card.PermanentOfThisCard();
  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. bool Used = false;
  201. List<Permanent> etbPermanents = new List<Permanent>();
  202. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  203. if (hashtables != null)
  204. {
  205. foreach (Hashtable hashtable1 in hashtables)
  206. {
  207. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  208. if (permanent != null)
  209. etbPermanents.Add(permanent);
  210. }
  211. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  212. }
  213. if (etbPermanents.Count > 0)
  214. {
  215. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  216. {
  217. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  218. selectPermanentEffect.SetUp(
  219. selectPlayer: card.Owner,
  220. canTargetCondition: MyDigimonAlliance,
  221. canTargetCondition_ByPreSelecetedList: null,
  222. canEndSelectCondition: null,
  223. maxCount: 1,
  224. canNoSelect: false,
  225. canEndNotMax: false,
  226. selectPermanentCoroutine: SelectBoostedDigimon,
  227. afterSelectPermanentCoroutine: null,
  228. mode: SelectPermanentEffect.Mode.Custom,
  229. cardEffect: activateClass);
  230. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  231. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  232. IEnumerator SelectBoostedDigimon(Permanent target)
  233. {
  234. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  235. }
  236. Used = true;
  237. }
  238. }
  239. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  240. {
  241. Permanent selectedPermanent = null;
  242. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  243. selectPermanentEffect.SetUp(
  244. selectPlayer: card.Owner,
  245. canTargetCondition: MyDigimonAttacking,
  246. canTargetCondition_ByPreSelecetedList: null,
  247. canEndSelectCondition: null,
  248. maxCount: 1,
  249. canNoSelect: true,
  250. canEndNotMax: false,
  251. selectPermanentCoroutine: SelectPermanentCoroutine,
  252. afterSelectPermanentCoroutine: null,
  253. mode: SelectPermanentEffect.Mode.Custom,
  254. cardEffect: activateClass);
  255. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  256. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  257. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  258. {
  259. selectedPermanent = permanent;
  260. yield return null;
  261. }
  262. if (selectedPermanent != null)
  263. {
  264. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  265. selectAttackEffect.SetUp(
  266. attacker: selectedPermanent,
  267. canAttackPlayerCondition: () => true,
  268. defenderCondition: _ => true,
  269. cardEffect: activateClass);
  270. selectAttackEffect.SetAfterOnAttackCoroutine(AfterOnAttackCoroutine);
  271. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  272. }
  273. IEnumerator AfterOnAttackCoroutine()
  274. {
  275. Used = true;
  276. yield return null;
  277. }
  278. }
  279. if (!Used)
  280. {
  281. activateClass.RemoveUse();
  282. }
  283. }
  284. }
  285. #endregion
  286. #region Alliance Inherit
  287. if (timing == EffectTiming.OnAllyAttack)
  288. {
  289. bool Condition()
  290. {
  291. return CardEffectCommons.IsExistOnBattleArea(card);
  292. }
  293. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  294. }
  295. #endregion
  296. return cardEffects;
  297. }
  298. }
  299. }