BT10_094.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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_094 : 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.OptionSkill)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  19. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Main] 1 of your Digimon gets +2000 DP for the turn. Then, by placing 1 Digimon card with [Gammamon] in its name from your hand under 1 of your Digimon as its bottom digivolution card, <Draw 1>. (Draw 1 card from your deck.)";
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  28. }
  29. bool CanSelectCardCondition(CardSource cardSource)
  30. {
  31. if (!cardSource.IsToken)
  32. {
  33. if (cardSource.IsDigimon)
  34. {
  35. if (cardSource.ContainsCardName("Gammamon"))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanSelectPermanentCondition1(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  46. {
  47. if (!permanent.IsToken)
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP +2000.", "The opponent is selecting 1 Digimon that will get DP +2000.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: 2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  81. }
  82. }
  83. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  84. {
  85. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  86. {
  87. CardSource selectedCard = null;
  88. int maxCount = 1;
  89. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  90. selectHandEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: CanSelectCardCondition,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: maxCount,
  96. canNoSelect: true,
  97. canEndNotMax: false,
  98. isShowOpponent: true,
  99. selectCardCoroutine: SelectCardCoroutine,
  100. afterSelectCardCoroutine: null,
  101. mode: SelectHandEffect.Mode.Custom,
  102. cardEffect: activateClass);
  103. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  104. yield return StartCoroutine(selectHandEffect.Activate());
  105. IEnumerator SelectCardCoroutine(CardSource cardSource)
  106. {
  107. selectedCard = cardSource;
  108. yield return null;
  109. }
  110. if (selectedCard != null)
  111. {
  112. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectPermanentCondition1,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: SelectPermanentCoroutine,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Custom,
  125. cardEffect: activateClass);
  126. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  129. {
  130. Permanent selectedPermanent = permanent;
  131. if (selectedPermanent != null)
  132. {
  133. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  134. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  135. }
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. if (timing == EffectTiming.SecuritySkill)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect($"Play 1 [Gammamon] from hand or trash", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  147. activateClass.SetIsSecurityEffect(true);
  148. cardEffects.Add(activateClass);
  149. string EffectDiscription()
  150. {
  151. return "[Security] You may play 1 [Gammamon] from your hand or trash without paying its memory cost.";
  152. }
  153. bool CanSelectCardCondition(CardSource cardSource)
  154. {
  155. if (cardSource.CardNames.Contains("Gammamon"))
  156. {
  157. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  158. {
  159. return true;
  160. }
  161. }
  162. return false;
  163. }
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  169. {
  170. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  171. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  172. if (canSelectHand || canSelectTrash)
  173. {
  174. if (canSelectHand && canSelectTrash)
  175. {
  176. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  177. {
  178. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  179. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  180. };
  181. string selectPlayerMessage = "From which area do you play a card?";
  182. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  183. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  184. }
  185. else
  186. {
  187. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  188. }
  189. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  190. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  191. List<CardSource> selectedCards = new List<CardSource>();
  192. IEnumerator SelectCardCoroutine(CardSource cardSource)
  193. {
  194. selectedCards.Add(cardSource);
  195. yield return null;
  196. }
  197. if (fromHand)
  198. {
  199. int maxCount = 1;
  200. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  201. selectHandEffect.SetUp(
  202. selectPlayer: card.Owner,
  203. canTargetCondition: CanSelectCardCondition,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. maxCount: maxCount,
  207. canNoSelect: true,
  208. canEndNotMax: false,
  209. isShowOpponent: true,
  210. selectCardCoroutine: SelectCardCoroutine,
  211. afterSelectCardCoroutine: null,
  212. mode: SelectHandEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  215. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  216. yield return StartCoroutine(selectHandEffect.Activate());
  217. }
  218. else
  219. {
  220. int maxCount = 1;
  221. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  222. selectCardEffect.SetUp(
  223. canTargetCondition: CanSelectCardCondition,
  224. canTargetCondition_ByPreSelecetedList: null,
  225. canEndSelectCondition: null,
  226. canNoSelect: () => true,
  227. selectCardCoroutine: SelectCardCoroutine,
  228. afterSelectCardCoroutine: null,
  229. message: "Select 1 card to play.",
  230. maxCount: maxCount,
  231. canEndNotMax: false,
  232. isShowOpponent: true,
  233. mode: SelectCardEffect.Mode.Custom,
  234. root: SelectCardEffect.Root.Trash,
  235. customRootCardList: null,
  236. canLookReverseCard: true,
  237. selectPlayer: card.Owner,
  238. cardEffect: activateClass);
  239. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  240. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  241. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  242. }
  243. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  244. if (!fromHand)
  245. {
  246. root = SelectCardEffect.Root.Trash;
  247. }
  248. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  249. cardSources: selectedCards,
  250. activateClass: activateClass,
  251. payCost: false,
  252. isTapped: false,
  253. root: root,
  254. activateETB: true));
  255. }
  256. }
  257. }
  258. return cardEffects;
  259. }
  260. }
  261. }