RB1_036.cs 16 KB

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