P_111.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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 P_111 : 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. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. if (timing == EffectTiming.OnEnterFieldAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Opponent's 1 Digimon reduces DP", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  22. cardEffects.Add(activateClass);
  23. string EffectDiscription()
  24. {
  25. return "[On Play] 1 of your opponent's Digimon gets -3000 DP for each of your Digimon for the turn.";
  26. }
  27. int reduceDP()
  28. {
  29. return card.Owner.GetBattleAreaDigimons().Count * 3000;
  30. }
  31. bool CanSelectPermanentCondition(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  44. {
  45. int _reduceDP = reduceDP();
  46. if (_reduceDP > 0)
  47. {
  48. activateClass.SetEffectName($"DP -{_reduceDP}");
  49. return true;
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. int _reduceDP = reduceDP();
  58. if (_reduceDP > 0)
  59. {
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get DP -{_reduceDP}.", $"The opponent is selecting 1 Digimon that will get DP -{_reduceDP}.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -_reduceDP, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  79. }
  80. }
  81. }
  82. }
  83. if (timing == EffectTiming.OnEnterFieldAnyone)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("Opponent's 1 Digimon reduces DP", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  88. cardEffects.Add(activateClass);
  89. string EffectDiscription()
  90. {
  91. return "[When Digivolving] 1 of your opponent's Digimon gets -3000 DP for each of your Digimon for the turn.";
  92. }
  93. int reduceDP()
  94. {
  95. return card.Owner.GetBattleAreaDigimons().Count * 3000;
  96. }
  97. bool CanSelectPermanentCondition(Permanent permanent)
  98. {
  99. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  100. }
  101. bool CanUseCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  104. }
  105. bool CanActivateCondition(Hashtable hashtable)
  106. {
  107. if (CardEffectCommons.IsExistOnBattleArea(card))
  108. {
  109. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  110. {
  111. int _reduceDP = reduceDP();
  112. if (_reduceDP > 0)
  113. {
  114. activateClass.SetEffectName($"DP -{_reduceDP}");
  115. return true;
  116. }
  117. }
  118. }
  119. return false;
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  122. {
  123. int _reduceDP = reduceDP();
  124. if (_reduceDP > 0)
  125. {
  126. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  127. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  128. selectPermanentEffect.SetUp(
  129. selectPlayer: card.Owner,
  130. canTargetCondition: CanSelectPermanentCondition,
  131. canTargetCondition_ByPreSelecetedList: null,
  132. canEndSelectCondition: null,
  133. maxCount: maxCount,
  134. canNoSelect: false,
  135. canEndNotMax: false,
  136. selectPermanentCoroutine: SelectPermanentCoroutine,
  137. afterSelectPermanentCoroutine: null,
  138. mode: SelectPermanentEffect.Mode.Custom,
  139. cardEffect: activateClass);
  140. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get DP -{_reduceDP}.", $"The opponent is selecting 1 Digimon that will get DP -{_reduceDP}.");
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -_reduceDP, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  145. }
  146. }
  147. }
  148. }
  149. if (timing == EffectTiming.OnAllyAttack)
  150. {
  151. ActivateClass activateClass = new ActivateClass();
  152. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  153. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  154. activateClass.SetIsInheritedEffect(true);
  155. activateClass.SetHashString("Play1Digimon_P_111");
  156. cardEffects.Add(activateClass);
  157. string EffectDiscription()
  158. {
  159. return "[All Turns] [Once Per Turn] When another Digimon attacks, you may play 1 black or yellow level 3 Digimon from your hand without paying the cost.";
  160. }
  161. bool CanSelectCardCondition(CardSource cardSource)
  162. {
  163. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  164. {
  165. if (cardSource.Level == 3)
  166. {
  167. if (cardSource.IsDigimon)
  168. {
  169. if (cardSource.HasLevel)
  170. {
  171. if (cardSource.HasCardColor(CardColor.Yellow))
  172. {
  173. return true;
  174. }
  175. if (cardSource.HasCardColor(CardColor.Black))
  176. {
  177. return true;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. return false;
  184. }
  185. bool PermanentCondition(Permanent permanent)
  186. {
  187. if (timing == EffectTiming.OnAllyAttack)
  188. {
  189. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  190. {
  191. if (permanent.IsDigimon)
  192. {
  193. if (permanent != card.PermanentOfThisCard())
  194. {
  195. return true;
  196. }
  197. }
  198. }
  199. }
  200. else
  201. {
  202. if (CardEffectCommons.IsOpponentPermanent(permanent, card))
  203. {
  204. return true;
  205. }
  206. }
  207. return false;
  208. }
  209. bool CanUseCondition(Hashtable hashtable)
  210. {
  211. if (CardEffectCommons.IsExistOnBattleArea(card))
  212. {
  213. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  214. {
  215. return true;
  216. }
  217. }
  218. return false;
  219. }
  220. bool CanActivateCondition(Hashtable hashtable)
  221. {
  222. if (CardEffectCommons.IsExistOnBattleArea(card))
  223. {
  224. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  225. {
  226. return true;
  227. }
  228. }
  229. return false;
  230. }
  231. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  232. {
  233. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  234. {
  235. List<CardSource> selectedCards = new List<CardSource>();
  236. int maxCount = 1;
  237. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  238. selectHandEffect.SetUp(
  239. selectPlayer: card.Owner,
  240. canTargetCondition: CanSelectCardCondition,
  241. canTargetCondition_ByPreSelecetedList: null,
  242. canEndSelectCondition: null,
  243. maxCount: maxCount,
  244. canNoSelect: true,
  245. canEndNotMax: false,
  246. isShowOpponent: true,
  247. selectCardCoroutine: SelectCardCoroutine,
  248. afterSelectCardCoroutine: null,
  249. mode: SelectHandEffect.Mode.Custom,
  250. cardEffect: activateClass);
  251. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  252. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  253. yield return StartCoroutine(selectHandEffect.Activate());
  254. IEnumerator SelectCardCoroutine(CardSource cardSource)
  255. {
  256. selectedCards.Add(cardSource);
  257. yield return null;
  258. }
  259. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  260. }
  261. }
  262. }
  263. return cardEffects;
  264. }
  265. }