P_204.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Release of the Sealed Knight!
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_204 : 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 [X Antibody]/[Chronicle] 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 [X Antibody] or [Chronicle] 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.HasXAntibodyTraits || cardSource.HasChronicleTraits;
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCondition))
  34. {
  35. bool discarded = false;
  36. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  37. int discardCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectHandCondition));
  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. IEnumerator afterSelectCardCoroutine(List<CardSource> selectedCards)
  52. {
  53. if (selectedCards.Count > 0) discarded = true;
  54. yield return null;
  55. }
  56. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  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 All Turns - Delay
  67. if (timing == EffectTiming.OnAllyAttack)
  68. {
  69. ActivateClass activateClass = new ActivateClass();
  70. activateClass.SetUpICardEffect("1 [Grademon]/[Chronicle] digimon digivoles into [Alphamon]/ level 6 or lower [Chronicle] digimon", CanUseCondition, card);
  71. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  72. cardEffects.Add(activateClass);
  73. string EffectDiscription()
  74. {
  75. return "[All Turns] When Digimon attack players, <Delay>. 1 of your [Grademon] or Digimon with the [Chronicle] trait may digivolve into [Alphamon] or a level 6 or lower Digimon card with the [Chronicle] trait in the hand without paying the cost.";
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. return CardEffectCommons.CanDeclareOptionDelayEffect(card)
  80. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanentCondition);
  81. }
  82. bool CanActivateCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnField(card);
  85. }
  86. bool AttackingPermanentCondition(Permanent permanent)
  87. {
  88. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  89. && GManager.instance.attackProcess.AttackingPermanent == permanent
  90. // if DefendingPermanent is null, it means the attack is a player attack
  91. && GManager.instance.attackProcess.DefendingPermanent == null;
  92. }
  93. bool CanSelectPermanentCondition(Permanent permanent)
  94. {
  95. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  96. && (permanent.TopCard.EqualsCardName("Grademon") || permanent.TopCard.HasChronicleTraits);
  97. }
  98. IEnumerator ActivateCoroutine(Hashtable hashtable)
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  101. IEnumerator SuccessProcess()
  102. {
  103. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  104. {
  105. Permanent selectedPermanent = null;
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  108. selectPermanentEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: CanSelectPermanentCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: maxCount,
  114. canNoSelect: true,
  115. canEndNotMax: false,
  116. selectPermanentCoroutine: SelectPermanentCoroutine,
  117. afterSelectPermanentCoroutine: null,
  118. mode: SelectPermanentEffect.Mode.Custom,
  119. cardEffect: activateClass);
  120. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  121. {
  122. selectedPermanent = permanent;
  123. yield return null;
  124. }
  125. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve", "The opponent is selecting 1 Digimon to digivolve");
  126. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  127. if (selectedPermanent != null)
  128. {
  129. bool CanSelectCardCondition(CardSource cardSource)
  130. {
  131. return cardSource.IsDigimon
  132. && (cardSource.EqualsCardName("Alphamon") || (cardSource.Level <= 6 && cardSource.HasChronicleTraits))
  133. && cardSource.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass);
  134. }
  135. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  136. targetPermanent: selectedPermanent,
  137. cardCondition: CanSelectCardCondition,
  138. payCost: false,
  139. reduceCostTuple: null,
  140. fixedCostTuple: null,
  141. ignoreDigivolutionRequirementFixedCost: -1,
  142. isHand: true,
  143. activateClass: activateClass,
  144. successProcess: null));
  145. }
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. #region Security Effect
  152. if (timing == EffectTiming.SecuritySkill)
  153. {
  154. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: "Trash 1 [X Antibody]/[Chronicle] from hand, draw 2");
  155. }
  156. #endregion
  157. return cardEffects;
  158. }
  159. }
  160. }