Anfimon_RB1_016.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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 Anfimon_RB1_016 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region When Digivolving
  14. if (timing == EffectTiming.OnAllyAttack)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Trash cards from hand to trash digivolution cards, and return 1 Digimon to deck bottom", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[When Attacking] You may trash up to 2 blue cards in your hand. For each one, trash any 1 card under your opponent�fs Digimon or Tamers. Then, you may return 1 of your opponent�fDigimon with no digivolution cards to the bottom of the deck.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. return cardSource.CardColors.Contains(CardColor.Blue);
  27. }
  28. bool CanSelectPermanentCondition(Permanent permanent)
  29. {
  30. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  31. {
  32. if (permanent.IsDigimon || permanent.IsTamer)
  33. {
  34. if (permanent.DigivolutionCards.Count(CanSelectCardCondition1) >= 1)
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanSelectCardCondition1(CardSource cardSource)
  43. {
  44. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  45. }
  46. bool CanSelectPermanentCondition1(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  49. {
  50. if (permanent.HasNoDigivolutionCards)
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleArea(card))
  64. {
  65. if (card.Owner.HandCards.Count >= 1)
  66. {
  67. return true;
  68. }
  69. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  79. {
  80. List<CardSource> discardCards = new List<CardSource>();
  81. int maxCount = Math.Min(2, card.Owner.HandCards.Count(CanSelectCardCondition));
  82. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  83. selectHandEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectCardCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: true,
  91. isShowOpponent: true,
  92. selectCardCoroutine: null,
  93. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  94. mode: SelectHandEffect.Mode.Discard,
  95. cardEffect: activateClass);
  96. yield return StartCoroutine(selectHandEffect.Activate());
  97. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  98. {
  99. if (cardSources.Count >= 1)
  100. {
  101. discardCards = cardSources.Clone();
  102. yield return null;
  103. }
  104. }
  105. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  106. permanentCondition: CanSelectPermanentCondition,
  107. cardCondition: CanSelectCardCondition1,
  108. maxCount: discardCards.Count,
  109. canNoTrash: false,
  110. isFromOnly1Permanent: false,
  111. activateClass: activateClass,
  112. selectString: "Digimon or Tamer"
  113. ));
  114. }
  115. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  116. {
  117. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: CanSelectPermanentCondition1,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: maxCount,
  125. canNoSelect: true,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: null,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  130. cardEffect: activateClass);
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. }
  133. }
  134. }
  135. #endregion
  136. #region When Digivolving
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("Trash cards from hand to trash digivolution cards, and return 1 Digimon to deck bottom", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[When Digivolving] You may trash up to 2 blue cards in your hand. For each one, trash any 1 card under your opponent�fs Digimon or Tamers. Then, you may return 1 of your opponent�fDigimon with no digivolution cards to the bottom of the deck.";
  146. }
  147. bool CanSelectCardCondition(CardSource cardSource)
  148. {
  149. return cardSource.CardColors.Contains(CardColor.Blue);
  150. }
  151. bool CanSelectPermanentCondition(Permanent permanent)
  152. {
  153. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  154. {
  155. if (permanent.IsDigimon || permanent.IsTamer)
  156. {
  157. if (permanent.DigivolutionCards.Count(CanSelectCardCondition1) >= 1)
  158. {
  159. return true;
  160. }
  161. }
  162. }
  163. return false;
  164. }
  165. bool CanSelectCardCondition1(CardSource cardSource)
  166. {
  167. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  168. }
  169. bool CanSelectPermanentCondition1(Permanent permanent)
  170. {
  171. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  172. {
  173. if (permanent.HasNoDigivolutionCards)
  174. {
  175. return true;
  176. }
  177. }
  178. return false;
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  183. }
  184. bool CanActivateCondition(Hashtable hashtable)
  185. {
  186. if (CardEffectCommons.IsExistOnBattleArea(card))
  187. {
  188. if (card.Owner.HandCards.Count >= 1)
  189. {
  190. return true;
  191. }
  192. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  193. {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  200. {
  201. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  202. {
  203. List<CardSource> discardCards = new List<CardSource>();
  204. int maxCount = Math.Min(2, card.Owner.HandCards.Count(CanSelectCardCondition));
  205. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  206. selectHandEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: CanSelectCardCondition,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: maxCount,
  212. canNoSelect: true,
  213. canEndNotMax: true,
  214. isShowOpponent: true,
  215. selectCardCoroutine: null,
  216. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  217. mode: SelectHandEffect.Mode.Discard,
  218. cardEffect: activateClass);
  219. yield return StartCoroutine(selectHandEffect.Activate());
  220. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  221. {
  222. if (cardSources.Count >= 1)
  223. {
  224. discardCards = cardSources.Clone();
  225. yield return null;
  226. }
  227. }
  228. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  229. permanentCondition: CanSelectPermanentCondition,
  230. cardCondition: CanSelectCardCondition1,
  231. maxCount: discardCards.Count,
  232. canNoTrash: false,
  233. isFromOnly1Permanent: false,
  234. activateClass: activateClass,
  235. selectString: "Digimon or Tamer"
  236. ));
  237. }
  238. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  239. {
  240. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  241. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  242. selectPermanentEffect.SetUp(
  243. selectPlayer: card.Owner,
  244. canTargetCondition: CanSelectPermanentCondition1,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. maxCount: maxCount,
  248. canNoSelect: true,
  249. canEndNotMax: false,
  250. selectPermanentCoroutine: null,
  251. afterSelectPermanentCoroutine: null,
  252. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  253. cardEffect: activateClass);
  254. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  255. }
  256. }
  257. }
  258. #endregion
  259. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  260. {
  261. ActivateClass activateClass = new ActivateClass();
  262. activateClass.SetUpICardEffect("Return cards from trash to deck to prevent this Digimon from being deleted", CanUseCondition, card);
  263. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  264. activateClass.SetHashString("Substitute_RB1_016");
  265. cardEffects.Add(activateClass);
  266. string EffectDiscription()
  267. {
  268. return "[All Turns][Once Per Turn] When one of your blue Digimon would be deleted, by returning 3 cards with [Jellymon] in their texts from your trash to the bottom of the deck in any order, prevent its deletion.";
  269. }
  270. bool CanSelectCardCondition(CardSource cardSource)
  271. {
  272. return cardSource.HasText("Jellymon");
  273. }
  274. bool PermanentCondition(Permanent permanent)
  275. {
  276. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  277. {
  278. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  279. {
  280. return true;
  281. }
  282. }
  283. return false;
  284. }
  285. bool CanUseCondition(Hashtable hashtable)
  286. {
  287. if (CardEffectCommons.IsExistOnBattleArea(card))
  288. {
  289. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition))
  290. {
  291. return true;
  292. }
  293. }
  294. return false;
  295. }
  296. bool CanActivateCondition(Hashtable hashtable)
  297. {
  298. if (CardEffectCommons.IsExistOnBattleArea(card))
  299. {
  300. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  301. {
  302. return true;
  303. }
  304. }
  305. return false;
  306. }
  307. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  308. {
  309. bool returned = false;
  310. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  311. {
  312. int maxCount = 3;
  313. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  314. selectCardEffect.SetUp(
  315. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  316. canTargetCondition_ByPreSelecetedList: null,
  317. canEndSelectCondition: null,
  318. canNoSelect: () => true,
  319. selectCardCoroutine: null,
  320. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  321. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  322. maxCount: maxCount,
  323. canEndNotMax: false,
  324. isShowOpponent: false,
  325. mode: SelectCardEffect.Mode.Custom,
  326. root: SelectCardEffect.Root.Trash,
  327. customRootCardList: null,
  328. canLookReverseCard: true,
  329. selectPlayer: card.Owner,
  330. cardEffect: activateClass);
  331. selectCardEffect.SetNotShowCard();
  332. selectCardEffect.SetNotAddLog();
  333. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  334. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  335. {
  336. if (cardSources.Count == 3)
  337. {
  338. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  339. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  340. returned = true;
  341. }
  342. }
  343. }
  344. if (returned)
  345. {
  346. List<Permanent> permanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable);
  347. if (permanents != null)
  348. {
  349. bool CanSelectPermanentCondition(Permanent permanent)
  350. {
  351. if (PermanentCondition(permanent))
  352. {
  353. if (permanents.Contains(permanent))
  354. {
  355. return true;
  356. }
  357. }
  358. return false;
  359. }
  360. if (card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1)
  361. {
  362. Permanent selectedPermanent = null;
  363. if (card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) == 1)
  364. {
  365. selectedPermanent = card.Owner.GetBattleAreaDigimons().Find(CanSelectPermanentCondition);
  366. }
  367. else
  368. {
  369. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  370. selectPermanentEffect.SetUp(
  371. selectPlayer: card.Owner,
  372. canTargetCondition: CanSelectPermanentCondition,
  373. canTargetCondition_ByPreSelecetedList: null,
  374. canEndSelectCondition: null,
  375. maxCount: 1,
  376. canNoSelect: false,
  377. canEndNotMax: false,
  378. selectPermanentCoroutine: SelectPermanentCoroutine,
  379. afterSelectPermanentCoroutine: null,
  380. mode: SelectPermanentEffect.Mode.Custom,
  381. cardEffect: activateClass);
  382. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that prevents its deletion.", "The opponent is selecting 1 Digimon that prevents its deletion.");
  383. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  384. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  385. {
  386. selectedPermanent = permanent;
  387. yield return null;
  388. }
  389. }
  390. if (selectedPermanent != null)
  391. {
  392. selectedPermanent.willBeRemoveField = false;
  393. selectedPermanent.HideDeleteEffect();
  394. selectedPermanent.HideHandBounceEffect();
  395. selectedPermanent.HideDeckBounceEffect();
  396. }
  397. }
  398. }
  399. }
  400. }
  401. }
  402. return cardEffects;
  403. }
  404. }