| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770 |
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using System.Linq;
- using UnityEngine;
- public partial class CardEffectCommons
- {
- #region Reveal cards from top of deck and process for all of them
- public static IEnumerator RevealDeckTopCardsAndProcessForAll(
- int revealCount,
- SimplifiedSelectCardConditionClass simplifiedSelectCardCondition,
- RemainingCardsPlace remainingCardsPlace,
- ICardEffect activateClass,
- Func<List<CardSource>, IEnumerator> revealedCardsCoroutine = null,
- List<CardSource> refSelectedCards = null,
- bool isOpponentDeck = false)
- {
- if (revealCount <= 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player selectPlayer = effectSourceCard.Owner;
- if (selectPlayer == null) yield break;
- Player revealPlayer = isOpponentDeck ? selectPlayer.Enemy : selectPlayer;
- if (revealPlayer == null) yield break;
- if (revealPlayer.LibraryCards.Count == 0) yield break;
- if (simplifiedSelectCardCondition == null) yield break;
- RevealLibraryClass revealLibrary = new RevealLibraryClass(revealPlayer, revealCount);
- yield return ContinuousController.instance.StartCoroutine(revealLibrary.RevealLibrary());
- List<CardSource> selectedCards = revealLibrary.RevealedCards.Filter(simplifiedSelectCardCondition.CanTargetCondition);
- List<CardSource> remainingCards = revealLibrary.RevealedCards.Filter(cardSource => !selectedCards.Contains(cardSource));
- switch (simplifiedSelectCardCondition.Mode)
- {
- case SelectCardEffect.Mode.AddHand:
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(selectedCards, false, activateClass));
- if (selectedCards.Count >= 1)
- {
- string log = "";
- log += $"\nCard{Utils.PluralFormSuffix(selectedCards.Count)} added to hand:";
- foreach (CardSource cardSource in selectedCards)
- {
- log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
- }
- log += "\n";
- GManager.instance.playLog.AddLogString(log);
- }
- }
- break;
- case SelectCardEffect.Mode.Discard:
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(selectedCards, "Discarded Cards", true, true));
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCards(selectedCards));
- if (selectedCards.Count >= 1)
- {
- string log = "";
- log += $"\nTrash Card{Utils.PluralFormSuffix(selectedCards.Count)}:";
- foreach (CardSource cardSource in selectedCards)
- {
- log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
- }
- log += "\n";
- GManager.instance.playLog.AddLogString(log);
- }
- }
- break;
- case SelectCardEffect.Mode.Custom:
- if (simplifiedSelectCardCondition.SelectCardCoroutine != null)
- {
- foreach (CardSource selectedCard in selectedCards)
- {
- yield return ContinuousController.instance.StartCoroutine(simplifiedSelectCardCondition.SelectCardCoroutine(selectedCard));
- }
- }
- break;
- }
- if (revealedCardsCoroutine != null)
- {
- yield return ContinuousController.instance.StartCoroutine(revealedCardsCoroutine(revealLibrary.RevealedCards));
- }
- switch (remainingCardsPlace)
- {
- case RemainingCardsPlace.DeckBottom:
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryBottom(remainingCards, activateClass));
- break;
- case RemainingCardsPlace.DeckTop:
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryTop(remainingCards, activateClass));
- break;
- case RemainingCardsPlace.Trash:
- {
- yield return ContinuousController.instance.StartCoroutine(TrashRevealedCards(remainingCards, activateClass));
- if (remainingCards.Count >= 1)
- {
- string log = "";
- log += $"\nTrash Card{Utils.PluralFormSuffix(remainingCards.Count)}:";
- foreach (CardSource cardSource in remainingCards)
- {
- log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
- }
- log += "\n";
- GManager.instance.playLog.AddLogString(log);
- }
- }
- break;
- case RemainingCardsPlace.AddHand:
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(remainingCards, false, activateClass));
- if (remainingCards.Count >= 1)
- {
- string log = "";
- log += $"\nTrash Card{Utils.PluralFormSuffix(remainingCards.Count)}:";
- foreach (CardSource cardSource in remainingCards)
- {
- log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
- }
- log += "\n";
- GManager.instance.playLog.AddLogString(log);
- }
- }
- break;
- case RemainingCardsPlace.DeckTopOrBottom:
- if (remainingCards.Count >= 2)
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(remainingCards, "Remaining Cards", true, true));
- }
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryTopOrBottom(remainingCards, activateClass));
- break;
- }
- if (refSelectedCards != null)
- {
- foreach (CardSource selectedCard in selectedCards)
- {
- refSelectedCards.Add(selectedCard);
- }
- }
- revealLibrary.RevealedCards.ForEach(cardSource => cardSource.IsBeingRevealed = false);
- }
- #endregion
- #region Reveal cards from top of deck and select them
- public static IEnumerator SimplifiedRevealDeckTopCardsAndSelect(
- int revealCount,
- SimplifiedSelectCardConditionClass[] simplifiedSelectCardConditions,
- RemainingCardsPlace remainingCardsPlace,
- ICardEffect activateClass,
- Func<List<CardSource>, CardSource, bool> canTargetCondition_ByPreSelecetedList = null,
- Func<List<CardSource>, bool> canEndSelectCondition = null,
- bool canNoSelect = false,
- bool canEndNotMax = false,
- bool isSendAllCardsToSamePlace = false,
- bool isOpponentDeck = false,
- Func<List<CardSource>, IEnumerator> revealedCardsCoroutine = null)
- {
- if (revealCount <= 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player revealPlayer = effectSourceCard.Owner;
- if (revealPlayer == null) yield break;
- if (revealPlayer.LibraryCards.Count == 0) yield break;
- if (simplifiedSelectCardConditions == null) yield break;
- if (simplifiedSelectCardConditions.Length == 0) yield break;
- SelectCardConditionClass[] selectCardConditions = simplifiedSelectCardConditions.Map(selectCardConditionTuple =>
- new SelectCardConditionClass(
- canTargetCondition: selectCardConditionTuple.CanTargetCondition,
- canTargetCondition_ByPreSelecetedList: canTargetCondition_ByPreSelecetedList,
- canEndSelectCondition: canEndSelectCondition,
- canNoSelect: canNoSelect,
- selectCardCoroutine: selectCardConditionTuple.SelectCardCoroutine,
- message: selectCardConditionTuple.Message,
- maxCount: selectCardConditionTuple.MaxCount,
- canEndNotMax: canEndNotMax,
- mode: selectCardConditionTuple.Mode
- ));
- yield return ContinuousController.instance.StartCoroutine(RevealDeckTopCardsAndSelect(
- revealCount: revealCount,
- selectCardConditions: selectCardConditions,
- remainingCardsPlace: remainingCardsPlace,
- activateClass: activateClass,
- isSendAllCardsToSamePlace: isSendAllCardsToSamePlace,
- isOpponentDeck: isOpponentDeck,
- revealedCardsCoroutine: revealedCardsCoroutine
- ));
- }
- public static IEnumerator RevealDeckTopCardsAndSelect(
- int revealCount,
- SelectCardConditionClass[] selectCardConditions,
- RemainingCardsPlace remainingCardsPlace,
- ICardEffect activateClass,
- bool canNoAction = false,
- bool isSendAllCardsToSamePlace = false,
- bool isOpponentDeck = false,
- Func<List<CardSource>, IEnumerator> revealedCardsCoroutine = null)
- {
- if (revealCount <= 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player selectPlayer = effectSourceCard.Owner;
- if (selectPlayer == null) yield break;
- Player revealPlayer = isOpponentDeck ? selectPlayer.Enemy : selectPlayer;
- if (revealPlayer == null) yield break;
- if (revealPlayer.LibraryCards.Count == 0) yield break;
- if (selectCardConditions.Length == 0) yield break;
- RevealLibraryClass revealLibrary = new RevealLibraryClass(revealPlayer, revealCount);
- yield return ContinuousController.instance.StartCoroutine(revealLibrary.RevealLibrary());
- List<CardSource> revealedCards = revealLibrary.RevealedCards.Clone();
- List<CardSource> remainingCards = revealedCards.Clone();
- bool doAction = true;
- // バーニングスタークラッシャー(BT10-096)
- // ブレイジング・メモリーブースト
- if (selectCardConditions.Length >= 2)
- {
- if (canNoAction)
- {
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"Select cards", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"Not select", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "Will you select cards?";
- string notSelectPlayerMessage = "The opponent is wheter to select cards.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: selectPlayer, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- doAction = GManager.instance.userSelectionManager.SelectedBoolValue;
- }
- }
- if (doAction)
- {
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- foreach(SelectCardConditionClass selectCondition in selectCardConditions)
- {
- int maxCount = Math.Min(selectCondition.MaxCount, revealedCards.Count(selectCondition.CanTargetCondition));
- if (maxCount >= 1)
- {
- selectCardEffect.SetUp(
- canTargetCondition: selectCondition.CanTargetCondition,
- canTargetCondition_ByPreSelecetedList: selectCondition.CanTargetCondition_ByPreSelecetedList,
- canEndSelectCondition: selectCondition.CanEndSelectCondition,
- canNoSelect: () => selectCondition.CanNoSelect,
- selectCardCoroutine: selectCondition.SelectCardCoroutine,
- afterSelectCardCoroutine: AfterSelectCardCoroutine,
- message: selectCondition.Message,
- maxCount: maxCount,
- canEndNotMax: selectCondition.CanEndNotMax,
- isShowOpponent: true,
- mode: selectCondition.Mode,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: revealedCards,
- canLookReverseCard: true,
- selectPlayer: selectPlayer,
- cardEffect: activateClass);
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- }
- IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
- {
- foreach (CardSource cardSource in cardSources)
- {
- revealedCards.Remove(cardSource);
- }
- yield return null;
- }
- }
- remainingCards = revealedCards.Clone();
- /*SelectCardConditionClass selectCardCondition = selectCardConditions[0];
- int maxCount = Math.Min(selectCardCondition.MaxCount, revealedCards.Count(selectCardCondition.CanTargetCondition));
- //TODO: Clean this up - MBunch
- if (maxCount >= 1)
- {
- selectCardEffect.SetUp(
- canTargetCondition: selectCardCondition.CanTargetCondition,
- canTargetCondition_ByPreSelecetedList: selectCardCondition.CanTargetCondition_ByPreSelecetedList,
- canEndSelectCondition: selectCardCondition.CanEndSelectCondition,
- canNoSelect: () => selectCardCondition.CanNoSelect,
- selectCardCoroutine: selectCardCondition.SelectCardCoroutine,
- afterSelectCardCoroutine: AfterSelectCardCoroutine,
- message: selectCardCondition.Message,
- maxCount: maxCount,
- canEndNotMax: selectCardCondition.CanEndNotMax,
- isShowOpponent: true,
- mode: selectCardCondition.Mode,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: revealedCards,
- canLookReverseCard: true,
- selectPlayer: selectPlayer,
- cardEffect: activateClass);
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
- {
- foreach (CardSource cardSource in cardSources)
- {
- remainingCards = revealedCards.Filter(cardSource => !cardSources.Contains(cardSource));
- }
- yield return null;
- }
- }
- remainingCards = revealedCards.Clone();
- if (selectCardConditions.Length >= 2)
- {
- SelectCardConditionClass selectCardCondition1 = selectCardConditions[1];
- maxCount = Math.Min(selectCardCondition1.MaxCount, revealedCards.Count(selectCardCondition1.CanTargetCondition));
- if (maxCount >= 1)
- {
- selectCardEffect.SetUp(
- canTargetCondition: selectCardCondition1.CanTargetCondition,
- canTargetCondition_ByPreSelecetedList: selectCardCondition1.CanTargetCondition_ByPreSelecetedList,
- canEndSelectCondition: selectCardCondition1.CanEndSelectCondition,
- canNoSelect: () => selectCardCondition1.CanNoSelect,
- selectCardCoroutine: selectCardCondition1.SelectCardCoroutine,
- afterSelectCardCoroutine: AfterSelectCardCoroutine1,
- message: selectCardCondition1.Message,
- maxCount: maxCount,
- canEndNotMax: selectCardCondition1.CanEndNotMax,
- isShowOpponent: true,
- mode: selectCardCondition1.Mode,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: revealedCards,
- canLookReverseCard: true,
- selectPlayer: selectPlayer,
- cardEffect: activateClass);
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
- {
- remainingCards = revealedCards.Filter(cardSource => !cardSources.Contains(cardSource));
- yield return null;
- }
- }
- }*/
- }
- if (isSendAllCardsToSamePlace)
- {
- remainingCards = revealLibrary.RevealedCards.Clone();
- }
- switch (remainingCardsPlace)
- {
- case RemainingCardsPlace.DeckBottom:
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryBottom(remainingCards, activateClass));
- break;
- case RemainingCardsPlace.DeckTop:
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryTop(remainingCards, activateClass));
- break;
- case RemainingCardsPlace.Trash:
- yield return ContinuousController.instance.StartCoroutine(TrashRevealedCards(remainingCards, activateClass));
- break;
- case RemainingCardsPlace.AddHand:
- yield return ContinuousController.instance.StartCoroutine(AddRevealedCardsToHand(remainingCards, activateClass));
- break;
- case RemainingCardsPlace.DeckTopOrBottom:
- if (remainingCards.Count >= 2)
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(
- remainingCards,
- "Remaining Cards",
- true,
- true));
- }
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryTopOrBottom(remainingCards, activateClass));
- break;
- }
- if (revealedCardsCoroutine != null)
- {
- yield return ContinuousController.instance.StartCoroutine(revealedCardsCoroutine(revealLibrary.RevealedCards));
- }
- revealLibrary.RevealedCards.ForEach(cardSource => cardSource.IsBeingRevealed = false);
- }
- #endregion
- #region Return revealed cards to the bottom of deck by any order
- public static IEnumerator ReturnRevealedCardsToLibraryBottom(List<CardSource> remainingCards, ICardEffect activateClass)
- {
- if (remainingCards.Count == 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player selectPlayer = effectSourceCard.Owner;
- if (selectPlayer == null) yield break;
- if (remainingCards.Count == 1)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(remainingCards));
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(remainingCards, "Deck Bottom Card", true, true));
- }
- else
- {
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: (cardSource) => true,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => false,
- selectCardCoroutine: null,
- afterSelectCardCoroutine: AfterSelectCardCoroutine1,
- message: "Specify the order to place the card at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
- maxCount: remainingCards.Count,
- canEndNotMax: false,
- isShowOpponent: false,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: remainingCards,
- canLookReverseCard: true,
- selectPlayer: selectPlayer,
- cardEffect: activateClass);
- selectCardEffect.SetNotShowCard();
- selectCardEffect.SetNotAddLog();
- selectCardEffect.SetIsDeckBottom();
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- static IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(cardSources,
- "Deck Bottom Cards", true, true));
- }
- }
- }
- #endregion
- #region Return revealed cards to the top of deck by any order
- static IEnumerator ReturnRevealedCardsToLibraryTop(List<CardSource> remainingCards, ICardEffect activateClass)
- {
- if (remainingCards.Count == 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player selectPlayer = effectSourceCard.Owner;
- if (selectPlayer == null) yield break;
- if (remainingCards.Count == 1)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(remainingCards));
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(remainingCards, "Deck Top Card", true, true));
- }
- else
- {
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: (cardSource) => true,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => false,
- selectCardCoroutine: null,
- afterSelectCardCoroutine: AfterSelectCardCoroutine1,
- message: "Specify the order to place the card at the top of the deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).",
- maxCount: remainingCards.Count,
- canEndNotMax: false,
- isShowOpponent: false,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: remainingCards,
- canLookReverseCard: true,
- selectPlayer: selectPlayer,
- cardEffect: activateClass);
- selectCardEffect.SetNotShowCard();
- selectCardEffect.SetNotAddLog();
- selectCardEffect.SetIsDeckTop();
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- static IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
- {
- List<CardSource> topCards = cardSources.Clone();
- topCards.Reverse();
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(topCards));
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(cardSources, "Deck Top Cards", true, true));
- }
- }
- }
- #endregion
- #region Trash revealed cards
- static IEnumerator TrashRevealedCards(List<CardSource> remainingCards, ICardEffect activateClass)
- {
- if (remainingCards.Count == 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player selectPlayer = effectSourceCard.Owner;
- if (selectPlayer == null) yield break;
- yield return ContinuousController.instance.StartCoroutine(new ITrashDeckCards(remainingCards, activateClass).TrashDeckCards());
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(remainingCards, "Discarded Cards", true, true));
- }
- #endregion
- #region Add revealed cards to hand
- static IEnumerator AddRevealedCardsToHand(List<CardSource> remainingCards, ICardEffect activateClass)
- {
- if (remainingCards.Count == 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player selectPlayer = effectSourceCard.Owner;
- if (selectPlayer == null) yield break;
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(remainingCards, false, activateClass));
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(remainingCards, "Card added to hand", true, true));
- }
- #endregion
- #region Return revealed cards to the top or bottom of deck by any order
- static IEnumerator ReturnRevealedCardsToLibraryTopOrBottom(List<CardSource> remainingCards, ICardEffect activateClass)
- {
- if (remainingCards.Count == 0) yield break;
- if (activateClass == null) yield break;
- CardSource effectSourceCard = activateClass.EffectSourceCard;
- if (effectSourceCard == null) yield break;
- Player selectPlayer = effectSourceCard.Owner;
- if (selectPlayer == null) yield break;
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"Deck Top", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"Deck Bottom", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "To which area do you place cards?";
- string notSelectPlayerMessage = "The opponent is choosing to which area to place cards.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: selectPlayer, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
- if (toTop)
- {
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryTop(remainingCards, activateClass));
- }
- else
- {
- yield return ContinuousController.instance.StartCoroutine(ReturnRevealedCardsToLibraryBottom(remainingCards, activateClass));
- }
- }
- #endregion
- }
- #region Select conditions class
- public class SimplifiedSelectCardConditionClass
- {
- public SimplifiedSelectCardConditionClass(Func<CardSource, bool> canTargetCondition,
- string message,
- SelectCardEffect.Mode mode,
- int maxCount,
- Func<CardSource, IEnumerator> selectCardCoroutine)
- {
- _canTargetCondition = canTargetCondition;
- _selectCardCoroutine = selectCardCoroutine;
- _message = message;
- _maxCount = maxCount;
- _mode = mode;
- }
- Func<CardSource, bool> _canTargetCondition = null;
- Func<CardSource, IEnumerator> _selectCardCoroutine = null;
- string _message = null;
- int _maxCount = 0;
- SelectCardEffect.Mode _mode = SelectCardEffect.Mode.Custom;
- public Func<CardSource, bool> CanTargetCondition { get { return _canTargetCondition; } }
- public Func<CardSource, IEnumerator> SelectCardCoroutine { get { return _selectCardCoroutine; } }
- public string Message { get { return _message; } }
- public int MaxCount { get { return _maxCount; } }
- public SelectCardEffect.Mode Mode { get { return _mode; } }
- }
- public class SelectCardConditionClass
- {
- public SelectCardConditionClass(Func<CardSource, bool> canTargetCondition,
- Func<List<CardSource>, CardSource, bool> canTargetCondition_ByPreSelecetedList,
- Func<List<CardSource>, bool> canEndSelectCondition,
- bool canNoSelect,
- Func<CardSource, IEnumerator> selectCardCoroutine,
- string message,
- int maxCount,
- bool canEndNotMax,
- SelectCardEffect.Mode mode)
- {
- _canTargetCondition = canTargetCondition;
- _canTargetCondition_ByPreSelecetedList = canTargetCondition_ByPreSelecetedList;
- _canEndSelectCondition = canEndSelectCondition;
- _canNoSelect = canNoSelect;
- _selectCardCoroutine = selectCardCoroutine;
- _message = message;
- _maxCount = maxCount;
- _canEndNotMax = canEndNotMax;
- _mode = mode;
- }
- Func<CardSource, bool> _canTargetCondition = null;
- Func<List<CardSource>, CardSource, bool> _canTargetCondition_ByPreSelecetedList = null;
- Func<List<CardSource>, bool> _canEndSelectCondition = null;
- bool _canNoSelect = false;
- Func<CardSource, IEnumerator> _selectCardCoroutine = null;
- string _message = null;
- int _maxCount = 0;
- bool _canEndNotMax = false;
- SelectCardEffect.Mode _mode = SelectCardEffect.Mode.Custom;
- public Func<CardSource, bool> CanTargetCondition { get { return _canTargetCondition; } }
- public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get { return _canTargetCondition_ByPreSelecetedList; } }
- public Func<List<CardSource>, bool> CanEndSelectCondition { get { return _canEndSelectCondition; } }
- public bool CanNoSelect { get { return _canNoSelect; } }
- public Func<CardSource, IEnumerator> SelectCardCoroutine { get { return _selectCardCoroutine; } }
- public string Message { get { return _message; } }
- public int MaxCount { get { return _maxCount; } }
- public bool CanEndNotMax { get { return _canEndNotMax; } }
- public SelectCardEffect.Mode Mode { get { return _mode; } }
- }
- #endregion
- #region In which area the remaining cards are placed
- public enum RemainingCardsPlace
- {
- DeckBottom,
- DeckTop,
- DeckTopOrBottom,
- Trash,
- AddHand,
- None,
- }
- #endregion
- #region Reveal deck cards
- public class RevealLibraryClass
- {
- public RevealLibraryClass(Player player, int revealCount)
- {
- _player = player;
- _revealCount = revealCount;
- }
- Player _player = null;
- int _revealCount = 0;
- List<CardSource> _revealedCards = new List<CardSource>();
- public List<CardSource> RevealedCards => _revealedCards.Clone();
- public IEnumerator RevealLibrary()
- {
- _revealedCards = new List<CardSource>();
- for (int i = 0; i < _revealCount; i++)
- {
- if (_player.LibraryCards.Count > i)
- {
- _revealedCards.Add(_player.LibraryCards[i]);
- }
- }
- if (RevealedCards.Count >= 1)
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(RevealedCards, "Revealed Cards", true, true));
- }
- #region ログ追加
- if (RevealedCards.Count >= 1)
- {
- string log = "";
- log += $"\nRevealed Cards:";
- foreach (CardSource cardSource in RevealedCards)
- {
- if (cardSource != null)
- {
- log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
- }
- }
- log += "\n";
- GManager.instance.playLog.AddLogString(log);
- }
- #endregion
- yield return new WaitForSeconds(0.5f);
- _revealedCards.ForEach(cardSource => cardSource.IsBeingRevealed = true);
- }
- }
- #endregion
|