ArkhaiAngemon_BT18_038.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 ArkhaiAngemon_BT18_038 : 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.EqualsTraits("Angel") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4);
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region On Play
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Place a card in the bottom of security, then add top security to hand", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  28. cardEffects.Add(activateClass);
  29. string EffectDescription()
  30. {
  31. return "[On Play] You may place 1 Digimon card with the [Angel]/[Archangel]/[Three Great Angels] trait from your hand at the bottom of your security stack. Then, if you have 4 or more security cards, add the top card of your security stack to the hand.";
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  36. }
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. if (cardSource.IsDigimon)
  40. {
  41. if (cardSource.HasAngelTraitRestrictive)
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  51. {
  52. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectCardCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. mode: SelectHandEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the bottom of security.", "The opponent is selecting 1 card to place at the bottom of security.");
  77. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  78. yield return StartCoroutine(selectHandEffect.Activate());
  79. IEnumerator SelectCardCoroutine(CardSource cardSource)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  82. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateRecoveryEffect(cardSource.Owner));
  83. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(cardSource.Owner).AddSecurity());
  84. }
  85. if (card.Owner.SecurityCards.Count >= 4)
  86. {
  87. CardSource topCard = card.Owner.SecurityCards[0];
  88. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  89. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  90. player: card.Owner,
  91. refSkillInfos: ref ContinuousController.instance.nullSkillInfos).ReduceSecurity());
  92. }
  93. }
  94. }
  95. #endregion
  96. #region On Deletion
  97. if (timing == EffectTiming.OnDestroyedAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Place a card in the bottom of security, then add top security to hand", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  102. cardEffects.Add(activateClass);
  103. string EffectDescription()
  104. {
  105. return "[On Deletion] You may place 1 Digimon card with the [Angel]/[Archangel]/[Three Great Angels] trait from your hand at the bottom of your security stack. Then, if you have 4 or more security cards, add the top card of your security stack to the hand.";
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  110. }
  111. bool CanSelectCardCondition(CardSource cardSource)
  112. {
  113. if (cardSource.IsDigimon)
  114. {
  115. if (cardSource.HasAngelTraitRestrictive)
  116. {
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  125. {
  126. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  127. {
  128. return true;
  129. }
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable hashtable)
  134. {
  135. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  136. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  137. selectHandEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectCardCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. selectCardCoroutine: SelectCardCoroutine,
  147. afterSelectCardCoroutine: null,
  148. mode: SelectHandEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the bottom of security.", "The opponent is selecting 1 card to place at the bottom of security.");
  151. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  152. yield return StartCoroutine(selectHandEffect.Activate());
  153. IEnumerator SelectCardCoroutine(CardSource cardSource)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  156. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateRecoveryEffect(cardSource.Owner));
  157. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(cardSource.Owner).AddSecurity());
  158. }
  159. if (card.Owner.SecurityCards.Count >= 4)
  160. {
  161. CardSource topCard = card.Owner.SecurityCards[0];
  162. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  163. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(player: card.Owner, refSkillInfos: ref ContinuousController.instance.nullSkillInfos).ReduceSecurity());
  164. }
  165. }
  166. }
  167. #endregion
  168. #region Inherit
  169. if (timing == EffectTiming.OnDestroyedAnyone)
  170. {
  171. ActivateClass activateClass = new ActivateClass();
  172. activateClass.SetUpICardEffect("Recovery +1", CanUseCondition, card);
  173. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  174. activateClass.SetIsInheritedEffect(true);
  175. cardEffects.Add(activateClass);
  176. string EffectDiscription()
  177. {
  178. return "[On Deletion] Recovery +1.";
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  183. }
  184. bool CanActivateCondition(Hashtable hashtable)
  185. {
  186. if (CardEffectCommons.CanActivateOnDeletionInherited(hashtable, card))
  187. {
  188. if (card.Owner.CanAddSecurity(activateClass))
  189. {
  190. return true;
  191. }
  192. }
  193. return false;
  194. }
  195. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  196. {
  197. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  198. }
  199. }
  200. #endregion
  201. return cardEffects;
  202. }
  203. }
  204. }