P_193.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // The Wicked God Emerges!
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_193 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash 1 [Composite]/[Wicked god] from hand, draw 2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Main] By trashing 1 card with the [Composite] or [Wicked God] trait from your hand, <Draw 2> (Draw 2 cards from your deck). Then, place this card in the battle area.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  26. }
  27. bool CanSelectHandCondition(CardSource cardSource)
  28. {
  29. return cardSource.EqualsTraits("Composite") || cardSource.EqualsTraits("Wicked God");
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCondition))
  34. {
  35. bool discarded = false;
  36. int discardCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectHandCondition));
  37. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  38. selectHandEffect.SetUp(
  39. selectPlayer: card.Owner,
  40. canTargetCondition: CanSelectHandCondition,
  41. canTargetCondition_ByPreSelecetedList: null,
  42. canEndSelectCondition: null,
  43. maxCount: discardCount,
  44. canNoSelect: true,
  45. canEndNotMax: false,
  46. isShowOpponent: true,
  47. selectCardCoroutine: null,
  48. afterSelectCardCoroutine: afterSelectCardCoroutine,
  49. mode: SelectHandEffect.Mode.Discard,
  50. cardEffect: activateClass);
  51. yield return StartCoroutine(selectHandEffect.Activate());
  52. IEnumerator afterSelectCardCoroutine(List<CardSource> selectedCards)
  53. {
  54. if (selectedCards.Count > 0) discarded = true;
  55. yield return null;
  56. }
  57. if (discarded)
  58. {
  59. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  60. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  61. }
  62. }
  63. }
  64. }
  65. #endregion
  66. #region Delay
  67. if (timing == EffectTiming.OnEndTurn)
  68. {
  69. ActivateClass activateClass = new ActivateClass();
  70. activateClass.SetUpICardEffect("Delete Millenniummon, play 1 [Wicked God] digimon from hand or trash", CanUseCondition, card);
  71. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  72. cardEffects.Add(activateClass);
  73. string EffectDescription()
  74. {
  75. return "[End of All Turns] <Delay> (After this card is placed, by trashing it the next turn or later, activate the effect below). By deleting 1 of your [Millenniummon], you may play 1 [Wicked God] trait Digimon card from your hand or trash without paying the cost.";
  76. }
  77. bool CanSelectPermanentCondition(Permanent permanent)
  78. {
  79. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  80. permanent.TopCard.EqualsCardName("Millenniummon");
  81. }
  82. bool CanSelectCardCondition(CardSource cardSource)
  83. {
  84. return cardSource.IsDigimon && cardSource.EqualsTraits("Wicked God") && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  85. }
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.CanDeclareOptionDelayEffect(card);
  89. }
  90. bool CanActivateCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.IsExistOnField(card);
  93. }
  94. IEnumerator ActivateCoroutine(Hashtable hashtable)
  95. {
  96. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  97. IEnumerator SuccessProcess()
  98. {
  99. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  100. {
  101. List<Permanent> deletedPermanents = new List<Permanent>();
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectPermanentCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: 1,
  109. canNoSelect: true,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: null,
  112. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  113. mode: SelectPermanentEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  116. "The opponent is selecting 1 Digimon to delete.");
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> selectedPermanents)
  119. {
  120. if (selectedPermanents.Count > 0)
  121. deletedPermanents = selectedPermanents.Clone();
  122. yield return null;
  123. }
  124. if (deletedPermanents.Count > 0)
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deletedPermanents, activateClass: activateClass, successProcess: permanents => DeleteSuccessProcess(), failureProcess: null));
  126. }
  127. }
  128. IEnumerator DeleteSuccessProcess()
  129. {
  130. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  131. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  132. if (canSelectHand || canSelectTrash)
  133. {
  134. if (canSelectHand && canSelectTrash)
  135. {
  136. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  137. {
  138. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  139. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  140. };
  141. string selectPlayerMessage = "From which area do you select a card?";
  142. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  143. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  144. }
  145. else
  146. {
  147. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  148. }
  149. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  150. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  151. List<CardSource> selectedCards = new List<CardSource>();
  152. IEnumerator SelectCardCoroutine(CardSource cardSource)
  153. {
  154. selectedCards.Add(cardSource);
  155. yield return null;
  156. }
  157. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  158. if (fromHand)
  159. {
  160. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  161. selectHandEffect.SetUp(
  162. selectPlayer: card.Owner,
  163. canTargetCondition: CanSelectCardCondition,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. maxCount: 1,
  167. canNoSelect: true,
  168. canEndNotMax: false,
  169. isShowOpponent: true,
  170. selectCardCoroutine: SelectCardCoroutine,
  171. afterSelectCardCoroutine: null,
  172. mode: SelectHandEffect.Mode.Custom,
  173. cardEffect: activateClass);
  174. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
  175. yield return StartCoroutine(selectHandEffect.Activate());
  176. }
  177. else
  178. {
  179. root = SelectCardEffect.Root.Trash;
  180. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  181. selectCardEffect.SetUp(
  182. canTargetCondition: CanSelectCardCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. canNoSelect: () => true,
  186. selectCardCoroutine: SelectCardCoroutine,
  187. afterSelectCardCoroutine: null,
  188. message: "Select 1 digimon to play",
  189. maxCount: 1,
  190. canEndNotMax: false,
  191. isShowOpponent: true,
  192. mode: SelectCardEffect.Mode.Custom,
  193. root: SelectCardEffect.Root.Trash,
  194. customRootCardList: null,
  195. canLookReverseCard: true,
  196. selectPlayer: card.Owner,
  197. cardEffect: activateClass);
  198. selectCardEffect.SetUpCustomMessage("Select 1 1 digimon to play", "The opponent is selecting 1 digimon to play");
  199. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  200. }
  201. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  202. }
  203. }
  204. }
  205. }
  206. #endregion
  207. #region Security Effect
  208. if (timing == EffectTiming.SecuritySkill)
  209. {
  210. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Trash 1 [Composite]/[Wicked god] from hand, draw 2");
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }