BT22_090.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Rie Kishibe
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_090 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Main Phase
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. cardEffects.Add(CardEffectFactory.Gain1MemoryTamerOpponentDigimonEffect(card));
  16. }
  17. #endregion
  18. #region End of Your Turn
  19. if (timing == EffectTiming.OnEndTurn)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Delete 1 digimon or tamer [Knightmon] in text/[CS] trait, Digivolve into [LordKnightmon]", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  24. activateClass.SetHashString("BT22_090_Digivolve");
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[End of Your Turn] [Once Per Turn] By deleting 1 of your other Digimon or Tamers with [Knightmon] in its text or the [CS] trait, this Tamer may digivolve into [LordKnightmon] in the hand with the digivolution cost reduced by 3.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleArea(card)
  33. && CardEffectCommons.IsOwnerTurn(card);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleArea(card)
  38. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsValidPermament);
  39. }
  40. bool IsValidPermament(Permanent permanent)
  41. {
  42. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  43. (permanent.IsDigimon || permanent.IsTamer) &&
  44. (permanent.TopCard.HasText("Knightmon") || permanent.TopCard.HasCSTraits) &&
  45. permanent != card.PermanentOfThisCard();
  46. }
  47. bool IsLordKnightmon(CardSource cardSource)
  48. {
  49. return CardEffectCommons.IsExistOnHand(cardSource)
  50. && cardSource.EqualsCardName("LordKnightmon");
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsValidPermament))
  55. {
  56. Permanent selectedYourPermanent = null;
  57. #region Destroy Permanent
  58. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsValidPermament));
  59. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  60. selectPermanentEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: IsValidPermament,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: maxCount,
  66. canNoSelect: false,
  67. canEndNotMax: false,
  68. selectPermanentCoroutine: SelectPermanentCoroutine,
  69. afterSelectPermanentCoroutine: null,
  70. mode: SelectPermanentEffect.Mode.Custom,
  71. cardEffect: activateClass);
  72. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  73. {
  74. selectedYourPermanent = permanent;
  75. yield return null;
  76. }
  77. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete", "The opponent is selecting 1 Digimon to delete");
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. #endregion
  80. if (selectedYourPermanent != null)
  81. {
  82. yield return ContinuousController.instance.StartCoroutine(
  83. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  84. targetPermanents: new List<Permanent>() { selectedYourPermanent },
  85. activateClass: activateClass,
  86. successProcess: SuccessProcess,
  87. failureProcess: null));
  88. IEnumerator SuccessProcess(List<Permanent> permanents)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(
  91. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  92. targetPermanent: card.PermanentOfThisCard(),
  93. cardCondition: IsLordKnightmon,
  94. payCost: true,
  95. reduceCostTuple: (reduceCost: 3, reduceCostCardCondition: null),
  96. fixedCostTuple: null,
  97. ignoreDigivolutionRequirementFixedCost: -1,
  98. isHand: true,
  99. activateClass: activateClass,
  100. successProcess: null));
  101. }
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region Security
  108. if (timing == EffectTiming.SecuritySkill)
  109. {
  110. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  111. }
  112. #endregion
  113. return cardEffects;
  114. }
  115. }
  116. }