BT7_083.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 BT7_083 : 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("Place a card in digivolution cards to delete 1 Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] You may place 1 [Sistermon Ciel] from your hand or trash at the bottom of this Digimon's digivolution cards to delete 1 of your opponent's Digimon with a play cost of 5 or less.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.CardNames.Contains("Sistermon Ciel"))
  26. {
  27. return true;
  28. }
  29. if (cardSource.CardNames.Contains("SistermonCiel"))
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. bool CanSelectPermanentCondition(Permanent permanent)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.TopCard.GetCostItself <= 5)
  40. {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. if (CardEffectCommons.IsExistOnBattleArea(card))
  53. {
  54. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  55. {
  56. return true;
  57. }
  58. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  66. {
  67. if (isExistOnField(card))
  68. {
  69. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  70. {
  71. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  72. {
  73. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  74. {
  75. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  76. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  77. };
  78. string selectPlayerMessage = "From which area do you place a card in digivolution cards?";
  79. string notSelectPlayerMessage = "The opponent is choosing from which area to place a card in digivolution cards.";
  80. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  81. }
  82. else if (card.Owner.HandCards.Count(CanSelectCardCondition) == 0 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  83. {
  84. GManager.instance.userSelectionManager.SetBool(false);
  85. }
  86. else if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && card.Owner.TrashCards.Count(CanSelectCardCondition) == 0)
  87. {
  88. GManager.instance.userSelectionManager.SetBool(true);
  89. }
  90. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  91. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  92. List<CardSource> selectedCards = new List<CardSource>();
  93. IEnumerator SelectCardCoroutine(CardSource cardSource)
  94. {
  95. selectedCards.Add(cardSource);
  96. yield return null;
  97. }
  98. if (fromHand)
  99. {
  100. int maxCount = 1;
  101. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  102. selectHandEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: CanSelectCardCondition,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: maxCount,
  108. canNoSelect: true,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. selectCardCoroutine: SelectCardCoroutine,
  112. afterSelectCardCoroutine: null,
  113. mode: SelectHandEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectHandEffect.SetUpCustomMessage("Select 1 card to place in digivolution cards.", "The opponent is selecting 1 card to place in digivolution cards.");
  116. yield return StartCoroutine(selectHandEffect.Activate());
  117. }
  118. else
  119. {
  120. int maxCount = 1;
  121. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  122. selectCardEffect.SetUp(
  123. canTargetCondition: CanSelectCardCondition,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. canNoSelect: () => true,
  127. selectCardCoroutine: SelectCardCoroutine,
  128. afterSelectCardCoroutine: null,
  129. message: "Select 1 card to play.",
  130. maxCount: maxCount,
  131. canEndNotMax: false,
  132. isShowOpponent: true,
  133. mode: SelectCardEffect.Mode.Custom,
  134. root: SelectCardEffect.Root.Trash,
  135. customRootCardList: null,
  136. canLookReverseCard: true,
  137. selectPlayer: card.Owner,
  138. cardEffect: activateClass);
  139. selectCardEffect.SetUpCustomMessage("Select 1 card to place in digivolution cards.", "The opponent is selecting 1 card to place in digivolution cards.");
  140. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  141. }
  142. if (selectedCards.Count >= 1)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  145. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  146. {
  147. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  148. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  149. selectPermanentEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectPermanentCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: false,
  156. canEndNotMax: false,
  157. selectPermanentCoroutine: null,
  158. afterSelectPermanentCoroutine: null,
  159. mode: SelectPermanentEffect.Mode.Destroy,
  160. cardEffect: activateClass);
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. if (timing == EffectTiming.OnDestroyedAnyone)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("Return 1 card from trash to hand", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[On Deletion] Return 1 card with [Jesmon], [Huckmon], or [Sistermon] in its name other than [Sistermon Ciel (Awakened)] from your trash to your hand.";
  177. }
  178. bool CanSelectCardCondition(CardSource cardSource)
  179. {
  180. if (!cardSource.CardNames.Contains("Sistermon Ciel (Awakened)") && !cardSource.CardNames.Contains("SistermonCiel(Awakened)"))
  181. {
  182. if (cardSource.ContainsCardName("Jesmon"))
  183. {
  184. return true;
  185. }
  186. if (cardSource.ContainsCardName("Huckmon"))
  187. {
  188. return true;
  189. }
  190. if (cardSource.ContainsCardName("Sistermon"))
  191. {
  192. return true;
  193. }
  194. }
  195. return false;
  196. }
  197. bool CanUseCondition(Hashtable hashtable)
  198. {
  199. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  200. }
  201. bool CanActivateCondition(Hashtable hashtable)
  202. {
  203. if (CardEffectCommons.IsExistOnTrash(card))
  204. {
  205. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  206. {
  207. return true;
  208. }
  209. }
  210. return false;
  211. }
  212. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  213. {
  214. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  215. {
  216. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  217. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  218. selectCardEffect.SetUp(
  219. canTargetCondition: CanSelectCardCondition,
  220. canTargetCondition_ByPreSelecetedList: null,
  221. canEndSelectCondition: null,
  222. canNoSelect: () => false,
  223. selectCardCoroutine: null,
  224. afterSelectCardCoroutine: null,
  225. message: "Select 1 card to add to your hand.",
  226. maxCount: maxCount,
  227. canEndNotMax: false,
  228. isShowOpponent: true,
  229. mode: SelectCardEffect.Mode.AddHand,
  230. root: SelectCardEffect.Root.Trash,
  231. customRootCardList: null,
  232. canLookReverseCard: true,
  233. selectPlayer: card.Owner,
  234. cardEffect: activateClass);
  235. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  236. }
  237. }
  238. }
  239. return cardEffects;
  240. }
  241. }