EX11_021.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Kokeshimon
  4. namespace DCGO.CardEffects.EX11
  5. {
  6. public class EX11_021 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolution condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool Condition(Permanent permanent)
  15. {
  16. return permanent.TopCard.IsLevel3 && permanent.TopCard.EqualsTraits("Puppet");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(Condition, 2, false, card, null));
  19. }
  20. #endregion
  21. #region When Digivolving
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Play 1 [Mirai Kinosaki] from your hand", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  27. cardEffects.Add(activateClass);
  28. string EffectDescription()
  29. {
  30. return "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Mirai Kinosaki] from your hand without paying the cost.";
  31. }
  32. bool HasTamersPermanent(Permanent permanent)
  33. {
  34. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  35. && permanent.IsTamer;
  36. }
  37. bool HasTamerCard(CardSource source)
  38. {
  39. return source.EqualsCardName("Mirai Kinosaki")
  40. && CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass);
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  45. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  50. && CardEffectCommons.MatchConditionOwnersPermanentCount(card, HasTamersPermanent) <= 1;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. List<CardSource> selectedCards = new List<CardSource>();
  55. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasTamerCard))
  56. {
  57. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  58. selectHandEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: HasTamerCard,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: 1,
  64. canNoSelect: false,
  65. canEndNotMax: false,
  66. isShowOpponent: true,
  67. selectCardCoroutine: SelectCardCoroutine,
  68. afterSelectCardCoroutine: null,
  69. mode: SelectHandEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. yield return StartCoroutine(selectHandEffect.Activate());
  72. }
  73. IEnumerator SelectCardCoroutine(CardSource cardSource)
  74. {
  75. selectedCards.Add(cardSource);
  76. yield return null;
  77. }
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  79. }
  80. }
  81. #endregion
  82. #region ESS
  83. if (timing == EffectTiming.OnAllyAttack)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("End the attack by deleting 1 of your Digimon", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  88. activateClass.SetHashString("StopAttack_EX9-027");
  89. activateClass.SetIsInheritedEffect(true);
  90. cardEffects.Add(activateClass);
  91. string EffectDescription()
  92. {
  93. return "[Opponent's Turn][Once Per Turn] When an opponent's Digimon attacks, by deleting 1 of your other Digimon, end the attack.";
  94. }
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.IsExistOnBattleArea(card)
  98. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => true)
  99. && CardEffectCommons.IsOpponentTurn(card);
  100. }
  101. bool CanActivateCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleArea(card)
  104. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition);
  105. }
  106. bool CanSelectPermanentCondition(Permanent permanent)
  107. {
  108. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  109. && permanent != card.PermanentOfThisCard();
  110. }
  111. IEnumerator ActivateCoroutine(Hashtable hashtable)
  112. {
  113. int maxCount = 1;
  114. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  115. selectPermanentEffect.SetUp(
  116. selectPlayer: card.Owner,
  117. canTargetCondition: CanSelectPermanentCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. maxCount: maxCount,
  121. canNoSelect: false,
  122. canEndNotMax: false,
  123. selectPermanentCoroutine: SelectPermanentCoroutine,
  124. afterSelectPermanentCoroutine: null,
  125. mode: SelectPermanentEffect.Mode.Custom,
  126. cardEffect: activateClass);
  127. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  128. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  129. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  132. IEnumerator SuccessProcess()
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.EndAttack());
  135. }
  136. }
  137. }
  138. }
  139. #endregion
  140. return cardEffects;
  141. }
  142. }
  143. }