BT17_025.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // Cerberusmon: Werewolf Mode
  6. namespace DCGO.CardEffects.BT17
  7. {
  8. public class BT17_025 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution/ Rule Trait
  14. if (timing == EffectTiming.None)
  15. {
  16. // Alternate Digivolution
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.EqualsCardName("Cerberusmon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false,
  23. card: card, condition: null));
  24. }
  25. #endregion
  26. #region When Digivolving
  27. if (timing == EffectTiming.OnEnterFieldAnyone)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Play 1 level 3 blue or purple Digimon card from your trash or digivolution cards",
  31. CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  33. cardEffects.Add(activateClass);
  34. string EffectDescription()
  35. {
  36. return
  37. "[When Digivolving] You may play 1 level 3 blue or purple Digimon card from your trash or from one of your Digimon's digivolution cards without paying the cost. At the next end of your opponent's turn, return it to the hand.";
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  42. }
  43. bool CanSelectCardCondition(CardSource cardSource)
  44. {
  45. return CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass) &&
  46. cardSource.IsDigimon &&
  47. cardSource.IsLevel3 &&
  48. (cardSource.HasCardColor(CardColor.Blue) || cardSource.HasCardColor(CardColor.Purple));
  49. }
  50. bool CanSelectPermanentCondition(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  53. permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. return CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition) ||
  60. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  61. }
  62. return false;
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  67. bool canSelectDigivolutionCards = CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  68. if (canSelectTrash || canSelectDigivolutionCards)
  69. {
  70. if (canSelectTrash && canSelectDigivolutionCards)
  71. {
  72. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  73. {
  74. new(message: "From trash", value: true, spriteIndex: 0),
  75. new(message: "From digivolution cards", value: false, spriteIndex: 1),
  76. };
  77. string selectPlayerMessage = "From which area do you play a card?";
  78. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  79. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  80. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  81. notSelectPlayerMessage: notSelectPlayerMessage);
  82. }
  83. else
  84. {
  85. GManager.instance.userSelectionManager.SetBool(canSelectTrash);
  86. }
  87. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  88. .WaitForEndSelect());
  89. bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  90. List<CardSource> selectedCards = new List<CardSource>();
  91. IEnumerator SelectCardCoroutine(CardSource cardSource)
  92. {
  93. selectedCards.Add(cardSource);
  94. yield return null;
  95. }
  96. if (fromTrash)
  97. {
  98. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  99. selectCardEffect.SetUp(
  100. canTargetCondition: CanSelectCardCondition,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. canNoSelect: () => true,
  104. selectCardCoroutine: SelectCardCoroutine,
  105. afterSelectCardCoroutine: null,
  106. message: "Select 1 card to play.",
  107. maxCount: 1,
  108. canEndNotMax: false,
  109. isShowOpponent: true,
  110. mode: SelectCardEffect.Mode.Custom,
  111. root: SelectCardEffect.Root.Trash,
  112. customRootCardList: null,
  113. canLookReverseCard: true,
  114. selectPlayer: card.Owner,
  115. cardEffect: activateClass);
  116. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  117. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  118. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  119. }
  120. else
  121. {
  122. int maxCount = Math.Min(1,
  123. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  124. SelectPermanentEffect selectPermanentEffect =
  125. GManager.instance.GetComponent<SelectPermanentEffect>();
  126. selectPermanentEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectPermanentCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: maxCount,
  132. canNoSelect: true,
  133. canEndNotMax: false,
  134. selectPermanentCoroutine: SelectPermanentCoroutine,
  135. afterSelectPermanentCoroutine: null,
  136. mode: SelectPermanentEffect.Mode.Custom,
  137. cardEffect: activateClass);
  138. selectPermanentEffect.SetUpCustomMessage(
  139. "Select 1 Digimon which has digivolution cards.",
  140. "The opponent is selecting 1 Digimon which has digivolution cards.");
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  143. {
  144. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  145. {
  146. maxCount = Math.Min(1,
  147. permanent.DigivolutionCards.Count(CanSelectCardCondition));
  148. SelectCardEffect selectCardEffect =
  149. GManager.instance.GetComponent<SelectCardEffect>();
  150. selectCardEffect.SetUp(
  151. canTargetCondition: CanSelectCardCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. canNoSelect: () => true,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. message: "Select 1 digivolution card to play.",
  158. maxCount: maxCount,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. mode: SelectCardEffect.Mode.Custom,
  162. root: SelectCardEffect.Root.Custom,
  163. customRootCardList: permanent.DigivolutionCards,
  164. canLookReverseCard: true,
  165. selectPlayer: card.Owner,
  166. cardEffect: activateClass);
  167. selectCardEffect.SetUpCustomMessage(
  168. "Select 1 digivolution card to play.",
  169. "The opponent is selecting 1 digivolution card to play.");
  170. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  171. yield return StartCoroutine(selectCardEffect.Activate());
  172. }
  173. }
  174. }
  175. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  176. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  177. root: (fromTrash) ? SelectCardEffect.Root.Trash : SelectCardEffect.Root.DigivolutionCards,
  178. activateETB: true));
  179. if (selectedCards.Count > 0)
  180. {
  181. Permanent selectedPermanent = selectedCards[0].PermanentOfThisCard();
  182. ActivateClass activateDebuffClass = new ActivateClass();
  183. activateDebuffClass.SetUpICardEffect("Return this Digimon to the hand", CanUseDebuffCondition,
  184. selectedPermanent.TopCard);
  185. activateDebuffClass.SetUpActivateClass(CanActivateDebuffCondition, ActivateDebuffCoroutine, -1, false,
  186. EffectDebuffDescription());
  187. activateDebuffClass.SetEffectSourcePermanent(selectedPermanent);
  188. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  189. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  190. {
  191. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  192. .CreateDebuffEffect(selectedPermanent));
  193. }
  194. string EffectDebuffDescription()
  195. {
  196. return "[End of Opponent's Turn] Return this Digimon to the hand.";
  197. }
  198. bool CanUseDebuffCondition(Hashtable debuffHashtable)
  199. {
  200. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  201. GManager.instance.turnStateMachine.gameContext.TurnPlayer != selectedPermanent.TopCard.Owner;
  202. }
  203. bool CanActivateDebuffCondition(Hashtable debuffHashtable)
  204. {
  205. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  206. !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  207. }
  208. IEnumerator ActivateDebuffCoroutine(Hashtable debuffHashtable)
  209. {
  210. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  211. {
  212. yield return ContinuousController.instance.StartCoroutine(
  213. CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  214. targetPermanents: new List<Permanent>() { selectedPermanent },
  215. activateClass: activateDebuffClass,
  216. successProcess: null,
  217. failureProcess: null));
  218. }
  219. }
  220. ICardEffect GetCardEffect(EffectTiming debuffTiming)
  221. {
  222. if (debuffTiming == EffectTiming.OnEndTurn)
  223. {
  224. return activateDebuffClass;
  225. }
  226. return null;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. #endregion
  233. #region All Turns - ESS
  234. if (timing == EffectTiming.OnEnterFieldAnyone)
  235. {
  236. ActivateClass activateClass = new ActivateClass();
  237. activateClass.SetUpICardEffect("Return 1 of your opponent's level 3 Digimon to the hand", CanUseCondition, card);
  238. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  239. activateClass.SetIsInheritedEffect(true);
  240. activateClass.SetHashString("Return_BT17-025");
  241. cardEffects.Add(activateClass);
  242. string EffectDescription()
  243. {
  244. return
  245. "[All Turns] [Once Per Turn] When an effect plays one of your Digimon, return 1 of your opponent's level 3 Digimon to the hand.";
  246. }
  247. bool IsOwnDigimon(Permanent permanent)
  248. {
  249. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  250. }
  251. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  252. {
  253. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  254. permanent.TopCard.HasLevel &&
  255. permanent.TopCard.IsLevel3;
  256. }
  257. bool CanUseCondition(Hashtable hashtable)
  258. {
  259. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsOwnDigimon) &&
  260. CardEffectCommons.IsByEffect(hashtable, null);
  261. }
  262. bool CanActivateCondition(Hashtable hashtable)
  263. {
  264. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  265. CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition);
  266. }
  267. IEnumerator ActivateCoroutine(Hashtable hashtable)
  268. {
  269. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  270. {
  271. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  272. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  273. selectPermanentEffect.SetUp(
  274. selectPlayer: card.Owner,
  275. canTargetCondition: CanSelectOpponentPermanentCondition,
  276. canTargetCondition_ByPreSelecetedList: null,
  277. canEndSelectCondition: null,
  278. maxCount: maxCount,
  279. canNoSelect: false,
  280. canEndNotMax: false,
  281. selectPermanentCoroutine: null,
  282. afterSelectPermanentCoroutine: null,
  283. mode: SelectPermanentEffect.Mode.Bounce,
  284. cardEffect: activateClass);
  285. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  286. }
  287. }
  288. }
  289. #endregion
  290. return cardEffects;
  291. }
  292. }
  293. }