BT21_013.cs 15 KB

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