BT22_067.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // LordKnightmon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_067 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel5
  19. && targetPermanent.TopCard.HasCSTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion
  30. #region Rio Kishibe Alternative Digivolution Condition
  31. if (timing == EffectTiming.None)
  32. {
  33. bool PermanentCondition(Permanent targetPermanent)
  34. {
  35. return targetPermanent.TopCard.EqualsCardName("Rie Kishibe");
  36. }
  37. bool Condition()
  38. {
  39. return card.Owner.SecurityCards.Count <= 3;
  40. }
  41. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  42. permanentCondition: PermanentCondition,
  43. digivolutionCost: 5,
  44. ignoreDigivolutionRequirement: false,
  45. card: card,
  46. condition: Condition)
  47. );
  48. }
  49. #endregion
  50. #region Raid
  51. if (timing == EffectTiming.OnAllyAttack)
  52. {
  53. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  54. }
  55. #endregion
  56. #region Reboot
  57. if (timing == EffectTiming.None)
  58. {
  59. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  60. }
  61. #endregion
  62. #endregion
  63. #region OP/WD Shared
  64. bool SharedIsYourDigimon(Permanent permanent)
  65. {
  66. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  67. }
  68. bool SharedAttackingDigimon(Permanent permanent, ActivateClass activateClass)
  69. {
  70. return SharedIsYourDigimon(permanent)
  71. && permanent.CanAttack(activateClass);
  72. }
  73. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  74. {
  75. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, SharedIsYourDigimon))
  76. {
  77. Permanent selectedYourPermanent = null;
  78. #region Select Gain DP Permanent
  79. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, SharedIsYourDigimon));
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: SharedIsYourDigimon,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: SelectPermanentCoroutine,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  94. {
  95. selectedYourPermanent = permanent;
  96. yield return null;
  97. }
  98. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain 3K DP", "The opponent is selecting 1 Digimon to gain 3K DP");
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. #endregion
  101. if (selectedYourPermanent != null) yield return ContinuousController.instance.StartCoroutine(
  102. CardEffectCommons.ChangeDigimonDP(selectedYourPermanent, 3000, EffectDuration.UntilOpponentTurnEnd, activateClass));
  103. Permanent selectedAttackingPermament = null;
  104. #region Select Permanent To Attack
  105. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, perm => SharedAttackingDigimon(perm, activateClass)));
  106. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: perm => SharedAttackingDigimon(perm, activateClass),
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: maxCount1,
  113. canNoSelect: true,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine1,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  120. {
  121. selectedAttackingPermament = permanent;
  122. yield return null;
  123. }
  124. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon to attack", "The opponent is selecting 1 Digimon to attack");
  125. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  126. #endregion
  127. if (selectedAttackingPermament != null && selectedAttackingPermament.CanAttack(activateClass))
  128. {
  129. #region Setup SelectAttackEffect
  130. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  131. selectAttackEffect.SetUp(
  132. attacker: selectedAttackingPermament,
  133. canAttackPlayerCondition: () => true,
  134. defenderCondition: (permanent) => false,
  135. cardEffect: activateClass);
  136. #endregion
  137. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  138. }
  139. }
  140. }
  141. #endregion
  142. #region On Play
  143. if (timing == EffectTiming.OnEnterFieldAnyone)
  144. {
  145. ActivateClass activateClass = new ActivateClass();
  146. activateClass.SetUpICardEffect("+3K DP, then 1 digimon may attack", CanUseCondition, card);
  147. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  148. cardEffects.Add(activateClass);
  149. string EffectDiscription()
  150. {
  151. return "[On Play] 1 of your Digimon gets +3000 DP until your opponent's turn ends. Then, 1 of your Digimon may attack a player.";
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. yield return SharedActivateCoroutine(hashtable, activateClass);
  164. }
  165. }
  166. #endregion
  167. #region When Digivolving
  168. if (timing == EffectTiming.OnEnterFieldAnyone)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("+3K DP, then 1 digimon may attack", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[When Digivolving] 1 of your Digimon gets +3000 DP until your opponent's turn ends. Then, 1 of your Digimon may attack a player.";
  177. }
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  181. }
  182. bool CanActivateCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable hashtable)
  187. {
  188. yield return SharedActivateCoroutine(hashtable, activateClass);
  189. }
  190. }
  191. #endregion
  192. #region All Turns
  193. if (timing == EffectTiming.OnAllyAttack)
  194. {
  195. ActivateClass activateClass = new ActivateClass();
  196. activateClass.SetUpICardEffect("Reveal top 3, Play 1 4 cost or lower Black or Red card", CanUseCondition, card);
  197. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  198. activateClass.SetHashString("BT22_067_PlayTamer");
  199. cardEffects.Add(activateClass);
  200. string EffectDiscription()
  201. {
  202. return "[All Turns] [Once Per Turn] When Digimon attack players, reveal the top 3 cards of your deck. You may play 1 play cost 4 or lower black or red card among them without paying the cost. Trash the rest.";
  203. }
  204. bool CanUseCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsAttackingPlayer);
  207. }
  208. bool CanActivateCondition(Hashtable hashtable)
  209. {
  210. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  211. }
  212. bool IsAttackingPlayer(Permanent permanent)
  213. {
  214. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  215. && GManager.instance.attackProcess.IsAttacking
  216. && GManager.instance.attackProcess.DefendingPermanent == null;
  217. }
  218. bool IsProperCard(CardSource cardSource)
  219. {
  220. return cardSource.HasPlayCost && cardSource.BasePlayCostFromEntity <= 4 &&
  221. (cardSource.HasCardColor(CardColor.Black) || cardSource.HasCardColor(CardColor.Red)) &&
  222. CardEffectCommons.CanPlayAsNewPermanent(cardSource,false,activateClass,SelectCardEffect.Root.Library);
  223. }
  224. IEnumerator ActivateCoroutine(Hashtable hashtable)
  225. {
  226. CardSource selectedCard = null;
  227. #region Select Card
  228. IEnumerator SelectCardCoroutine(CardSource cardSource)
  229. {
  230. selectedCard = cardSource;
  231. yield return null;
  232. }
  233. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  234. revealCount: 3,
  235. simplifiedSelectCardConditions:
  236. new SimplifiedSelectCardConditionClass[]
  237. {
  238. new SimplifiedSelectCardConditionClass(
  239. canTargetCondition:IsProperCard,
  240. message: "Select 1 4 or lower play cost Black/Red card",
  241. mode: SelectCardEffect.Mode.Custom,
  242. maxCount: 1,
  243. selectCardCoroutine: SelectCardCoroutine),
  244. },
  245. remainingCardsPlace: RemainingCardsPlace.Trash,
  246. activateClass: activateClass
  247. ));
  248. #endregion
  249. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  250. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  251. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Execution, true));
  252. }
  253. }
  254. #endregion
  255. return cardEffects;
  256. }
  257. }
  258. }