WaruMonzaemon_BT15_065.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class WaruMonzaemon_BT15_065 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.ContainsCardName("Numemon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play - Place a card under this Digimon to gain effects.
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Place a card under this Digimon to gain effects.", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  29. activateClass.SetHashString("CantAttack_BT15_065");
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "[On Play] By placing 1 card with [Numemon] in it's name from your trash as this Digimon's bottom digivolution card, all of your opponent's Digimon with a play cost of 5 or less can't attack players until the end of your opponent's turn.";
  34. }
  35. bool CanSelectCardCondition(CardSource cardSource)
  36. {
  37. return cardSource.ContainsCardName("Numemon");
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (!card.PermanentOfThisCard().IsToken)
  48. {
  49. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (CardEffectCommons.IsExistOnBattleArea(card))
  60. {
  61. bool added = false;
  62. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  63. {
  64. List<CardSource> selectedCards = new List<CardSource>();
  65. int maxCount = 1;
  66. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  67. selectCardEffect.SetUp(
  68. canTargetCondition: CanSelectCardCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. canNoSelect: () => true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. message: "Select 1 card to place on bottom of digivolution cards.",
  75. maxCount: maxCount,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. mode: SelectCardEffect.Mode.Custom,
  79. root: SelectCardEffect.Root.Trash,
  80. customRootCardList: null,
  81. canLookReverseCard: true,
  82. selectPlayer: card.Owner,
  83. cardEffect: activateClass);
  84. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  85. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  86. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  87. IEnumerator SelectCardCoroutine(CardSource cardSource)
  88. {
  89. selectedCards.Add(cardSource);
  90. yield return null;
  91. }
  92. if (selectedCards.Count >= 1)
  93. {
  94. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  95. added = true;
  96. }
  97. }
  98. if (added)
  99. {
  100. bool AttackerCondition(Permanent Attacker)
  101. {
  102. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(Attacker, card))
  103. {
  104. if (Attacker.TopCard.GetCostItself <= 5)
  105. {
  106. if (Attacker.TopCard.HasPlayCost)
  107. {
  108. return true;
  109. }
  110. }
  111. }
  112. return false;
  113. }
  114. bool DefenderCondition(Permanent Defender)
  115. {
  116. return Defender == null;
  117. }
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttackPlayerEffect(
  119. attackerCondition: AttackerCondition,
  120. defenderCondition: DefenderCondition,
  121. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  122. activateClass: activateClass,
  123. effectName: "Can't Attack"));
  124. }
  125. }
  126. }
  127. }
  128. #endregion
  129. #region On Play - Trash 1 card from hand to DeDigivolve an opponent's Digimon.
  130. if (timing == EffectTiming.OnEnterFieldAnyone)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Trash 1 card from hand to DeDigivolve an opponent's Digimon.", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  135. activateClass.SetHashString("DeDigivolve_BT15_065");
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[On Play] By trashing 1 card with [Numemon] in it's name in your hand or from the bottom of this Digimon's digivolution cards, [De-Digivolve 1] 1 of your opponent's Digimon.";
  140. }
  141. bool CanSelectCardCondition(CardSource cardSource)
  142. {
  143. if (cardSource.ContainsCardName("Numemon"))
  144. {
  145. return true;
  146. }
  147. return false;
  148. }
  149. bool CanSelectPermanentCondition(Permanent permanent)
  150. {
  151. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  152. {
  153. if (permanent.TopCard.HasLevel)
  154. {
  155. return true;
  156. }
  157. }
  158. return false;
  159. }
  160. bool CanUseCondition(Hashtable hashtable)
  161. {
  162. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. if (CardEffectCommons.IsExistOnBattleArea(card))
  167. {
  168. if (card.Owner.HandCards.Count >= 1)
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  176. {
  177. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  178. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  179. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  180. if (canSelectHand || canSelectDigivolutionCards)
  181. {
  182. if (canSelectHand && canSelectDigivolutionCards)
  183. {
  184. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  185. {
  186. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  187. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  188. };
  189. string selectPlayerMessage = "From which area do you play a card?";
  190. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  191. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  192. }
  193. else
  194. {
  195. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  196. }
  197. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  198. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  199. bool discarded = false;
  200. int discardCount = 1;
  201. if (fromHand)
  202. {
  203. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  204. selectHandEffect.SetUp(
  205. selectPlayer: card.Owner,
  206. canTargetCondition: CanSelectCardCondition,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. maxCount: discardCount,
  210. canNoSelect: true,
  211. canEndNotMax: false,
  212. isShowOpponent: true,
  213. selectCardCoroutine: null,
  214. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  215. mode: SelectHandEffect.Mode.Discard,
  216. cardEffect: activateClass);
  217. yield return StartCoroutine(selectHandEffect.Activate());
  218. }
  219. else
  220. {
  221. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  222. selectCardEffect.SetUp(
  223. canTargetCondition: CanSelectCardCondition,
  224. canTargetCondition_ByPreSelecetedList: null,
  225. canEndSelectCondition: null,
  226. canNoSelect: () => true,
  227. selectCardCoroutine: null,
  228. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  229. message: "Select 1 card to trash.",
  230. maxCount: discardCount,
  231. canEndNotMax: false,
  232. isShowOpponent: true,
  233. mode: SelectCardEffect.Mode.Discard,
  234. root: SelectCardEffect.Root.DigivolutionCards,
  235. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  236. canLookReverseCard: true,
  237. selectPlayer: card.Owner,
  238. cardEffect: activateClass);
  239. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to trash.", "The opponent is selecting 1 digivolution card to trash.");
  240. yield return StartCoroutine(selectCardEffect.Activate());
  241. }
  242. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  243. {
  244. if (cardSources.Count >= 1)
  245. {
  246. discarded = true;
  247. yield return null;
  248. }
  249. }
  250. if (discarded)
  251. {
  252. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  253. {
  254. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  255. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  256. selectPermanentEffect.SetUp(
  257. selectPlayer: card.Owner,
  258. canTargetCondition: CanSelectPermanentCondition,
  259. canTargetCondition_ByPreSelecetedList: null,
  260. canEndSelectCondition: null,
  261. maxCount: maxCount,
  262. canNoSelect: false,
  263. canEndNotMax: false,
  264. selectPermanentCoroutine: SelectPermanentCoroutine,
  265. afterSelectPermanentCoroutine: null,
  266. mode: SelectPermanentEffect.Mode.Custom,
  267. cardEffect: activateClass);
  268. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  269. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  270. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  271. {
  272. Permanent selectedPermanent = permanent;
  273. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  274. }
  275. }
  276. }
  277. }
  278. }
  279. }
  280. #endregion
  281. #region When Digivolving - Trash 1 card from hand to DeDigivolve an opponent's Digimon.
  282. if (timing == EffectTiming.OnEnterFieldAnyone)
  283. {
  284. ActivateClass activateClass = new ActivateClass();
  285. activateClass.SetUpICardEffect("Trash 1 card from hand to DeDigivolve an opponent's Digimon.", CanUseCondition, card);
  286. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  287. activateClass.SetHashString("DeDigivolve_BT15_065");
  288. cardEffects.Add(activateClass);
  289. string EffectDiscription()
  290. {
  291. return "[On Play] [When Digivolving] By trashing 1 card with [Numemon] in it's name in your hand or from the bottom of this Digimon's digivolution cards, [De-Digivolve 1] 1 of your opponent's Digimon.";
  292. }
  293. bool CanSelectCardCondition(CardSource cardSource)
  294. {
  295. if (cardSource.ContainsCardName("Numemon"))
  296. {
  297. return true;
  298. }
  299. return false;
  300. }
  301. bool CanSelectPermanentCondition(Permanent permanent)
  302. {
  303. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  304. {
  305. if (permanent.TopCard.HasLevel)
  306. {
  307. return true;
  308. }
  309. }
  310. return false;
  311. }
  312. bool CanUseCondition(Hashtable hashtable)
  313. {
  314. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  315. }
  316. bool CanActivateCondition(Hashtable hashtable)
  317. {
  318. if (CardEffectCommons.IsExistOnBattleArea(card))
  319. {
  320. if (card.Owner.HandCards.Count >= 1)
  321. {
  322. return true;
  323. }
  324. }
  325. return false;
  326. }
  327. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  328. {
  329. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  330. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  331. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  332. if (canSelectHand || canSelectDigivolutionCards)
  333. {
  334. if (canSelectHand && canSelectDigivolutionCards)
  335. {
  336. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  337. {
  338. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  339. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  340. };
  341. string selectPlayerMessage = "From which area do you play a card?";
  342. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  343. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  344. }
  345. else
  346. {
  347. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  348. }
  349. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  350. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  351. bool discarded = false;
  352. int discardCount = 1;
  353. if (fromHand)
  354. {
  355. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  356. selectHandEffect.SetUp(
  357. selectPlayer: card.Owner,
  358. canTargetCondition: CanSelectCardCondition,
  359. canTargetCondition_ByPreSelecetedList: null,
  360. canEndSelectCondition: null,
  361. maxCount: discardCount,
  362. canNoSelect: true,
  363. canEndNotMax: false,
  364. isShowOpponent: true,
  365. selectCardCoroutine: null,
  366. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  367. mode: SelectHandEffect.Mode.Discard,
  368. cardEffect: activateClass);
  369. yield return StartCoroutine(selectHandEffect.Activate());
  370. }
  371. else
  372. {
  373. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  374. selectCardEffect.SetUp(
  375. canTargetCondition: CanSelectCardCondition,
  376. canTargetCondition_ByPreSelecetedList: null,
  377. canEndSelectCondition: null,
  378. canNoSelect: () => true,
  379. selectCardCoroutine: null,
  380. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  381. message: "Select 1 card to trash.",
  382. maxCount: discardCount,
  383. canEndNotMax: false,
  384. isShowOpponent: true,
  385. mode: SelectCardEffect.Mode.Discard,
  386. root: SelectCardEffect.Root.Custom,
  387. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  388. canLookReverseCard: true,
  389. selectPlayer: card.Owner,
  390. cardEffect: activateClass);
  391. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to trash.", "The opponent is selecting 1 digivolution card to trash.");
  392. yield return StartCoroutine(selectCardEffect.Activate());
  393. }
  394. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  395. {
  396. if (cardSources.Count >= 1)
  397. {
  398. discarded = true;
  399. yield return null;
  400. }
  401. }
  402. if (discarded)
  403. {
  404. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  405. {
  406. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  407. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  408. selectPermanentEffect.SetUp(
  409. selectPlayer: card.Owner,
  410. canTargetCondition: CanSelectPermanentCondition,
  411. canTargetCondition_ByPreSelecetedList: null,
  412. canEndSelectCondition: null,
  413. maxCount: maxCount,
  414. canNoSelect: false,
  415. canEndNotMax: false,
  416. selectPermanentCoroutine: SelectPermanentCoroutine,
  417. afterSelectPermanentCoroutine: null,
  418. mode: SelectPermanentEffect.Mode.Custom,
  419. cardEffect: activateClass);
  420. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  421. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  422. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  423. {
  424. Permanent selectedPermanent = permanent;
  425. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. #endregion
  433. #region Your Turn - When you have a [Monzaemon] or [Numemon] in play, this Digimon gains Security Atk +1.
  434. if (timing == EffectTiming.None)
  435. {
  436. bool PermanentCondition(Permanent permanent)
  437. {
  438. if(permanent.IsDigimon)
  439. {
  440. if (permanent.TopCard != card)
  441. {
  442. return permanent.TopCard.ContainsCardName("Monzaemon") || permanent.TopCard.ContainsCardName("Numemon");
  443. }
  444. }
  445. return false;
  446. }
  447. bool Condition()
  448. {
  449. if (CardEffectCommons.IsExistOnBattleArea(card))
  450. {
  451. if (CardEffectCommons.IsOwnerTurn(card))
  452. {
  453. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  454. {
  455. return true;
  456. }
  457. }
  458. }
  459. return false;
  460. }
  461. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: Condition));
  462. }
  463. #endregion
  464. return cardEffects;
  465. }
  466. }