P_029.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. using System.Security;
  9. public class P_029 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.OnAllyAttack)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("This Digimon digivolves into 1 [AncientGreymon]", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[When Attacking] This Digimon can digivolve into an [AncientGreymon] in your hand for a memory cost of 2, ignoring its digivolution requirements. If it does, delete this Digimon at the end of the turn.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. return cardSource.CardNames.Contains("AncientGreymon");
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleArea(card))
  35. {
  36. if (card.Owner.HandCards.Count >= 1)
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. Permanent thisPermanent = card.PermanentOfThisCard();
  48. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  49. targetPermanent: card.PermanentOfThisCard(),
  50. cardCondition: CanSelectCardCondition,
  51. payCost: true,
  52. reduceCostTuple: null,
  53. fixedCostTuple: null,
  54. ignoreDigivolutionRequirementFixedCost: 2,
  55. isHand: true,
  56. activateClass: activateClass,
  57. successProcess: SuccessProcess()));
  58. IEnumerator SuccessProcess()
  59. {
  60. ActivateClass activateClass1 = new ActivateClass();
  61. activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition2, card);
  62. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, "");
  63. activateClass1.SetEffectSourcePermanent(thisPermanent);
  64. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnEndTurn);
  65. bool CanUseCondition2(Hashtable hashtable)
  66. {
  67. return true;
  68. }
  69. bool CanActivateCondition1(Hashtable hashtable)
  70. {
  71. if (thisPermanent.TopCard != null)
  72. {
  73. if (thisPermanent.CanBeDestroyedBySkill(activateClass1))
  74. {
  75. if (!thisPermanent.TopCard.CanNotBeAffected(activateClass1))
  76. {
  77. return true;
  78. }
  79. }
  80. }
  81. return false;
  82. }
  83. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { thisPermanent }, CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  86. }
  87. yield return null;
  88. }
  89. }
  90. }
  91. }
  92. if (timing == EffectTiming.None)
  93. {
  94. bool Condition()
  95. {
  96. return CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.IsExistOnBattleArea(card);
  97. }
  98. bool PermanentCondition(Permanent targetPermanent)
  99. {
  100. return targetPermanent == card.PermanentOfThisCard();
  101. }
  102. bool CardSourceCondition(CardSource cardSource)
  103. {
  104. return cardSource.IsDigimon && cardSource.CardNames.Contains("AncientGreymon") && cardSource.Owner.HandCards.Contains(cardSource);
  105. }
  106. bool RootCondition(SelectCardEffect.Root root)
  107. {
  108. return root == SelectCardEffect.Root.Hand;
  109. }
  110. cardEffects.Add(CardEffectFactory.ChangeDigivolutionCostStaticEffect(
  111. changeValue: -2,
  112. permanentCondition: PermanentCondition,
  113. cardCondition: CardSourceCondition,
  114. rootCondition: RootCondition,
  115. isInheritedEffect: true,
  116. card: card,
  117. condition: Condition,
  118. setFixedCost: false));
  119. }
  120. return cardEffects;
  121. }
  122. }