BT11_081.cs 9.9 KB

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