BT23_022.cs 16 KB

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