BT9_098.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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_098 : 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. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (card.Owner.GetBattleAreaDigimons().Count((permanet) => permanet.TopCard.CardTraits.Contains("Armor Form") || permanet.TopCard.CardTraits.Contains("ArmorForm")) >= 1)
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. }
  36. if (timing == EffectTiming.OptionSkill)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  40. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[Main] You may digivolve 1 of your Digimon with [Armor Form] in its traits into a Digimon card with [Magnamon] in its name in your hand, ignoring its digivolution requirements and without paying its memory cost. The Digimon that digivolved with this effect can't have its DP reduced by your opponent's effects until the end of your opponent's turn.";
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  49. {
  50. if (permanent.TopCard.CardTraits.Contains("Armor Form") || permanent.TopCard.CardTraits.Contains("ArmorForm"))
  51. {
  52. foreach (CardSource cardSource in card.Owner.HandCards)
  53. {
  54. if (CanSelectCardCondition(cardSource))
  55. {
  56. if (!cardSource.CanNotEvolve(permanent))
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanSelectCardCondition(CardSource cardSource)
  67. {
  68. return cardSource.ContainsCardName("Magnamon") && cardSource.IsDigimon;
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  77. {
  78. Permanent selectedPermanent = null;
  79. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount,
  87. canNoSelect: true,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: SelectPermanentCoroutine,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  96. {
  97. selectedPermanent = permanent;
  98. yield return null;
  99. }
  100. if (selectedPermanent != null)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  103. targetPermanent: selectedPermanent,
  104. cardCondition: CanSelectCardCondition,
  105. payCost: false,
  106. reduceCostTuple: null,
  107. fixedCostTuple: null,
  108. ignoreDigivolutionRequirementFixedCost: 0,
  109. isHand: true,
  110. activateClass: activateClass,
  111. successProcess: SuccessProcess()));
  112. IEnumerator SuccessProcess()
  113. {
  114. bool CardEffectCondition(ICardEffect cardEffect)
  115. {
  116. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  117. }
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
  119. targetPermanent: selectedPermanent,
  120. cardEffectCondition: CardEffectCondition,
  121. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  122. activateClass: activateClass,
  123. effectName: "Can't have DP reduced by opponent's effects"));
  124. }
  125. }
  126. }
  127. }
  128. }
  129. if (timing == EffectTiming.SecuritySkill)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect($"Return 1 card from trash to hand add this card to hand", CanUseCondition, card);
  133. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  134. activateClass.SetIsSecurityEffect(true);
  135. cardEffects.Add(activateClass);
  136. string EffectDiscription()
  137. {
  138. return "[Security] Return 1 card with [Magnamon] in its name from your trash to your hand, and add this card to your hand.";
  139. }
  140. bool CanSelectCardCondition(CardSource cardSource)
  141. {
  142. if (cardSource != null)
  143. {
  144. if (cardSource.Owner == card.Owner)
  145. {
  146. if (cardSource.ContainsCardName("Magnamon"))
  147. {
  148. return true;
  149. }
  150. }
  151. }
  152. return false;
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  159. {
  160. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  161. {
  162. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  163. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  164. selectCardEffect.SetUp(
  165. canTargetCondition: CanSelectCardCondition,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. canNoSelect: () => false,
  169. selectCardCoroutine: null,
  170. afterSelectCardCoroutine: null,
  171. message: "Select 1 card to add to your hand.",
  172. maxCount: maxCount,
  173. canEndNotMax: false,
  174. isShowOpponent: true,
  175. mode: SelectCardEffect.Mode.AddHand,
  176. root: SelectCardEffect.Root.Trash,
  177. customRootCardList: null,
  178. canLookReverseCard: true,
  179. selectPlayer: card.Owner,
  180. cardEffect: activateClass);
  181. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  182. }
  183. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  184. }
  185. }
  186. return cardEffects;
  187. }
  188. }