RB1_030.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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_030 : 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.ContainsCardName("Gammamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone || timing == EffectTiming.OnAllyAttack)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Trash 1 card from hand and your 1 Digimon gains effects", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  26. activateClass.SetHashString("Discard_RB1_030");
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. return "[When Digivolving] [Once Per Turn] By trashing 1 card with [Gammamon] in its text in your hand, 1 of your Digimon gains \"[On Deletion] Delete 1 of your opponent's Digimon with the lowest level\" until the end of your opponent's turn.";
  33. }
  34. else
  35. {
  36. return "[When Attacking] [Once Per Turn] By trashing 1 card with [Gammamon] in its text in your hand, 1 of your Digimon gains \"[On Deletion] Delete 1 of your opponent's Digimon with the lowest level\" until the end of your opponent's turn.";
  37. }
  38. }
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. return cardSource.HasText("Gammamon");
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. if (timing == EffectTiming.OnEnterFieldAnyone)
  50. {
  51. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. else
  54. {
  55. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  56. }
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (card.Owner.HandCards.Count >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. bool discarded = false;
  72. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  73. {
  74. int discardCount = 1;
  75. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  76. selectHandEffect.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: CanSelectCardCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: discardCount,
  82. canNoSelect: true,
  83. canEndNotMax: false,
  84. isShowOpponent: true,
  85. selectCardCoroutine: null,
  86. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  87. mode: SelectHandEffect.Mode.Discard,
  88. cardEffect: activateClass);
  89. yield return StartCoroutine(selectHandEffect.Activate());
  90. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  91. {
  92. if (cardSources.Count >= 1)
  93. {
  94. discarded = true;
  95. yield return null;
  96. }
  97. }
  98. }
  99. if (discarded)
  100. {
  101. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  102. {
  103. int maxCount = 1;
  104. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  105. selectPermanentEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: CanSelectPermanentCondition,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: maxCount,
  111. canNoSelect: false,
  112. canEndNotMax: false,
  113. selectPermanentCoroutine: SelectPermanentCoroutine,
  114. afterSelectPermanentCoroutine: null,
  115. mode: SelectPermanentEffect.Mode.Custom,
  116. cardEffect: activateClass);
  117. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  118. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  119. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  120. {
  121. Permanent selectedPermanent = permanent;
  122. if (selectedPermanent != null)
  123. {
  124. CardSource _topCard = selectedPermanent.TopCard;
  125. ActivateClass activateClass1 = new ActivateClass();
  126. activateClass1.SetUpICardEffect("Delete 1 Digimon with the lowest level", CanUseCondition1, selectedPermanent.TopCard);
  127. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  128. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  129. CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnDestroyedAnyone);
  130. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  131. string EffectDiscription1()
  132. {
  133. return "[On Deletion] Delete 1 of your opponent's Digimon with the lowest level.";
  134. }
  135. bool CanSelectPermanentCondition1(Permanent permanent)
  136. {
  137. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  138. {
  139. if (CardEffectCommons.IsMinLevel(permanent, _topCard.Owner.Enemy))
  140. {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146. bool CanUseCondition1(Hashtable hashtable1)
  147. {
  148. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  149. {
  150. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable1, (permanent) => permanent == selectedPermanent, activateClass))
  151. {
  152. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  153. {
  154. return true;
  155. }
  156. }
  157. }
  158. return false;
  159. }
  160. bool CanActivateCondition1(Hashtable hashtable1)
  161. {
  162. if (CardEffectCommons.IsTopCardInTrashOnDeletion(hashtable1))
  163. {
  164. if (_topCard.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition1) >= 1)
  165. {
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  172. {
  173. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  174. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: _topCard.Owner,
  177. canTargetCondition: CanSelectPermanentCondition1,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: false,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: null,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Destroy,
  186. cardEffect: activateClass);
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. if (timing == EffectTiming.None)
  196. {
  197. AddSkillClass addSkillClass = new AddSkillClass();
  198. addSkillClass.SetUpICardEffect("This Digimon gains all effects of [Gammamon] in digivolution cards", CanUseCondition, card);
  199. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  200. cardEffects.Add(addSkillClass);
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleArea(card);
  204. }
  205. bool PermanentCondition(Permanent permanent)
  206. {
  207. return permanent == card.PermanentOfThisCard();
  208. }
  209. bool CardSourceCondition(CardSource cardSource)
  210. {
  211. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  212. {
  213. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  214. {
  215. return true;
  216. }
  217. }
  218. return false;
  219. }
  220. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  221. {
  222. if (CardSourceCondition(cardSource))
  223. {
  224. foreach (CardSource cardSource1 in cardSource.PermanentOfThisCard().DigivolutionCards)
  225. {
  226. if (cardSource1.ContainsCardName("Gammamon"))
  227. {
  228. foreach (ICardEffect cardEffect in cardSource1.cEntity_EffectController.GetCardEffects_ExceptAddedEffects(_timing, card))
  229. {
  230. if (!cardEffect.IsSecurityEffect && !cardEffect.IsInheritedEffect)
  231. {
  232. cardEffects.Add(cardEffect);
  233. }
  234. }
  235. }
  236. }
  237. }
  238. return cardEffects;
  239. }
  240. }
  241. if (timing == EffectTiming.None)
  242. {
  243. AddSkillClass addSkillClass = new AddSkillClass();
  244. addSkillClass.SetUpICardEffect("This Digimon gains all effects of [Gammamon] in digivolution cards", CanUseCondition, card);
  245. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  246. addSkillClass.SetIsInheritedEffect(true);
  247. cardEffects.Add(addSkillClass);
  248. bool CanUseCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.IsExistOnBattleArea(card);
  251. }
  252. bool PermanentCondition(Permanent permanent)
  253. {
  254. return permanent == card.PermanentOfThisCard();
  255. }
  256. bool CardSourceCondition(CardSource cardSource)
  257. {
  258. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  259. {
  260. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  261. {
  262. return true;
  263. }
  264. }
  265. return false;
  266. }
  267. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  268. {
  269. if (CardSourceCondition(cardSource))
  270. {
  271. foreach (CardSource cardSource1 in cardSource.PermanentOfThisCard().DigivolutionCards)
  272. {
  273. if (cardSource1.ContainsCardName("Gammamon"))
  274. {
  275. foreach (ICardEffect cardEffect in cardSource1.cEntity_EffectController.GetCardEffects_ExceptAddedEffects(_timing, card))
  276. {
  277. if (!cardEffect.IsSecurityEffect && !cardEffect.IsInheritedEffect)
  278. {
  279. cardEffects.Add(cardEffect);
  280. }
  281. }
  282. }
  283. }
  284. }
  285. return cardEffects;
  286. }
  287. }
  288. return cardEffects;
  289. }
  290. }