| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using Photon.Pun;
- namespace DCGO.CardEffects.BT19
- {
- public class BT19_099 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region Main
- if (timing == EffectTiming.OptionSkill)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Play 1 [Composite] trait Digimon card from your trash with the play cost reduced by 4.", CanUseCondition, card);
- activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[Main] You may play 1 [Composite] trait Digimon card from your trash with the play cost reduced by 4. Then, place this card in the battle area.";
- }
- bool HasCompositeTrait(CardSource cardSource)
- {
- if (cardSource.IsDigimon)
- return cardSource.ContainsTraits("Composite");
- return false;
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- if(CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasCompositeTrait))
- {
- #region reduce play cost
- ChangeCostClass changeCostClass = new ChangeCostClass();
- changeCostClass.SetUpICardEffect($"Play Cost -4", CanUseCondition1, card);
- changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
- Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
- card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
- ICardEffect GetCardEffect(EffectTiming _timing)
- {
- if (_timing == EffectTiming.None)
- {
- return changeCostClass;
- }
- return null;
- }
- bool CanUseCondition1(Hashtable hashtable)
- {
- return true;
- }
- int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
- {
- if (CardSourceCondition(cardSource))
- {
- if (RootCondition(root))
- {
- if (PermanentsCondition(targetPermanents))
- {
- Cost -= 4;
- }
- }
- }
- return Cost;
- }
- bool PermanentsCondition(List<Permanent> targetPermanents)
- {
- if (targetPermanents == null)
- {
- return true;
- }
- else
- {
- if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
- {
- return true;
- }
- }
- return false;
- }
- bool CardSourceCondition(CardSource cardSource)
- {
- if (cardSource.HasPlayCost)
- {
- if (cardSource.IsDigimon)
- return cardSource.ContainsTraits("Composite");
- }
- return false;
- }
- bool RootCondition(SelectCardEffect.Root root)
- {
- return true;
- }
- bool isUpDown()
- {
- return true;
- }
- #endregion
- List<CardSource> selectedCards = new List<CardSource>();
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: HasCompositeTrait,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: null,
- afterSelectCardCoroutine: SelectCardCoroutine,
- message: "Select 1 [Composite] trait Digimon card to play.",
- maxCount: 1,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Trash,
- customRootCardList: null,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: activateClass);
- selectCardEffect.SetUpCustomMessage(
- "Select 1 [Composite] trait Digimon card to play.",
- "The opponent is selecting 1 [Composite] trait Digimon card to play.");
- selectCardEffect.SetUpCustomMessage_ShowCard("Play Card");
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- IEnumerator SelectCardCoroutine(List<CardSource> sources)
- {
- selectedCards = sources;
- yield return null;
- }
- #region Place As Source
- if (selectedCards.Count > 0)
- {
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
- cardSources: selectedCards,
- activateClass: activateClass,
- payCost: true,
- isTapped: false,
- root: SelectCardEffect.Root.Trash,
- activateETB: true));
- }
- #endregion
- #region Remove Cost effect after use
- card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
- #endregion
- }
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
- }
- }
- #endregion
- #region All Turns - Delay
- if (timing == EffectTiming.WhenRemoveField)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Play 1 [Wicked God] trait Digimon card from hand or trash", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[All Turns] When any of your Digimon with [Millenniummon] in its name would leave the battle area, <Delay>.\r\n• You may play 1 [Wicked God] trait Digimon card with a play cost 1 greater than that Digimon from your hand or trash without paying the cost.";
- }
- bool PermanentCondition(Permanent permanent)
- {
- if (CardEffectCommons.IsOwnerPermanent(permanent, card))
- {
- return permanent.TopCard.ContainsCardName("Millenniummon");
- }
- return false;
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleArea(card))
- {
- if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition))
- {
- if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
- {
- return true;
- }
- }
- }
- return false;
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleArea(card))
- {
- if (card.PermanentOfThisCard().CanBeDestroyedBySkill(activateClass))
- {
- return true;
- }
- }
- return false;
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- bool deleted = false;
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
- targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
- activateClass: activateClass,
- successProcess: permanents => SuccessProcess(),
- failureProcess: null));
- IEnumerator SuccessProcess()
- {
- deleted = true;
- yield return null;
- }
- if (deleted)
- {
- List<Permanent> selectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable);
- bool CanPlayWickedGodCondition(CardSource cardSource)
- {
- foreach (Permanent permanent in selectedPermanents)
- {
- if (PermanentCondition(permanent))
- {
- if(permanent.TopCard.GetCostItself + 1 == cardSource.GetCostItself)
- {
- if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
- {
- return cardSource.IsDigimon &&
- cardSource.ContainsTraits("Wicked God");
- }
- }
- }
- }
- return false;
- }
- if (selectedPermanents.Count > 0)
- {
- if (card.Owner.HandCards.Count(CanPlayWickedGodCondition) >= 1 || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayWickedGodCondition))
- {
- if (card.Owner.HandCards.Count(CanPlayWickedGodCondition) >= 1 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayWickedGodCondition))
- {
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "From which area do you play a card?";
- string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- }
- else if (card.Owner.HandCards.Count(CanPlayWickedGodCondition) == 0 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayWickedGodCondition))
- {
- GManager.instance.userSelectionManager.SetBool(false);
- }
- else if (card.Owner.HandCards.Count(CanPlayWickedGodCondition) >= 1 && card.Owner.TrashCards.Count(CanPlayWickedGodCondition) == 0)
- {
- GManager.instance.userSelectionManager.SetBool(true);
- }
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
- List <CardSource> selectedCards = new List<CardSource>();
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedCards.Add(cardSource);
- yield return null;
- }
- if (fromHand)
- {
- int maxCount = 1;
- SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
- selectHandEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanPlayWickedGodCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: maxCount,
- canNoSelect: true,
- canEndNotMax: false,
- isShowOpponent: true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- mode: SelectHandEffect.Mode.Custom,
- cardEffect: activateClass);
- selectHandEffect.SetUpCustomMessage(
- "Select 1 [Wicked God] trait Digimon card to play.",
- "The opponent is selecting 1 [Wicked God] trait Digimon card to play.");
- selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
- yield return StartCoroutine(selectHandEffect.Activate());
- }
- else
- {
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: CanPlayWickedGodCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => false,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- message: "Select 1 [Wicked God] trait Digimon card to play.",
- maxCount: 1,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Trash,
- customRootCardList: null,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: activateClass);
- selectCardEffect.SetUpCustomMessage(
- "Select 1 [Wicked God] trait Digimon card to play.",
- "The opponent is selecting 1 [Wicked God] trait Digimon card to play.");
- selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- }
- SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
- if (!fromHand)
- {
- root = SelectCardEffect.Root.Trash;
- }
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
- cardSources: selectedCards,
- activateClass: activateClass,
- payCost: false,
- isTapped: false,
- root: root,
- activateETB: true));
- }
- }
- }
- }
- }
- #endregion
- #region Security
- if (timing == EffectTiming.SecuritySkill)
- {
- cardEffects.Add(CardEffectFactory.PlaceSelfDelayOptionSecurityEffect(card));
- }
- #endregion
- return cardEffects;
- }
- }
- }
|