P_142.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_142 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardNames.Contains("Pinamon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Suspend 1 level 6 or lower Digimon", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] Suspend 1 of your opponent's level 6 or lower Digimon. Then, by placing this Digimon as the bottom digivolution card of 1 of your Digimon with [Ravemon] in its name, that Digimon may attack an opponent's Digimon.";
  31. }
  32. bool CanSelectPermanentCondition(Permanent permanent)
  33. {
  34. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  35. {
  36. if (permanent.Level <= 6)
  37. {
  38. if (permanent.TopCard.HasLevel)
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanSelectOwnPermanentCondition(Permanent targetPermanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  49. {
  50. if (targetPermanent.TopCard.name.Contains("Ravemon"))
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  58. {
  59. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: null,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Tap,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. }
  89. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition))
  90. {
  91. Permanent selectedPermanent = null;
  92. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOwnPermanentCondition));
  93. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  94. selectPermanentEffect.SetUp(
  95. selectPlayer: card.Owner,
  96. canTargetCondition: CanSelectOwnPermanentCondition,
  97. canTargetCondition_ByPreSelecetedList: null,
  98. canEndSelectCondition: null,
  99. maxCount: maxCount,
  100. canNoSelect: true,
  101. canEndNotMax: false,
  102. selectPermanentCoroutine: SelectPermanentCoroutine,
  103. afterSelectPermanentCoroutine: null,
  104. mode: SelectPermanentEffect.Mode.Custom,
  105. cardEffect: activateClass);
  106. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon with [Ravemon] in its name to add bottom digivolution source.", "The opponent is selecting 1 Digimon to add bottom digivolution source.");
  107. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  108. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  109. {
  110. selectedPermanent = permanent;
  111. yield return null;
  112. }
  113. if (selectedPermanent != null)
  114. {
  115. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  116. new List<CardSource>() { card },
  117. activateClass));
  118. if (selectedPermanent.CanAttack(activateClass) && CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  119. {
  120. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  121. selectAttackEffect.SetUp(
  122. attacker: selectedPermanent,
  123. canAttackPlayerCondition: () => false,
  124. defenderCondition: (permanent) => true,
  125. cardEffect: activateClass);
  126. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  127. }
  128. }
  129. }
  130. }
  131. }
  132. #endregion
  133. #region Inherit
  134. if (timing == EffectTiming.OnDestroyedAnyone)
  135. {
  136. ActivateClass activateClass = new ActivateClass();
  137. activateClass.SetUpICardEffect("Opponent trashes 1 card from hand", CanUseCondition, card);
  138. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  139. activateClass.SetIsInheritedEffect(true);
  140. cardEffects.Add(activateClass);
  141. string EffectDiscription()
  142. {
  143. return "[On Deletion] When this Digimon is deleted other than in battle, your opponent trashes 1 card in their hand.";
  144. }
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  148. }
  149. bool CanActivateCondition(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  152. {
  153. if (!CardEffectCommons.IsByBattle(hashtable))
  154. {
  155. if (card.Owner.Enemy.HandCards.Count >= 1)
  156. {
  157. return true;
  158. }
  159. }
  160. }
  161. return false;
  162. }
  163. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  164. {
  165. if (card.Owner.Enemy.HandCards.Count >= 1)
  166. {
  167. int discardCount = Math.Min(1, card.Owner.HandCards.Count);
  168. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  169. selectHandEffect.SetUp(
  170. selectPlayer: card.Owner.Enemy,
  171. canTargetCondition: (cardSource) => true,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: discardCount,
  175. canNoSelect: false,
  176. canEndNotMax: false,
  177. isShowOpponent: true,
  178. selectCardCoroutine: null,
  179. afterSelectCardCoroutine: null,
  180. mode: SelectHandEffect.Mode.Discard,
  181. cardEffect: activateClass);
  182. yield return StartCoroutine(selectHandEffect.Activate());
  183. }
  184. }
  185. }
  186. #endregion
  187. return cardEffects;
  188. }
  189. }
  190. }