| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- using System.Collections;
- using System.Collections.Generic;
- // Royal Base
- namespace DCGO.CardEffects.P
- {
- public class P_181 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region Your Turn Face Up Security
- if (timing == EffectTiming.BeforePayCost)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Reduce Digivolve Cost", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
- activateClass.SetHashString("P-181-ReduceDigivovleCost");
- cardEffects.Add(activateClass);
- string EffectDiscription()
- => "[Security] [Your Turn] [Once Per Turn] When any of your Digimon would digivolve into a Digimon card with the [Royal Base] trait, reduce the digivolution cost by 1.";
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistInSecurity(card, false) &&
- CardEffectCommons.IsOwnerTurn(card) &&
- CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, DigivolveTargetCondition, DigivolveCondition);
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistInSecurity(card, false);
- }
- bool DigivolveTargetCondition(Permanent permanent)
- => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
- bool DigivolveCondition(CardSource source)
- => source.IsDigimon
- && source.HasRoyalBaseTraits;
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
- ChangeCostClass changeCostClass = new ChangeCostClass();
- changeCostClass.SetUpICardEffect("Digivolve Cost -1", hashtable => true, card);
- changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: root => true, isUpDown: () => true, isCheckAvailability: () => false, isChangePayingCost: () => true);
- card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
- int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
- {
- if (CardSourceCondition(cardSource))
- {
- if (PermanentsCondition(targetPermanents))
- {
- Cost -= 1;
- }
- }
- return Cost;
- }
- bool PermanentsCondition(List<Permanent> targetPermanents)
- => targetPermanents != null;
- bool CardSourceCondition(CardSource cardSource)
- {
- if (cardSource != null)
- {
- return cardSource.Owner == card.Owner &&
- cardSource.HasRoyalBaseTraits;
- }
- return false;
- }
- }
- }
- #endregion
- #region Main Effect
- if (timing == EffectTiming.OptionSkill)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Add top sec to hand, send this to bottom sec", CanUseCondition, card);
- activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
- cardEffects.Add(activateClass);
- string EffectDescription()
- {
- return "[Main] Add your top security card to the hand. Then, place this card face up as the bottom security card.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- if (card.Owner.SecurityCards.Count >= 1)
- {
- // Add your top security card to the hand
- CardSource topSecCard = card.Owner.SecurityCards[0];
- yield return ContinuousController.instance.StartCoroutine(
- CardObjectController.AddHandCards(new List<CardSource>() { topSecCard }, false, activateClass));
- yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
- player: card.Owner,
- refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
- activateClass).ReduceSecurity());
- }
- // Place this card face up as the bottom security card
- if (card.Owner.CanAddSecurity(activateClass))
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
- card, toTop: false, faceUp: true));
- }
- }
- }
- #endregion
- #region Security Effect
- if (timing == EffectTiming.SecuritySkill)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect($"Play 1 [Royal Base] Digimon card from hand", CanUseCondition, card);
- activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
- activateClass.SetIsSecurityEffect(true);
- cardEffects.Add(activateClass);
- string EffectDescription()
- {
- return
- "[Security] You may play 1 level 5 or lower [Royal Base] trait Digimon card from your hand without paying the cost.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
- }
- bool CanSelectCardCondition(CardSource cardSource)
- {
- return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 5 &&
- cardSource.HasRoyalBaseTraits &&
- CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
- {
- List<CardSource> selectedCards = new List<CardSource>();
- 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);
- selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
- selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
- yield return StartCoroutine(selectHandEffect.Activate());
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedCards.Add(cardSource);
- yield return null;
- }
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
- cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
- root: SelectCardEffect.Root.Hand, activateETB: true));
- }
- }
- }
- #endregion
- return cardEffects;
- }
- }
- }
|