EX12_050.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // SymbareAngoramon
  6. namespace DCGO.CardEffects.EX12
  7. {
  8. public class EX12_050 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.EqualsCardName("Angoramon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 2, false, card, null));
  21. }
  22. if (timing == EffectTiming.None)
  23. {
  24. bool PermanentCondition(Permanent permanent)
  25. {
  26. return permanent.TopCard.EqualsTraits("NSp");
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 2, false, card, null, level: 3));
  29. }
  30. #endregion
  31. #region Main
  32. if (timing == EffectTiming.OnDeclaration)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Play/Use 1 [Angoramon] in text/[NSp] from hand for 2 less", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDescription());
  37. activateClass.SetHashString("EX12_050_Main");
  38. cardEffects.Add(activateClass);
  39. string EffectDescription()
  40. => "[Main] [Once Per Turn] You may play or use 1 card with [Angoramon] in its text or the [NSp] trait from your hand with the cost reduced by 2.";
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleArea(card)
  44. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  45. }
  46. bool CanSelectCardCondition(CardSource cardSource)
  47. {
  48. return (cardSource.HasText("Angoramon")
  49. || cardSource.EqualsTraits("NSp"))
  50. && ((cardSource.IsOption
  51. && !cardSource.CanNotPlayThisOption)
  52. || (cardSource.HasPlayCost
  53. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: cardSource.GetCostItself - 2)));
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable hashtable)
  56. {
  57. bool isUsed = false;
  58. CardSource selectedCard = null;
  59. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  60. selectHandEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectCardCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: 1,
  66. canNoSelect: true,
  67. canEndNotMax: false,
  68. isShowOpponent: true,
  69. selectCardCoroutine: SelectCardCoroutine,
  70. afterSelectCardCoroutine: null,
  71. mode: SelectHandEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  74. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  75. IEnumerator SelectCardCoroutine(CardSource cardSource)
  76. {
  77. selectedCard = cardSource;
  78. yield return null;
  79. }
  80. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  81. if (selectedCard != null)
  82. {
  83. isUsed = true;
  84. #region reduce cost
  85. int reducecost = 2;
  86. ChangeCostClass changeCostClass = new ChangeCostClass();
  87. changeCostClass.SetUpICardEffect($"Play/Use Cost -{reducecost}", CanUseCondition1, card);
  88. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: PlayOrUseCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  89. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  90. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  91. ICardEffect GetCardEffect(EffectTiming _timing)
  92. {
  93. if (_timing == EffectTiming.None)
  94. {
  95. return changeCostClass;
  96. }
  97. return null;
  98. }
  99. bool CanUseCondition1(Hashtable hashtable)
  100. {
  101. return true;
  102. }
  103. bool PlayOrUseCondition(CardSource cardSource)
  104. {
  105. return true;
  106. }
  107. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  108. {
  109. if (PlayOrUseCondition(cardSource)
  110. && RootCondition(root)
  111. && PermanentsCondition(targetPermanents))
  112. {
  113. Cost -= reducecost;
  114. }
  115. return Cost;
  116. }
  117. bool PermanentsCondition(List<Permanent> targetPermanents)
  118. {
  119. return targetPermanents == null
  120. || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  121. }
  122. bool RootCondition(SelectCardEffect.Root root)
  123. {
  124. return true;
  125. }
  126. bool isUpDown()
  127. {
  128. return true;
  129. }
  130. #endregion
  131. if (selectedCard.IsOption)
  132. {
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  134. cardSources: new List<CardSource> { selectedCard },
  135. activateClass: activateClass,
  136. payCost: true,
  137. root: SelectCardEffect.Root.Hand));
  138. }
  139. else
  140. {
  141. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  142. cardSources: new List<CardSource> { selectedCard },
  143. activateClass: activateClass,
  144. payCost: true,
  145. isTapped: false,
  146. root: SelectCardEffect.Root.Hand,
  147. activateETB: true));
  148. }
  149. #region release reduction
  150. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  151. #endregion
  152. isUsed = true;
  153. }
  154. if (!isUsed) activateClass.RemoveUse();
  155. }
  156. }
  157. #endregion
  158. #region All Turns Inherited
  159. if (timing == EffectTiming.None)
  160. {
  161. bool Condition()
  162. {
  163. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  164. }
  165. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 1000, isInheritedEffect: true, card: card, condition: Condition));
  166. }
  167. #endregion
  168. return cardEffects;
  169. }
  170. }
  171. }