RB1_031.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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 RB1_031 : 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.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Gammamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Place 1 card from trash to digivolution cards and delete 1 Digimon", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[When Digivolving] You may place 1 Digimon card with [Gammamon] in its text from your trash as this Digimon's bottom digivolution card. Then, you may delete 1 Digimon with a level less than or equal to the number of this Digimon's digivolution cards.";
  30. }
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. if (cardSource.IsDigimon)
  34. {
  35. if (cardSource.HasText("Gammamon"))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanSelectPermanentCondition(Permanent permanent)
  43. {
  44. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (permanent.Level <= card.PermanentOfThisCard().DigivolutionCards.Count)
  49. {
  50. if (permanent.TopCard.HasLevel)
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  62. }
  63. bool CanActivateCondition(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.IsExistOnBattleArea(card))
  66. {
  67. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  68. {
  69. return true;
  70. }
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  79. {
  80. if (CardEffectCommons.IsExistOnBattleArea(card))
  81. {
  82. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  83. {
  84. List<CardSource> selectedCards = new List<CardSource>();
  85. int maxCount = 1;
  86. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  87. selectCardEffect.SetUp(
  88. canTargetCondition: CanSelectCardCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. canNoSelect: () => true,
  92. selectCardCoroutine: SelectCardCoroutine,
  93. afterSelectCardCoroutine: null,
  94. message: "Select 1 card to place on bottom of digivolution cards.",
  95. maxCount: maxCount,
  96. canEndNotMax: false,
  97. isShowOpponent: true,
  98. mode: SelectCardEffect.Mode.Custom,
  99. root: SelectCardEffect.Root.Trash,
  100. customRootCardList: null,
  101. canLookReverseCard: true,
  102. selectPlayer: card.Owner,
  103. cardEffect: activateClass);
  104. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  105. 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.");
  106. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  107. IEnumerator SelectCardCoroutine(CardSource cardSource)
  108. {
  109. selectedCards.Add(cardSource);
  110. yield return null;
  111. }
  112. if (selectedCards.Count >= 1)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  115. }
  116. }
  117. }
  118. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  119. {
  120. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  121. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  122. selectPermanentEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectPermanentCondition,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: maxCount,
  128. canNoSelect: true,
  129. canEndNotMax: false,
  130. selectPermanentCoroutine: null,
  131. afterSelectPermanentCoroutine: null,
  132. mode: SelectPermanentEffect.Mode.Destroy,
  133. cardEffect: activateClass);
  134. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  135. }
  136. }
  137. }
  138. if (timing == EffectTiming.OnDestroyedAnyone)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("Return 1 card from trash and play 1 [Proximamon] from hand", CanUseCondition, card);
  142. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  143. cardEffects.Add(activateClass);
  144. string EffectDiscription()
  145. {
  146. return "[On Deletion] You may return 1 Digimon card from your trash to the hand. Then, by trashing 1 [Siriusmon] in your hand, you may play 1 [Proximamon] from your hand without paying the cost.";
  147. }
  148. bool CanSelectCardCondition(CardSource cardSource)
  149. {
  150. return cardSource.IsDigimon;
  151. }
  152. bool CanSelectCardCondition1(CardSource cardSource)
  153. {
  154. return cardSource.CardNames.Contains("Siriusmon");
  155. }
  156. bool CanSelectCardCondition2(CardSource cardSource)
  157. {
  158. if (cardSource.CardNames.Contains("Proximamon"))
  159. {
  160. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanUseCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  170. }
  171. bool CanActivateCondition(Hashtable hashtable)
  172. {
  173. return CardEffectCommons.IsExistOnTrash(card);
  174. }
  175. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  176. {
  177. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  178. {
  179. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  180. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  181. selectCardEffect.SetUp(
  182. canTargetCondition: CanSelectCardCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. canNoSelect: () => true,
  186. selectCardCoroutine: null,
  187. afterSelectCardCoroutine: null,
  188. message: "Select 1 card to add to your hand.",
  189. maxCount: maxCount,
  190. canEndNotMax: false,
  191. isShowOpponent: true,
  192. mode: SelectCardEffect.Mode.AddHand,
  193. root: SelectCardEffect.Root.Trash,
  194. customRootCardList: null,
  195. canLookReverseCard: true,
  196. selectPlayer: card.Owner,
  197. cardEffect: activateClass);
  198. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  199. }
  200. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  201. {
  202. bool discarded = false;
  203. int discardCount = 1;
  204. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  205. selectHandEffect.SetUp(
  206. selectPlayer: card.Owner,
  207. canTargetCondition: CanSelectCardCondition1,
  208. canTargetCondition_ByPreSelecetedList: null,
  209. canEndSelectCondition: null,
  210. maxCount: discardCount,
  211. canNoSelect: true,
  212. canEndNotMax: false,
  213. isShowOpponent: true,
  214. selectCardCoroutine: null,
  215. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  216. mode: SelectHandEffect.Mode.Discard,
  217. cardEffect: activateClass);
  218. yield return StartCoroutine(selectHandEffect.Activate());
  219. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  220. {
  221. if (cardSources.Count >= 1)
  222. {
  223. discarded = true;
  224. yield return null;
  225. }
  226. }
  227. if (discarded)
  228. {
  229. if (card.Owner.HandCards.Count(CanSelectCardCondition2) >= 1)
  230. {
  231. List<CardSource> selectedCards = new List<CardSource>();
  232. int maxCount = 1;
  233. selectHandEffect.SetUp(
  234. selectPlayer: card.Owner,
  235. canTargetCondition: CanSelectCardCondition2,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. maxCount: maxCount,
  239. canNoSelect: true,
  240. canEndNotMax: false,
  241. isShowOpponent: true,
  242. selectCardCoroutine: SelectCardCoroutine,
  243. afterSelectCardCoroutine: null,
  244. mode: SelectHandEffect.Mode.Custom,
  245. cardEffect: activateClass);
  246. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  247. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  248. yield return StartCoroutine(selectHandEffect.Activate());
  249. IEnumerator SelectCardCoroutine(CardSource cardSource)
  250. {
  251. selectedCards.Add(cardSource);
  252. yield return null;
  253. }
  254. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  255. }
  256. }
  257. }
  258. }
  259. }
  260. if (timing == EffectTiming.OnDestroyedAnyone)
  261. {
  262. ActivateClass activateClass = new ActivateClass();
  263. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  264. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  265. activateClass.SetIsInheritedEffect(true);
  266. activateClass.SetHashString("TrashSecurity_RB1_031");
  267. cardEffects.Add(activateClass);
  268. string EffectDiscription()
  269. {
  270. return "[Your Turn][Once Per Turn] When an opponent's Digimon is deleted, if this Digimon has [Gammamon] in its text, trash the top card of your opponent's security stack.";
  271. }
  272. bool PermanentCondition(Permanent permanent)
  273. {
  274. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  275. }
  276. bool CanUseCondition(Hashtable hashtable)
  277. {
  278. if (CardEffectCommons.IsExistOnBattleArea(card))
  279. {
  280. if (CardEffectCommons.IsOwnerTurn(card))
  281. {
  282. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  283. {
  284. return true;
  285. }
  286. }
  287. }
  288. return false;
  289. }
  290. bool CanActivateCondition(Hashtable hashtable)
  291. {
  292. if (CardEffectCommons.IsExistOnBattleArea(card))
  293. {
  294. if (card.PermanentOfThisCard().TopCard.HasText("Gammamon"))
  295. {
  296. return true;
  297. }
  298. }
  299. return false;
  300. }
  301. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  302. {
  303. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  304. player: card.Owner.Enemy,
  305. destroySecurityCount: 1,
  306. cardEffect: activateClass,
  307. fromTop: true).DestroySecurity());
  308. }
  309. }
  310. return cardEffects;
  311. }
  312. }