EX3_066.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. if (card.Owner.isYou)
  125. {
  126. GManager.instance.commandText.OpenCommandText("From which area do you select a card?");
  127. List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>()
  128. {
  129. new Command_SelectCommand($"From hand", () => photonView.RPC("SetFromHand", RpcTarget.All, true), 0),
  130. new Command_SelectCommand($"From trash", () => photonView.RPC("SetFromHand", RpcTarget.All, false), 1),
  131. };
  132. GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
  133. }
  134. else
  135. {
  136. GManager.instance.commandText.OpenCommandText("The opponent is choosing from which area to select a card.");
  137. #region AI�‚�[�h
  138. if (GManager.instance.IsAI)
  139. {
  140. SetFromHand(RandomUtility.IsSucceedProbability(0.5f));
  141. }
  142. #endregion
  143. }
  144. }
  145. else if (card.Owner.HandCards.Count(CanSelectCardCondition) == 0 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  146. {
  147. SetFromHand(false);
  148. }
  149. else if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && card.Owner.TrashCards.Count(CanSelectCardCondition) == 0)
  150. {
  151. SetFromHand(true);
  152. }
  153. yield return new WaitWhile(() => !endSelect);
  154. endSelect = false;
  155. GManager.instance.commandText.CloseCommandText();
  156. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  157. List<CardSource> selectedCards = new List<CardSource>();
  158. IEnumerator SelectCardCoroutine(CardSource cardSource)
  159. {
  160. selectedCards.Add(cardSource);
  161. yield return null;
  162. }
  163. if (fromHand)
  164. {
  165. int maxCount = 1;
  166. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  167. selectHandEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectCardCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: maxCount,
  173. canNoSelect: true,
  174. canEndNotMax: false,
  175. isShowOpponent: true,
  176. selectCardCoroutine: SelectCardCoroutine,
  177. afterSelectCardCoroutine: null,
  178. mode: SelectHandEffect.Mode.Custom,
  179. cardEffect: activateClass);
  180. 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.");
  181. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  182. yield return StartCoroutine(selectHandEffect.Activate());
  183. }
  184. else
  185. {
  186. int maxCount = 1;
  187. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  188. selectCardEffect.SetUp(
  189. canTargetCondition: CanSelectCardCondition,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. canNoSelect: () => true,
  193. selectCardCoroutine: SelectCardCoroutine,
  194. afterSelectCardCoroutine: null,
  195. message: "Select 1 card to place on bottom of digivolution cards.",
  196. maxCount: maxCount,
  197. canEndNotMax: false,
  198. isShowOpponent: true,
  199. mode: SelectCardEffect.Mode.Custom,
  200. root: SelectCardEffect.Root.Trash,
  201. customRootCardList: null,
  202. canLookReverseCard: true,
  203. selectPlayer: card.Owner,
  204. cardEffect: activateClass);
  205. 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.");
  206. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  207. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  208. }
  209. if (selectedCards.Count >= 1)
  210. {
  211. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  212. {
  213. int maxCount = 1;
  214. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  215. selectPermanentEffect.SetUp(
  216. selectPlayer: card.Owner,
  217. canTargetCondition: CanSelectPermanentCondition1,
  218. canTargetCondition_ByPreSelecetedList: null,
  219. canEndSelectCondition: null,
  220. maxCount: maxCount,
  221. canNoSelect: true,
  222. canEndNotMax: false,
  223. selectPermanentCoroutine: SelectPermanentCoroutine,
  224. afterSelectPermanentCoroutine: null,
  225. mode: SelectPermanentEffect.Mode.Custom,
  226. cardEffect: activateClass);
  227. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  228. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  229. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  230. {
  231. Permanent selectedPermanent = permanent;
  232. if (selectedPermanent != null)
  233. {
  234. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  235. addedDigivolutionCard = true;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. }
  242. if (addedDigivolutionCard)
  243. {
  244. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition2))
  245. {
  246. int maxCount = 1;
  247. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  248. selectPermanentEffect.SetUp(
  249. selectPlayer: card.Owner,
  250. canTargetCondition: CanSelectPermanentCondition2,
  251. canTargetCondition_ByPreSelecetedList: null,
  252. canEndSelectCondition: null,
  253. maxCount: maxCount,
  254. canNoSelect: false,
  255. canEndNotMax: false,
  256. selectPermanentCoroutine: null,
  257. afterSelectPermanentCoroutine: null,
  258. mode: SelectPermanentEffect.Mode.Destroy,
  259. cardEffect: activateClass);
  260. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  261. }
  262. }
  263. }
  264. }
  265. if (timing == EffectTiming.SecuritySkill)
  266. {
  267. 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");
  268. }
  269. return cardEffects;
  270. }
  271. bool endSelect = false;
  272. bool fromHand = false;
  273. [PunRPC]
  274. public void SetFromHand(bool fromHand)
  275. {
  276. this.fromHand = fromHand;
  277. endSelect = true;
  278. }
  279. }
  280. }