ST17_04.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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 ST17_04 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if((targetPermanent.TopCard.ContainsCardName("Terriermon") && targetPermanent.Level == 3) || (targetPermanent.TopCard.ContainsCardName("Lopmon") && targetPermanent.Level == 3))
  19. {
  20. return true;
  21. }
  22. return false;
  23. }
  24. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  25. }
  26. #endregion
  27. #region Inherit
  28. if (timing == EffectTiming.None)
  29. {
  30. bool Condition()
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. if (card.PermanentOfThisCard().IsSuspended)
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 1000, isInheritedEffect: true, card: card, condition: Condition));
  42. }
  43. #endregion
  44. #region On Play
  45. if (timing == EffectTiming.OnEnterFieldAnyone)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("Delete 1 level 3 Digimon.", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  50. cardEffects.Add(activateClass);
  51. string EffectDiscription()
  52. {
  53. return "[On Play] Delete 1 level 3 or lower Digimon. If this effect deleted your Digimon , you may play 1 level 3 Digimon card with [Terriermon] or [Lopmon] in its name from your trash without paying the cost.";
  54. }
  55. bool CanSelectPermanentCondition(Permanent permanent)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  58. {
  59. if (permanent.Level <= 3)
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanSelectTerrierOrLop(CardSource cardSource)
  67. {
  68. if (cardSource != null)
  69. {
  70. if (cardSource.IsDigimon)
  71. {
  72. if (cardSource.Owner == card.Owner)
  73. {
  74. if (cardSource.ContainsCardName("Terriermon") || cardSource.ContainsCardName("Lopmon"))
  75. {
  76. return true;
  77. }
  78. }
  79. }
  80. }
  81. return false;
  82. }
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. if (CardEffectCommons.IsExistOnBattleArea(card))
  90. {
  91. return true;
  92. }
  93. return false;
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  96. {
  97. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  98. {
  99. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  100. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. selectPermanentEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanSelectPermanentCondition,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: maxCount,
  107. canNoSelect: false,
  108. canEndNotMax: false,
  109. selectPermanentCoroutine: SelectPermanentCoroutine,
  110. afterSelectPermanentCoroutine: null,
  111. mode: SelectPermanentEffect.Mode.Custom,
  112. cardEffect: activateClass);
  113. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  114. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  115. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  116. {
  117. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  120. IEnumerator SuccessProcess()
  121. {
  122. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTerrierOrLop))
  123. {
  124. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTerrierOrLop);
  125. if (canSelectTrash)
  126. {
  127. List<CardSource> selectedCards = new List<CardSource>();
  128. IEnumerator SelectCardCoroutine(CardSource cardSource)
  129. {
  130. selectedCards.Add(cardSource);
  131. yield return null;
  132. }
  133. int maxCount = 1;
  134. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  135. selectCardEffect.SetUp(
  136. canTargetCondition: CanSelectTerrierOrLop,
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. canNoSelect: () => true,
  140. selectCardCoroutine: SelectCardCoroutine,
  141. afterSelectCardCoroutine: null,
  142. message: "Select 1 card to play.",
  143. maxCount: maxCount,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. mode: SelectCardEffect.Mode.Custom,
  147. root: SelectCardEffect.Root.Trash,
  148. customRootCardList: null,
  149. canLookReverseCard: true,
  150. selectPlayer: card.Owner,
  151. cardEffect: activateClass);
  152. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  153. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  154. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  155. SelectCardEffect.Root root = SelectCardEffect.Root.Trash;
  156. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  157. }
  158. }
  159. }
  160. }
  161. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: null, failureProcess: null));
  164. }
  165. }
  166. }
  167. }
  168. }
  169. #endregion
  170. #region When Digivolving
  171. if (timing == EffectTiming.OnEnterFieldAnyone)
  172. {
  173. ActivateClass activateClass = new ActivateClass();
  174. activateClass.SetUpICardEffect("Delete 1 level 3 Digimon.", CanUseCondition, card);
  175. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  176. cardEffects.Add(activateClass);
  177. string EffectDiscription()
  178. {
  179. return "[When Digivolving] Delete 1 level 3 or lower Digimon. If this effect deleted your Digimon , you may play 1 level 3 Digimon card with [Terriermon] or [Lopmon] in its name from your trash without paying the cost.";
  180. }
  181. bool CanSelectPermanentCondition(Permanent permanent)
  182. {
  183. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  184. {
  185. if (permanent.Level <= 3)
  186. {
  187. return true;
  188. }
  189. }
  190. return false;
  191. }
  192. bool CanSelectTerrierOrLop(CardSource cardSource)
  193. {
  194. if (cardSource != null)
  195. {
  196. if (cardSource.IsDigimon)
  197. {
  198. if (cardSource.Owner == card.Owner)
  199. {
  200. if (cardSource.ContainsCardName("Terriermon") || cardSource.ContainsCardName("Lopmon"))
  201. {
  202. return true;
  203. }
  204. }
  205. }
  206. }
  207. return false;
  208. }
  209. bool CanUseCondition(Hashtable hashtable)
  210. {
  211. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  212. }
  213. bool CanActivateCondition(Hashtable hashtable)
  214. {
  215. if (CardEffectCommons.IsExistOnBattleArea(card))
  216. {
  217. return true;
  218. }
  219. return false;
  220. }
  221. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  222. {
  223. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  224. {
  225. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  226. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  227. selectPermanentEffect.SetUp(
  228. selectPlayer: card.Owner,
  229. canTargetCondition: CanSelectPermanentCondition,
  230. canTargetCondition_ByPreSelecetedList: null,
  231. canEndSelectCondition: null,
  232. maxCount: maxCount,
  233. canNoSelect: false,
  234. canEndNotMax: false,
  235. selectPermanentCoroutine: SelectPermanentCoroutine,
  236. afterSelectPermanentCoroutine: null,
  237. mode: SelectPermanentEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  240. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  241. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  242. {
  243. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  244. {
  245. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  246. IEnumerator SuccessProcess()
  247. {
  248. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTerrierOrLop))
  249. {
  250. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTerrierOrLop);
  251. if (canSelectTrash)
  252. {
  253. List<CardSource> selectedCards = new List<CardSource>();
  254. IEnumerator SelectCardCoroutine(CardSource cardSource)
  255. {
  256. selectedCards.Add(cardSource);
  257. yield return null;
  258. }
  259. int maxCount = 1;
  260. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  261. selectCardEffect.SetUp(
  262. canTargetCondition: CanSelectTerrierOrLop,
  263. canTargetCondition_ByPreSelecetedList: null,
  264. canEndSelectCondition: null,
  265. canNoSelect: () => true,
  266. selectCardCoroutine: SelectCardCoroutine,
  267. afterSelectCardCoroutine: null,
  268. message: "Select 1 card to play.",
  269. maxCount: maxCount,
  270. canEndNotMax: false,
  271. isShowOpponent: true,
  272. mode: SelectCardEffect.Mode.Custom,
  273. root: SelectCardEffect.Root.Trash,
  274. customRootCardList: null,
  275. canLookReverseCard: true,
  276. selectPlayer: card.Owner,
  277. cardEffect: activateClass);
  278. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  279. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  280. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  281. SelectCardEffect.Root root = SelectCardEffect.Root.Trash;
  282. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  283. }
  284. }
  285. }
  286. }
  287. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  288. {
  289. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: null, failureProcess: null));
  290. }
  291. }
  292. }
  293. }
  294. }
  295. #endregion
  296. return cardEffects;
  297. }
  298. }