BT10_077.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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_077 : 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.OnAddHand)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Opponent discards hand", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  20. activateClass.SetHashString("Discard_BT10_077");
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[Opponent's Turn][Once Per Turn] When an effect adds cards to your opponent's hand, by trashing 1 of this Digimon's digivolution cards, your opponent trashes cards in their hand equal to the number of cards added to their hand by the effect.";
  25. }
  26. bool CanSelectCardCondition(CardSource cardSource)
  27. {
  28. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. if (CardEffectCommons.IsOpponentTurn(card))
  35. {
  36. if (CardEffectCommons.CanTriggerWhenAddHand(hashtable, player => player == card.Owner.Enemy, cardEffect => cardEffect != null))
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. bool trashed = false;
  60. List<CardSource> selectedCards = new List<CardSource>();
  61. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  62. selectCardEffect.SetUp(
  63. canTargetCondition: CanSelectCardCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. canNoSelect: () => false,
  67. selectCardCoroutine: SelectCardCoroutine,
  68. afterSelectCardCoroutine: null,
  69. message: "Select 1 digivolution card to discard.",
  70. maxCount: 1,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. mode: SelectCardEffect.Mode.Custom,
  74. root: SelectCardEffect.Root.Custom,
  75. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  76. canLookReverseCard: true,
  77. selectPlayer: card.Owner,
  78. cardEffect: null);
  79. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to discard.", "The opponent is selecting 1 digivolution card to discard.");
  80. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  81. IEnumerator SelectCardCoroutine(CardSource cardSource)
  82. {
  83. selectedCards.Add(cardSource);
  84. yield return null;
  85. }
  86. if (selectedCards.Count >= 1)
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  89. trashed = true;
  90. }
  91. if (trashed)
  92. {
  93. List<CardSource> CardSources = CardEffectCommons.GetCardSourcesFromHashtable(_hashtable);
  94. if (CardSources != null)
  95. {
  96. int discardCount = CardSources.Count((cardSource) => cardSource.Owner == card.Owner.Enemy);
  97. if (discardCount >= 1)
  98. {
  99. if (card.Owner.Enemy.HandCards.Count >= 1)
  100. {
  101. if (card.Owner.Enemy.HandCards.Count < discardCount)
  102. {
  103. discardCount = card.Owner.HandCards.Count;
  104. }
  105. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  106. selectHandEffect.SetUp(
  107. selectPlayer: card.Owner.Enemy,
  108. canTargetCondition: (cardSource) => true,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: discardCount,
  112. canNoSelect: false,
  113. canEndNotMax: false,
  114. isShowOpponent: true,
  115. selectCardCoroutine: null,
  116. afterSelectCardCoroutine: null,
  117. mode: SelectHandEffect.Mode.Discard,
  118. cardEffect: activateClass);
  119. yield return StartCoroutine(selectHandEffect.Activate());
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. if (timing == EffectTiming.OnDestroyedAnyone)
  128. {
  129. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  130. }
  131. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  135. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  136. activateClass.SetIsInheritedEffect(true);
  137. cardEffects.Add(activateClass);
  138. string EffectDiscription()
  139. {
  140. return "[Opponent's Turn] When an effect trashes this digivolution card, gain 1 memory.";
  141. }
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. if (CardEffectCommons.IsExistOnBattleArea(card))
  145. {
  146. if (CardEffectCommons.IsOpponentTurn(card))
  147. {
  148. if (CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card))
  149. {
  150. return true;
  151. }
  152. }
  153. }
  154. return false;
  155. }
  156. bool CanActivateCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsExistOnTrash(card))
  159. {
  160. if (card.Owner.CanAddMemory(activateClass))
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  168. {
  169. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  170. }
  171. }
  172. if (timing == EffectTiming.None)
  173. {
  174. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  175. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  176. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  177. addDigiXrosConditionClass.SetNotShowUI(true);
  178. cardEffects.Add(addDigiXrosConditionClass);
  179. bool CanUseCondition(Hashtable hashtable)
  180. {
  181. return true;
  182. }
  183. DigiXrosCondition GetDigiXros(CardSource cardSource)
  184. {
  185. if (cardSource == card)
  186. {
  187. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "[Bagra Army] Digimon");
  188. bool CanSelectCardCondition(CardSource cardSource)
  189. {
  190. if (cardSource != null)
  191. {
  192. if (cardSource.Owner == card.Owner)
  193. {
  194. if (cardSource.IsDigimon)
  195. {
  196. if (cardSource.CardTraits.Contains("BagraArmy"))
  197. {
  198. return true;
  199. }
  200. if (cardSource.CardTraits.Contains("Bagra Army"))
  201. {
  202. return true;
  203. }
  204. }
  205. }
  206. }
  207. return false;
  208. }
  209. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element };
  210. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  211. return digiXrosCondition;
  212. }
  213. return null;
  214. }
  215. }
  216. return cardEffects;
  217. }
  218. }
  219. }