BT8_031.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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 BT8_031 : 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("Trash digivolution cards and return 1 Digimon to hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Trash the top digivolution card of 1 of your opponent's Digimon. Then, return 1 of your opponent's Digimon with no digivolution cards to its owner's hand.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. return true;
  28. }
  29. return false;
  30. }
  31. bool CanSelectPermanentCondition1(Permanent permanent)
  32. {
  33. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  34. {
  35. if (permanent.HasNoDigivolutionCards)
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  45. }
  46. bool CanActivateCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. return true;
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (isExistOnField(card))
  57. {
  58. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  79. {
  80. Permanent selectedPermanent = permanent;
  81. if (selectedPermanent != null)
  82. {
  83. if (selectedPermanent.DigivolutionCards.Count >= 1 && !selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  84. {
  85. List<CardSource> selectedCards = new List<CardSource>();
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: true, activateClass: activateClass));
  87. }
  88. }
  89. }
  90. }
  91. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  92. {
  93. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. selectPermanentEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: CanSelectPermanentCondition1,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: maxCount,
  101. canNoSelect: false,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: null,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Bounce,
  106. cardEffect: activateClass);
  107. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  108. }
  109. }
  110. }
  111. }
  112. }
  113. if (timing == EffectTiming.None)
  114. {
  115. AddSkillClass addSkillClass = new AddSkillClass();
  116. addSkillClass.SetUpICardEffect("Opponent's Digimon trashes its digivolution card when it attacks", CanUseCondition, card);
  117. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  118. cardEffects.Add(addSkillClass);
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleArea(card))
  122. {
  123. if (CardEffectCommons.IsOpponentTurn(card))
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. bool PermanentCondition(Permanent permanent)
  131. {
  132. if (permanent != null)
  133. {
  134. if (permanent.TopCard != null)
  135. {
  136. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent))
  137. {
  138. if (!permanent.TopCard.CanNotBeAffected(addSkillClass))
  139. {
  140. return true;
  141. }
  142. }
  143. }
  144. }
  145. return false;
  146. }
  147. bool CardSourceCondition(CardSource cardSource)
  148. {
  149. if (cardSource.PermanentOfThisCard() != null)
  150. {
  151. if (cardSource.Owner == card.Owner.Enemy)
  152. {
  153. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  154. {
  155. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  156. {
  157. if (cardSource.Owner.GetBattleAreaDigimons().Contains(cardSource.PermanentOfThisCard()))
  158. {
  159. return true;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. return false;
  166. }
  167. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  168. {
  169. if (_timing == EffectTiming.OnAllyAttack)
  170. {
  171. ActivateClass activateClass1 = new ActivateClass();
  172. activateClass1.SetUpICardEffect("Trash the bottom digivolution card", CanUseCondition1, cardSource);
  173. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription());
  174. activateClass1.SetRootCardEffect(addSkillClass);
  175. activateClass1.SetHashString("TrashDigivolutionCards_BT8_031");
  176. cardEffects.Add(activateClass1);
  177. string EffectDiscription()
  178. {
  179. return "[When Attacking] Trash the bottom digivolution card of this Digimon.";
  180. }
  181. bool CanUseCondition1(Hashtable hashtable)
  182. {
  183. if (CardSourceCondition(cardSource))
  184. {
  185. if (isExistOnField(cardSource))
  186. {
  187. if (cardSource.Owner.GetBattleAreaDigimons().Contains(cardSource.PermanentOfThisCard()))
  188. {
  189. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == cardSource.Owner)
  190. {
  191. if (GManager.instance.attackProcess.AttackingPermanent == cardSource.PermanentOfThisCard())
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. return false;
  200. }
  201. bool CanActivateCondition1(Hashtable hashtable)
  202. {
  203. if (CardSourceCondition(cardSource))
  204. {
  205. if (isExistOnField(cardSource))
  206. {
  207. if (cardSource.Owner.GetBattleAreaDigimons().Contains(cardSource.PermanentOfThisCard()))
  208. {
  209. if (!cardSource.CanNotBeAffected(activateClass1))
  210. {
  211. if (cardSource.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  212. {
  213. if (!cardSource.PermanentOfThisCard().DigivolutionCards[cardSource.PermanentOfThisCard().DigivolutionCards.Count - 1].CanNotTrashFromDigivolutionCards(activateClass1))
  214. {
  215. return true;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. return false;
  223. }
  224. IEnumerator ActivateCoroutine1(Hashtable _hashtable)
  225. {
  226. if (CardSourceCondition(cardSource))
  227. {
  228. if (isExistOnField(cardSource))
  229. {
  230. if (cardSource.Owner.GetBattleAreaDigimons().Contains(cardSource.PermanentOfThisCard()))
  231. {
  232. if (cardSource.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  233. {
  234. Permanent selectedPermanent = cardSource.PermanentOfThisCard();
  235. if (selectedPermanent != null)
  236. {
  237. if (selectedPermanent.DigivolutionCards.Count >= 1)
  238. {
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass1));
  240. }
  241. }
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. return cardEffects;
  249. }
  250. }
  251. return cardEffects;
  252. }
  253. }