ST16_08.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 ST16_08 : 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. if (targetPermanent.TopCard.ContainsCardName("Gabumon"))
  18. {
  19. if (targetPermanent.TopCard.HasLevel)
  20. {
  21. if (targetPermanent.Level == 3)
  22. {
  23. return true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. if (timing == EffectTiming.SecuritySkill)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Play 1 [Gabumon] or 1 Tamer card with [Matt Ishida] from hand or trash", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  36. activateClass.SetIsSecurityEffect(true);
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[Security] You may play 1 [Gabumon] or 1 Tamer card with [Matt Ishida] in its name from your hand or trash without paying the cost.";
  41. }
  42. bool CanSelectCardCondition(CardSource cardSource)
  43. {
  44. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  45. {
  46. if (cardSource.CardNames.Contains("Gabumon"))
  47. {
  48. return true;
  49. }
  50. if (cardSource.IsTamer)
  51. {
  52. if (cardSource.ContainsCardName("Matt Ishida"))
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. if (card.Owner.ExecutingCards.Contains(card))
  63. {
  64. CardSource cardSource = CardEffectCommons.GetCardFromHashtable(hashtable);
  65. if (cardSource == card)
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. bool CanActivateCondition(Hashtable hashtable)
  73. {
  74. if (card.Owner.ExecutingCards.Contains(card))
  75. {
  76. if (card.Owner.HandCards.Count >= 1)
  77. {
  78. return true;
  79. }
  80. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  81. {
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
  87. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  88. {
  89. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  90. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  91. if (canSelectHand || canSelectTrash)
  92. {
  93. if (canSelectHand && canSelectTrash)
  94. {
  95. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  96. {
  97. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  98. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  99. };
  100. string selectPlayerMessage = "From which area do you play a card?";
  101. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  102. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  103. }
  104. else
  105. {
  106. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  107. }
  108. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  109. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  110. List<CardSource> selectedCards = new List<CardSource>();
  111. IEnumerator SelectCardCoroutine(CardSource cardSource)
  112. {
  113. selectedCards.Add(cardSource);
  114. yield return null;
  115. }
  116. if (fromHand)
  117. {
  118. int maxCount = 1;
  119. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  120. selectHandEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectCardCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount,
  126. canNoSelect: true,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. selectCardCoroutine: SelectCardCoroutine,
  130. afterSelectCardCoroutine: null,
  131. mode: SelectHandEffect.Mode.Custom,
  132. cardEffect: activateClass);
  133. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  134. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  135. yield return StartCoroutine(selectHandEffect.Activate());
  136. }
  137. else
  138. {
  139. int maxCount = 1;
  140. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  141. selectCardEffect.SetUp(
  142. canTargetCondition: CanSelectCardCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. canNoSelect: () => true,
  146. selectCardCoroutine: SelectCardCoroutine,
  147. afterSelectCardCoroutine: null,
  148. message: "Select 1 card to play.",
  149. maxCount: maxCount,
  150. canEndNotMax: false,
  151. isShowOpponent: true,
  152. mode: SelectCardEffect.Mode.Custom,
  153. root: SelectCardEffect.Root.Trash,
  154. customRootCardList: null,
  155. canLookReverseCard: true,
  156. selectPlayer: card.Owner,
  157. cardEffect: activateClass);
  158. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  159. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  160. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  161. }
  162. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  163. if (!fromHand)
  164. {
  165. root = SelectCardEffect.Root.Trash;
  166. }
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  168. }
  169. }
  170. }
  171. if (timing == EffectTiming.OnEnterFieldAnyone)
  172. {
  173. ActivateClass activateClass = new ActivateClass();
  174. activateClass.SetUpICardEffect("Draw 1 and trash 1 card from hand", CanUseCondition, card);
  175. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  176. cardEffects.Add(activateClass);
  177. string EffectDiscription()
  178. {
  179. return "[When Digivolving] <Draw 1>. (Draw 1 card from your deck.) Then, trash 1 card in your hand.";
  180. }
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. if (CardEffectCommons.IsExistOnBattleArea(card))
  188. {
  189. if (card.Owner.LibraryCards.Count >= 1)
  190. {
  191. return true;
  192. }
  193. if (card.Owner.HandCards.Count >= 1)
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  201. {
  202. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  203. if (card.Owner.HandCards.Count >= 1)
  204. {
  205. int discardCount = 1;
  206. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  207. selectHandEffect.SetUp(
  208. selectPlayer: card.Owner,
  209. canTargetCondition: (cardSource) => true,
  210. canTargetCondition_ByPreSelecetedList: null,
  211. canEndSelectCondition: null,
  212. maxCount: discardCount,
  213. canNoSelect: false,
  214. canEndNotMax: false,
  215. isShowOpponent: true,
  216. selectCardCoroutine: null,
  217. afterSelectCardCoroutine: null,
  218. mode: SelectHandEffect.Mode.Discard,
  219. cardEffect: activateClass);
  220. yield return StartCoroutine(selectHandEffect.Activate());
  221. }
  222. }
  223. }
  224. if (timing == EffectTiming.OnAllyAttack)
  225. {
  226. ActivateClass activateClass = new ActivateClass();
  227. activateClass.SetUpICardEffect("Draw 1 and trash 1 card from hand", CanUseCondition, card);
  228. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  229. activateClass.SetIsInheritedEffect(true);
  230. activateClass.SetHashString("Draw_ST16_08");
  231. cardEffects.Add(activateClass);
  232. string EffectDiscription()
  233. {
  234. return "[When Attacking][Once Per Turn] <Draw 1>. (Draw 1 card from your deck.) Then, trash 1 card in your hand.";
  235. }
  236. bool CanUseCondition(Hashtable hashtable)
  237. {
  238. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  239. }
  240. bool CanActivateCondition(Hashtable hashtable)
  241. {
  242. if (CardEffectCommons.IsExistOnBattleArea(card))
  243. {
  244. return true;
  245. }
  246. return false;
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  249. {
  250. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  251. if (card.Owner.HandCards.Count >= 1)
  252. {
  253. int discardCount = 1;
  254. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  255. selectHandEffect.SetUp(
  256. selectPlayer: card.Owner,
  257. canTargetCondition: (cardSource) => true,
  258. canTargetCondition_ByPreSelecetedList: null,
  259. canEndSelectCondition: null,
  260. maxCount: discardCount,
  261. canNoSelect: false,
  262. canEndNotMax: false,
  263. isShowOpponent: true,
  264. selectCardCoroutine: null,
  265. afterSelectCardCoroutine: null,
  266. mode: SelectHandEffect.Mode.Discard,
  267. cardEffect: activateClass);
  268. yield return StartCoroutine(selectHandEffect.Activate());
  269. }
  270. }
  271. }
  272. return cardEffects;
  273. }
  274. }