BT8_065.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 BT8_065 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Return cards from trash to deck top to De-Digivolve", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may return up to 4 Digimon cards with [Mamemon] in their names from your hand and/or trash to the top of your deck in any order. If you return 3 or more cards with this effect, <De-Digivolve 1> 1 of your opponent's Digimon. (Trash 1 card from the top of one of your opponent's Digimon. If it has no digivolution cards, or becomes a level 3 Digimon, you can't trash any more cards.)";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon)
  26. {
  27. if (cardSource.ContainsCardName("Mamemon"))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  47. {
  48. return true;
  49. }
  50. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (card.Owner.HandCards.Count(CanSelectCardCondition) + card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  60. {
  61. List<CardSource> libraryCards = new List<CardSource>();
  62. if (card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  63. {
  64. List<CardSource> selectedCards = new List<CardSource>();
  65. int maxCount = Math.Min(4, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  66. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  67. selectHandEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectCardCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: true,
  74. canEndNotMax: true,
  75. isShowOpponent: true,
  76. selectCardCoroutine: SelectCardCoroutine,
  77. afterSelectCardCoroutine: null,
  78. mode: SelectHandEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectHandEffect.SetUpCustomMessage("Select cards to place to the top of the deck.", "The opponent is selecting cards.");
  81. yield return StartCoroutine(selectHandEffect.Activate());
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. selectedCards.Add(cardSource);
  85. libraryCards.Add(cardSource);
  86. yield return null;
  87. }
  88. if (selectedCards.Count >= 1)
  89. {
  90. foreach (CardSource selectedCard in selectedCards)
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  93. }
  94. }
  95. }
  96. if (card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  97. {
  98. List<CardSource> selectedCards = new List<CardSource>();
  99. int maxCount = Math.Min(4 - libraryCards.Count, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  100. if (maxCount >= 1)
  101. {
  102. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  103. selectCardEffect.SetUp(
  104. canTargetCondition: CanSelectCardCondition,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. canNoSelect: () => true,
  108. selectCardCoroutine: SelectCardCoroutine,
  109. afterSelectCardCoroutine: null,
  110. message: "Select cards to place to the top of the deck.",
  111. maxCount: maxCount,
  112. canEndNotMax: true,
  113. isShowOpponent: true,
  114. mode: SelectCardEffect.Mode.Custom,
  115. root: SelectCardEffect.Root.Trash,
  116. customRootCardList: null,
  117. canLookReverseCard: true,
  118. selectPlayer: card.Owner,
  119. cardEffect: activateClass);
  120. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  121. IEnumerator SelectCardCoroutine(CardSource cardSource)
  122. {
  123. selectedCards.Add(cardSource);
  124. libraryCards.Add(cardSource);
  125. yield return null;
  126. }
  127. if (selectedCards.Count >= 1)
  128. {
  129. foreach (CardSource selectedCard in selectedCards)
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  132. }
  133. }
  134. }
  135. }
  136. if (libraryCards.Count >= 1)
  137. {
  138. if (libraryCards.Count == 1)
  139. {
  140. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(libraryCards));
  141. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(
  142. libraryCards,
  143. "Deck Top Cards",
  144. true,
  145. true));
  146. }
  147. else
  148. {
  149. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  150. selectCardEffect.SetUp(
  151. canTargetCondition: (cardSource) => true,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. canNoSelect: () => false,
  155. selectCardCoroutine: null,
  156. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  157. message: "Specify the order to place the card at the top of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  158. maxCount: libraryCards.Count,
  159. canEndNotMax: false,
  160. isShowOpponent: false,
  161. mode: SelectCardEffect.Mode.Custom,
  162. root: SelectCardEffect.Root.Custom,
  163. customRootCardList: libraryCards,
  164. canLookReverseCard: true,
  165. selectPlayer: card.Owner,
  166. cardEffect: activateClass);
  167. selectCardEffect.SetNotAddLog();
  168. selectCardEffect.SetUpCustomMessage_ShowCard("Deck Top Cards");
  169. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  170. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  171. {
  172. cardSources.Reverse();
  173. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(cardSources));
  174. }
  175. }
  176. }
  177. if (libraryCards.Count >= 3)
  178. {
  179. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  180. {
  181. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  182. List<Permanent> selectedPermanents = new List<Permanent>();
  183. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  184. selectPermanentEffect.SetUp(
  185. selectPlayer: card.Owner,
  186. canTargetCondition: CanSelectPermanentCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: CanEndSelectCondition,
  189. maxCount: maxCount,
  190. canNoSelect: false,
  191. canEndNotMax: false,
  192. selectPermanentCoroutine: SelectPermanentCoroutine,
  193. afterSelectPermanentCoroutine: null,
  194. mode: SelectPermanentEffect.Mode.Custom,
  195. cardEffect: activateClass);
  196. selectPermanentEffect.SetUpCustomMessage(
  197. "Select 1 Digimon to De-Digivolve.",
  198. "The opponent is selecting 1 Digimon to De-Digivolve.");
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. bool CanEndSelectCondition(List<Permanent> permanents)
  201. {
  202. if (CardEffectCommons.HasNoElement(permanents))
  203. {
  204. return false;
  205. }
  206. return true;
  207. }
  208. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  209. {
  210. selectedPermanents.Add(permanent);
  211. yield return null;
  212. }
  213. if (selectedPermanents.Count >= 1)
  214. {
  215. foreach (Permanent selectedPermanent in selectedPermanents)
  216. {
  217. if (selectedPermanent != null)
  218. {
  219. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  220. selectedPermanent,
  221. 1,
  222. activateClass).Degeneration());
  223. }
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. return cardEffects;
  232. }
  233. }