BT21_013.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //Agunimon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_013 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition - Tamer
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.IsTamer)
  18. {
  19. return targetPermanent.TopCard.CardColors.Contains(CardColor.Red);
  20. }
  21. return false;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  24. permanentCondition: PermanentCondition,
  25. digivolutionCost: 2,
  26. ignoreDigivolutionRequirement: false,
  27. card: card,
  28. condition: null)
  29. );
  30. }
  31. #endregion
  32. #region Alternative Digivolution Condition - BurningGreymon
  33. if (timing == EffectTiming.None)
  34. {
  35. bool PermanentCondition(Permanent targetPermanent)
  36. {
  37. if (targetPermanent.TopCard.EqualsCardName("BurningGreymon"))
  38. {
  39. return true;
  40. }
  41. return false;
  42. }
  43. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  44. permanentCondition: PermanentCondition,
  45. digivolutionCost: 0,
  46. ignoreDigivolutionRequirement: false,
  47. card: card,
  48. condition: null)
  49. );
  50. }
  51. #endregion
  52. #region When Digivolving
  53. if (timing == EffectTiming.OnEnterFieldAnyone)
  54. {
  55. ActivateClass activateClass = new ActivateClass();
  56. activateClass.SetUpICardEffect("Place 1 [Hybrid] or [Hero] digimon under this or a red tamer", CanUseCondition, card);
  57. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  58. cardEffects.Add(activateClass);
  59. string EffectDiscription()
  60. => "[When Digivolving] You may place 1 [Hybrid]/[Hero] trait Digimon card from your hand or trash as this Digimon's bottom digivolution card or under any of your red Tamers with inherited effects.";
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  64. {
  65. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. bool CanActivateCondition(Hashtable hashtable)
  73. {
  74. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  75. {
  76. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  77. {
  78. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectSourceCard) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectSourceCard))
  79. {
  80. return true;
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86. bool CanSelectSourceCard(CardSource source)
  87. {
  88. if (source.IsDigimon)
  89. {
  90. if (source.EqualsTraits("Hybrid") || source.EqualsTraits("Hero"))
  91. {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. bool CanSelectPermanent(Permanent permanent)
  98. {
  99. if (permanent == card.PermanentOfThisCard())
  100. {
  101. return true;
  102. }
  103. if (permanent.TopCard.CardColors.Contains(CardColor.Red) && permanent.IsTamer && permanent.TopCard.HasInheritedEffect)
  104. {
  105. return true;
  106. }
  107. return false;
  108. }
  109. IEnumerator ActivateCoroutine(Hashtable hashtable)
  110. {
  111. Permanent selectedPermanent = null;
  112. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanent));
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectPermanent,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: SelectPermanentCoroutine,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Custom,
  125. cardEffect: activateClass);
  126. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  127. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  128. {
  129. selectedPermanent = permanent;
  130. yield return null;
  131. }
  132. if (selectedPermanent != null)
  133. {
  134. SelectCardEffect.Root? rootmode = null!;
  135. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectSourceCard);
  136. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectSourceCard);
  137. if (canSelectHand && !canSelectTrash) rootmode = SelectCardEffect.Root.Hand;
  138. if (!canSelectHand && canSelectTrash) rootmode = SelectCardEffect.Root.Trash;
  139. if (canSelectHand && canSelectTrash)
  140. {
  141. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  142. {
  143. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  144. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  145. };
  146. string selectPlayerMessage = "From which area do you select a card?";
  147. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  148. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  149. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  150. rootmode = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  151. }
  152. if (rootmode != null)
  153. {
  154. CardSource selectedCard = null;
  155. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  156. selectCardEffect.SetUp(
  157. canTargetCondition: CanSelectSourceCard,
  158. canTargetCondition_ByPreSelecetedList: null,
  159. canEndSelectCondition: null,
  160. canNoSelect: () => true,
  161. selectCardCoroutine: SelectCardCoroutine,
  162. afterSelectCardCoroutine: null,
  163. message: "Select 1 card to add as source.",
  164. maxCount: 1,
  165. canEndNotMax: false,
  166. isShowOpponent: true,
  167. mode: SelectCardEffect.Mode.Custom,
  168. root: (SelectCardEffect.Root)rootmode!,
  169. customRootCardList: null,
  170. canLookReverseCard: true,
  171. selectPlayer: card.Owner,
  172. cardEffect: activateClass);
  173. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  174. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  175. IEnumerator SelectCardCoroutine(CardSource cardSource)
  176. {
  177. selectedCard = cardSource;
  178. yield return null;
  179. }
  180. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  181. }
  182. }
  183. }
  184. }
  185. #endregion
  186. #region When Attacking
  187. if (timing == EffectTiming.OnAllyAttack)
  188. {
  189. ActivateClass activateClass = new ActivateClass();
  190. activateClass.SetUpICardEffect("Digivolve into a [Hybrid]/[Hero] digimon", CanUseCondition, card);
  191. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  192. cardEffects.Add(activateClass);
  193. string EffectDiscription()
  194. => "[When Attacking] This Digimon may digivolve into a red [Hybrid]/[Hero] trait Digimon card in the hand with the digivolution cost reduced by 1.";
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  198. {
  199. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  200. {
  201. return true;
  202. }
  203. }
  204. return false;
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  209. {
  210. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCard))
  211. {
  212. return true;
  213. }
  214. }
  215. return false;
  216. }
  217. bool CanSelectCard(CardSource source)
  218. {
  219. if (source.IsDigimon)
  220. {
  221. if (source.EqualsTraits("Hybrid") || source.EqualsTraits("Hero"))
  222. {
  223. if (source.CardColors.Contains(CardColor.Red))
  224. {
  225. return true;
  226. }
  227. }
  228. }
  229. return false;
  230. }
  231. IEnumerator ActivateCoroutine(Hashtable hashtable)
  232. {
  233. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  234. targetPermanent: card.PermanentOfThisCard(),
  235. cardCondition: CanSelectCard,
  236. payCost: true,
  237. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  238. fixedCostTuple: null,
  239. ignoreDigivolutionRequirementFixedCost: -1,
  240. isHand: true,
  241. activateClass: activateClass,
  242. successProcess: null));
  243. }
  244. }
  245. #endregion
  246. #region ESS
  247. if (timing == EffectTiming.None)
  248. {
  249. bool Condition()
  250. {
  251. if (CardEffectCommons.IsOwnerTurn(card))
  252. {
  253. return true;
  254. }
  255. return false;
  256. }
  257. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 2000, isInheritedEffect: true, card: card, condition: Condition));
  258. }
  259. #endregion
  260. return cardEffects;
  261. }
  262. }
  263. }