EX11_073.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // ExMaquinamon
  7. namespace DCGO.CardEffects.EX11
  8. {
  9. public class EX11_073 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region DNA Digivolve
  15. if (timing == EffectTiming.None)
  16. {
  17. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  18. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  19. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  20. addJogressConditionClass.SetNotShowUI(true);
  21. cardEffects.Add(addJogressConditionClass);
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return true;
  25. }
  26. JogressCondition GetJogress(CardSource cardSource)
  27. {
  28. if (cardSource == card)
  29. {
  30. bool PermanentCondition1(Permanent permanent)
  31. {
  32. return permanent != null
  33. && permanent.TopCard != null
  34. && CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  35. && permanent.TopCard.CardColors.Contains(CardColor.Green)
  36. && permanent.Levels_ForJogress(card).Contains(6);
  37. }
  38. bool PermanentCondition2(Permanent permanent)
  39. {
  40. return permanent != null
  41. && permanent.TopCard != null
  42. && CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  43. && permanent.TopCard.CardColors.Contains(CardColor.Black)
  44. && permanent.Levels_ForJogress(card).Contains(6);
  45. }
  46. JogressConditionElement[] elements =
  47. {
  48. new JogressConditionElement(PermanentCondition1, "a level 6 green Digimon"),
  49. new JogressConditionElement(PermanentCondition2, "a level 6 black Digimon"),
  50. };
  51. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  52. return jogressCondition;
  53. }
  54. return null;
  55. }
  56. }
  57. #endregion
  58. #region Security Attack +1
  59. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  60. #endregion
  61. #region Blocker
  62. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  63. #endregion
  64. #region Link +2
  65. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(2, false, card, null));
  66. #endregion
  67. #region When Digivolving
  68. if (timing == EffectTiming.OnEnterFieldAnyone)
  69. {
  70. ActivateClass activateClass = new ActivateClass();
  71. activateClass.SetUpICardEffect("You may link up to 3 [Maquinamon] from hand, trash or digivolution cards", CanUseCondition, card);
  72. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  73. cardEffects.Add(activateClass);
  74. string EffectDescription() => "[When Digivolving] If DNA Digivolving, you may link up to 3 [Maquinamon] from your hand, trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  75. bool CanUseCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  78. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  79. }
  80. bool CanActivateCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  83. && CardEffectCommons.IsJogress(hashtable)
  84. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  85. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)
  86. || card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition));
  87. }
  88. bool CanSelectCardCondition(CardSource cardSource)
  89. {
  90. return cardSource.EqualsCardName("Maquinamon")
  91. && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  92. }
  93. IEnumerator ActivateCoroutine(Hashtable hashtable)
  94. {
  95. Permanent thisPermanent = card.PermanentOfThisCard();
  96. List<CardSource> selectedCards = new List<CardSource>();
  97. IEnumerator SelectCardCoroutine(CardSource cardSource)
  98. {
  99. selectedCards.Add(cardSource);
  100. yield return null;
  101. }
  102. while (selectedCards.Count < 3)
  103. {
  104. List<CardSource> validHandCards = card.Owner.HandCards.Filter(CanSelectCardCondition).Except(selectedCards).ToList();
  105. List<CardSource> validTrashCards = card.Owner.TrashCards.Filter(CanSelectCardCondition).Except(selectedCards).ToList();
  106. List<CardSource> validDigivolutionCards = thisPermanent.DigivolutionCards.Filter(CanSelectCardCondition).Except(selectedCards).ToList();
  107. int validHandCardCount = validHandCards.Count;
  108. int validTrashCardCount = validTrashCards.Count;
  109. int validDigivolutionCardCount = validDigivolutionCards.Count;
  110. if (validHandCardCount + validTrashCardCount + validDigivolutionCardCount <= 0)//No cards left to pick
  111. {
  112. goto END_LOOP;
  113. }
  114. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  115. if (validHandCardCount > 0)
  116. {
  117. selectionElements.Add(new (message: $"Link from Hand", value : 1, spriteIndex: 0));
  118. }
  119. if (validTrashCardCount > 0)
  120. {
  121. selectionElements.Add(new (message: $"Link from Trash", value : 2, spriteIndex: 0));
  122. }
  123. if (validDigivolutionCardCount > 0)
  124. {
  125. selectionElements.Add(new (message: $"Link from Digivolution Cards", value : 3, spriteIndex: 0));
  126. }
  127. selectionElements.Add( new (message: (selectedCards.Count == 0 ? $"Don't link" : $"Finish Linking"), value: 4, spriteIndex: 1));
  128. string selectPlayerMessage = "From which area will you link a Maquinamon?";
  129. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  130. Debug.Log("Selection Elements Count: " + selectionElements.Count);
  131. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  132. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  133. switch (GManager.instance.userSelectionManager.SelectedIntValue)
  134. {
  135. case 1: // From Hand
  136. {
  137. int maxCount = Math.Min(3-selectedCards.Count, validHandCardCount);
  138. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  139. selectHandEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: cardSource => validHandCards.Contains(cardSource),
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: true,
  146. canEndNotMax: true,
  147. isShowOpponent: true,
  148. selectCardCoroutine: SelectCardCoroutine,
  149. afterSelectCardCoroutine: null,
  150. mode: SelectHandEffect.Mode.Custom,
  151. cardEffect: activateClass);
  152. selectHandEffect.SetUpCustomMessage($"Select up to {maxCount} cards to link.", "The opponent is selecting cards to link.");
  153. yield return StartCoroutine(selectHandEffect.Activate());
  154. break;
  155. }
  156. case 2: // From Trash
  157. {
  158. int maxCount = Math.Min(3-selectedCards.Count, validTrashCardCount);
  159. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  160. selectCardEffect.SetUp(
  161. canTargetCondition: cardSource => validTrashCards.Contains(cardSource),
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. canNoSelect: () => true,
  165. selectCardCoroutine: SelectCardCoroutine,
  166. afterSelectCardCoroutine: null,
  167. message: "Select cards to link",
  168. maxCount: maxCount,
  169. canEndNotMax: true,
  170. isShowOpponent: true,
  171. mode: SelectCardEffect.Mode.Custom,
  172. root: SelectCardEffect.Root.Trash,
  173. customRootCardList: null,
  174. canLookReverseCard: true,
  175. selectPlayer: card.Owner,
  176. cardEffect: activateClass);
  177. selectCardEffect.SetUpCustomMessage($"Select up to {maxCount} cards to link.", "The opponent is selecting cards to link.");
  178. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  179. break;
  180. }
  181. case 3: // From Digivolution Cards
  182. {
  183. int maxCount = Math.Min(3-selectedCards.Count, validDigivolutionCardCount);
  184. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  185. selectCardEffect.SetUp(
  186. canTargetCondition: cardSource => validDigivolutionCards.Contains(cardSource),
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. canNoSelect: () => true,
  190. selectCardCoroutine: SelectCardCoroutine,
  191. afterSelectCardCoroutine: null,
  192. message: "Select cards to link.",
  193. maxCount: maxCount,
  194. canEndNotMax: true,
  195. isShowOpponent: true,
  196. mode: SelectCardEffect.Mode.Custom,
  197. root: SelectCardEffect.Root.Custom,
  198. customRootCardList: thisPermanent.DigivolutionCards,
  199. canLookReverseCard: true,
  200. selectPlayer: card.Owner,
  201. cardEffect: activateClass);
  202. selectCardEffect.SetUpCustomMessage($"Select up to {maxCount} cards to link.", "The opponent is selecting cards to link.");
  203. yield return StartCoroutine(selectCardEffect.Activate());
  204. break;
  205. }
  206. default:
  207. goto END_LOOP;
  208. }
  209. }
  210. END_LOOP:;
  211. foreach(CardSource linkCard in selectedCards)
  212. {
  213. yield return ContinuousController.instance.StartCoroutine(thisPermanent.AddLinkCard(linkCard, activateClass));
  214. }
  215. }
  216. }
  217. #endregion
  218. #region End of Opponent's turn
  219. if (timing == EffectTiming.OnEndTurn)
  220. {
  221. ActivateClass activateClass = new ActivateClass();
  222. activateClass.SetUpICardEffect("Trash a security and bottom deck a digimon per link card", CanUseCondition, card);
  223. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  224. activateClass.SetHashString("EX11_073_EOOT_TRASH_BOUNCE");
  225. cardEffects.Add(activateClass);
  226. string EffectDescription() => "[End of Opponent's Turn] [Once Per Turn] For each of this Digimon's link cards, trash your opponent's top security card and return 1 of their digimon to the bottom of the deck.";
  227. bool CanUseCondition(Hashtable hashtable)
  228. {
  229. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  230. && CardEffectCommons.IsOpponentTurn(card);
  231. }
  232. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  233. bool OpponentsDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  234. IEnumerator ActivateCoroutine(Hashtable hashtable)
  235. {
  236. int effectCount = card.PermanentOfThisCard().LinkedCards.Count;
  237. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  238. player: card.Owner.Enemy,
  239. destroySecurityCount: effectCount,
  240. cardEffect: activateClass,
  241. fromTop: true).DestroySecurity());
  242. int maxCount = Math.Min(effectCount, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, OpponentsDigimonCondition));
  243. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  244. selectPermanentEffect.SetUp(
  245. selectPlayer: card.Owner,
  246. canTargetCondition: OpponentsDigimonCondition,
  247. canTargetCondition_ByPreSelecetedList: null,
  248. canEndSelectCondition: null,
  249. maxCount: maxCount,
  250. canNoSelect: false,
  251. canEndNotMax: false,
  252. selectPermanentCoroutine: null,
  253. afterSelectPermanentCoroutine: null,
  254. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  255. cardEffect: activateClass);
  256. selectPermanentEffect.SetUpCustomMessage($"Select {maxCount} Digimon to return to bottom of deck.", "Opponent is selecting Digimon to return to bottom of deck.");
  257. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  258. }
  259. }
  260. #endregion
  261. return cardEffects;
  262. }
  263. }
  264. }