BT21_078.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //BT21-078 Weregarurumon
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. public class BT21_078 : 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. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 &&
  17. (targetPermanent.TopCard.HasGarurumonName || targetPermanent.TopCard.HasAdventureTraits);
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null));
  25. }
  26. #endregion
  27. #region On Play/When Digivolving shared
  28. bool CanActivateConditionShared(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition);
  31. }
  32. bool TamerTwoColourCount()
  33. {
  34. List<CardSource> tamerCards = new List<CardSource>();
  35. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  36. {
  37. if (permanent.IsTamer)
  38. {
  39. tamerCards.Add(permanent.TopCard);
  40. }
  41. }
  42. return Combinations.GetDifferenetColorCardCount(tamerCards) >= 2;
  43. }
  44. bool CanSelectPermanentCondition(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.Level <= (TamerTwoColourCount() ? 5 : 4);
  47. }
  48. #endregion
  49. #region On Play
  50. if (timing == EffectTiming.OnEnterFieldAnyone)
  51. {
  52. ActivateClass activateClass = new ActivateClass();
  53. activateClass.SetUpICardEffect("Delete a level 4 digimon, or 5 if tamers have 2+ color", CanUseCondition, card);
  54. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDiscription());
  55. cardEffects.Add(activateClass);
  56. string EffectDiscription()
  57. {
  58. return "[On Play] Delete 1 of your opponent's level 4 or lower Digimon. If your Tamers have 2 or more total colors, add 1 to this effect's level maximum.";
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectPermanentCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: 1,
  75. canNoSelect: false,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: null,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Destroy,
  80. cardEffect: activateClass);
  81. selectPermanentEffect.SetUpCustomMessage(
  82. "Select 1 opposing Digimon to delete.",
  83. "The opponent is selecting 1 of your Digimon to delete");
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. }
  86. }
  87. }
  88. #endregion
  89. #region When Digivolving
  90. if (timing == EffectTiming.OnEnterFieldAnyone)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect("Delete a level 4 digimon, or 5 if tamers have 2+ color", CanUseCondition, card);
  94. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDiscription());
  95. cardEffects.Add(activateClass);
  96. string EffectDiscription()
  97. {
  98. return "[When Digivolving] Delete 1 of your opponent's level 4 or lower Digimon. If your Tamers have 2 or more total colors, add 1 to this effect's level maximum.";
  99. }
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  103. }
  104. IEnumerator ActivateCoroutine(Hashtable hashtable)
  105. {
  106. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  107. {
  108. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  109. selectPermanentEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: CanSelectPermanentCondition,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: 1,
  115. canNoSelect: false,
  116. canEndNotMax: false,
  117. selectPermanentCoroutine: null,
  118. afterSelectPermanentCoroutine: null,
  119. mode: SelectPermanentEffect.Mode.Destroy,
  120. cardEffect: activateClass);
  121. selectPermanentEffect.SetUpCustomMessage(
  122. "Select 1 opposing Digimon to delete.",
  123. "The opponent is selecting 1 of your Digimon to delete");
  124. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  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_078");
  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. }