EX11_022.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Karakurumon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_022 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel4
  18. && targetPermanent.TopCard.EqualsTraits("Puppet")
  19. && (targetPermanent.TopCard.CardColors.Contains(CardColor.Yellow)
  20. || targetPermanent.TopCard.CardColors.Contains(CardColor.Purple));
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Scapegoat
  26. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  27. {
  28. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: card, condition: null, effectName: "<Scapegoat>", effectDiscription: null));
  29. }
  30. #endregion
  31. #region OP/WD Shared
  32. string SharedEffectName() => "Play a 4K DP or less [Puppet] trait Digimon from hand or trash for free. End of turn, delete it.";
  33. string SharedEffectDescription(string tag) => $"[{tag}] You may play 1 [Puppet] trait Digimon card with 4000 DP or less from your hand or trash without paying the cost. At turn end, delete the Digimon this effect played.";
  34. bool SharedCanActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  35. {
  36. return CardEffectCommons.IsExistOnBattleArea(card)
  37. && (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCardCondition(cardSource, activateClass))
  38. || CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCardCondition(cardSource, activateClass)));
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource, ActivateClass activateClass)
  41. {
  42. return cardSource.IsDigimon
  43. && cardSource.HasDP
  44. && cardSource.CardDP <= 4000
  45. && cardSource.EqualsTraits("Puppet")
  46. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  47. }
  48. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  49. {
  50. #region Setup Location Selection
  51. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCardCondition(cardSource, activateClass));
  52. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCardCondition(cardSource, activateClass));
  53. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  54. if (canSelectHand)
  55. {
  56. selectionElements.Add(new(message: "From hand", value: 0, spriteIndex: 0));
  57. }
  58. if (canSelectTrash)
  59. {
  60. selectionElements.Add(new(message: "From trash", value: 1, spriteIndex: 0));
  61. }
  62. selectionElements.Add(new(message: "Do not play", value: 2, spriteIndex: 1));
  63. string selectPlayerMessage = "From which area will you play?";
  64. string notSelectPlayerMessage = "The opponent is choosing if they will activate their effect.";
  65. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  66. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  67. notSelectPlayerMessage: notSelectPlayerMessage);
  68. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  69. .WaitForEndSelect());
  70. int selection = GManager.instance.userSelectionManager.SelectedIntValue;
  71. #endregion
  72. #region Hand/Trash Card Selection & Play
  73. if (selection != 2)
  74. {
  75. CardSource selectedCard = null;
  76. IEnumerator SelectCardCoroutine(CardSource cardSource)
  77. {
  78. selectedCard = cardSource;
  79. yield return null;
  80. }
  81. if (selection == 0)
  82. {
  83. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  84. selectHandEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: cardSource => CanSelectCardCondition(cardSource, activateClass),
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: 1,
  90. canNoSelect: true,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. selectCardCoroutine: SelectCardCoroutine,
  94. afterSelectCardCoroutine: null,
  95. mode: SelectHandEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectHandEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon to play.");
  98. yield return StartCoroutine(selectHandEffect.Activate());
  99. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  100. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Hand, true));
  101. }
  102. else
  103. {
  104. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  105. selectCardEffect.SetUp(
  106. canTargetCondition: cardSource => CanSelectCardCondition(cardSource, activateClass),
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. canNoSelect: () => true,
  110. selectCardCoroutine: SelectCardCoroutine,
  111. afterSelectCardCoroutine: null,
  112. message: "Select 1 Digimon to play.",
  113. maxCount: 1,
  114. canEndNotMax: false,
  115. isShowOpponent: true,
  116. mode: SelectCardEffect.Mode.Custom,
  117. root: SelectCardEffect.Root.Trash,
  118. customRootCardList: null,
  119. canLookReverseCard: true,
  120. selectPlayer: card.Owner,
  121. cardEffect: activateClass);
  122. selectCardEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon to play.");
  123. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  124. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  125. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Trash, true));
  126. }
  127. #region Delete Played Digimon
  128. if (selectedCard != null)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(
  131. CardEffectCommons.AddSelfDeleteEffect(selectedCard.PermanentOfThisCard(), CardEffectCommons.DeleteTiming.AtTurnEnd, activateClass));
  132. }
  133. #endregion
  134. }
  135. #endregion
  136. }
  137. #endregion
  138. #region On Play
  139. if (timing == EffectTiming.OnEnterFieldAnyone)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  143. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("On Play"));
  144. cardEffects.Add(activateClass);
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  148. && CardEffectCommons.IsExistOnBattleArea(card);
  149. }
  150. }
  151. #endregion
  152. #region When Digivolving
  153. if (timing == EffectTiming.OnEnterFieldAnyone)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  157. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  158. cardEffects.Add(activateClass);
  159. bool CanUseCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  162. && CardEffectCommons.IsExistOnBattleArea(card);
  163. }
  164. }
  165. #endregion
  166. #region ESS
  167. if (timing == EffectTiming.WhenRemoveField)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect("Delete your 1 other token or [Puppet] Digimon to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  172. activateClass.SetIsInheritedEffect(true);
  173. activateClass.SetHashString("Substitute_EX11_022");
  174. cardEffects.Add(activateClass);
  175. string EffectDescription()
  176. {
  177. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, by deleting 1 of your Tokens or other [Puppet] trait Digimon, prevent it from leaving.";
  178. }
  179. bool CanSelectPermanentCondition(Permanent permanent)
  180. {
  181. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  182. && permanent != card.PermanentOfThisCard()
  183. && (permanent.IsToken
  184. || permanent.TopCard.EqualsTraits("Puppet"));
  185. }
  186. bool CanUseCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleArea(card)
  189. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  190. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  191. }
  192. bool CanActivateCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.IsExistOnBattleArea(card)
  195. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  196. }
  197. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  198. {
  199. Permanent thisCardPermanent = card.PermanentOfThisCard();
  200. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  201. {
  202. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  203. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  204. selectPermanentEffect.SetUp(
  205. selectPlayer: card.Owner,
  206. canTargetCondition: CanSelectPermanentCondition,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. maxCount: maxCount,
  210. canNoSelect: true,
  211. canEndNotMax: false,
  212. selectPermanentCoroutine: SelectPermanentCoroutine,
  213. afterSelectPermanentCoroutine: null,
  214. mode: SelectPermanentEffect.Mode.Custom,
  215. cardEffect: activateClass);
  216. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  217. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  218. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  219. {
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  221. targetPermanents: new List<Permanent>() { permanent },
  222. activateClass: activateClass,
  223. successProcess: permanents => SuccessProcess(),
  224. failureProcess: null));
  225. IEnumerator SuccessProcess()
  226. {
  227. thisCardPermanent.willBeRemoveField = false;
  228. thisCardPermanent.HideDeleteEffect();
  229. thisCardPermanent.HideHandBounceEffect();
  230. thisCardPermanent.HideDeckBounceEffect();
  231. thisCardPermanent.HideWillRemoveFieldEffect();
  232. yield return null;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. #endregion
  239. return cardEffects;
  240. }
  241. }
  242. }