Rhihimon_BT18_081.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class Rhihimon_BT18_081 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.ContainsTraits("Hybrid")
  17. && (targetPermanent.TopCard.CardColors.Contains(CardColor.Purple) ||
  18. targetPermanent.TopCard.CardColors.Contains(CardColor.Yellow));
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Hand - Main
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Your purple or yellow tamer digivolves into this card", CanUseCondition,
  34. card);
  35. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  36. cardEffects.Add(activateClass);
  37. string EffectDescription()
  38. {
  39. return
  40. "[Hand] [Main] By placing 1 [Loweemon] and [KaiserLeomon] from your trash under 1 of your purple or yellow Tamers, that Tamer digivolves into this card for digivolution cost of 3, ignoring its digivolution requirements.";
  41. }
  42. bool CanSelectHumanSpiritCardCondition(CardSource cardSource)
  43. {
  44. return cardSource.EqualsCardName("Loweemon");
  45. }
  46. bool CanSelectBeastSpiritCardCondition(CardSource cardSource)
  47. {
  48. return cardSource.EqualsCardName("KaiserLeomon");
  49. }
  50. bool CanSelectTamerPermanentCondition(Permanent permanent)
  51. {
  52. return permanent != null && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  53. permanent.IsTamer &&
  54. (permanent.TopCard.CardColors.Contains(CardColor.Purple) ||
  55. permanent.TopCard.CardColors.Contains(CardColor.Yellow));
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return card.Owner.HandCards.Contains(card) &&
  60. CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerPermanentCondition) &&
  61. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectHumanSpiritCardCondition) &&
  62. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectBeastSpiritCardCondition);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerPermanentCondition))
  67. {
  68. Permanent selectedPermanent = null;
  69. SelectPermanentEffect selectPermanentEffect =
  70. GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectTamerPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage("Select 1 tamer to digivolve.",
  84. "The opponent is selecting 1 tamer to digivolve.");
  85. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. selectedPermanent = permanent;
  89. yield return null;
  90. }
  91. if (selectedPermanent != null &&
  92. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectHumanSpiritCardCondition) &&
  93. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectBeastSpiritCardCondition))
  94. {
  95. bool digivolve = false;
  96. List<CardSource> selectedCards = new List<CardSource>();
  97. SelectCardEffect selectCardEffect =
  98. GManager.instance.GetComponent<SelectCardEffect>();
  99. selectCardEffect.SetUp(
  100. canTargetCondition: (cardSource) =>
  101. CanSelectHumanSpiritCardCondition(cardSource) ||
  102. CanSelectBeastSpiritCardCondition(cardSource),
  103. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  104. canEndSelectCondition: CanEndSelectCondition,
  105. canNoSelect: () => false,
  106. selectCardCoroutine: SelectCardCoroutine,
  107. afterSelectCardCoroutine: null,
  108. message:
  109. "Select cards to place on the bottom of Digivolution cards\n(cards will be placed in the digivolution cards so that cards with lower numbers are on top).",
  110. maxCount: 2,
  111. canEndNotMax: false,
  112. isShowOpponent: true,
  113. mode: SelectCardEffect.Mode.Custom,
  114. root: SelectCardEffect.Root.Trash,
  115. customRootCardList: null,
  116. canLookReverseCard: true,
  117. selectPlayer: card.Owner,
  118. cardEffect: activateClass);
  119. yield return ContinuousController.instance.StartCoroutine(
  120. selectCardEffect.Activate());
  121. bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources,
  122. CardSource cardSource)
  123. {
  124. if (cardSources.Count(CanSelectHumanSpiritCardCondition) >= 1)
  125. {
  126. if (CanSelectHumanSpiritCardCondition(cardSource))
  127. {
  128. return false;
  129. }
  130. }
  131. if (cardSources.Count(CanSelectBeastSpiritCardCondition) >= 1)
  132. {
  133. if (CanSelectBeastSpiritCardCondition(cardSource))
  134. {
  135. return false;
  136. }
  137. }
  138. return true;
  139. }
  140. bool CanEndSelectCondition(List<CardSource> cardSources)
  141. {
  142. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  143. CanSelectHumanSpiritCardCondition))
  144. {
  145. if (cardSources.Count(CanSelectHumanSpiritCardCondition) == 0)
  146. {
  147. return false;
  148. }
  149. }
  150. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  151. CanSelectBeastSpiritCardCondition))
  152. {
  153. if (cardSources.Count(CanSelectBeastSpiritCardCondition) == 0)
  154. {
  155. return false;
  156. }
  157. }
  158. if (cardSources.Count(CanSelectHumanSpiritCardCondition) >= 2)
  159. {
  160. return false;
  161. }
  162. if (cardSources.Count(CanSelectBeastSpiritCardCondition) >= 2)
  163. {
  164. return false;
  165. }
  166. return true;
  167. }
  168. IEnumerator SelectCardCoroutine(CardSource cardSource)
  169. {
  170. selectedCards.Add(cardSource);
  171. yield return null;
  172. }
  173. if (selectedCards.Count >= 1)
  174. {
  175. yield return ContinuousController.instance.StartCoroutine(
  176. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  177. if (selectedCards.Count == 2)
  178. {
  179. digivolve = true;
  180. }
  181. }
  182. if (digivolve)
  183. {
  184. yield return ContinuousController.instance.StartCoroutine(
  185. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  186. targetPermanent: selectedPermanent,
  187. cardCondition: source => source == card,
  188. payCost: true,
  189. reduceCostTuple: null,
  190. fixedCostTuple: null,
  191. ignoreDigivolutionRequirementFixedCost: 3,
  192. isHand: true,
  193. activateClass: activateClass,
  194. successProcess: null));
  195. }
  196. }
  197. }
  198. }
  199. }
  200. #endregion
  201. #region Jamming
  202. if (timing == EffectTiming.None)
  203. {
  204. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  205. }
  206. #endregion
  207. #region When Digivolving
  208. if (timing == EffectTiming.OnEnterFieldAnyone)
  209. {
  210. ActivateClass activateClass = new ActivateClass();
  211. activateClass.SetUpICardEffect("Play 1 Tamer card from trash", CanUseCondition, card);
  212. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  213. cardEffects.Add(activateClass);
  214. string EffectDescription()
  215. {
  216. return
  217. "[When Digivolving] You may play 1 Tamer card with inherited effects from your trash without paying the cost.";
  218. }
  219. bool CanUseCondition(Hashtable hashtable)
  220. {
  221. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  222. }
  223. bool CanSelectCardCondition(CardSource cardSource)
  224. {
  225. return cardSource.IsTamer && cardSource.HasInheritedEffect &&
  226. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  227. }
  228. bool CanActivateCondition(Hashtable hashtable)
  229. {
  230. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  231. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  232. }
  233. IEnumerator ActivateCoroutine(Hashtable hashtable)
  234. {
  235. List<CardSource> selectedCards = new List<CardSource>();
  236. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  237. selectCardEffect.SetUp(
  238. canTargetCondition: CanSelectCardCondition,
  239. canTargetCondition_ByPreSelecetedList: null,
  240. canEndSelectCondition: null,
  241. canNoSelect: () => true,
  242. selectCardCoroutine: SelectCardCoroutine,
  243. afterSelectCardCoroutine: null,
  244. message: "Select 1 Tamer card to play.",
  245. maxCount: 1,
  246. canEndNotMax: false,
  247. isShowOpponent: true,
  248. mode: SelectCardEffect.Mode.Custom,
  249. root: SelectCardEffect.Root.Trash,
  250. customRootCardList: null,
  251. canLookReverseCard: true,
  252. selectPlayer: card.Owner,
  253. cardEffect: activateClass);
  254. selectCardEffect.SetUpCustomMessage("Select 1 Tamer card to play.", "The opponent is selecting 1 Tamer card to play.");
  255. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  256. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  257. IEnumerator SelectCardCoroutine(CardSource cardSource)
  258. {
  259. selectedCards.Add(cardSource);
  260. yield return null;
  261. }
  262. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  263. cardSources: selectedCards,
  264. activateClass: activateClass,
  265. payCost: false,
  266. isTapped: false,
  267. root: SelectCardEffect.Root.Trash,
  268. activateETB: true));
  269. }
  270. }
  271. #endregion
  272. #region When Attacking - ESS
  273. if (timing == EffectTiming.OnAllyAttack)
  274. {
  275. ActivateClass activateClass = new ActivateClass();
  276. activateClass.SetUpICardEffect("DP -4000", CanUseCondition, card);
  277. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false,
  278. EffectDescription());
  279. activateClass.SetIsInheritedEffect(true);
  280. cardEffects.Add(activateClass);
  281. string EffectDescription()
  282. {
  283. return "[When Attacking] (Once Per Turn) 1 of your opponent's Digimon gets -4000 DP for the turn.";
  284. }
  285. bool CanUseCondition(Hashtable hashtable)
  286. {
  287. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  288. }
  289. bool CanSelectPermanentCondition(Permanent permanent)
  290. {
  291. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  292. }
  293. bool CanActivateCondition(Hashtable hashtable)
  294. {
  295. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  296. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  297. }
  298. IEnumerator ActivateCoroutine(Hashtable hashtable)
  299. {
  300. SelectPermanentEffect selectPermanentEffect =
  301. GManager.instance.GetComponent<SelectPermanentEffect>();
  302. selectPermanentEffect.SetUp(
  303. selectPlayer: card.Owner,
  304. canTargetCondition: CanSelectPermanentCondition,
  305. canTargetCondition_ByPreSelecetedList: null,
  306. canEndSelectCondition: null,
  307. maxCount: 1,
  308. canNoSelect: false,
  309. canEndNotMax: false,
  310. selectPermanentCoroutine: SelectPermanentCoroutine,
  311. afterSelectPermanentCoroutine: null,
  312. mode: SelectPermanentEffect.Mode.Custom,
  313. cardEffect: activateClass);
  314. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  315. "The opponent is selecting 1 Digimon that will get DP -4000.");
  316. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  317. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  318. {
  319. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  320. targetPermanent: permanent,
  321. changeValue: -4000,
  322. effectDuration: EffectDuration.UntilEachTurnEnd,
  323. activateClass: activateClass));
  324. }
  325. }
  326. }
  327. #endregion
  328. return cardEffects;
  329. }
  330. }
  331. }