EX3_066.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.EX3
  8. {
  9. public class EX3_066 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.None)
  15. {
  16. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  17. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  18. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  19. cardEffects.Add(ignoreColorConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.CardTraits.Contains("Machine") && permanent.TopCard.Level == 6 && permanent.TopCard.HasLevel))
  23. {
  24. return true;
  25. }
  26. return false;
  27. }
  28. bool CardCondition(CardSource cardSource)
  29. {
  30. if (cardSource == card)
  31. {
  32. return true;
  33. }
  34. return false;
  35. }
  36. }
  37. if (timing == EffectTiming.OptionSkill)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  41. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "[Main] <De-Digivolve 3> 1 of your opponent's Digimon. Then, by placing 1 card with [Cyborg] in its traits from your hand or trash under 1 of your level 6 Digimon with [Machine] in its traits as its bottom digivolution card, delete 1 of your opponent's Digimon with 6000 DP or less.";
  46. }
  47. bool CanSelectPermanentCondition(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  50. }
  51. bool CanSelectCardCondition(CardSource cardSource)
  52. {
  53. if (cardSource != null)
  54. {
  55. if (cardSource.Owner == card.Owner)
  56. {
  57. if (cardSource.CardTraits.Contains("Cyborg"))
  58. {
  59. return true;
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. bool CanSelectPermanentCondition1(Permanent permanent)
  66. {
  67. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  68. {
  69. if (permanent.TopCard.CardTraits.Contains("Machine") && permanent.TopCard.Level == 6 && permanent.TopCard.HasLevel)
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. bool CanSelectPermanentCondition2(Permanent permanent)
  77. {
  78. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  79. {
  80. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  81. {
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  92. {
  93. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  94. {
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectPermanentCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: false,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: SelectPermanentCoroutine,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  112. {
  113. Permanent selectedPermanent = permanent;
  114. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 3, activateClass).Degeneration());
  115. }
  116. }
  117. bool addedDigivolutionCard = false;
  118. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  119. {
  120. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  121. {
  122. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  123. {
  124. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  125. {
  126. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  127. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  128. };
  129. string selectPlayerMessage = "From which area do you select a card?";
  130. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  131. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  132. }
  133. else if (card.Owner.HandCards.Count(CanSelectCardCondition) == 0 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  134. {
  135. GManager.instance.userSelectionManager.SetBool(false);
  136. }
  137. else if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && card.Owner.TrashCards.Count(CanSelectCardCondition) == 0)
  138. {
  139. GManager.instance.userSelectionManager.SetBool(true);
  140. }
  141. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  142. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  143. List<CardSource> selectedCards = new List<CardSource>();
  144. IEnumerator SelectCardCoroutine(CardSource cardSource)
  145. {
  146. selectedCards.Add(cardSource);
  147. yield return null;
  148. }
  149. if (fromHand)
  150. {
  151. int maxCount = 1;
  152. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  153. selectHandEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectCardCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: maxCount,
  159. canNoSelect: true,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. selectCardCoroutine: SelectCardCoroutine,
  163. afterSelectCardCoroutine: null,
  164. mode: SelectHandEffect.Mode.Custom,
  165. cardEffect: activateClass);
  166. 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.");
  167. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  168. yield return StartCoroutine(selectHandEffect.Activate());
  169. }
  170. else
  171. {
  172. int maxCount = 1;
  173. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  174. selectCardEffect.SetUp(
  175. canTargetCondition: CanSelectCardCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. canNoSelect: () => true,
  179. selectCardCoroutine: SelectCardCoroutine,
  180. afterSelectCardCoroutine: null,
  181. message: "Select 1 card to place on bottom of digivolution cards.",
  182. maxCount: maxCount,
  183. canEndNotMax: false,
  184. isShowOpponent: true,
  185. mode: SelectCardEffect.Mode.Custom,
  186. root: SelectCardEffect.Root.Trash,
  187. customRootCardList: null,
  188. canLookReverseCard: true,
  189. selectPlayer: card.Owner,
  190. cardEffect: activateClass);
  191. 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.");
  192. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  193. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  194. }
  195. if (selectedCards.Count >= 1)
  196. {
  197. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  198. {
  199. int maxCount = 1;
  200. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  201. selectPermanentEffect.SetUp(
  202. selectPlayer: card.Owner,
  203. canTargetCondition: CanSelectPermanentCondition1,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. maxCount: maxCount,
  207. canNoSelect: true,
  208. canEndNotMax: false,
  209. selectPermanentCoroutine: SelectPermanentCoroutine,
  210. afterSelectPermanentCoroutine: null,
  211. mode: SelectPermanentEffect.Mode.Custom,
  212. cardEffect: activateClass);
  213. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  214. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  215. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  216. {
  217. Permanent selectedPermanent = permanent;
  218. if (selectedPermanent != null)
  219. {
  220. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  221. addedDigivolutionCard = true;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. if (addedDigivolutionCard)
  229. {
  230. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition2))
  231. {
  232. int maxCount = 1;
  233. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  234. selectPermanentEffect.SetUp(
  235. selectPlayer: card.Owner,
  236. canTargetCondition: CanSelectPermanentCondition2,
  237. canTargetCondition_ByPreSelecetedList: null,
  238. canEndSelectCondition: null,
  239. maxCount: maxCount,
  240. canNoSelect: false,
  241. canEndNotMax: false,
  242. selectPermanentCoroutine: null,
  243. afterSelectPermanentCoroutine: null,
  244. mode: SelectPermanentEffect.Mode.Destroy,
  245. cardEffect: activateClass);
  246. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  247. }
  248. }
  249. }
  250. }
  251. if (timing == EffectTiming.SecuritySkill)
  252. {
  253. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"De-Digivolve 3 and place a card to digivolution cards to delete 1 Digimon with 6000 DP or less");
  254. }
  255. return cardEffects;
  256. }
  257. }
  258. }