BT23_021.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Dosukomon
  4. namespace DCGO.CardEffects.BT23
  5. {
  6. public class BT23_021 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Static Effects
  12. #region App Fusion (Dokamon, Perorimon, Musclemon)
  13. if (timing == EffectTiming.None)
  14. {
  15. AddAppFusionConditionClass addAppFusionConditionClass = new AddAppFusionConditionClass();
  16. addAppFusionConditionClass.SetUpICardEffect($"App Fusion", (hashtable) => true, card);
  17. addAppFusionConditionClass.SetUpAddAppFusionConditionClass(getAppFusionCondition: GetAppFusion);
  18. addAppFusionConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addAppFusionConditionClass);
  20. AppFusionCondition GetAppFusion(CardSource cardSource)
  21. {
  22. bool linkCondition(Permanent permanent, CardSource source)
  23. {
  24. if (source != null && source != card)
  25. {
  26. if (permanent.TopCard.EqualsCardName("Dokamon"))
  27. {
  28. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Perorimon") || x.EqualsCardName("Musclemon")))
  29. {
  30. return true;
  31. }
  32. }
  33. if (permanent.TopCard.EqualsCardName("Perorimon"))
  34. {
  35. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Dokamon") || x.EqualsCardName("Musclemon")))
  36. {
  37. return true;
  38. }
  39. }
  40. if (permanent.TopCard.EqualsCardName("Musclemon"))
  41. {
  42. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Dokamon") || x.EqualsCardName("Perorimon")))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool digimonCondition(Permanent permanent)
  51. {
  52. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  53. {
  54. if (permanent.TopCard.EqualsCardName("Dokamon"))
  55. {
  56. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Perorimon") || x.EqualsCardName("Musclemon")))
  57. {
  58. return true;
  59. }
  60. }
  61. if (permanent.TopCard.EqualsCardName("Perorimon"))
  62. {
  63. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Dokamon") || x.EqualsCardName("Musclemon")))
  64. {
  65. return true;
  66. }
  67. }
  68. if (permanent.TopCard.EqualsCardName("Musclemon"))
  69. {
  70. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Dokamon") || x.EqualsCardName("Perorimon")))
  71. {
  72. return true;
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. if (cardSource == card)
  79. {
  80. AppFusionCondition AppFusionCondition = new AppFusionCondition(
  81. linkCondition,
  82. digimonCondition,
  83. 0);
  84. return AppFusionCondition;
  85. }
  86. return null;
  87. }
  88. }
  89. #endregion
  90. #region Alternative Digivolution Condition
  91. if (timing == EffectTiming.None)
  92. {
  93. bool PermanentCondition(Permanent targetPermanent)
  94. {
  95. return targetPermanent.TopCard.HasStandardAppTraits;
  96. }
  97. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  98. permanentCondition: PermanentCondition,
  99. digivolutionCost: 3,
  100. ignoreDigivolutionRequirement: false,
  101. card: card,
  102. condition: null)
  103. );
  104. }
  105. #endregion
  106. #region Link Condition
  107. if (timing == EffectTiming.None)
  108. {
  109. static bool PermanentCondition(Permanent targetPermanent)
  110. {
  111. return targetPermanent.TopCard.HasAppmonTraits;
  112. }
  113. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  114. }
  115. #endregion
  116. #region Link
  117. if (timing == EffectTiming.OnDeclaration)
  118. {
  119. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  120. }
  121. #endregion
  122. #endregion
  123. #region WD/WA OPT Shared
  124. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  125. {
  126. Permanent thisPermament = card.PermanentOfThisCard();
  127. bool CanSelectCardCondition(CardSource cardSource)
  128. {
  129. return cardSource.IsDigimon
  130. && cardSource.HasLevel && cardSource.IsLevel3
  131. && cardSource.CanLinkToTargetPermanent(thisPermament, false);
  132. }
  133. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  134. bool canSelectDigivolutionSources = thisPermament.StackCards.Exists(CanSelectCardCondition);
  135. if (canSelectHand || canSelectDigivolutionSources)
  136. {
  137. if (canSelectHand && canSelectDigivolutionSources)
  138. {
  139. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  140. {
  141. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  142. new SelectionElement<bool>(message: $"From digivolution", value : false, spriteIndex: 1),
  143. };
  144. string selectPlayerMessage = "From which area do you select a card?";
  145. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  146. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  147. }
  148. else
  149. {
  150. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  151. }
  152. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  153. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  154. CardSource selectedCard = null;
  155. IEnumerator SelectCardCoroutine(CardSource cardSource)
  156. {
  157. selectedCard = cardSource;
  158. yield return null;
  159. }
  160. if (fromHand)
  161. {
  162. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  163. selectHandEffect.SetUp(
  164. selectPlayer: card.Owner,
  165. canTargetCondition: CanSelectCardCondition,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. maxCount: 1,
  169. canNoSelect: true,
  170. canEndNotMax: false,
  171. isShowOpponent: true,
  172. selectCardCoroutine: SelectCardCoroutine,
  173. afterSelectCardCoroutine: null,
  174. mode: SelectHandEffect.Mode.Custom,
  175. cardEffect: activateClass);
  176. selectHandEffect.SetUpCustomMessage("Select 1 card to add as link", "The opponent is selecting 1 card to add as link");
  177. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  178. }
  179. else
  180. {
  181. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  182. selectCardEffect.SetUp(
  183. canTargetCondition: CanSelectCardCondition,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. canNoSelect: () => true,
  187. selectCardCoroutine: SelectCardCoroutine,
  188. afterSelectCardCoroutine: null,
  189. message: "Select 1 card to add as link.",
  190. maxCount: 1,
  191. canEndNotMax: false,
  192. isShowOpponent: true,
  193. mode: SelectCardEffect.Mode.Custom,
  194. root: SelectCardEffect.Root.DigivolutionCards,
  195. customRootCardList: thisPermament.StackCards,
  196. canLookReverseCard: true,
  197. selectPlayer: card.Owner,
  198. cardEffect: activateClass);
  199. selectCardEffect.SetUpCustomMessage("Select 1 card to add as link.", "The opponent is selecting 1 card to add as link.");
  200. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  201. }
  202. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(thisPermament.AddLinkCard(addedLinkCard: selectedCard, cardEffect: activateClass));
  203. }
  204. }
  205. #endregion
  206. #region When Digivolving - OPT
  207. if (timing == EffectTiming.OnEnterFieldAnyone)
  208. {
  209. ActivateClass activateClass = new ActivateClass();
  210. activateClass.SetUpICardEffect("Link 1 level 3 digimon from hand or digivolution cards", CanUseCondition, card);
  211. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), 1, true, EffectDiscription());
  212. activateClass.SetHashString("BT23_021_WD/WA");
  213. cardEffects.Add(activateClass);
  214. string EffectDiscription()
  215. {
  216. return "[When Digivolving] [Once Per Turn] You may link 1 level 3 Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  221. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  222. }
  223. bool CanActivateCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  226. }
  227. }
  228. #endregion
  229. #region When Attacking - OPT
  230. if (timing == EffectTiming.OnAllyAttack)
  231. {
  232. ActivateClass activateClass = new ActivateClass();
  233. activateClass.SetUpICardEffect("Link 1 level 3 digimon from hand or digivolution cards", CanUseCondition, card);
  234. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), 1, true, EffectDiscription());
  235. activateClass.SetHashString("BT23_021_WD/WA");
  236. cardEffects.Add(activateClass);
  237. string EffectDiscription()
  238. {
  239. return "[When Attacking] [Once Per Turn] You may link 1 level 3 Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  240. }
  241. bool CanUseCondition(Hashtable hashtable)
  242. {
  243. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  244. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  245. }
  246. bool CanActivateCondition(Hashtable hashtable)
  247. {
  248. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  249. }
  250. }
  251. #endregion
  252. #region YT/ESS Shared
  253. IEnumerator SharedActivateCoroutine1(Hashtable hashtable, ActivateClass activateClass)
  254. {
  255. bool CanNotBeDestroyedByBattleCondition(Permanent permanent, Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  256. {
  257. if (permanent == AttackingPermanent)
  258. {
  259. return true;
  260. }
  261. if (permanent == DefendingPermanent)
  262. {
  263. return true;
  264. }
  265. return false;
  266. }
  267. Permanent thisPermanent = card.PermanentOfThisCard().TopCard.PermanentOfThisCard();
  268. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  269. targetPermanent: thisPermanent,
  270. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  271. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  272. activateClass: activateClass,
  273. effectName: "Can't be destroyed by battle"));
  274. }
  275. #endregion
  276. #region Your Turns - OPT
  277. if (timing == EffectTiming.WhenLinked)
  278. {
  279. ActivateClass activateClass = new ActivateClass();
  280. activateClass.SetUpICardEffect("Gain immunity from battle", CanUseCondition, card);
  281. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine1(hashtable, activateClass), 1, false, EffectDiscription());
  282. activateClass.SetHashString("BT23_021_WL");
  283. cardEffects.Add(activateClass);
  284. string EffectDiscription()
  285. {
  286. return "[Your Turn] [Once Per Turn] When this Digimon gets linked, it can't be deleted in battle until your opponent's turn ends.";
  287. }
  288. bool CanUseCondition(Hashtable hashtable)
  289. {
  290. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  291. && CardEffectCommons.CanTriggerWhenLinked(hashtable, permanent => permanent == card.PermanentOfThisCard(), null)
  292. && CardEffectCommons.IsOwnerTurn(card);
  293. }
  294. bool CanActivateCondition(Hashtable hashtable)
  295. {
  296. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  297. }
  298. }
  299. #endregion
  300. #region Link Effect
  301. if (timing == EffectTiming.WhenLinked)
  302. {
  303. ActivateClass activateClass = new ActivateClass();
  304. activateClass.SetUpICardEffect("Gain immunity from battle", CanUseCondition, card);
  305. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  306. activateClass.SetIsLinkedEffect(true);
  307. cardEffects.Add(activateClass);
  308. string EffectDiscription()
  309. {
  310. return "[When Linking] This Digimon can't be deleted in battle until your opponent's turn ends.";
  311. }
  312. bool CanUseCondition(Hashtable hashtable)
  313. {
  314. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  315. }
  316. bool CanActivateCondition(Hashtable hashtable)
  317. {
  318. return CardEffectCommons.IsExistOnBattleArea(card);
  319. }
  320. IEnumerator ActivateCoroutine(Hashtable hashtable)
  321. {
  322. bool CanNotBeDestroyedByBattleCondition(Permanent permanent, Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  323. {
  324. if (permanent == AttackingPermanent)
  325. {
  326. return true;
  327. }
  328. if (permanent == DefendingPermanent)
  329. {
  330. return true;
  331. }
  332. return false;
  333. }
  334. Permanent thisPermanent = card.PermanentOfThisCard().TopCard.PermanentOfThisCard();
  335. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  336. targetPermanent: thisPermanent,
  337. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  338. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  339. activateClass: activateClass,
  340. effectName: "Can't be deleted in battle"));
  341. }
  342. }
  343. #endregion
  344. return cardEffects;
  345. }
  346. }
  347. }