BT10_009.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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_009 : 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.WhenPermanentWouldBeDeleted)
  16. {
  17. cardEffects.Add(CardEffectFactory.MaterialSaveEffect(card: card, materialSaveCount: 2));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Draw 2", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[On Play] Trigger <Draw 2>. (Draw 2 card from your deck.)";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  32. }
  33. bool CanActivateCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (card.Owner.LibraryCards.Count >= 1)
  38. {
  39. return true;
  40. }
  41. }
  42. return false;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  45. {
  46. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  47. }
  48. }
  49. if (timing == EffectTiming.OnEndAttack)
  50. {
  51. ActivateClass activateClass = new ActivateClass();
  52. activateClass.SetUpICardEffect("Place digivolution cards from this Digimon under your Tamer to unsuspend 1 Tamer and delete this Digimon", CanUseCondition, card);
  53. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  54. cardEffects.Add(activateClass);
  55. string EffectDiscription()
  56. {
  57. return "[End of Attack] By placing all digivolution cards from under this Digimon under 1 of your Tamers, unsuspend 1 of your Tamers, and delete this Digimon.";
  58. }
  59. bool CanSelectPermanentCondition(Permanent permanent)
  60. {
  61. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  62. {
  63. if (permanent.IsTamer)
  64. {
  65. if (!permanent.IsToken)
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. bool CanSelectPermanentCondition1(Permanent permanent)
  74. {
  75. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  76. {
  77. if (permanent.IsTamer)
  78. {
  79. return true;
  80. }
  81. }
  82. return false;
  83. }
  84. bool CanUseCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  87. }
  88. bool CanActivateCondition(Hashtable hashtable)
  89. {
  90. if (CardEffectCommons.IsExistOnBattleArea(card))
  91. {
  92. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  93. {
  94. if (card.Owner.GetBattleAreaPermanents().Some(CanSelectPermanentCondition))
  95. {
  96. return true;
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  103. {
  104. if (CardEffectCommons.IsExistOnBattleArea(card))
  105. {
  106. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  107. {
  108. if (card.Owner.GetBattleAreaPermanents().Some(CanSelectPermanentCondition))
  109. {
  110. bool addedDigivolutionCards = false;
  111. Permanent selectedPermanent = null;
  112. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectPermanentCondition,
  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(
  127. "Select 1 Tamer that will get digivolution cards.",
  128. "The opponent is selecting 1 Tamer that will get digivolution cards.");
  129. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  130. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  131. {
  132. selectedPermanent = permanent;
  133. yield return null;
  134. }
  135. if (selectedPermanent != null)
  136. {
  137. List<CardSource> digivolutionCards = new List<CardSource>();
  138. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  139. {
  140. if (card.PermanentOfThisCard().DigivolutionCards.Count == 1)
  141. {
  142. foreach (CardSource cardSource in card.PermanentOfThisCard().DigivolutionCards)
  143. {
  144. digivolutionCards.Add(cardSource);
  145. }
  146. }
  147. else
  148. {
  149. maxCount = card.PermanentOfThisCard().DigivolutionCards.Count;
  150. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  151. selectCardEffect.SetUp(
  152. canTargetCondition: (cardSource) => true,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. canNoSelect: () => true,
  156. selectCardCoroutine: SelectCardCoroutine,
  157. afterSelectCardCoroutine: null,
  158. message: "Specify the order to place the card on bottom of digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  159. maxCount: maxCount,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. mode: SelectCardEffect.Mode.Custom,
  163. root: SelectCardEffect.Root.Custom,
  164. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  165. canLookReverseCard: true,
  166. selectPlayer: card.Owner,
  167. cardEffect: activateClass);
  168. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  169. yield return StartCoroutine(selectCardEffect.Activate());
  170. IEnumerator SelectCardCoroutine(CardSource cardSource)
  171. {
  172. digivolutionCards.Add(cardSource);
  173. yield return null;
  174. }
  175. }
  176. }
  177. if (digivolutionCards.Count >= 1)
  178. {
  179. if (selectedPermanent != null)
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  182. addedDigivolutionCards = true;
  183. }
  184. }
  185. }
  186. if (addedDigivolutionCards)
  187. {
  188. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  189. {
  190. maxCount = 1;
  191. selectPermanentEffect.SetUp(
  192. selectPlayer: card.Owner,
  193. canTargetCondition: CanSelectPermanentCondition1,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. maxCount: maxCount,
  197. canNoSelect: false,
  198. canEndNotMax: false,
  199. selectPermanentCoroutine: null,
  200. afterSelectPermanentCoroutine: null,
  201. mode: SelectPermanentEffect.Mode.UnTap,
  202. cardEffect: activateClass);
  203. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  204. }
  205. if (CardEffectCommons.IsExistOnBattleArea(card))
  206. {
  207. Hashtable hashtable = new Hashtable();
  208. hashtable.Add("CardEffect", activateClass);
  209. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  210. new List<Permanent>() { card.PermanentOfThisCard() },
  211. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. if (timing == EffectTiming.None)
  220. {
  221. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  222. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  223. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  224. addDigiXrosConditionClass.SetNotShowUI(true);
  225. cardEffects.Add(addDigiXrosConditionClass);
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. return true;
  229. }
  230. DigiXrosCondition GetDigiXros(CardSource cardSource)
  231. {
  232. if (cardSource == card)
  233. {
  234. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Shoutmon");
  235. bool CanSelectCardCondition(CardSource cardSource)
  236. {
  237. if (cardSource != null)
  238. {
  239. if (cardSource.Owner == card.Owner)
  240. {
  241. if (cardSource.IsDigimon)
  242. {
  243. if (cardSource.CardNames_DigiXros.Contains("Shoutmon"))
  244. {
  245. return true;
  246. }
  247. }
  248. }
  249. }
  250. return false;
  251. }
  252. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "Ballistamon");
  253. bool CanSelectCardCondition1(CardSource cardSource)
  254. {
  255. if (cardSource != null)
  256. {
  257. if (cardSource.Owner == card.Owner)
  258. {
  259. if (cardSource.IsDigimon)
  260. {
  261. if (cardSource.CardNames_DigiXros.Contains("Ballistamon"))
  262. {
  263. return true;
  264. }
  265. }
  266. }
  267. }
  268. return false;
  269. }
  270. DigiXrosConditionElement element2 = new DigiXrosConditionElement(CanSelectCardCondition2, "Dorulumon");
  271. bool CanSelectCardCondition2(CardSource cardSource)
  272. {
  273. if (cardSource != null)
  274. {
  275. if (cardSource.Owner == card.Owner)
  276. {
  277. if (cardSource.IsDigimon)
  278. {
  279. if (cardSource.CardNames_DigiXros.Contains("Dorulumon"))
  280. {
  281. return true;
  282. }
  283. }
  284. }
  285. }
  286. return false;
  287. }
  288. DigiXrosConditionElement element3 = new DigiXrosConditionElement(CanSelectCardCondition3, "Starmons");
  289. bool CanSelectCardCondition3(CardSource cardSource)
  290. {
  291. if (cardSource != null)
  292. {
  293. if (cardSource.Owner == card.Owner)
  294. {
  295. if (cardSource.IsDigimon)
  296. {
  297. if (cardSource.CardNames_DigiXros.Contains("Starmons"))
  298. {
  299. return true;
  300. }
  301. }
  302. }
  303. }
  304. return false;
  305. }
  306. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1, element2, element3 };
  307. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  308. return digiXrosCondition;
  309. }
  310. return null;
  311. }
  312. }
  313. return cardEffects;
  314. }
  315. }
  316. }