BT18_013.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_013 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Gazimon") ||
  18. targetPermanent.TopCard.EqualsCardName("Gizamon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Raid
  24. if (timing == EffectTiming.OnAllyAttack)
  25. {
  26. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Trash 1 card from hand to return 1 card from trash to hand", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[On Play] By trashing 1 card in your hand, return 1 card with the [Composite] or [Wicked God] trait from your trash to the hand.";
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. if (cardSource.EqualsTraits("Composite"))
  43. {
  44. return true;
  45. }
  46. if (cardSource.EqualsTraits("Wicked God"))
  47. {
  48. return true;
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  55. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  56. return false;
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (card.Owner.HandCards.Count >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (card.Owner.HandCards.Count >= 1)
  72. {
  73. bool discarded = false;
  74. int discardCount = 1;
  75. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  76. selectHandEffect.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: cardSource => true,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: discardCount,
  82. canNoSelect: true,
  83. canEndNotMax: false,
  84. isShowOpponent: true,
  85. selectCardCoroutine: null,
  86. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  87. mode: SelectHandEffect.Mode.Discard,
  88. cardEffect: activateClass);
  89. yield return StartCoroutine(selectHandEffect.Activate());
  90. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  91. {
  92. if (cardSources.Count == 1)
  93. {
  94. discarded = true;
  95. yield return null;
  96. }
  97. }
  98. if (discarded)
  99. {
  100. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  101. {
  102. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  103. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  104. selectCardEffect.SetUp(
  105. canTargetCondition: CanSelectCardCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. canNoSelect: () => false,
  109. selectCardCoroutine: null,
  110. afterSelectCardCoroutine: null,
  111. message: "Select 1 card to add to your hand.",
  112. maxCount: maxCount,
  113. canEndNotMax: false,
  114. isShowOpponent: true,
  115. mode: SelectCardEffect.Mode.AddHand,
  116. root: SelectCardEffect.Root.Trash,
  117. customRootCardList: null,
  118. canLookReverseCard: true,
  119. selectPlayer: card.Owner,
  120. cardEffect: activateClass);
  121. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  122. }
  123. }
  124. }
  125. }
  126. }
  127. #endregion
  128. #region When Digivolving
  129. if (timing == EffectTiming.OnEnterFieldAnyone)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect("Trash 1 card from hand to return 1 card from trash to hand", CanUseCondition, card);
  133. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  134. cardEffects.Add(activateClass);
  135. string EffectDiscription()
  136. {
  137. return "[When Digivolving] By trashing 1 card in your hand, return 1 card with the [Composite] or [Wicked God] trait from your trash to the hand.";
  138. }
  139. bool CanSelectCardCondition(CardSource cardSource)
  140. {
  141. if (cardSource.EqualsTraits("Composite"))
  142. {
  143. return true;
  144. }
  145. if (cardSource.EqualsTraits("Wicked God"))
  146. {
  147. return true;
  148. }
  149. return false;
  150. }
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  154. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  155. return false;
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleArea(card))
  160. {
  161. if (card.Owner.HandCards.Count >= 1)
  162. {
  163. return true;
  164. }
  165. }
  166. return false;
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  169. {
  170. if (card.Owner.HandCards.Count >= 1)
  171. {
  172. bool discarded = false;
  173. int discardCount = 1;
  174. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  175. selectHandEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: cardSource => true,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: discardCount,
  181. canNoSelect: true,
  182. canEndNotMax: false,
  183. isShowOpponent: true,
  184. selectCardCoroutine: null,
  185. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  186. mode: SelectHandEffect.Mode.Discard,
  187. cardEffect: activateClass);
  188. yield return StartCoroutine(selectHandEffect.Activate());
  189. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  190. {
  191. if (cardSources.Count == 1)
  192. {
  193. discarded = true;
  194. yield return null;
  195. }
  196. }
  197. if (discarded)
  198. {
  199. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  200. {
  201. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  202. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  203. selectCardEffect.SetUp(
  204. canTargetCondition: CanSelectCardCondition,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. canNoSelect: () => false,
  208. selectCardCoroutine: null,
  209. afterSelectCardCoroutine: null,
  210. message: "Select 1 card to add to your hand.",
  211. maxCount: maxCount,
  212. canEndNotMax: false,
  213. isShowOpponent: true,
  214. mode: SelectCardEffect.Mode.AddHand,
  215. root: SelectCardEffect.Root.Trash,
  216. customRootCardList: null,
  217. canLookReverseCard: true,
  218. selectPlayer: card.Owner,
  219. cardEffect: activateClass);
  220. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  221. }
  222. }
  223. }
  224. }
  225. }
  226. #endregion
  227. #region Retaliation - ESS
  228. if (timing == EffectTiming.OnDestroyedAnyone)
  229. {
  230. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  231. }
  232. #endregion
  233. return cardEffects;
  234. }
  235. }
  236. }