| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Linq;
- using Photon;
- using System;
- using Photon.Pun;
- using System.Runtime.InteropServices.WindowsRuntime;
- public class Magnadramon_BT15_042 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region All Turns
- if (timing == EffectTiming.OnLoseSecurity)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Place 1 yellow card from your hand to the top or bottom of your security stack.", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[All Turns][Once per turn] When a card is removed from your security stack, if you have 3 or less security cards, you may place 1 yellow card from your hand at the top or bottom of your security stack.";
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleArea(card))
- {
- return true;
- }
- return false;
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleArea(card))
- {
- if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner))
- {
- return true;
- if (card.Owner.SecurityCards.Count() <= 3)
- {
- return true;
- }
- }
- }
- return false;
- }
- bool CanSelectCardCondition(CardSource cardSource)
- {
- if(cardSource.CardColors.Contains(CardColor.Yellow))
- {
- return true;
- }
- return false;
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- if (card.Owner.SecurityCards.Count <= 3)
- {
- if (card.Owner.CanAddSecurity(activateClass))
- {
- if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
- {
- List<CardSource> selectedCard = new List<CardSource>();
- int maxCount = 1;
- SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
- selectHandEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectCardCondition,
- 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 card to place at the top or bottom of security.",
- "The opponent is selecting 1 card to place at the bottom of security.");
- selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
- yield return StartCoroutine(selectHandEffect.Activate());
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- if (selectedCard != null)
- {
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "Will you place the card on the top or bottom of the security?";
- string notSelectPlayerMessage = "The opponent is selecting whether to place the card on the top or bottom of security.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
- if (toTop)
- {
- GManager.instance.commandText.OpenCommandText("\"Place to the top of security\" was selected.");
- GManager.instance.playLog.AddLogString($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the top of security\n");
- }
- else
- {
- GManager.instance.commandText.OpenCommandText("\"Place to the bottom of security\" was selected.");
- GManager.instance.playLog.AddLogString($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the bottom of security\n");
- }
- yield return new WaitForSeconds(0.4f);
- GManager.instance.commandText.CloseCommandText();
- yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
- selectedCard.Add(cardSource);
- yield return null;
- foreach (CardSource card in selectedCard)
- {
- if (toTop)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: true));
- }
- if (!toTop)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false));
- }
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateRecoveryEffect(card.Owner));
- yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(card.Owner).AddSecurity());
- }
- }
- }
- }
- }
- }
- }
- }
- #endregion
- #region On Play
- if (timing == EffectTiming.OnEnterFieldAnyone)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Trash the top or bottom of your security to reduce opponent's Digimon DP.", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
- activateClass.SetHashString("TrashSecuirtyToReduceDP_BT15_042");
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[On Play] By trashing the top or bottom card of your security stack, 1 of your opponent's Digimon gets -9000 DP until the end of your opponent's turn.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleArea(card))
- {
- if (card.Owner.SecurityCards.Count >= 1)
- {
- return true;
- }
- }
- return false;
- }
- bool CanSelectPermanentCondition(Permanent permanent)
- {
- if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
- {
- if (permanent.HasDP)
- {
- return true;
- }
- }
- return false;
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- if (card.Owner.SecurityCards.Count >= 1)
- {
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "Which will you trash the top or bottom card of the security?";
- string notSelectPlayerMessage = "The opponent is selecting whether to trash the top or bottom card of security.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- bool fromTop = GManager.instance.userSelectionManager.SelectedBoolValue;
- yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
- card.Owner,
- 1,
- activateClass,
- fromTop).DestroySecurity());
- if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
- {
- int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectPermanentCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: maxCount,
- canNoSelect: false,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectPermanentCoroutine,
- afterSelectPermanentCoroutine: null,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -9000.", "The opponent is selecting 1 Digimon that will get DP -9000.");
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- IEnumerator SelectPermanentCoroutine(Permanent permanent)
- {
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -9000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
- }
- }
- }
- }
- }
- #endregion
- #region When Digivolving
- if (timing == EffectTiming.OnEnterFieldAnyone)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Trash the top or bottom of your security to reduce opponent's Digimon DP.", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
- activateClass.SetHashString("TrashSecuirtyToReduceDP_BT15_042");
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[When Digivolving] By trashing the top or bottom card of your security stack, 1 of your opponent's Digimon gets -9000 DP until the end of your opponent's turn.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleArea(card))
- {
- if (card.Owner.SecurityCards.Count >= 1)
- {
- return true;
- }
- }
- return false;
- }
- bool CanSelectPermanentCondition(Permanent permanent)
- {
- if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
- {
- if (permanent.HasDP)
- {
- return true;
- }
- }
- return false;
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- if (card.Owner.SecurityCards.Count >= 1)
- {
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "Which will you trash the top or bottom card of the security?";
- string notSelectPlayerMessage = "The opponent is selecting whether to trash the top or bottom card of security.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- bool fromTop = GManager.instance.userSelectionManager.SelectedBoolValue;
- yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
- card.Owner,
- 1,
- activateClass,
- fromTop).DestroySecurity());
- if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
- {
- int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectPermanentCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: maxCount,
- canNoSelect: false,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectPermanentCoroutine,
- afterSelectPermanentCoroutine: null,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -9000.", "The opponent is selecting 1 Digimon that will get DP -9000.");
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- IEnumerator SelectPermanentCoroutine(Permanent permanent)
- {
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -9000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
- }
- }
- }
- }
- }
- #endregion
- return cardEffects;
- }
- }
|