BT20_087.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_087 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Treated As
  12. if (timing == EffectTiming.None)
  13. {
  14. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  15. changeCardNamesClass.SetUpICardEffect("[Rule] Name: Also treated as [Kota Domoto]/[Yuji Musya].", CanUseCondition, card);
  16. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  17. cardEffects.Add(changeCardNamesClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. return true;
  21. }
  22. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  23. {
  24. if (cardSource == card)
  25. {
  26. CardNames.Add("Kota Domoto");
  27. CardNames.Add("Yuji Musya");
  28. }
  29. return CardNames;
  30. }
  31. }
  32. #endregion
  33. #region Start of Your Turn
  34. if (timing == EffectTiming.OnStartTurn)
  35. {
  36. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  37. }
  38. #endregion
  39. #region Your Turn
  40. if (timing == EffectTiming.OnAllyAttack)
  41. {
  42. ActivateClass activateClass = new ActivateClass();
  43. activateClass.SetUpICardEffect("Digivolve 1 of your Digimon", CanUseCondition, card);
  44. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  45. cardEffects.Add(activateClass);
  46. string EffectDescription()
  47. {
  48. return
  49. "[Your Turn] When one of your [Chronicle] trait Digimon attacks by suspending this Tamer, 1 of your Digimon on the field may digivolve into a level 6 or lower [Chronicle] trait Digimon card in the hand with the digivolution cost reduced by 1.";
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnBattleArea(card) &&
  54. CardEffectCommons.IsOwnerTurn(card) &&
  55. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanent);
  56. }
  57. bool AttackingPermanent(Permanent permanent)
  58. {
  59. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  60. permanent.TopCard.EqualsTraits("Chronicle");
  61. }
  62. bool DigivolveFromPermanentCondition(Permanent permanent)
  63. {
  64. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  65. {
  66. return card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  67. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  68. }
  69. if(CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  70. {
  71. return card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  72. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, isBreedingArea: true));
  73. }
  74. return false;
  75. }
  76. bool DigivolveToCardCondition(CardSource cardSource)
  77. {
  78. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 6 &&
  79. cardSource.EqualsTraits("Chronicle");
  80. }
  81. bool CanActivateCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.IsExistOnBattleArea(card) &&
  84. CardEffectCommons.CanActivateSuspendCostEffect(card) &&
  85. CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition,true);
  86. }
  87. IEnumerator ActivateCoroutine(Hashtable hashtable)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(
  90. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  91. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  92. Permanent selectedPermanent = null;
  93. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  94. selectPermanentEffect.SetUp(
  95. selectPlayer: card.Owner,
  96. canTargetCondition: DigivolveFromPermanentCondition,
  97. canTargetCondition_ByPreSelecetedList: null,
  98. canEndSelectCondition: null,
  99. maxCount: 1,
  100. canNoSelect: true,
  101. canEndNotMax: false,
  102. selectPermanentCoroutine: SelectPermanentCoroutine,
  103. afterSelectPermanentCoroutine: null,
  104. mode: SelectPermanentEffect.Mode.Custom,
  105. cardEffect: activateClass);
  106. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  107. "The opponent is selecting 1 Digimon that will digivolve.");
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  110. {
  111. selectedPermanent = permanent;
  112. yield return null;
  113. }
  114. if (selectedPermanent != null)
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  117. targetPermanent: selectedPermanent,
  118. cardCondition: DigivolveToCardCondition,
  119. payCost: true,
  120. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  121. fixedCostTuple: null,
  122. ignoreDigivolutionRequirementFixedCost: -1,
  123. isHand: true,
  124. activateClass: activateClass,
  125. successProcess: null));
  126. }
  127. }
  128. }
  129. #endregion
  130. #region Security Effect
  131. if (timing == EffectTiming.SecuritySkill)
  132. {
  133. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  134. }
  135. #endregion
  136. return cardEffects;
  137. }
  138. }
  139. }