BT19_078.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT19
  7. {
  8. public class BT19_078 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("-1000DP for each digivolution source", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[On Play] For each digivolution card of 1 of your [Mother D-Reaper]s, 1 of your opponent's Digimon gets -1000 for the turn.";
  23. }
  24. bool IsMotherDReaper(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  27. permanent.TopCard.EqualsCardName("Mother D-Reaper");
  28. }
  29. bool CanSelectOpponentsDigimon(Permanent permanent)
  30. {
  31. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. if (CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentsDigimon))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  49. {
  50. Permanent selectedMother = null;
  51. Permanent selectedPermanent = null;
  52. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  53. selectPermanentEffect.SetUp(
  54. selectPlayer: card.Owner,
  55. canTargetCondition: IsMotherDReaper,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. maxCount: 1,
  59. canNoSelect: false,
  60. canEndNotMax: false,
  61. selectPermanentCoroutine: SelectMotherCoroutine,
  62. afterSelectPermanentCoroutine: null,
  63. mode: SelectPermanentEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectPermanentEffect.SetUpCustomMessage($"Choose 1 [Mother D-Reaper].", "The opponent is choosing 1 [Mother D-Reaper].");
  66. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  67. IEnumerator SelectMotherCoroutine(Permanent permanent)
  68. {
  69. selectedMother = permanent;
  70. yield return null;
  71. }
  72. if(selectedMother != null)
  73. {
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectOpponentsDigimon,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get -{1000 * selectedMother.DigivolutionCards.Count} DP.", "The opponent is selecting 1 Digimon that will be DP reduced.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. selectedPermanent = permanent;
  91. yield return null;
  92. }
  93. if (selectedPermanent != null)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  96. targetPermanent: selectedPermanent,
  97. changeValue: -1000 * selectedMother.DigivolutionCards.Count,
  98. effectDuration: EffectDuration.UntilEachTurnEnd,
  99. activateClass: activateClass));
  100. }
  101. }
  102. }
  103. }
  104. #endregion
  105. #region Main
  106. if (timing == EffectTiming.OnDeclaration)
  107. {
  108. ActivateClass activateClass = new ActivateClass();
  109. activateClass.SetUpICardEffect("Place 1 this card as 1 of your [Mother D-Reaper] digivolution cards", CanUseCondition, card);
  110. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  111. activateClass.SetHashString("PlaceUnder_BT19-078");
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. {
  115. return "[Main] Place this Digimon as the bottom digivolution card of 1 of your [Mother D-Reaper] without [ADR-01 Jeri] in its digivolution cards.";
  116. }
  117. bool CanSelectPermanentCondition(Permanent permanent)
  118. {
  119. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  120. {
  121. if (!permanent.IsToken)
  122. {
  123. if (IsMotherDReaper(permanent))
  124. {
  125. if(permanent.DigivolutionCards.Count(source => source.EqualsCardName("ADR-01 Jeri")) < 1)
  126. return true;
  127. }
  128. }
  129. }
  130. return false;
  131. }
  132. bool IsMotherDReaper(Permanent permanent)
  133. {
  134. return permanent.TopCard.Owner == card.Owner &&
  135. permanent.TopCard.EqualsCardName("Mother D-Reaper");
  136. }
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. if (CardEffectCommons.IsExistOnBattleArea(card))
  140. {
  141. if (!card.PermanentOfThisCard().IsToken)
  142. {
  143. if (CardEffectCommons.HasMatchConditionPermanent(IsMotherDReaper))
  144. {
  145. return true;
  146. }
  147. }
  148. }
  149. return false;
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  152. {
  153. if (isExistOnField(card))
  154. {
  155. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  156. {
  157. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in digivolution cards.", "The opponent is selecting 1 Digimon to place in digivolution cards.");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  173. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  174. {
  175. Permanent selectedPermanent = permanent;
  176. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), selectedPermanent } }, false, activateClass).PlacePermanentToDigivolutionCards());
  177. }
  178. }
  179. }
  180. }
  181. }
  182. #endregion
  183. #region When Opponents Attacks
  184. if (timing == EffectTiming.OnAllyAttack)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect("You may play 1 [ADR-01 Jeri] from this Digimon's digivolution cards, then change the attack target to the Digimon played.", CanUseCondition, card);
  188. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  189. activateClass.SetIsInheritedEffect(true);
  190. cardEffects.Add(activateClass);
  191. string EffectDiscription()
  192. {
  193. return "[Opponent's Turn] When any of your opponent's Digimon attack, you may play 1 [ADR-01 Jeri] from this Digimon's digivolution cards without paying the cost. If you played, you may change the attack target to the Digimon played by this effect.";
  194. }
  195. bool IsOpponentDigimon(Permanent permanent)
  196. {
  197. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  198. }
  199. bool IsADRJeri(CardSource source)
  200. {
  201. return CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass) &&
  202. source.EqualsCardName("ADR-01 Jeri");
  203. }
  204. bool CanUseCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.IsOpponentTurn(card) &&
  207. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  208. }
  209. bool CanActivateCondition(Hashtable hashtable)
  210. {
  211. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  212. card.PermanentOfThisCard().DigivolutionCards.Count(IsADRJeri) > 0;
  213. }
  214. IEnumerator ActivateCoroutine(Hashtable hashtable)
  215. {
  216. bool didPlay = false;
  217. Permanent selectedPermanent = null;
  218. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  219. selectCardEffect.SetUp(
  220. selectPlayer: card.Owner,
  221. canTargetCondition: IsADRJeri,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. maxCount: 1,
  225. canNoSelect: () => true,
  226. canEndNotMax: false,
  227. message: "Select 1 card to play",
  228. isShowOpponent: true,
  229. canLookReverseCard:false,
  230. selectCardCoroutine: null,
  231. afterSelectCardCoroutine: SelectCardCoroutine,
  232. mode: SelectCardEffect.Mode.Custom,
  233. root: SelectCardEffect.Root.Custom,
  234. customRootCardList:card.PermanentOfThisCard().DigivolutionCards,
  235. cardEffect: activateClass);
  236. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  237. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  238. {
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  240. cardSources: cardSources,
  241. activateClass: activateClass,
  242. payCost: false,
  243. isTapped: false,
  244. root: SelectCardEffect.Root.Custom,
  245. activateETB: true));
  246. if(cardSources.Count > 0)
  247. {
  248. didPlay = true;
  249. selectedPermanent = cardSources[0].PermanentOfThisCard();
  250. }
  251. }
  252. if (didPlay)
  253. {
  254. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  255. {
  256. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  257. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  258. };
  259. string selectPlayerMessage = "Will you change attack target?";
  260. string notSelectPlayerMessage = "The opponent is choosing whether or not to change attack target.";
  261. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  262. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  263. bool willRedirect = GManager.instance.userSelectionManager.SelectedBoolValue;
  264. if (willRedirect)
  265. {
  266. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  267. activateClass,
  268. false,
  269. selectedPermanent));
  270. }
  271. }
  272. }
  273. }
  274. #endregion
  275. return cardEffects;
  276. }
  277. }
  278. }