P_215.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // Icemon
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_215 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel3 &&
  19. (targetPermanent.TopCard.EqualsTraits("Ice-Snow") ||
  20. targetPermanent.TopCard.HasRockMineralTraits);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 2,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null)
  28. );
  29. }
  30. #endregion
  31. #region Shared WM / OP / WD
  32. string SharedEffectName()
  33. => "By placing 1 [Ice-Snow], [Mineral] or [Rock] Digimon from hand or trash under this, 1 such digimon cannot be returned to deck or de-digivolved.";
  34. string SharedEffectDescription(string tag)
  35. {
  36. return $"[{tag}] By placing 1 level 4 or lower [Ice-Snow], [Mineral] or [Rock] trait card from your hand or trash as this Digimon's bottom digivolution card, until your opponent's turn ends, their effects can't return 1 of your [Ice-Snow], [Mineral] or [Rock] trait Digimon to hands or decks or affect it with <De-Digivolve> effects.";
  37. }
  38. bool SharedCanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleArea(card)
  41. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CardSelectCondition)
  42. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CardSelectCondition));
  43. }
  44. bool CardSelectCondition(CardSource cardSource)
  45. {
  46. return cardSource.HasLevel &&
  47. cardSource.Level <= 4 &&
  48. (cardSource.EqualsTraits("Ice-Snow")
  49. || cardSource.HasRockMineralTraits);
  50. }
  51. bool PermanentSelectCondition(Permanent permanent)
  52. {
  53. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  54. && (permanent.TopCard.EqualsTraits("Ice-Snow")
  55. || permanent.TopCard.HasRockMineralTraits);
  56. }
  57. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  58. {
  59. Permanent thisPermament = card.PermanentOfThisCard();
  60. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CardSelectCondition);
  61. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CardSelectCondition);
  62. if (canSelectHand || canSelectTrash)
  63. {
  64. if (canSelectHand && canSelectTrash)
  65. {
  66. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  67. {
  68. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  69. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  70. };
  71. string selectPlayerMessage = "From which area do you select a card?";
  72. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  73. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  74. }
  75. else
  76. {
  77. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  78. }
  79. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  80. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  81. CardSource selectedCard = null;
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. selectedCard = cardSource;
  85. yield return null;
  86. }
  87. if (fromHand)
  88. {
  89. int maxCount = 1;
  90. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  91. selectHandEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: CardSelectCondition,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. maxCount: maxCount,
  97. canNoSelect: true,
  98. canEndNotMax: false,
  99. isShowOpponent: true,
  100. selectCardCoroutine: SelectCardCoroutine,
  101. afterSelectCardCoroutine: null,
  102. mode: SelectHandEffect.Mode.Custom,
  103. cardEffect: activateClass);
  104. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  105. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  106. yield return StartCoroutine(selectHandEffect.Activate());
  107. }
  108. else
  109. {
  110. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CardSelectCondition));
  111. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  112. selectCardEffect.SetUp(
  113. canTargetCondition: CardSelectCondition,
  114. canTargetCondition_ByPreSelecetedList: null,
  115. canEndSelectCondition: null,
  116. canNoSelect: () => true,
  117. selectCardCoroutine: SelectCardCoroutine,
  118. afterSelectCardCoroutine: null,
  119. message:"Select 1 card to place as digivolution source",
  120. maxCount: maxCount,
  121. canEndNotMax: false,
  122. isShowOpponent: true,
  123. mode: SelectCardEffect.Mode.Custom,
  124. root: SelectCardEffect.Root.Trash,
  125. customRootCardList: null,
  126. canLookReverseCard: true,
  127. selectPlayer: card.Owner,
  128. cardEffect: activateClass);
  129. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  130. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  131. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  132. }
  133. if (selectedCard != null)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  136. new List<CardSource> { selectedCard },
  137. activateClass));
  138. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentSelectCondition))
  139. {
  140. var selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  141. selectPermanentEffect.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: PermanentSelectCondition,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: 1,
  147. canNoSelect: false,
  148. canEndNotMax: false,
  149. selectPermanentCoroutine: SelectPermanentCoroutine,
  150. afterSelectPermanentCoroutine: null,
  151. mode: SelectPermanentEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. selectPermanentEffect.SetUpCustomMessage(
  154. "Select 1 Digimon that will get effects.",
  155. "The opponent is selecting 1 Digimon that will get effects.");
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. IEnumerator SelectPermanentCoroutine(Permanent selectedPermanent)
  158. {
  159. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  160. targetPermanent: selectedPermanent,
  161. cardEffectCondition: CardEffectCondition,
  162. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  163. activateClass: activateClass,
  164. effectName: "Can't return to hand by opponent's effects"));
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  166. targetPermanent: selectedPermanent,
  167. cardEffectCondition: CardEffectCondition,
  168. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  169. activateClass: activateClass,
  170. effectName: "Can't return to deck by opponent's effects"));
  171. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  172. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseCondition1, selectedPermanent.TopCard);
  173. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentCondition);
  174. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromDeDigivolveClass);
  175. bool CanUseCondition1(Hashtable hashtable1)
  176. {
  177. if (selectedPermanent.TopCard != null)
  178. {
  179. return true;
  180. }
  181. return false;
  182. }
  183. bool PermanentCondition(Permanent permanent)
  184. {
  185. if (permanent == selectedPermanent)
  186. {
  187. return true;
  188. }
  189. return false;
  190. }
  191. }
  192. bool CardEffectCondition(ICardEffect cardEffect)
  193. {
  194. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  195. }
  196. }
  197. }
  198. }
  199. }
  200. #endregion
  201. #region When Moving
  202. if (timing == EffectTiming.OnMove)
  203. {
  204. ActivateClass activateClass = new ActivateClass();
  205. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  206. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("When Moving"));
  207. cardEffects.Add(activateClass);
  208. bool PermanentCondition(Permanent permanent)
  209. {
  210. return permanent == card.PermanentOfThisCard();
  211. }
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  215. CardEffectCommons.CanTriggerOnMove(hashtable, PermanentCondition);
  216. }
  217. }
  218. #endregion
  219. #region On Play
  220. if (timing == EffectTiming.OnEnterFieldAnyone)
  221. {
  222. ActivateClass activateClass = new ActivateClass();
  223. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  224. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("On Play"));
  225. cardEffects.Add(activateClass);
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  229. }
  230. }
  231. #endregion
  232. #region When Digivolving
  233. if (timing == EffectTiming.OnEnterFieldAnyone)
  234. {
  235. ActivateClass activateClass = new ActivateClass();
  236. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  237. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  238. cardEffects.Add(activateClass);
  239. bool CanUseCondition(Hashtable hashtable)
  240. {
  241. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  242. }
  243. }
  244. #endregion
  245. #region ESS
  246. if (timing == EffectTiming.None)
  247. {
  248. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  249. isInheritedEffect: true,
  250. card: card,
  251. condition: null));
  252. }
  253. #endregion
  254. return cardEffects;
  255. }
  256. }
  257. }