BT10_106.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_106 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.None)
  16. {
  17. int count()
  18. {
  19. return card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  20. }
  21. ChangeCostClass changeCostClass = new ChangeCostClass();
  22. changeCostClass.SetUpICardEffect($"Play Cost -", CanUseCondition, card);
  23. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  24. cardEffects.Add(changeCostClass);
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. if (count() >= 1)
  28. {
  29. changeCostClass.SetEffectName($"Play Cost -{count()}");
  30. return true;
  31. }
  32. return false;
  33. }
  34. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  35. {
  36. if (CardSourceCondition(cardSource))
  37. {
  38. if (RootCondition(root))
  39. {
  40. if (PermanentsCondition(targetPermanents))
  41. {
  42. Cost -= count();
  43. }
  44. }
  45. }
  46. return Cost;
  47. }
  48. bool PermanentsCondition(List<Permanent> targetPermanents)
  49. {
  50. return true;
  51. }
  52. bool CardSourceCondition(CardSource cardSource)
  53. {
  54. return cardSource == card;
  55. }
  56. bool RootCondition(SelectCardEffect.Root root)
  57. {
  58. return true;
  59. }
  60. bool isUpDown()
  61. {
  62. return true;
  63. }
  64. }
  65. if (timing == EffectTiming.OptionSkill)
  66. {
  67. ActivateClass activateClass = new ActivateClass();
  68. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  69. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  70. cardEffects.Add(activateClass);
  71. string EffectDiscription()
  72. {
  73. return "[Main] You may play 1 Digimon card with [Justimon] in its name from your hand without paying its memory cost. If you do, delete 1 of your opponent's Digimon with a play cost less than or equal to the Digimon you played.";
  74. }
  75. bool CanSelectCardCondition(CardSource cardSource)
  76. {
  77. if (cardSource != null)
  78. {
  79. if (cardSource.ContainsCardName("Justimon"))
  80. {
  81. if (cardSource.Owner == card.Owner)
  82. {
  83. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  84. {
  85. return true;
  86. }
  87. }
  88. }
  89. }
  90. return false;
  91. }
  92. bool CanUseCondition(Hashtable hashtable)
  93. {
  94. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  97. {
  98. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  99. {
  100. Permanent playedPermanent = null;
  101. List<CardSource> selectedCards = new List<CardSource>();
  102. int maxCount = 1;
  103. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  104. selectHandEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: CanSelectCardCondition,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: maxCount,
  110. canNoSelect: true,
  111. canEndNotMax: false,
  112. isShowOpponent: true,
  113. selectCardCoroutine: SelectCardCoroutine,
  114. afterSelectCardCoroutine: null,
  115. mode: SelectHandEffect.Mode.Custom,
  116. cardEffect: activateClass);
  117. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  118. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  119. yield return StartCoroutine(selectHandEffect.Activate());
  120. IEnumerator SelectCardCoroutine(CardSource cardSource)
  121. {
  122. selectedCards.Add(cardSource);
  123. yield return null;
  124. }
  125. if (selectedCards.Count >= 1)
  126. {
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  128. cardSources: selectedCards,
  129. activateClass: activateClass,
  130. payCost: false,
  131. isTapped: false,
  132. root: SelectCardEffect.Root.Hand,
  133. activateETB: true));
  134. playedPermanent = selectedCards[0].PermanentOfThisCard();
  135. }
  136. if (CardEffectCommons.IsPermanentExistsOnBattleArea(playedPermanent))
  137. {
  138. int maxCost = playedPermanent.TopCard.GetCostItself;
  139. bool CanSelectPermanentCondition(Permanent permanent)
  140. {
  141. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  142. {
  143. if (permanent.TopCard.GetCostItself <= maxCost)
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  151. {
  152. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  153. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  154. selectPermanentEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: CanSelectPermanentCondition,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: maxCount,
  160. canNoSelect: false,
  161. canEndNotMax: false,
  162. selectPermanentCoroutine: null,
  163. afterSelectPermanentCoroutine: null,
  164. mode: SelectPermanentEffect.Mode.Destroy,
  165. cardEffect: activateClass);
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. }
  168. }
  169. }
  170. }
  171. }
  172. if (timing == EffectTiming.SecuritySkill)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect($"Play 1 black Tamer from hand and add this card to hand", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  177. activateClass.SetIsSecurityEffect(true);
  178. cardEffects.Add(activateClass);
  179. string EffectDiscription()
  180. {
  181. return "[Security] You may play 1 black Tamer card from your hand without paying its memory cost. Then, add this card to its owner's hand.";
  182. }
  183. bool CanSelectCardCondition(CardSource cardSource)
  184. {
  185. if (cardSource.HasCardColor(CardColor.Black))
  186. {
  187. if (cardSource.IsTamer)
  188. {
  189. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  190. {
  191. return true;
  192. }
  193. }
  194. }
  195. return false;
  196. }
  197. bool CanUseCondition(Hashtable hashtable)
  198. {
  199. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  200. }
  201. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  202. {
  203. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  204. {
  205. List<CardSource> selectedCards = new List<CardSource>();
  206. int maxCount = 1;
  207. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  208. selectHandEffect.SetUp(
  209. selectPlayer: card.Owner,
  210. canTargetCondition: CanSelectCardCondition,
  211. canTargetCondition_ByPreSelecetedList: null,
  212. canEndSelectCondition: null,
  213. maxCount: maxCount,
  214. canNoSelect: true,
  215. canEndNotMax: false,
  216. isShowOpponent: true,
  217. selectCardCoroutine: SelectCardCoroutine,
  218. afterSelectCardCoroutine: null,
  219. mode: SelectHandEffect.Mode.Custom,
  220. cardEffect: activateClass);
  221. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  222. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  223. yield return StartCoroutine(selectHandEffect.Activate());
  224. IEnumerator SelectCardCoroutine(CardSource cardSource)
  225. {
  226. selectedCards.Add(cardSource);
  227. yield return null;
  228. }
  229. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  230. cardSources: selectedCards,
  231. activateClass: activateClass,
  232. payCost: false,
  233. isTapped: false,
  234. root: SelectCardEffect.Root.Hand,
  235. activateETB: true));
  236. }
  237. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  238. }
  239. }
  240. return cardEffects;
  241. }
  242. }
  243. }