BT17_050.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_050 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alliance
  13. if (timing == EffectTiming.OnAllyAttack)
  14. {
  15. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region Hand - Main
  19. if (timing == EffectTiming.OnDeclaration)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Suspend one of your opponents Digimon, Then attack an opponents suspended Digimon", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  24. activateClass.SetIsDigimonEffect(true);
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[Hand] [Main] By paying 4 cost and placing this card as the bottom digivolution card of 1 of your level 5 or higher Digimon, you may suspend 1 of your opponent’s Digimon and attack an opponent’s Digimon with the Digimon this card was placed under.";
  29. }
  30. bool IsLevel5OorHigher(Permanent targetPermanent)
  31. {
  32. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  33. {
  34. if (targetPermanent.TopCard.HasLevel && targetPermanent.Level >= 5)
  35. return true;
  36. }
  37. return false;
  38. }
  39. bool IsEnemyPermanent(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnHand(card))
  46. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsLevel5OorHigher);
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable hashtable)
  50. {
  51. Permanent selectedPermanent = null;
  52. bool willsuspend = false;
  53. if (CardEffectCommons.HasMatchConditionPermanent(IsLevel5OorHigher))
  54. {
  55. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLevel5OorHigher));
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: IsLevel5OorHigher,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: SelectPermanentCoroutine,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to add bottom digivolution source.", "The opponent is selecting 1 Digimon to add bottom digivolution source.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. selectedPermanent = permanent;
  74. if (selectedPermanent != null)
  75. {
  76. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-4, activateClass));
  77. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  78. new List<CardSource>() { card },
  79. activateClass));
  80. }
  81. }
  82. }
  83. if(selectedPermanent != null)
  84. {
  85. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  86. {
  87. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  88. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  89. };
  90. string selectPlayerMessage = "Will you suspend opponents digimon, and attack?";
  91. string notSelectPlayerMessage = "The opponent is choosing whether or not to suspend opponents digimon, and attack.";
  92. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  93. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  94. willsuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  95. }
  96. if (willsuspend)
  97. {
  98. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanent))
  99. {
  100. int enemyCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanent));
  101. SelectPermanentEffect selectEnemyEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  102. selectEnemyEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: IsEnemyPermanent,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: enemyCount,
  108. canNoSelect: false,
  109. canEndNotMax: false,
  110. selectPermanentCoroutine: null,
  111. afterSelectPermanentCoroutine: null,
  112. mode: SelectPermanentEffect.Mode.Tap,
  113. cardEffect: activateClass);
  114. selectEnemyEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  115. yield return ContinuousController.instance.StartCoroutine(selectEnemyEffect.Activate());
  116. if (selectedPermanent.CanAttack(activateClass))
  117. {
  118. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  119. selectAttackEffect.SetUp(
  120. attacker: selectedPermanent,
  121. canAttackPlayerCondition: () => false,
  122. defenderCondition: (permanent) => true,
  123. cardEffect: activateClass);
  124. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  125. }
  126. }
  127. }
  128. }
  129. }
  130. #endregion
  131. #region End of Attack
  132. if (timing == EffectTiming.OnEndAttack)
  133. {
  134. ActivateClass activateClass = new ActivateClass();
  135. activateClass.SetUpICardEffect("Place this digimon as the bottom digivolution card", CanUseCondition, card);
  136. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  137. cardEffects.Add(activateClass);
  138. string EffectDiscription()
  139. {
  140. return "[End of Attack] You may place this Digimon as the bottom digivolution card of 1 of your other Digimon.";
  141. }
  142. bool CanSelectMyOtherDigimon(Permanent permanent)
  143. {
  144. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  145. {
  146. if (permanent != card.PermanentOfThisCard())
  147. {
  148. return true;
  149. }
  150. }
  151. return false;
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  160. {
  161. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectMyOtherDigimon))
  162. {
  163. return true;
  164. }
  165. }
  166. return false;
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable hashtable)
  169. {
  170. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectMyOtherDigimon))
  171. {
  172. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectMyOtherDigimon));
  173. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  174. selectPermanentEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: CanSelectMyOtherDigimon,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: maxCount,
  180. canNoSelect: true,
  181. canEndNotMax: false,
  182. selectPermanentCoroutine: SelectPermanentCoroutine,
  183. afterSelectPermanentCoroutine: null,
  184. mode: SelectPermanentEffect.Mode.Custom,
  185. cardEffect: activateClass);
  186. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  189. {
  190. Permanent selectedPermanent = permanent;
  191. if (selectedPermanent != null)
  192. {
  193. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  194. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  195. }
  196. }
  197. }
  198. }
  199. }
  200. #endregion
  201. #region All Turns - Protection
  202. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  203. {
  204. ActivateClass activateClass = new ActivateClass();
  205. activateClass.SetUpICardEffect("Play 1 [Parasitemon]", CanUseCondition, card);
  206. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  207. activateClass.SetIsInheritedEffect(true);
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. return "[All Turns] When an opponent’s effect would delete this Digimon, you may play 1 [Parasitemon] from this Digimon’s digivolution cards without paying the cost.";
  212. }
  213. bool CardEffectCondition(ICardEffect cardEffect)
  214. {
  215. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  216. }
  217. bool CanSelectCardCondition(CardSource cardSource)
  218. {
  219. if (cardSource.IsDigimon)
  220. {
  221. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  222. {
  223. if (cardSource.EqualsCardName("Parasitemon"))
  224. {
  225. return true;
  226. }
  227. }
  228. }
  229. return false;
  230. }
  231. bool CanUseCondition(Hashtable hashtable)
  232. {
  233. if (CardEffectCommons.IsExistOnBattleArea(card))
  234. {
  235. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  236. {
  237. if (CardEffectCommons.IsByEffect(hashtable, CardEffectCondition))
  238. {
  239. return true;
  240. }
  241. }
  242. }
  243. return false;
  244. }
  245. bool CanActivateCondition(Hashtable hashtable)
  246. {
  247. if (CardEffectCommons.IsExistOnBattleArea(card))
  248. {
  249. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  250. {
  251. return true;
  252. }
  253. }
  254. return false;
  255. }
  256. IEnumerator ActivateCoroutine(Hashtable hashtable)
  257. {
  258. Permanent selectedPermanent = card.PermanentOfThisCard();
  259. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  260. {
  261. List<CardSource> selectedCards = new List<CardSource>();
  262. int maxCount = 1;
  263. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  264. selectCardEffect.SetUp(
  265. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  266. canTargetCondition_ByPreSelecetedList: null,
  267. canEndSelectCondition: null,
  268. canNoSelect: () => true,
  269. selectCardCoroutine: null,
  270. afterSelectCardCoroutine: SelectCardCoroutine,
  271. message: "Select 1 card to play.",
  272. maxCount: maxCount,
  273. canEndNotMax: false,
  274. isShowOpponent: true,
  275. mode: SelectCardEffect.Mode.Custom,
  276. root: SelectCardEffect.Root.Custom,
  277. customRootCardList: selectedPermanent.DigivolutionCards,
  278. canLookReverseCard: true,
  279. selectPlayer: card.Owner,
  280. cardEffect: activateClass);
  281. selectCardEffect.SetUpCustomMessage("Select digivolution cards to play.", "The opponent is selecting digivolution cards to play.");
  282. selectCardEffect.SetUpCustomMessage_ShowCard("Played Cards");
  283. yield return StartCoroutine(selectCardEffect.Activate());
  284. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  285. {
  286. if(cardSources != null)
  287. {
  288. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  289. cardSources: cardSources,
  290. activateClass: activateClass,
  291. payCost: false,
  292. isTapped: false,
  293. root: SelectCardEffect.Root.DigivolutionCards,
  294. activateETB: true));
  295. }
  296. }
  297. }
  298. }
  299. }
  300. #endregion
  301. #region Your Turn
  302. if (timing == EffectTiming.None)
  303. {
  304. bool Condition()
  305. {
  306. if (CardEffectCommons.IsExistOnBattleArea(card))
  307. {
  308. if (CardEffectCommons.IsOwnerTurn(card))
  309. {
  310. return true;
  311. }
  312. }
  313. return false;
  314. }
  315. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 3000, isInheritedEffect: true, card: card, condition: Condition));
  316. }
  317. #endregion
  318. return cardEffects;
  319. }
  320. }
  321. }