BT21_013.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectSourceCard);
  135. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectSourceCard);
  136. if (canSelectHand || canSelectTrash)
  137. {
  138. if (canSelectHand && canSelectTrash)
  139. {
  140. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  141. {
  142. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  143. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  144. };
  145. string selectPlayerMessage = "From which area do you select a card?";
  146. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  147. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  148. }
  149. else
  150. {
  151. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  152. }
  153. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  154. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  155. if (fromHand)
  156. {
  157. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  158. selectHandEffect.SetUp(
  159. selectPlayer: card.Owner,
  160. canTargetCondition: CanSelectSourceCard,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. maxCount: 1,
  164. canNoSelect: true,
  165. canEndNotMax: false,
  166. isShowOpponent: true,
  167. selectCardCoroutine: SelectCardCoroutine,
  168. afterSelectCardCoroutine: null,
  169. mode: SelectHandEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectHandEffect.SetUpCustomMessage(
  172. "Select 1 card to add as source.",
  173. "The opponent is selecting 1 card to add as source.");
  174. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  175. yield return StartCoroutine(selectHandEffect.Activate());
  176. }
  177. else
  178. {
  179. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  180. selectCardEffect.SetUp(
  181. canTargetCondition: CanSelectSourceCard,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. canNoSelect: () => true,
  185. selectCardCoroutine: SelectCardCoroutine,
  186. afterSelectCardCoroutine: null,
  187. message: "Select 1 card to add as source.",
  188. maxCount: 1,
  189. canEndNotMax: false,
  190. isShowOpponent: true,
  191. mode: SelectCardEffect.Mode.Custom,
  192. root: SelectCardEffect.Root.Trash,
  193. customRootCardList: null,
  194. canLookReverseCard: true,
  195. selectPlayer: card.Owner,
  196. cardEffect: activateClass);
  197. selectCardEffect.SetUpCustomMessage(
  198. "Select 1 card to add as source.",
  199. "The opponent is selecting 1 card to add as source.");
  200. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  201. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  202. }
  203. CardSource selectedCard = null;
  204. IEnumerator SelectCardCoroutine(CardSource cardSource)
  205. {
  206. selectedCard = cardSource;
  207. yield return null;
  208. }
  209. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  210. }
  211. }
  212. }
  213. }
  214. #endregion
  215. #region When Attacking
  216. if (timing == EffectTiming.OnAllyAttack)
  217. {
  218. ActivateClass activateClass = new ActivateClass();
  219. activateClass.SetUpICardEffect("Digivolve into a [Hybrid]/[Hero] digimon", CanUseCondition, card);
  220. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  221. cardEffects.Add(activateClass);
  222. string EffectDiscription()
  223. => "[When Attacking] This Digimon may digivolve into a red [Hybrid]/[Hero] trait Digimon card in the hand with the digivolution cost reduced by 1.";
  224. bool CanUseCondition(Hashtable hashtable)
  225. {
  226. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  227. {
  228. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  229. {
  230. return true;
  231. }
  232. }
  233. return false;
  234. }
  235. bool CanActivateCondition(Hashtable hashtable)
  236. {
  237. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  238. {
  239. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCard))
  240. {
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. bool CanSelectCard(CardSource source)
  247. {
  248. if (source.IsDigimon)
  249. {
  250. if (source.EqualsTraits("Hybrid") || source.EqualsTraits("Hero"))
  251. {
  252. if (source.CardColors.Contains(CardColor.Red))
  253. {
  254. return true;
  255. }
  256. }
  257. }
  258. return false;
  259. }
  260. IEnumerator ActivateCoroutine(Hashtable hashtable)
  261. {
  262. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  263. targetPermanent: card.PermanentOfThisCard(),
  264. cardCondition: CanSelectCard,
  265. payCost: true,
  266. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  267. fixedCostTuple: null,
  268. ignoreDigivolutionRequirementFixedCost: -1,
  269. isHand: true,
  270. activateClass: activateClass,
  271. successProcess: null));
  272. }
  273. }
  274. #endregion
  275. #region ESS
  276. if (timing == EffectTiming.None)
  277. {
  278. bool Condition()
  279. {
  280. if (CardEffectCommons.IsOwnerTurn(card))
  281. {
  282. return true;
  283. }
  284. return false;
  285. }
  286. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 2000, isInheritedEffect: true, card: card, condition: Condition));
  287. }
  288. #endregion
  289. return cardEffects;
  290. }
  291. }
  292. }