BT10_112.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_112 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasRoyalKnightTraits && targetPermanent.TopCard.HasLevel && targetPermanent.Level == 6;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 5,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("Place 1 card to digivolution cards to activate effects and Blitz", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[When Digivolving] You may place 1 card with [Royal Knight] in its traits and a play cost of 13 or less from your hand or trash under this Digimon as its bottom digivolution card. Activate 1 of that Digimon's [When Digivolving] effects as an effect of this Digimon. Then, <Blitz>.";
  37. }
  38. bool CanSelectCardCondition(CardSource cardSource)
  39. {
  40. if (cardSource.HasRoyalKnightTraits)
  41. {
  42. if (cardSource.GetCostItself <= 13)
  43. {
  44. if (cardSource.HasPlayCost)
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  61. {
  62. return true;
  63. }
  64. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  65. {
  66. return true;
  67. }
  68. if (CardEffectCommons.CanActivateBlitz(card, activateClass))
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. if (CardEffectCommons.IsExistOnBattleArea(card))
  78. {
  79. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  80. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  81. if (canSelectHand || canSelectTrash)
  82. {
  83. if (canSelectHand && canSelectTrash)
  84. {
  85. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  86. {
  87. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  88. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  89. };
  90. string selectPlayerMessage = "From which area do you select a card?";
  91. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  92. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  93. }
  94. else
  95. {
  96. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  97. }
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  99. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  100. List<CardSource> selectedCards = new List<CardSource>();
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. selectedCards.Add(cardSource);
  104. yield return null;
  105. }
  106. if (fromHand)
  107. {
  108. int maxCount = 1;
  109. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  110. selectHandEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectCardCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: maxCount,
  116. canNoSelect: true,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. selectCardCoroutine: SelectCardCoroutine,
  120. afterSelectCardCoroutine: null,
  121. mode: SelectHandEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. selectHandEffect.SetUpCustomMessage(
  124. "Select 1 card to place on bottom of digivolution cards.",
  125. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  126. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  127. yield return StartCoroutine(selectHandEffect.Activate());
  128. }
  129. else
  130. {
  131. int maxCount = 1;
  132. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  133. selectCardEffect.SetUp(
  134. canTargetCondition: CanSelectCardCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. canNoSelect: () => true,
  138. selectCardCoroutine: SelectCardCoroutine,
  139. afterSelectCardCoroutine: null,
  140. message: "Select 1 card to place on bottom of digivolution cards.",
  141. maxCount: maxCount,
  142. canEndNotMax: false,
  143. isShowOpponent: true,
  144. mode: SelectCardEffect.Mode.Custom,
  145. root: SelectCardEffect.Root.Trash,
  146. customRootCardList: null,
  147. canLookReverseCard: true,
  148. selectPlayer: card.Owner,
  149. cardEffect: activateClass);
  150. selectCardEffect.SetUpCustomMessage(
  151. "Select 1 card to place on bottom of digivolution cards.",
  152. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  153. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  154. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  155. }
  156. CardSource selectedCard = null;
  157. if (selectedCards.Count >= 1)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleArea(card))
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  162. selectedCards,
  163. activateClass));
  164. selectedCard = selectedCards[0];
  165. }
  166. }
  167. if (selectedCard != null)
  168. {
  169. List<ICardEffect> candidateEffects = selectedCard.EffectList_ForCard(EffectTiming.OnEnterFieldAnyone, card)
  170. .Clone()
  171. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  172. if (candidateEffects.Count >= 1)
  173. {
  174. ICardEffect selectedEffect = null;
  175. if (candidateEffects.Count == 1)
  176. {
  177. selectedEffect = candidateEffects[0];
  178. }
  179. else
  180. {
  181. List<SkillInfo> skillInfos = candidateEffects
  182. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  183. List<CardSource> cardSources = candidateEffects
  184. .Map(cardEffect => cardEffect.EffectSourceCard);
  185. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  186. selectCardEffect.SetUp(
  187. canTargetCondition: (cardSource) => true,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: null,
  190. canNoSelect: () => false,
  191. selectCardCoroutine: null,
  192. afterSelectCardCoroutine: null,
  193. message: "Select 1 effect to activate.",
  194. maxCount: 1,
  195. canEndNotMax: false,
  196. isShowOpponent: false,
  197. mode: SelectCardEffect.Mode.Custom,
  198. root: SelectCardEffect.Root.Custom,
  199. customRootCardList: cardSources,
  200. canLookReverseCard: true,
  201. selectPlayer: card.Owner,
  202. cardEffect: activateClass);
  203. selectCardEffect.SetNotShowCard();
  204. selectCardEffect.SetUpSkillInfos(skillInfos);
  205. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  206. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  207. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  208. {
  209. if (selectedIndexes.Count == 1)
  210. {
  211. selectedEffect = candidateEffects[selectedIndexes[0]];
  212. yield return null;
  213. }
  214. }
  215. }
  216. if (selectedEffect != null)
  217. {
  218. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(card);
  219. if (selectedEffect.CanUse(effectHashtable))
  220. {
  221. selectedEffect.SetIsDigimonEffect(true);
  222. yield return ContinuousController.instance.StartCoroutine(
  223. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  224. }
  225. }
  226. }
  227. }
  228. }
  229. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BlitzProcess(card, activateClass));
  230. }
  231. }
  232. }
  233. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  234. {
  235. bool Condition()
  236. {
  237. if (CardEffectCommons.IsExistOnBattleArea(card))
  238. {
  239. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.HasRoyalKnightTraits) >= 1)
  240. {
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: Condition));
  247. }
  248. if (timing == EffectTiming.None)
  249. {
  250. bool Condition()
  251. {
  252. if (CardEffectCommons.IsExistOnBattleArea(card))
  253. {
  254. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.HasRoyalKnightTraits) >= 1)
  255. {
  256. return true;
  257. }
  258. }
  259. return false;
  260. }
  261. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: Condition));
  262. }
  263. if (timing == EffectTiming.None)
  264. {
  265. int count()
  266. {
  267. int count = 0;
  268. if (CardEffectCommons.IsExistOnBattleArea(card))
  269. {
  270. count = card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.HasRoyalKnightTraits);
  271. }
  272. return count;
  273. }
  274. bool Condition()
  275. {
  276. if (CardEffectCommons.IsExistOnBattleArea(card))
  277. {
  278. if (count() >= 1)
  279. {
  280. return true;
  281. }
  282. }
  283. return false;
  284. }
  285. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect<Func<int>>(
  286. changeValue: () => count(),
  287. isInheritedEffect: false,
  288. card: card,
  289. condition: Condition));
  290. }
  291. return cardEffects;
  292. }
  293. }
  294. }