BT9_076.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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_076 : 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 1 card from hand to delete 1 level 3 Digimon and DP -3000", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] You may trash 1 card in your hand. If you trash a purple card, delete 1 of your opponent's level 3 Digimon. If you trash a yellow card, 1 of your opponent's Digimon gets -3000 DP for the turn.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.Level == 3)
  28. {
  29. if (permanent.TopCard.HasLevel)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanSelectPermanentCondition1(Permanent permanent)
  38. {
  39. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (card.Owner.HandCards.Count >= 1)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (card.Owner.HandCards.Count >= 1)
  59. {
  60. List<CardSource> selectedCards = new List<CardSource>();
  61. int discardCount = 1;
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: (cardSource) => true,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: discardCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: null,
  73. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  74. mode: SelectHandEffect.Mode.Discard,
  75. cardEffect: activateClass);
  76. yield return StartCoroutine(selectHandEffect.Activate());
  77. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  78. {
  79. if (cardSources.Count >= 1)
  80. {
  81. selectedCards = cardSources.Clone();
  82. yield return null;
  83. }
  84. }
  85. if (selectedCards.Count >= 1)
  86. {
  87. if (selectedCards.Count((cardSource) => cardSource.HasCardColor(CardColor.Purple)) >= 1)
  88. {
  89. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  90. {
  91. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  92. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  93. selectPermanentEffect.SetUp(
  94. selectPlayer: card.Owner,
  95. canTargetCondition: CanSelectPermanentCondition,
  96. canTargetCondition_ByPreSelecetedList: null,
  97. canEndSelectCondition: null,
  98. maxCount: maxCount,
  99. canNoSelect: false,
  100. canEndNotMax: false,
  101. selectPermanentCoroutine: null,
  102. afterSelectPermanentCoroutine: null,
  103. mode: SelectPermanentEffect.Mode.Destroy,
  104. cardEffect: activateClass);
  105. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  106. }
  107. }
  108. if (selectedCards.Count((cardSource) => cardSource.HasCardColor(CardColor.Yellow)) >= 1)
  109. {
  110. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  111. {
  112. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectPermanentCondition1,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: false,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: SelectPermanentCoroutine,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Custom,
  125. cardEffect: activateClass);
  126. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -3000.", "The opponent is selecting 1 Digimon that will get DP -3000.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. }
  138. if (timing == EffectTiming.OnEnterFieldAnyone)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 level 3 Digimon and DP -3000", CanUseCondition, card);
  142. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  143. cardEffects.Add(activateClass);
  144. string EffectDiscription()
  145. {
  146. return "[When Digivolving] You may trash 1 card in your hand. If you trash a purple card, delete 1 of your opponent's level 3 Digimon. If you trash a yellow card, 1 of your opponent's Digimon gets -3000 DP for the turn.";
  147. }
  148. bool CanSelectPermanentCondition(Permanent permanent)
  149. {
  150. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  151. {
  152. if (permanent.Level == 3)
  153. {
  154. if (permanent.TopCard.HasLevel)
  155. {
  156. return true;
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanSelectPermanentCondition1(Permanent permanent)
  163. {
  164. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  165. }
  166. bool CanUseCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  169. }
  170. bool CanActivateCondition(Hashtable hashtable)
  171. {
  172. if (CardEffectCommons.IsExistOnBattleArea(card))
  173. {
  174. if (card.Owner.HandCards.Count >= 1)
  175. {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  182. {
  183. if (card.Owner.HandCards.Count >= 1)
  184. {
  185. List<CardSource> selectedCards = new List<CardSource>();
  186. int discardCount = 1;
  187. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  188. selectHandEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: (cardSource) => true,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: discardCount,
  194. canNoSelect: true,
  195. canEndNotMax: false,
  196. isShowOpponent: true,
  197. selectCardCoroutine: null,
  198. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  199. mode: SelectHandEffect.Mode.Discard,
  200. cardEffect: activateClass);
  201. yield return StartCoroutine(selectHandEffect.Activate());
  202. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  203. {
  204. if (cardSources.Count >= 1)
  205. {
  206. selectedCards = cardSources.Clone();
  207. yield return null;
  208. }
  209. }
  210. if (selectedCards.Count >= 1)
  211. {
  212. if (selectedCards.Count((cardSource) => cardSource.HasCardColor(CardColor.Purple)) >= 1)
  213. {
  214. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  215. {
  216. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  217. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  218. selectPermanentEffect.SetUp(
  219. selectPlayer: card.Owner,
  220. canTargetCondition: CanSelectPermanentCondition,
  221. canTargetCondition_ByPreSelecetedList: null,
  222. canEndSelectCondition: null,
  223. maxCount: maxCount,
  224. canNoSelect: false,
  225. canEndNotMax: false,
  226. selectPermanentCoroutine: null,
  227. afterSelectPermanentCoroutine: null,
  228. mode: SelectPermanentEffect.Mode.Destroy,
  229. cardEffect: activateClass);
  230. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  231. }
  232. }
  233. if (selectedCards.Count((cardSource) => cardSource.HasCardColor(CardColor.Yellow)) >= 1)
  234. {
  235. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  236. {
  237. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  238. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  239. selectPermanentEffect.SetUp(
  240. selectPlayer: card.Owner,
  241. canTargetCondition: CanSelectPermanentCondition1,
  242. canTargetCondition_ByPreSelecetedList: null,
  243. canEndSelectCondition: null,
  244. maxCount: maxCount,
  245. canNoSelect: false,
  246. canEndNotMax: false,
  247. selectPermanentCoroutine: SelectPermanentCoroutine,
  248. afterSelectPermanentCoroutine: null,
  249. mode: SelectPermanentEffect.Mode.Custom,
  250. cardEffect: activateClass);
  251. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -3000.", "The opponent is selecting 1 Digimon that will get DP -3000.");
  252. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  253. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  254. {
  255. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. if (timing == EffectTiming.OnDestroyedAnyone)
  264. {
  265. ActivateClass activateClass = new ActivateClass();
  266. activateClass.SetUpICardEffect("Memory +2", CanUseCondition, card);
  267. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  268. activateClass.SetIsInheritedEffect(true);
  269. cardEffects.Add(activateClass);
  270. string EffectDiscription()
  271. {
  272. return "[On Deletion] If this Digimon has 2 or more colors, gain 2 memory.";
  273. }
  274. bool CanUseCondition(Hashtable hashtable)
  275. {
  276. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  277. }
  278. bool CanActivateCondition(Hashtable hashtable)
  279. {
  280. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  281. {
  282. if (card.Owner.CanAddMemory(activateClass))
  283. {
  284. if (CardEffectCommons.CanActivateSelfOnDeletionWithCardColors(hashtable, (cardColors) => cardColors.Count >= 2, card))
  285. {
  286. return true;
  287. }
  288. }
  289. }
  290. return false;
  291. }
  292. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  293. {
  294. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  295. }
  296. }
  297. return cardEffects;
  298. }
  299. }