| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- //Hakubamon
- namespace DCGO.CardEffects.EX12
- {
- public class EX12_043 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region Alternative Digivolution Condition
- if (timing == EffectTiming.None)
- {
- bool PermanentCondition(Permanent targetPermanent)
- {
- return targetPermanent.TopCard.HasText("Shambala");
- }
- cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
- permanentCondition: PermanentCondition,
- digivolutionCost: 2,
- ignoreDigivolutionRequirement: false,
- card: card,
- condition: null,
- level: 3)
- );
- }
- #endregion
- #region Main
- if (timing == EffectTiming.OnDeclaration)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("May play/use 1 card with [SW] trait from hand for 2 less", CanUseCondition, card);
- activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDescription());
- activateClass.SetHashString("EX12_043_Main");
- cardEffects.Add(activateClass);
- string EffectDescription()
- => "[Main] [Once Per Turn] You may play or use 1 card with the [SW] trait from your hand with the cost reduced by 2.";
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleArea(card)
- && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
- }
- bool CanSelectCardCondition(CardSource cardSource)
- {
- return cardSource.EqualsTraits("SW")
- && ((cardSource.IsOption
- && !cardSource.CanNotPlayThisOption)
- || (cardSource.HasPlayCost
- && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass, fixedCost: cardSource.GetCostItself - 2)));
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- bool isUsed = false;
- CardSource selectedCard = null;
- #region Selected card in hand to play/use
- SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
- selectHandEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: 1,
- canNoSelect: true,
- canEndNotMax: false,
- isShowOpponent: true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- mode: SelectHandEffect.Mode.Custom,
- cardEffect: activateClass);
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedCard = cardSource;
- yield return null;
- }
- selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
- selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
- yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
- #endregion
- if (selectedCard != null)
- {
- isUsed = true;
- #region Reduce Cost
- IEnumerator ReduceCost(string type)
- {
- if (card.Owner.CanReduceCost(null, card))
- {
- ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
- }
- Hashtable hashtable = new Hashtable
- {
- { "CardEffect", activateClass }
- };
- ChangeCostClass changeCostClass = new ChangeCostClass();
- changeCostClass.SetUpICardEffect($"{type} cost: -2", CanUseCondition1, card);
- changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
- card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
- bool CanUseCondition1(Hashtable hashtable)
- {
- return true;
- }
- int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
- {
- if (CardSourceCondition(cardSource) &&
- RootCondition(root) &&
- PermanentsCondition(targetPermanents))
- {
- cost -= 2;
- }
- return cost;
- }
- bool PermanentsCondition(List<Permanent> targetPermanents)
- {
- return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
- }
- bool CardSourceCondition(CardSource cardSource)
- {
- return cardSource != null
- && cardSource.Owner == card.Owner;
- }
- bool RootCondition(SelectCardEffect.Root root)
- {
- return true;
- }
- bool isUpDown()
- {
- return true;
- }
- }
- #endregion
- if (selectedCard.IsOption)
- {
- yield return ContinuousController.instance.StartCoroutine(ReduceCost("Use"));
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
- cardSources: new List<CardSource>() { selectedCard },
- activateClass: activateClass,
- payCost: true,
- root: SelectCardEffect.Root.Hand));
- }
- else
- {
- yield return ContinuousController.instance.StartCoroutine(ReduceCost("Play"));
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
- cardSources: new List<CardSource>() { selectedCard },
- activateClass: activateClass,
- payCost: true,
- isTapped: false,
- root: SelectCardEffect.Root.Hand,
- activateETB: true));
- }
- }
- if (!isUsed) activateClass.RemoveUse();
- }
- }
- #endregion
- #region Inherited Barrier
- if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
- {
- cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: true, card: card, condition: null));
- }
- #endregion
- return cardEffects;
- }
- }
- }
|