| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using System.Collections;
- using System.Collections.Generic;
- public partial class CardEffectCommons
- {
- static bool CanSelectPermanentCondition(Permanent permanent, string trait, CardSource cardSource)
- {
- return IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, cardSource) &&
- permanent != cardSource.PermanentOfThisCard() &&
- (permanent.IsToken || permanent.TopCard.ContainsTraits(trait));
- }
- #region Can activate [Overclock]
- public static bool CanActivateOverclock(string trait, CardSource cardSource, ICardEffect activateClass)
- {
- return IsExistOnBattleArea(cardSource) &&
- HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, trait, cardSource)) &&
- cardSource.PermanentOfThisCard().CanAttack(activateClass, withoutTap: true);
- }
- #endregion
- #region Effect process of [Overclock]
- public static IEnumerator OverclockProcess(string trait, CardSource cardSource, ICardEffect activateClass)
- {
- if (HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, trait, cardSource)))
- {
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: cardSource.Owner,
- canTargetCondition: permanent => CanSelectPermanentCondition(permanent, trait, cardSource),
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: 1,
- canNoSelect: true,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectPermanentCoroutine,
- afterSelectPermanentCoroutine: null,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
- "The opponent is selecting 1 Digimon to delete.");
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- IEnumerator SelectPermanentCoroutine(Permanent permanent)
- {
- yield return ContinuousController.instance.StartCoroutine(
- DeletePeremanentAndProcessAccordingToResult(
- targetPermanents: new List<Permanent>() { permanent },
- activateClass: activateClass,
- successProcess: _ => SuccessProcess(),
- failureProcess: null));
- IEnumerator SuccessProcess()
- {
- Permanent selectedPermanent = cardSource.PermanentOfThisCard();
- if (selectedPermanent.CanAttack(activateClass, withoutTap: true))
- {
- SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
- selectAttackEffect.SetUp(
- attacker: selectedPermanent,
- canAttackPlayerCondition: () => true,
- defenderCondition: _ => false,
- cardEffect: activateClass);
- selectAttackEffect.SetWithoutTap();
- yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
- }
- }
- }
- }
- }
- #endregion
- #region Target 1 Digimon gains [Overclock]
- public static IEnumerator GainOverclock(string trait, Permanent targetPermanent, EffectDuration effectDuration,
- ICardEffect activateClass)
- {
- if (targetPermanent == null) yield break;
- if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
- if (activateClass == null) yield break;
- if (activateClass.EffectSourceCard == null) yield break;
- CardSource card = activateClass.EffectSourceCard;
- bool CanUseCondition()
- {
- return IsPermanentExistsOnBattleArea(targetPermanent) &&
- !targetPermanent.TopCard.CanNotBeAffected(activateClass);
- }
- ActivateClass overclock = CardEffectFactory.OverclockEffect(
- trait: trait,
- targetPermanent: targetPermanent,
- isInheritedEffect: false,
- condition: CanUseCondition,
- rootCardEffect: activateClass,
- targetPermanent.TopCard);
- AddEffectToPermanent(
- targetPermanent: targetPermanent,
- effectDuration: effectDuration,
- card: card,
- cardEffect: overclock,
- timing: EffectTiming.OnAllyAttack);
- if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
- .CreateBuffEffect(targetPermanent));
- }
- }
- #endregion
- }
|