BT9_044.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. public class BT9_044 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Magnamon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnAllyAttack)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Switch attack target to this Digimon", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  26. cardEffects.Add(activateClass);
  27. string EffectDescription()
  28. {
  29. return "[Opponent's Turn] When an opponent's Digimon attacks, if a card with [Armor Form] in its traits or [X Antibody] is in this Digimon's digivolution cards, you may switch the target of attack to this Digimon.";
  30. }
  31. bool PermanentCondition(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (CardEffectCommons.IsOpponentTurn(card))
  40. {
  41. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.IsExistOnBattleArea(card))
  52. {
  53. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardTraits.Contains("Armor Form") || cardSource.CardTraits.Contains("ArmorForm") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  54. {
  55. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  56. {
  57. return true;
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(activateClass, false, card.PermanentOfThisCard()));
  66. }
  67. }
  68. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  69. {
  70. ActivateClass activateClass = new ActivateClass();
  71. activateClass.SetUpICardEffect("Place top card of this Digimon to security to prevent deletion", CanUseCondition, card);
  72. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  73. activateClass.SetHashString("Substitute_BT9_044");
  74. cardEffects.Add(activateClass);
  75. string EffectDiscription()
  76. {
  77. return "[All Turns] When this Digimon would be deleted, you may place the top card of this Digimon on top of your security stack face down to prevent that deletion.";
  78. }
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. if (CardEffectCommons.IsExistOnBattleArea(card))
  82. {
  83. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  84. {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. bool CanActivateCondition(Hashtable hashtable)
  91. {
  92. if (CardEffectCommons.IsExistOnBattleArea(card))
  93. {
  94. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  95. {
  96. if (card.Owner.CanAddSecurity(activateClass))
  97. {
  98. return true;
  99. }
  100. }
  101. }
  102. return false;
  103. }
  104. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  105. {
  106. if (CardEffectCommons.IsExistOnBattleArea(card))
  107. {
  108. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  109. {
  110. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(card.PermanentOfThisCard()));
  111. CardSource cardSource = card.PermanentOfThisCard().TopCard;
  112. Permanent permanent = card.PermanentOfThisCard();
  113. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource));
  114. permanent.ShowingPermanentCard.ShowPermanentData(true);
  115. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, permanent));
  116. if (!cardSource.IsToken)
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource));
  119. permanent.willBeRemoveField = false;
  120. if (permanent.ShowingPermanentCard != null)
  121. {
  122. if (permanent.ShowingPermanentCard.WillBeDeletedObject != null)
  123. {
  124. permanent.ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. return cardEffects;
  133. }
  134. }