BT22_076.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //ShinMonzaemon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_076 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasDMTraits)
  18. {
  19. if (targetPermanent.TopCard.HasLevel)
  20. {
  21. if (targetPermanent.Level == 5)
  22. {
  23. return true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region Static Effects
  33. #region Reduce Cost
  34. if (timing == EffectTiming.None)
  35. {
  36. bool Condition()
  37. {
  38. return !CardEffectCommons.IsExistOnField(card);
  39. }
  40. bool PermanentCondition(Permanent targetPermanent)
  41. {
  42. if (targetPermanent != null)
  43. {
  44. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card))
  45. {
  46. if (targetPermanent.TopCard.EqualsTraits("Ver.1"))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CardSourceCondition(CardSource cardSource)
  55. {
  56. return cardSource == card;
  57. }
  58. bool RootCondition(SelectCardEffect.Root root)
  59. {
  60. return true;
  61. }
  62. cardEffects.Add(
  63. CardEffectFactory.ChangeDigivolutionCostStaticEffect(
  64. changeValue: -2,
  65. permanentCondition: PermanentCondition,
  66. cardCondition: CardSourceCondition,
  67. rootCondition: RootCondition,
  68. isInheritedEffect: false,
  69. card: card,
  70. condition: Condition,
  71. setFixedCost: false));
  72. }
  73. #endregion
  74. #region Security Atk +1
  75. if (timing == EffectTiming.None)
  76. {
  77. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  78. }
  79. #endregion
  80. #region Armor Purge
  81. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  82. {
  83. cardEffects.Add(CardEffectFactory.ArmorPurgeEffect(card: card));
  84. }
  85. #endregion
  86. #endregion
  87. #region When Digivolving
  88. if (timing == EffectTiming.OnEnterFieldAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Trash face down source, Place 1 in security", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  93. activateClass.SetHashString("TrashEffect_BT22-076");
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. return "[When Digivolving] [Once Per Turn] By trashing this Digimon's bottom face-down digivolution card, place 1 Digimon with as much or less DP as this Digimon as the top security card.";
  98. }
  99. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  100. {
  101. return cardSource.IsFlipped && !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  102. }
  103. bool CanSelectPermanentCondition(Permanent permanent)
  104. {
  105. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  106. permanent.HasDP && permanent.DP <= card.PermanentOfThisCard().DP;
  107. }
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  111. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  112. }
  113. bool CanActivateCondition(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  116. card.PermanentOfThisCard().DigivolutionCards.Exists(CanSelectTrashSourceCardCondition);
  117. }
  118. IEnumerator ActivateCoroutine(Hashtable hashtable)
  119. {
  120. List<CardSource> selectedCards = new List<CardSource>();
  121. CardSource trashTargetCard = card.PermanentOfThisCard().DigivolutionCards.Filter(CanSelectTrashSourceCardCondition)[^1];
  122. selectedCards.Add(trashTargetCard);
  123. if (selectedCards.Count >= 1)
  124. {
  125. yield return ContinuousController.instance.StartCoroutine(
  126. new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  127. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  128. {
  129. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  130. selectPermanentEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: CanSelectPermanentCondition,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: 1,
  136. canNoSelect: false,
  137. canEndNotMax: false,
  138. selectPermanentCoroutine: SelectPermanentCoroutine,
  139. afterSelectPermanentCoroutine: null,
  140. mode: SelectPermanentEffect.Mode.Custom,
  141. cardEffect: activateClass);
  142. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place to security.", "The opponent is selecting 1 Digimon to place to security.");
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  145. {
  146. Permanent selectedPermanent = permanent;
  147. if (selectedPermanent != null)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  150. selectedPermanent,
  151. CardEffectCommons.CardEffectHashtable(activateClass),
  152. toTop: true).PutSecurity());
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. #region When Attacking
  161. if (timing == EffectTiming.OnAllyAttack)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("Trash face down source, Place 1 in security", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  166. activateClass.SetHashString("TrashEffect_BT22-076");
  167. cardEffects.Add(activateClass);
  168. string EffectDiscription()
  169. {
  170. return "[When Attacking] [Once Per Turn] By trashing this Digimon's bottom face-down digivolution card, place 1 Digimon with as much or less DP as this Digimon as the top security card.";
  171. }
  172. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  173. {
  174. return cardSource.IsFlipped && !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  175. }
  176. bool CanSelectPermanentCondition(Permanent permanent)
  177. {
  178. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  179. permanent.HasDP && permanent.DP <= card.PermanentOfThisCard().DP;
  180. }
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  184. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  185. }
  186. bool CanActivateCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  189. card.PermanentOfThisCard().DigivolutionCards.Exists(CanSelectTrashSourceCardCondition);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. List<CardSource> selectedCards = new List<CardSource>();
  194. CardSource trashTargetCard = card.PermanentOfThisCard().DigivolutionCards.Filter(CanSelectTrashSourceCardCondition)[^1];
  195. selectedCards.Add(trashTargetCard);
  196. if (selectedCards.Count >= 1)
  197. {
  198. yield return ContinuousController.instance.StartCoroutine(
  199. new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  200. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  201. {
  202. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  203. selectPermanentEffect.SetUp(
  204. selectPlayer: card.Owner,
  205. canTargetCondition: CanSelectPermanentCondition,
  206. canTargetCondition_ByPreSelecetedList: null,
  207. canEndSelectCondition: null,
  208. maxCount: 1,
  209. canNoSelect: false,
  210. canEndNotMax: false,
  211. selectPermanentCoroutine: SelectPermanentCoroutine,
  212. afterSelectPermanentCoroutine: null,
  213. mode: SelectPermanentEffect.Mode.Custom,
  214. cardEffect: activateClass);
  215. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place to security.", "The opponent is selecting 1 Digimon to place to security.");
  216. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  217. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  218. {
  219. Permanent selectedPermanent = permanent;
  220. if (selectedPermanent != null)
  221. {
  222. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  223. selectedPermanent,
  224. CardEffectCommons.CardEffectHashtable(activateClass),
  225. toTop: true).PutSecurity());
  226. }
  227. }
  228. }
  229. }
  230. }
  231. }
  232. #endregion
  233. return cardEffects;
  234. }
  235. }
  236. }