BT9_042.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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_042 : 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.OnDeclaration)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Place this card to digivolution cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Hand][Main] If you have a Digimon with [Justimon] or [Raidenmon] in its name in play, you may pay 1 memory to place this card under that Digimon as its bottom digivolution card.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.TopCard.ContainsCardName("Justimon") || permanent.TopCard.ContainsCardName("Raidenmon"))
  28. {
  29. if (!permanent.IsToken)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. if (card.Owner.HandCards.Contains(card))
  40. {
  41. if (card.Owner.MaxMemoryCost >= 1)
  42. {
  43. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  52. {
  53. if (card.Owner.HandCards.Contains(card))
  54. {
  55. if (card.Owner.MaxMemoryCost >= 1)
  56. {
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-1, activateClass));
  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 a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. Permanent selectedPermanent = permanent;
  79. if (selectedPermanent != null)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. if (timing == EffectTiming.OnEnterFieldAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("Trash 1 card from hand to DP -4000", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. return "[When Digivolving] You may trash 1 Digimon card with [Machine] or [Cyborg] in its traits in your hand to have 1 of your opponent's Digimon get -4000 DP for the turn.";
  98. }
  99. bool CanSelectCardCondition(CardSource cardSource)
  100. {
  101. if (cardSource != null)
  102. {
  103. if (cardSource.Owner == card.Owner)
  104. {
  105. if (cardSource.CardTraits.Contains("Machine"))
  106. {
  107. return true;
  108. }
  109. if (cardSource.CardTraits.Contains("Cyborg"))
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanSelectPermanentCondition(Permanent permanent)
  118. {
  119. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleArea(card))
  128. {
  129. if (card.Owner.HandCards.Count >= 1)
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. if (isExistOnField(card))
  139. {
  140. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  141. {
  142. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  143. {
  144. bool discarded = false;
  145. int discardCount = 1;
  146. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  147. selectHandEffect.SetUp(
  148. selectPlayer: card.Owner,
  149. canTargetCondition: CanSelectCardCondition,
  150. canTargetCondition_ByPreSelecetedList: null,
  151. canEndSelectCondition: null,
  152. maxCount: discardCount,
  153. canNoSelect: true,
  154. canEndNotMax: false,
  155. isShowOpponent: true,
  156. selectCardCoroutine: null,
  157. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  158. mode: SelectHandEffect.Mode.Discard,
  159. cardEffect: activateClass);
  160. yield return StartCoroutine(selectHandEffect.Activate());
  161. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  162. {
  163. if (cardSources.Count >= 1)
  164. {
  165. discarded = true;
  166. yield return null;
  167. }
  168. }
  169. if (discarded)
  170. {
  171. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  172. {
  173. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  174. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: CanSelectPermanentCondition,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: false,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: SelectPermanentCoroutine,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Custom,
  186. cardEffect: activateClass);
  187. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.", "The opponent is selecting 1 Digimon that will get DP -4000.");
  188. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  189. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  190. {
  191. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -4000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. if (timing == EffectTiming.OnAllyAttack)
  201. {
  202. ActivateClass activateClass = new ActivateClass();
  203. activateClass.SetUpICardEffect("DP -4000", CanUseCondition, card);
  204. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  205. activateClass.SetIsInheritedEffect(true);
  206. cardEffects.Add(activateClass);
  207. string EffectDiscription()
  208. {
  209. return "[When Attacking] 1 of your opponent's Digimon gets -4000 DP for the turn.";
  210. }
  211. bool CanSelectPermanentCondition(Permanent permanent)
  212. {
  213. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  214. }
  215. bool CanUseCondition(Hashtable hashtable)
  216. {
  217. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  218. }
  219. bool CanActivateCondition(Hashtable hashtable)
  220. {
  221. if (CardEffectCommons.IsExistOnBattleArea(card))
  222. {
  223. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  224. {
  225. return true;
  226. }
  227. }
  228. return false;
  229. }
  230. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  231. {
  232. if (isExistOnField(card))
  233. {
  234. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  235. {
  236. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  237. {
  238. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  239. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: CanSelectPermanentCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: maxCount,
  246. canNoSelect: false,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: SelectPermanentCoroutine,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Custom,
  251. cardEffect: activateClass);
  252. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.", "The opponent is selecting 1 Digimon that will get DP -4000.");
  253. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  254. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  255. {
  256. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -4000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. return cardEffects;
  264. }
  265. }