BT18_078.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_078 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. // Any purple
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.IsTamer && targetPermanent.TopCard.CardColors.Contains(CardColor.Purple);
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  21. card: card, condition: null));
  22. }
  23. // Koichi Kimura
  24. if (timing == EffectTiming.None)
  25. {
  26. bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.EqualsCardName("Koichi Kimura");
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  31. permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false,
  32. card: card, condition: null));
  33. }
  34. // Velgrmon
  35. if (timing == EffectTiming.None)
  36. {
  37. bool PermanentCondition(Permanent targetPermanent)
  38. {
  39. return targetPermanent.TopCard.EqualsCardName("Velgrmon");
  40. }
  41. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  42. permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false,
  43. card: card, condition: null));
  44. }
  45. #endregion
  46. #region On Play/ When Digivolving Shared
  47. bool CanSelectPermanentConditionShared(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  50. (permanent.IsDigimon || permanent.IsTamer);
  51. }
  52. bool CanActivateConditionShared(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  55. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared);
  56. }
  57. #endregion
  58. #region On Play
  59. if (timing == EffectTiming.OnEnterFieldAnyone)
  60. {
  61. ActivateClass activateClass = new ActivateClass();
  62. activateClass.SetUpICardEffect("Change the color of 1 of your opponent's Digimon or Tamer", CanUseCondition, card);
  63. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  64. cardEffects.Add(activateClass);
  65. string EffectDescription()
  66. {
  67. return
  68. "[On Play] Until the end of your opponent's turn, change 1 of their Digimon or Tamers into a color other than white.";
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable hashtable)
  75. {
  76. Permanent selectedPermanent = null;
  77. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  78. selectPermanentEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectPermanentConditionShared,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: false,
  85. canEndNotMax: false,
  86. selectPermanentCoroutine: SelectPermanentCoroutine,
  87. afterSelectPermanentCoroutine: null,
  88. mode: SelectPermanentEffect.Mode.Custom,
  89. cardEffect: activateClass);
  90. selectPermanentEffect.SetUpCustomMessage(
  91. "Select 1 Digimon that will change color.",
  92. "The opponent is selecting 1 Digimon that will change color.");
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  95. {
  96. selectedPermanent = permanent;
  97. yield return null;
  98. }
  99. if (selectedPermanent != null)
  100. {
  101. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  102. {
  103. new(message: $"Red", value: (int)CardColor.Red, spriteIndex: 0),
  104. new(message: $"Blue", value: (int)CardColor.Blue, spriteIndex: 0),
  105. new(message: $"Yellow", value: (int)CardColor.Yellow, spriteIndex: 0),
  106. new(message: $"Green", value: (int)CardColor.Green, spriteIndex: 0),
  107. new(message: $"Black", value: (int)CardColor.Black, spriteIndex: 0),
  108. new(message: $"Purple", value: (int)CardColor.Purple, spriteIndex: 0),
  109. };
  110. string selectPlayerMessage = "Select a color.";
  111. string notSelectPlayerMessage = "The opponent is selecting a color.";
  112. GManager.instance.userSelectionManager.SetIntSelection(
  113. selectionElements: selectionElements,
  114. selectPlayer: card.Owner,
  115. selectPlayerMessage: selectPlayerMessage,
  116. notSelectPlayerMessage: notSelectPlayerMessage);
  117. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  118. .WaitForEndSelect());
  119. CardColor chosenColor = (CardColor)GManager.instance.userSelectionManager.SelectedIntValue;
  120. ChangeBaseCardColorClass changeBaseCardNameClass = new ChangeBaseCardColorClass();
  121. changeBaseCardNameClass.SetUpICardEffect($"Original card color is changed: {chosenColor}", CanUseChangeColorCondition, card);
  122. changeBaseCardNameClass.SetUpChangeBaseCardColorClass(ChangeBaseCardColors: ChangeBaseCardColors);
  123. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => changeBaseCardNameClass);
  124. #region Log
  125. string log = "";
  126. log += $"\nChanged Card Color to {chosenColor}:";
  127. log += $"\n{selectedPermanent.TopCard.BaseENGCardNameFromEntity}({selectedPermanent.TopCard.CardID})";
  128. log += "\n";
  129. PlayLog.OnAddLog?.Invoke(log);
  130. #endregion
  131. bool CanUseChangeColorCondition(Hashtable hashtableColor)
  132. {
  133. return selectedPermanent.TopCard != null && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  134. }
  135. List<CardColor> ChangeBaseCardColors(CardSource cardSource, List<CardColor> cardColors)
  136. {
  137. if (cardSource == selectedPermanent.TopCard)
  138. {
  139. cardColors = new List<CardColor>() { chosenColor };
  140. }
  141. return cardColors;
  142. }
  143. }
  144. }
  145. }
  146. #endregion
  147. #region When Digivolving
  148. if (timing == EffectTiming.OnEnterFieldAnyone)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Change the color of 1 of your opponent's Digimon or Tamer", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  153. cardEffects.Add(activateClass);
  154. string EffectDescription()
  155. {
  156. return
  157. "[When Digivolving] Until the end of your opponent's turn, change 1 of their Digimon or Tamers into a color other than white.";
  158. }
  159. bool CanUseCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  162. }
  163. IEnumerator ActivateCoroutine(Hashtable hashtable)
  164. {
  165. Permanent selectedPermanent = null;
  166. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  167. selectPermanentEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectPermanentConditionShared,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: 1,
  173. canNoSelect: false,
  174. canEndNotMax: false,
  175. selectPermanentCoroutine: SelectPermanentCoroutine,
  176. afterSelectPermanentCoroutine: null,
  177. mode: SelectPermanentEffect.Mode.Custom,
  178. cardEffect: activateClass);
  179. selectPermanentEffect.SetUpCustomMessage(
  180. "Select 1 Digimon that will change color.",
  181. "The opponent is selecting 1 Digimon that will change color.");
  182. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  183. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  184. {
  185. selectedPermanent = permanent;
  186. yield return null;
  187. }
  188. if (selectedPermanent != null)
  189. {
  190. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  191. {
  192. new(message: $"Red", value: (int)CardColor.Red, spriteIndex: 0),
  193. new(message: $"Blue", value: (int)CardColor.Blue, spriteIndex: 0),
  194. new(message: $"Yellow", value: (int)CardColor.Yellow, spriteIndex: 0),
  195. new(message: $"Green", value: (int)CardColor.Green, spriteIndex: 0),
  196. new(message: $"Black", value: (int)CardColor.Black, spriteIndex: 0),
  197. new(message: $"Purple", value: (int)CardColor.Purple, spriteIndex: 0),
  198. };
  199. string selectPlayerMessage = "Select a color.";
  200. string notSelectPlayerMessage = "The opponent is selecting a color.";
  201. GManager.instance.userSelectionManager.SetIntSelection(
  202. selectionElements: selectionElements,
  203. selectPlayer: card.Owner,
  204. selectPlayerMessage: selectPlayerMessage,
  205. notSelectPlayerMessage: notSelectPlayerMessage);
  206. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  207. .WaitForEndSelect());
  208. CardColor chosenColor = (CardColor)GManager.instance.userSelectionManager.SelectedIntValue;
  209. ChangeBaseCardColorClass changeBaseCardNameClass = new ChangeBaseCardColorClass();
  210. changeBaseCardNameClass.SetUpICardEffect($"Original card color is changed: {chosenColor}", CanUseChangeColorCondition, card);
  211. changeBaseCardNameClass.SetUpChangeBaseCardColorClass(ChangeBaseCardColors: ChangeBaseCardColors);
  212. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => changeBaseCardNameClass);
  213. #region Log
  214. string log = "";
  215. log += $"\nChanged Card Color to {chosenColor}:";
  216. log += $"\n{selectedPermanent.TopCard.BaseENGCardNameFromEntity}({selectedPermanent.TopCard.CardID})";
  217. log += "\n";
  218. PlayLog.OnAddLog?.Invoke(log);
  219. #endregion
  220. bool CanUseChangeColorCondition(Hashtable hashtableColor)
  221. {
  222. return selectedPermanent.TopCard != null && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  223. }
  224. List<CardColor> ChangeBaseCardColors(CardSource cardSource, List<CardColor> cardColors)
  225. {
  226. if (cardSource == selectedPermanent.TopCard)
  227. {
  228. cardColors = new List<CardColor>() { chosenColor };
  229. }
  230. return cardColors;
  231. }
  232. }
  233. }
  234. }
  235. #endregion
  236. #region When Attacking
  237. if (timing == EffectTiming.OnAllyAttack)
  238. {
  239. ActivateClass activateClass = new ActivateClass();
  240. activateClass.SetUpICardEffect("1 of your Digimon or Tamers digivolves", CanUseCondition, card);
  241. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  242. EffectDescription());
  243. cardEffects.Add(activateClass);
  244. string EffectDescription()
  245. {
  246. return
  247. "[When Attacking] 1 of your Digimon or Tamers may digivolve into a level 4 card with the [Hybrid] trait in the trash with the digivolution cost reduced by 1.";
  248. }
  249. bool CanUseCondition(Hashtable hashtable)
  250. {
  251. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  252. }
  253. bool DigivolveFromPermanentCondition(Permanent permanent)
  254. {
  255. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  256. (permanent.IsDigimon || permanent.IsTamer) &&
  257. card.Owner.TrashCards.Where(DigivolveToCardCondition).Any(cardSource =>
  258. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, SelectCardEffect.Root.Trash));
  259. }
  260. bool DigivolveToCardCondition(CardSource cardSource)
  261. {
  262. return cardSource.IsDigimon && cardSource.ContainsTraits("Hybrid") &&
  263. cardSource.HasLevel && cardSource.Level == 4;
  264. }
  265. bool CanActivateCondition(Hashtable hashtable)
  266. {
  267. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  268. CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition);
  269. }
  270. IEnumerator ActivateCoroutine(Hashtable hashtable)
  271. {
  272. Permanent selectedPermanent = null;
  273. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  274. selectPermanentEffect.SetUp(
  275. selectPlayer: card.Owner,
  276. canTargetCondition: DigivolveFromPermanentCondition,
  277. canTargetCondition_ByPreSelecetedList: null,
  278. canEndSelectCondition: null,
  279. maxCount: 1,
  280. canNoSelect: true,
  281. canEndNotMax: false,
  282. selectPermanentCoroutine: SelectPermanentCoroutine,
  283. afterSelectPermanentCoroutine: null,
  284. mode: SelectPermanentEffect.Mode.Custom,
  285. cardEffect: activateClass);
  286. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  287. "The opponent is selecting 1 Digimon that will digivolve.");
  288. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  289. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  290. {
  291. selectedPermanent = permanent;
  292. yield return null;
  293. }
  294. if (selectedPermanent != null)
  295. {
  296. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  297. targetPermanent: selectedPermanent,
  298. cardCondition: DigivolveToCardCondition,
  299. payCost: true,
  300. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  301. fixedCostTuple: null,
  302. ignoreDigivolutionRequirementFixedCost: -1,
  303. isHand: false,
  304. activateClass: activateClass,
  305. successProcess: null));
  306. }
  307. }
  308. }
  309. #endregion
  310. #region On Deletion - ESS
  311. if (timing == EffectTiming.OnDestroyedAnyone)
  312. {
  313. ActivateClass activateClass = new ActivateClass();
  314. activateClass.SetUpICardEffect("Play Tamer card from trash", CanUseCondition, card);
  315. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  316. activateClass.SetIsInheritedEffect(true);
  317. cardEffects.Add(activateClass);
  318. string EffectDescription()
  319. {
  320. return "[On Deletion] You may play 1 Tamer card with a play cost of 4 or less from your trash without paying the cost.";
  321. }
  322. bool CanUseCondition(Hashtable hashtable)
  323. {
  324. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  325. }
  326. bool CanSelectCardCondition(CardSource cardSource)
  327. {
  328. return cardSource.IsTamer && cardSource.HasPlayCost && cardSource.GetCostItself <= 4 &&
  329. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  330. }
  331. bool CanActivateCondition(Hashtable hashtable)
  332. {
  333. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  334. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  335. }
  336. IEnumerator ActivateCoroutine(Hashtable hashtable)
  337. {
  338. List<CardSource> selectedCards = new List<CardSource>();
  339. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  340. selectCardEffect.SetUp(
  341. canTargetCondition: CanSelectCardCondition,
  342. canTargetCondition_ByPreSelecetedList: null,
  343. canEndSelectCondition: null,
  344. canNoSelect: () => true,
  345. selectCardCoroutine: SelectCardCoroutine,
  346. afterSelectCardCoroutine: null,
  347. message: "Select 1 card to play.",
  348. maxCount: 1,
  349. canEndNotMax: false,
  350. isShowOpponent: true,
  351. mode: SelectCardEffect.Mode.Custom,
  352. root: SelectCardEffect.Root.Trash,
  353. customRootCardList: null,
  354. canLookReverseCard: true,
  355. selectPlayer: card.Owner,
  356. cardEffect: activateClass);
  357. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  358. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  359. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  360. IEnumerator SelectCardCoroutine(CardSource cardSource)
  361. {
  362. selectedCards.Add(cardSource);
  363. yield return null;
  364. }
  365. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  366. cardSources: selectedCards,
  367. activateClass: activateClass,
  368. payCost: false,
  369. isTapped: false,
  370. root: SelectCardEffect.Root.Trash,
  371. activateETB: true));
  372. }
  373. }
  374. #endregion
  375. return cardEffects;
  376. }
  377. }
  378. }