EX11_027.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Maquinamon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_027 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel2 && targetPermanent.TopCard.HasText("Maquinamon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region On Play
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Reveal top 3, Add [Maquinamon] & 1 [Maquinamon] in text, then may link", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. => "[On Play] Reveal the top 3 cards of your deck. Add 1 [Maquinamon] and 1 card with [Maquinamon] in its text among them to the hand. Return the rest to the bottom of the deck. Then, you may link this Digimon or 1 [Maquinamon] in your hand to 1 of your other Digimon without paying the cost.";
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleArea(card)
  34. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleArea(card);
  39. }
  40. bool IsMaquinamon(CardSource cardSource)
  41. {
  42. return cardSource.EqualsCardName("Maquinamon");
  43. }
  44. bool HasMaquinamonText(CardSource cardSource)
  45. {
  46. return cardSource.HasText("Maquinamon");
  47. }
  48. bool CanMaybeLinkPermanent(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  51. && permanent != card.PermanentOfThisCard()
  52. && (card.CanLinkToTargetPermanent(permanent, false)
  53. || card.Owner.HandCards.Filter(CanSelectCardCondition).Some(cardSource => cardSource.CanLinkToTargetPermanent(permanent, false)));
  54. }
  55. bool CanSelectLinkTarget(Permanent permanent, CardSource cardSource)
  56. {
  57. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  58. && permanent != card.PermanentOfThisCard()
  59. && cardSource.CanLinkToTargetPermanent(permanent, false);
  60. }
  61. bool CanSelectCardCondition(CardSource cardSource)
  62. {
  63. return IsMaquinamon(cardSource)
  64. && cardSource.CanLink(false);
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  69. revealCount: 3,
  70. simplifiedSelectCardConditions:
  71. new SimplifiedSelectCardConditionClass[]
  72. {
  73. new SimplifiedSelectCardConditionClass(
  74. canTargetCondition: IsMaquinamon,
  75. message: "Select 1 [Maquinamon].",
  76. mode: SelectCardEffect.Mode.AddHand,
  77. maxCount: 1,
  78. selectCardCoroutine: null),
  79. new SimplifiedSelectCardConditionClass(
  80. canTargetCondition: HasMaquinamonText,
  81. message: "Select 1 card with [Maquinamon] in its text.",
  82. mode: SelectCardEffect.Mode.AddHand,
  83. maxCount: 1,
  84. selectCardCoroutine: null),
  85. },
  86. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  87. activateClass: activateClass
  88. ));
  89. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanMaybeLinkPermanent))
  90. {
  91. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  92. {
  93. new (message: $"Link this Maquinamon", value : 1, spriteIndex: 0)
  94. };
  95. bool canLinkHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  96. if (canLinkHand)
  97. {
  98. selectionElements.Add( new (message: $"Link from Hand", value : 2, spriteIndex: 0));
  99. }
  100. selectionElements.Add( new (message: $"Don't link", value: 3, spriteIndex: 1));
  101. string selectPlayerMessage = canLinkHand ? "From which area will you link a Maquinamon?" : "Will you link your Maquinamon to another Digimon?";
  102. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  103. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  104. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  105. bool doLink = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  106. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 2;
  107. if (doLink)
  108. {
  109. CardSource selectedCard = null;
  110. if (fromHand)
  111. {
  112. int maxCount = 1;
  113. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  114. selectHandEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectCardCondition,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. isShowOpponent: true,
  123. selectCardCoroutine: SelectCardCoroutine,
  124. afterSelectCardCoroutine: null,
  125. mode: SelectHandEffect.Mode.Custom,
  126. cardEffect: activateClass);
  127. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  128. yield return StartCoroutine(selectHandEffect.Activate());
  129. IEnumerator SelectCardCoroutine(CardSource cardSource)
  130. {
  131. selectedCard = cardSource;
  132. yield return null;
  133. }
  134. }
  135. if (selectedCard != null || !fromHand)
  136. {
  137. Permanent selectedPermanent = null;
  138. CardSource linkTarget = selectedCard != null ? selectedCard : card;
  139. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(permanent => CanSelectLinkTarget(permanent, linkTarget)));
  140. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  141. selectPermanentEffect.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: permanent => CanSelectLinkTarget(permanent, linkTarget),
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: maxCount,
  147. canNoSelect: false,
  148. canEndNotMax: false,
  149. selectPermanentCoroutine: SelectPermanentCoroutine,
  150. afterSelectPermanentCoroutine: null,
  151. mode: SelectPermanentEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link.", "The opponent is selecting 1 Digimon to link.");
  154. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  155. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  156. {
  157. selectedPermanent = permanent;
  158. yield return null;
  159. }
  160. if (selectedPermanent != null){
  161. if(fromHand)
  162. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(selectedCard, activateClass));
  163. else
  164. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToLinkCards(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), selectedPermanent } }, activateClass).PlacePermanentToLinkCards());
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. #endregion
  172. #region Link Condition
  173. if (timing == EffectTiming.None)
  174. {
  175. static bool PermanentCondition(Permanent targetPermanent)
  176. {
  177. return targetPermanent.TopCard.HasText("Maquinamon");
  178. }
  179. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  180. }
  181. #endregion
  182. #region Link
  183. if (timing == EffectTiming.OnDeclaration)
  184. {
  185. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  186. }
  187. #endregion
  188. #region Link Effect
  189. if (timing == EffectTiming.WhenRemoveField)
  190. {
  191. List<Permanent> removedPermanents = new List<Permanent>();
  192. ActivateClass activateClass = new ActivateClass();
  193. activateClass.SetUpICardEffect("Place a linked card into digivolution cards to prevent this digimon from leaving", CanUseCondition, card);
  194. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  195. activateClass.SetIsLinkedEffect(true);
  196. cardEffects.Add(activateClass);
  197. string EffectDescription()
  198. {
  199. return
  200. "[All Turns] When this Digimon would leave the battle area, by placing 1 of its link cards as its bottom digivolution card, it doesn't leave.";
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. return CardEffectCommons.IsExistLinked(card) &&
  205. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  206. }
  207. bool CanActivateCondition(Hashtable hashtable)
  208. {
  209. return CardEffectCommons.IsExistLinked(card) &&
  210. card.PermanentOfThisCard().LinkedCards.Contains(card);
  211. }
  212. IEnumerator ActivateCoroutine(Hashtable hashtable)
  213. {
  214. Permanent thisPermanent = card.PermanentOfThisCard();
  215. CardSource selectedCard = null;
  216. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  217. selectCardEffect.SetUp(
  218. canTargetCondition: _ => true,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. canNoSelect: () => true,
  222. selectCardCoroutine: SelectCardCoroutine,
  223. afterSelectCardCoroutine: null,
  224. message: "Select 1 link card to place as bottom digivolution card.",
  225. maxCount: 1,
  226. canEndNotMax: false,
  227. isShowOpponent: true,
  228. mode: SelectCardEffect.Mode.Custom,
  229. root: SelectCardEffect.Root.LinkedCards,
  230. customRootCardList: card.PermanentOfThisCard().LinkedCards,
  231. canLookReverseCard: true,
  232. selectPlayer: card.Owner,
  233. cardEffect: activateClass);
  234. selectCardEffect.SetUpCustomMessage("Select 1 link card to place as bottom digivolution card.", "The opponent is selecting 1 link card to place in digivolution cards.");
  235. yield return StartCoroutine(selectCardEffect.Activate());
  236. IEnumerator SelectCardCoroutine(CardSource cardSource)
  237. {
  238. selectedCard = cardSource;
  239. yield return null;
  240. }
  241. if (selectedCard != null)
  242. {
  243. yield return ContinuousController.instance.StartCoroutine(thisPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  244. thisPermanent.willBeRemoveField = false;
  245. thisPermanent.HideHandBounceEffect();
  246. thisPermanent.HideDeckBounceEffect();
  247. thisPermanent.HideWillRemoveFieldEffect();
  248. thisPermanent.HideDeleteEffect();
  249. }
  250. }
  251. }
  252. #endregion
  253. return cardEffects;
  254. }
  255. }
  256. }