Fenrirugamon_BT14_081.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 Fenrirugamon_BT14_081 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play Digimon cards from trash", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may play 1 level 4 or lower card with the [Dark Animal] or [SoC] trait from your trash without paying the cost. If [Eiji Nagasumi] is in this Digimon's digivolution cards, add 2 to the number of cards this effect may play.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.Level <= 4)
  26. {
  27. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  28. {
  29. if (cardSource.HasLevel && cardSource.HasPlayCost)
  30. {
  31. if (cardSource.CardTraits.Contains("Dark Animal"))
  32. {
  33. return true;
  34. }
  35. if (cardSource.CardTraits.Contains("DarkAnimal"))
  36. {
  37. return true;
  38. }
  39. if (cardSource.CardTraits.Contains("SoC"))
  40. {
  41. return true;
  42. }
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. int maxCount = 1;
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("Eiji Nagasumi")) || card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("EijiNagasumi")))
  69. {
  70. maxCount += 2;
  71. }
  72. }
  73. maxCount = Math.Min(maxCount, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  74. maxCount = Math.Min(maxCount, card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()));
  75. List<CardSource> selectedCards = new List<CardSource>();
  76. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  77. selectCardEffect.SetUp(
  78. canTargetCondition: CanSelectCardCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. canNoSelect: () => true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. message: "Select cards to play.",
  85. maxCount: maxCount,
  86. canEndNotMax: false,
  87. isShowOpponent: true,
  88. mode: SelectCardEffect.Mode.Custom,
  89. root: SelectCardEffect.Root.Trash,
  90. customRootCardList: null,
  91. canLookReverseCard: true,
  92. selectPlayer: card.Owner,
  93. cardEffect: activateClass);
  94. selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  95. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  96. yield return StartCoroutine(selectCardEffect.Activate());
  97. IEnumerator SelectCardCoroutine(CardSource cardSource)
  98. {
  99. selectedCards.Add(cardSource);
  100. yield return null;
  101. }
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  103. }
  104. }
  105. if (timing == EffectTiming.OnAllyAttack)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect("Delete 1 opponent's Digimon to unsuspend this Digimon", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  110. activateClass.SetHashString("Delete_BT14_081");
  111. cardEffects.Add(activateClass);
  112. string EffectDiscription()
  113. {
  114. return "[When Attacking][Once Per Turn] By deleting 1 of your opponent's level 3 or lower Digimon, unsuspend this Digimon. For each of your Digimon, add 1 to the level this effect may choose.";
  115. }
  116. bool CanSelectPermanentCondition(Permanent permanent)
  117. {
  118. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  119. {
  120. int maxLevel = 3;
  121. maxLevel += card.Owner.GetBattleAreaDigimons().Count;
  122. if (permanent.Level <= maxLevel)
  123. {
  124. if (permanent.TopCard.HasLevel)
  125. {
  126. return true;
  127. }
  128. }
  129. }
  130. return false;
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  135. }
  136. bool CanActivateCondition(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.IsExistOnBattleArea(card))
  139. {
  140. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  141. {
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  148. {
  149. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  150. {
  151. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  152. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  153. selectPermanentEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectPermanentCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: maxCount,
  159. canNoSelect: true,
  160. canEndNotMax: false,
  161. selectPermanentCoroutine: SelectPermanentCoroutine,
  162. afterSelectPermanentCoroutine: null,
  163. mode: SelectPermanentEffect.Mode.Custom,
  164. cardEffect: activateClass);
  165. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  168. {
  169. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  170. targetPermanents: new List<Permanent>() { permanent },
  171. activateClass: activateClass,
  172. successProcess: permanents => SuccessProcess(),
  173. failureProcess: null));
  174. IEnumerator SuccessProcess()
  175. {
  176. Permanent selectedPermanent = card.PermanentOfThisCard();
  177. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  178. }
  179. }
  180. }
  181. }
  182. }
  183. if (timing == EffectTiming.None)
  184. {
  185. ChangeEndTurnMinMemoryClass changeEndTurnMinMemoryClass = new ChangeEndTurnMinMemoryClass();
  186. changeEndTurnMinMemoryClass.SetUpICardEffect("The turn end condition is the opponent having 3 or more memory.", CanUseCondition, card);
  187. changeEndTurnMinMemoryClass.SetUpChangeEndTurnMinMemoryClass(minMemory => 3);
  188. cardEffects.Add(changeEndTurnMinMemoryClass);
  189. bool CanUseCondition(Hashtable hashtable)
  190. {
  191. if (CardEffectCommons.IsExistOnBattleArea(card))
  192. {
  193. if (CardEffectCommons.IsOwnerTurn(card))
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. }
  201. return cardEffects;
  202. }
  203. }