P_164.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_164 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Place 1 level 5 or lower as bottom digivolution card.", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[On Play] By placing 1 level 5 or lower Digimon card with [Aqua] or [Sea Animal] in any of its traits from your hand as this Digimon's bottom digivolution card, <Draw 1>.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.ContainsTraits("Aqua") || cardSource.ContainsTraits("Sea Animal"))
  26. {
  27. if (cardSource.HasLevel)
  28. {
  29. if (cardSource.Level <= 5)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  44. {
  45. if(CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. CardSource selectedCard = null;
  55. int maxCount = Math.Min(1, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  56. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  57. selectHandEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectCardCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: true,
  64. canEndNotMax: false,
  65. isShowOpponent: true,
  66. selectCardCoroutine: SelectCardCoroutine,
  67. afterSelectCardCoroutine: null,
  68. mode: SelectHandEffect.Mode.Custom,
  69. cardEffect: activateClass);
  70. selectHandEffect.SetUpCustomMessage(
  71. "Select 1 card to place on bottom of digivolution cards.",
  72. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  73. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  74. yield return StartCoroutine(selectHandEffect.Activate());
  75. IEnumerator SelectCardCoroutine(CardSource cardSource)
  76. {
  77. selectedCard = cardSource;
  78. yield return null;
  79. }
  80. if (selectedCard != null)
  81. {
  82. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  85. new List<CardSource> { selectedCard },
  86. activateClass));
  87. yield return ContinuousController.instance.StartCoroutine(
  88. new DrawClass(card.Owner, 1, activateClass).Draw());
  89. }
  90. }
  91. }
  92. }
  93. #endregion
  94. #region When Digivolving
  95. if (timing == EffectTiming.OnEnterFieldAnyone)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect("Place 1 level 5 or lower as bottom digivolution card.", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  100. cardEffects.Add(activateClass);
  101. string EffectDescription()
  102. {
  103. return "[When Digivolving] By placing 1 level 5 or lower Digimon card with [Aqua] or [Sea Animal] in any of its traits from your hand as this Digimon's bottom digivolution card, <Draw 1>.";
  104. }
  105. bool CanSelectCardCondition(CardSource cardSource)
  106. {
  107. if(cardSource.ContainsTraits("Aqua") || cardSource.ContainsTraits("Sea Animal"))
  108. {
  109. if (cardSource.HasLevel)
  110. {
  111. if (cardSource.Level <= 5)
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. return false;
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  122. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  127. {
  128. if(CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  129. {
  130. return true;
  131. }
  132. }
  133. return false;
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable hashtable)
  136. {
  137. CardSource selectedCard = null;
  138. int maxCount = Math.Min(1, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  139. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  140. selectHandEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: CanSelectCardCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: maxCount,
  146. canNoSelect: true,
  147. canEndNotMax: false,
  148. isShowOpponent: true,
  149. selectCardCoroutine: SelectCardCoroutine,
  150. afterSelectCardCoroutine: null,
  151. mode: SelectHandEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. selectHandEffect.SetUpCustomMessage(
  154. "Select 1 card to place on bottom of digivolution cards.",
  155. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  156. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  157. yield return StartCoroutine(selectHandEffect.Activate());
  158. IEnumerator SelectCardCoroutine(CardSource cardSource)
  159. {
  160. selectedCard = cardSource;
  161. yield return null;
  162. }
  163. if (selectedCard != null)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  166. {
  167. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  168. new List<CardSource> { selectedCard },
  169. activateClass));
  170. yield return ContinuousController.instance.StartCoroutine(
  171. new DrawClass(card.Owner, 1, activateClass).Draw());
  172. }
  173. }
  174. }
  175. }
  176. #endregion
  177. #region Inherited Effect
  178. if (timing == EffectTiming.OnEndAttack)
  179. {
  180. ActivateClass activateClass = new ActivateClass();
  181. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  182. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  183. activateClass.SetIsInheritedEffect(true);
  184. activateClass.SetHashString("Draw1_P_164");
  185. cardEffects.Add(activateClass);
  186. string EffectDescription()
  187. {
  188. return "[End of Attack] [Once Per Turn] <Draw 1>";
  189. }
  190. bool CanUseCondition(Hashtable hashtable)
  191. {
  192. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(
  201. new DrawClass(card.Owner, 1, activateClass).Draw());
  202. }
  203. }
  204. #endregion
  205. return cardEffects;
  206. }
  207. }
  208. }