| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- using System.Linq;
- public class Permanent
- {
- public Permanent(List<CardSource> cardSources)
- {
- SetCardSources(cardSources);
- }
- public void SetCardSources(List<CardSource> cardSources)
- {
- List<CardSource> newCardSources = cardSources.Clone();
- newCardSources.Reverse();
- foreach (CardSource cardSource in newCardSources)
- {
- AddCardSource(cardSource);
- }
- }
- public FieldCardFrame PermanentFrame
- {
- get
- {
- if (TopCard != null)
- {
- int index = Array.IndexOf(TopCard.Owner.FieldPermanents, this);
- if (0 <= index && index <= TopCard.Owner.fieldCardFrames.Count - 1)
- {
- return TopCard.Owner.fieldCardFrames[index];
- }
- }
- return null;
- }
- }
- public bool oldIsTapped_playCard { get; set; }
- #region Level
- public int Level
- {
- get
- {
- int Level = 0;
- if (TopCard != null)
- {
- Level = TopCard.Level;
- if (!TopCard.HasLevel)
- {
- Level = 1145140;
- }
- #region レベルを変更する効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangePermanentLevelEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangePermanentLevelEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
- }
- }
- }
- #endregion
- }
- #endregion
- }
- return Level;
- }
- }
- #endregion
- #region Place all evolution sources in the trash
- public IEnumerator DiscardEvoRoots(bool ignoreOverflow = false, bool putToTrash = true)
- {
- List<CardSource> evoRoots = DigivolutionCards.Clone();
- if (!ignoreOverflow)
- {
- yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(evoRoots).Overflow());
- }
- foreach (CardSource cardSource1 in evoRoots)
- {
- if (putToTrash)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource1));
- }
- else
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource1));
- }
- }
- }
- #endregion
- #region Whether this permanent has DP
- public bool HasDP
- {
- get
- {
- if (TopCard == null)
- {
- return false;
- }
- if (!IsDigimon)
- {
- return false;
- }
- if (!TopCard.HasDP && TopCard.IsDigiEgg)
- {
- return false;
- }
- #region Effect of not having DP
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is IDontHaveDPEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((IDontHaveDPEffect)cardEffect1).DontHaveDP(this))
- {
- return false;
- }
- }
- }
- }
- }
- }
- #endregion
- return true;
- }
- }
- #endregion
- #region Base DP
- public int BaseDP
- {
- get
- {
- int BaseDP = 0;
- if (HasDP)
- {
- BaseDP = TopCard.BaseCardDP;
- #region 基礎DPを変更する効果
- List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeBaseDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
- {
- if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
- {
- if (this.ImmuneFromDPMinus(cardEffect))
- {
- continue;
- }
- }
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeDP.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeBaseDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
- {
- if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
- {
- if (this.ImmuneFromDPMinus(cardEffect))
- {
- continue;
- }
- }
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeDP.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
- List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
- {
- if (cardEffect is IChangeBaseDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((IChangeBaseDPEffect)cardEffect).IsUpDown())
- {
- cardEffects_ChangeDP_isUpDown.Add(cardEffect);
- }
- else
- {
- cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
- }
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
- {
- if (cardEffect is IChangeBaseDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
- {
- if (cardEffect is IChangeBaseDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
- }
- }
- }
- #endregion
- if (BaseDP < 0)
- {
- BaseDP = 0;
- }
- }
- return BaseDP;
- }
- }
- #endregion
- #region DP
- public int DP
- {
- get
- {
- int DP = -1;
- if (HasDP)
- {
- DP = BaseDP;
- #region DPを変更する効果
- List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- #region Effects of permanents in play
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
- {
- if (((IChangeDPEffect)cardEffect).IsMinusDP())
- {
- if (this.ImmuneFromDPMinus(cardEffect))
- {
- continue;
- }
- }
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeDP.Add(cardEffect);
- }
- }
- }
- }
- }
- }
- #endregion
- #region Effects of face up security
- foreach (CardSource cardSource in player.SecurityCards)
- {
- if (cardSource.IsFlipped)
- continue;
- foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
- {
- if (((IChangeDPEffect)cardEffect).IsMinusDP())
- {
- if (this.ImmuneFromDPMinus(cardEffect))
- {
- continue;
- }
- }
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeDP.Add(cardEffect);
- }
- }
- }
- }
- }
- }
- #endregion
- #region Player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
- {
- if (((IChangeDPEffect)cardEffect).IsMinusDP())
- {
- if (this.ImmuneFromDPMinus(cardEffect))
- {
- continue;
- }
- }
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeDP.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
- List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((IChangeDPEffect)cardEffect).IsUpDown())
- {
- cardEffects_ChangeDP_isUpDown.Add(cardEffect);
- }
- else
- {
- cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
- }
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
- }
- }
- }
- #endregion
- if (DP < 0)
- {
- DP = 0;
- }
- }
- return DP;
- }
- }
- #endregion
- #region Will it not receive negative DP effect?
- public bool ImmuneFromDPMinus(ICardEffect cardEffect)
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is IImmuneFromDPMinusEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
- {
- return true;
- }
- }
- }
- }
- }
- foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is IImmuneFromDPMinusEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region Can be returned to your hand?
- public bool CannotReturnToHand(ICardEffect cardEffect)
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICannotReturnToHandEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
- {
- return true;
- }
- }
- }
- }
- foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICannotReturnToHandEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
- {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region Can be returned to deck?
- public bool CannotReturnToLibrary(ICardEffect cardEffect)
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICannotReturnToLibraryEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
- {
- return true;
- }
- }
- }
- }
- foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICannotReturnToLibraryEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
- {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region 退化を受けないか
- public bool ImmuneFromDeDigivolve()
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is IImmuneFromDeDigivolveEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((IImmuneFromDeDigivolveEffect)cardEffect1).ImmuneDeDigivolve(this))
- {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region このパーマネントの持つカードリスト
- public List<CardSource> cardSources = new List<CardSource>();
- #endregion
- #region 一番上以外のカード
- public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard);
- #endregion
- #region パーマネントのカードリストにカードを追加
- public void AddCardSource(CardSource cardSource)
- {
- cardSources.Insert(0, cardSource);
- cardSource.SetFace();
- }
- #endregion
- #region Add digivolution cards to top of sources
- /// <summary>
- /// IEnumerator to add a list of CardSource to a permanents top sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToDigivolutionCards
- /// </summary>
- /// <param name="addedDigivolutionCards"></param>
- /// <param name="cardEffect"></param>
- /// <param name="skipEffectAndActivateSkill"></param>
- /// <returns></returns>
- public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
- {
- List<CardSource> addedCards = new List<CardSource>();
- bool isFromSameDigimon = false;
- bool isFromDigimon = false;
- foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
- {
- if (cardSources.Contains(addedDigivolutionCard))
- {
- isFromSameDigimon = true;
- }
- if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
- {
- if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
- {
- isFromDigimon = true;
- }
- }
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
- if (!this.IsToken && !addedDigivolutionCard.IsToken)
- {
- this.cardSources.Insert(1, addedDigivolutionCard);
- addedDigivolutionCard.SetFace();
- addedCards.Add(addedDigivolutionCard);
- }
- }
- if (addedCards.Count >= 1)
- {
- if (ShowingPermanentCard != null)
- {
- yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
- }
- #region "進化元が増えた時"の効果
- #region Hashtable Setting
- Hashtable hashtable = new Hashtable()
- {
- {"Permanent", this},
- {"CardEffect", cardEffect},
- {"CardSources", addedCards},
- {"isFromSameDigimon", isFromSameDigimon},
- {"isFromDigimon", isFromDigimon},
- };
- #endregion
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
- #endregion
- }
- }
- #endregion
- #region Add digivolution cards to bottom of sources
- /// <summary>
- /// IEnumerator to add a list of CardSource to a permanents bottom sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToDigivolutionCards
- /// </summary>
- /// <param name="addedDigivolutionCards"></param>
- /// <param name="cardEffect"></param>
- /// <param name="skipEffectAndActivateSkill"></param>
- /// <returns></returns>
- public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false)
- {
- List<CardSource> addedCards = new List<CardSource>();
- bool isFromSameDigimon = false;
- bool isFromDigimon = false;
- foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
- {
- if (addedDigivolutionCard.PermanentOfThisCard() != null)
- {
- if (addedDigivolutionCard.PermanentOfThisCard() != this)
- {
- if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
- {
- IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
- yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
- if (!placePermanent.Placed)
- {
- continue;
- }
- }
- }
- }
- if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
- {
- if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
- {
- isFromDigimon = true;
- }
- }
- if (cardSources.Contains(addedDigivolutionCard))
- {
- isFromSameDigimon = true;
- if (addedDigivolutionCard == TopCard)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
- ShowingPermanentCard.ShowPermanentData(true);
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
- addedDigivolutionCard,
- this));
- }
- }
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
- if (!IsToken && !addedDigivolutionCard.IsToken)
- {
- cardSources.Add(addedDigivolutionCard);
- addedDigivolutionCard.SetFace();
- addedCards.Add(addedDigivolutionCard);
- }
- }
- if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
- {
- if (ShowingPermanentCard != null)
- {
- yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
- }
- #region Effect of "when the number of evolution sources increases"
- #region Hashtable Setting
- Hashtable hashtable = new Hashtable()
- {
- {"Permanent", this},
- {"CardEffect", cardEffect},
- {"CardSources", addedCards},
- {"isFromSameDigimon", isFromSameDigimon},
- {"isFromDigimon", isFromDigimon},
- };
- #endregion
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
- #endregion
- }
- }
- #endregion
- #region パーマネントのカードリストからカードを除く
- public IEnumerator RemoveCardSource(CardSource cardSource)
- {
- yield return null;
- cardSources.Remove(cardSource);
- }
- #endregion
- #region このパーマネントの一番上のカード
- public CardSource TopCard
- {
- get
- {
- if (cardSources.Count >= 1)
- {
- return cardSources[0];
- }
- return null;
- }
- }
- #endregion
- #region Permanent effect list
- #region このパーマネントの効果リスト
- public List<ICardEffect> EffectList(EffectTiming timing)
- {
- return EffectList_ForCard(timing, TopCard);
- }
- #endregion
- #region このポケモンの追加効果リスト
- public List<ICardEffect> EffectList_Added(EffectTiming timing)
- {
- List<ICardEffect> _EffectList = new List<ICardEffect>();
- if (TopCard != null)
- {
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
- {
- ICardEffect cardEffect = GetCardEffect(timing);
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
- foreach (ICardEffect cardEffect in _EffectList)
- {
- if (cardEffect != null)
- {
- if (cardEffect.EffectSourceCard == null)
- {
- cardEffect.SetEffectSourceCard(TopCard);
- }
- cardEffect.SetIsInheritedEffect(false);
- }
- }
- }
- return _EffectList;
- }
- #endregion
- #region このパーマネントの効果リスト(引数:CardSource)
- public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
- {
- List<ICardEffect> _EffectList = new List<ICardEffect>();
- if (TopCard != null && _cardSource != null)
- {
- foreach (CardSource cardSource in cardSources)
- {
- if (cardSource != null)
- {
- if (!cardSource.IsFlipped)
- {
- bool isTopCard = cardSource == TopCard;
- if (!isTopCard)
- {
- if (!IsDigimon)
- {
- continue;
- }
- }
- foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
- {
- if (cardEffect != null)
- {
- if (isTopCard == cardEffect.IsInheritedEffect)
- {
- continue;
- }
- _EffectList.Add(cardEffect);
- }
- }
- }
- }
- }
- foreach (ICardEffect cardEffect in EffectList_Added(timing))
- {
- if (cardEffect != null)
- {
- _EffectList.Add(cardEffect);
- }
- }
- foreach (ICardEffect cardEffect in _EffectList)
- {
- if (cardEffect != null)
- {
- if (cardEffect.EffectSourceCard == null)
- {
- cardEffect.SetEffectSourceCard(_cardSource);
- }
- }
- }
- }
- return _EffectList;
- }
- #endregion
- #region 自分のターン終了時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region 自分のドローフェイズ終了時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region お互いのターン終了時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region 相手のターン終了時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region バトル終了時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region 攻撃終了時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region 自分のターン開始時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region 次にアンタップする時に消える効果
- public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #region 場を離れるまで残る効果
- public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
- #endregion
- #endregion
- #region 起動型効果を宣言できるか
- public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
- #endregion
- #region 宣言可能な起動型効果リスト
- public List<ICardEffect> CanDeclareSkillList()
- {
- List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
- if (TopCard != null)
- {
- foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
- {
- if (_cardEffect is ActivateICardEffect)
- {
- if (_cardEffect.CanUse(null))
- {
- CanDeclareSkillList.Add(_cardEffect);
- }
- }
- }
- }
- return CanDeclareSkillList;
- }
- #endregion
- #region このパーマネントが場に出たターン
- public int EnterFieldTurnCount { get; set; } = -1;
- #endregion
- #region このパーマネントを表す場のオブジェクト
- public FieldPermanentCard ShowingPermanentCard { get; set; }
- #endregion
- #region Whether this permanent can be selected by the effect
- public bool CanSelectBySkill(ICardEffect skill)
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- #region Effects of field permanents
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotSelectBySkillEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
- {
- return false;
- }
- }
- }
- }
- }
- #endregion
- }
- return true;
- }
- #endregion
- #region Number of sheets to undergo security check
- public int InvertSecutiryValue
- {
- get
- {
- int Invert = 0;
- List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Effects of permanents in play
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IInvertSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_InvertStrike.Add(cardEffect);
- }
- }
- }
- }
- #endregion
- }
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IInvertSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_InvertStrike.Add(cardEffect);
- }
- }
- }
- }
- #endregion
- }
- foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
- {
- Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
- }
- return Mathf.Clamp(Invert,-1,1);
- }
- }
- public List<int> SecurityAttackChanges
- {
- get
- {
- List<int> SecurityAttackChanges = new List<int>();
- int Strike = 1;
- List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
- {
- cardEffects_ChangeDirectStrike.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
- {
- cardEffects_ChangeDirectStrike.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
- if (Strike1 != Strike)
- {
- SecurityAttackChanges.Add(Strike1 - Strike);
- }
- }
- }
- }
- return SecurityAttackChanges;
- }
- }
- public bool HasSecurityAttackChanges
- {
- get
- {
- if (!IsDigimon)
- {
- return false;
- }
- return SecurityAttackChanges.Count >= 1;
- }
- }
- public int Strike_AllowMinus
- {
- get
- {
- int Strike = 1;
- #region Effect of changing the number of sheets to undergo security check
- List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Effects of permanents in play
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeDirectStrike.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeDirectStrike.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
- List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
- List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
- foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- switch (((IChangeSAttackEffect)cardEffect).isUpDown())
- {
- case CalculateOrder.UpToConstant:
- cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
- break;
- case CalculateOrder.UpDownValue:
- cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
- break;
- case CalculateOrder.DownToConstant:
- cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
- break;
- }
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
- {
- if (cardEffect is IChangeSAttackEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
- }
- }
- }
- #endregion
- return Strike;
- }
- }
- public int Strike
- {
- get
- {
- int Strike = Strike_AllowMinus;
- if (Strike < 0)
- {
- Strike = 0;
- }
- return Strike;
- }
- }
- #endregion
- #region このパーマネントがタップされているかどうか
- public bool OldIsSuspended = false;
- public bool IsSuspended = false;
- public int DPWhenSuspended = 114514;
- #endregion
- #region Whether this permanent can unsuspend
- public bool CanUnsuspend
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- #region Effects of field permanents
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotUnsuspendEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
- {
- return false;
- }
- }
- }
- }
- }
- #endregion
- #region Effects of players
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotUnsuspendEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- return true;
- }
- }
- #endregion
- #region このパーマネントが移動できるかどうか
- public bool CanMove
- {
- get
- {
- if (TopCard != null)
- {
- #region the effects of permanents
- if (GManager.instance.turnStateMachine.gameContext.Players
- .Map(player => player.GetFieldPermanents())
- .Flat()
- .Map(permanent => permanent.EffectList(EffectTiming.None))
- .Flat()
- .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
- && cardEffect.CanUse(null)
- && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
- {
- return false;
- }
- #endregion
- #region the effects of players
- if (GManager.instance.turnStateMachine.gameContext.Players
- .Map(player => player.EffectList(EffectTiming.None))
- .Flat()
- .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
- && cardEffect.CanUse(null)
- && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
- {
- return false;
- }
- #endregion
- #region the effects of itself
- if (this == null)
- {
- if (EffectList(EffectTiming.None)
- .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
- && cardEffect.CanUse(null)
- && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
- {
- return false;
- }
- }
- #endregion
- if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
- {
- return false;
- }
- if (!IsDigimon)
- {
- return false;
- }
- if (DP <= 0)
- {
- return false;
- }
- if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- return true;
- }
- }
- #endregion
- #region このパーマネントが攻撃できるかどうか
- public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
- {
- // can not attack with empty cards
- if (TopCard == null)
- {
- return false;
- }
- // can not attack during opponent's turn
- if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
- {
- return false;
- }
- // can not attack to player
- if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex))
- {
- // can not attack to opponent's Digimon
- if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex)) == 0)
- {
- return false;
- }
- }
- return true;
- }
- #endregion
- #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
- public bool CanBlock(Permanent AttackingPermanent)
- {
- if (TopCard == null)
- {
- return false;
- }
- if (!IsDigimon)
- {
- return false;
- }
- if (IsSuspended)
- {
- return false;
- }
- if (!CanSuspend)
- {
- return false;
- }
- if (PermanentFrame != null)
- {
- if (!PermanentFrame.IsBattleAreaFrame())
- {
- return false;
- }
- }
- if (!AttackingPermanent.CanSwitchAttackTarget)
- return false;
- #region "Unblockable" effect
- #region Effects of permanents in play
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICannotBlockEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
- {
- return false;
- }
- }
- }
- }
- }
- }
- #endregion
- #region player effect
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICannotBlockEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- return false;
- }
- }
- }
- }
- }
- }
- #endregion
- #endregion
- return true;
- }
- #endregion
- #region 対象のパーマネントを攻撃できるか
- public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
- {
- if (TopCard != null)
- {
- if (!IsDigimon)
- {
- return false;
- }
- if (!withoutTap)
- {
- if (IsSuspended)
- {
- return false;
- }
- if (!CanSuspend)
- {
- return false;
- }
- }
- if (PermanentFrame != null)
- {
- if (!PermanentFrame.IsBattleAreaFrame())
- {
- return false;
- }
- }
- if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
- {
- if (!HasRush && !isVortex)
- {
- return false;
- }
- }
- #region 「対象の防御パーマネントを攻撃できない」効果
- #region 場のパーマネントの効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
- {
- if (!TopCard.CanNotBeAffected(cardEffect1))
- {
- return false;
- }
- }
- }
- }
- }
- }
- }
- #endregion
- #region プレイヤーの効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
- {
- if (!TopCard.CanNotBeAffected(cardEffect1))
- {
- return false;
- }
- }
- }
- }
- }
- }
- #endregion
- #endregion
- if (Defender != null)
- {
- if (Defender.TopCard != null)
- {
- if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
- {
- if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
- {
- if (Defender.IsSuspended)
- {
- return true;
- }
- #region 「対象の防御パーマネントを攻撃できる」効果
- #region 場のパーマネントの効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
- {
- return true;
- }
- }
- }
- }
- }
- }
- #endregion
- #region プレイヤーの効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
- {
- return true;
- }
- }
- }
- }
- }
- #endregion
- #endregion
- }
- }
- }
- }
- else
- {
- return true;
- }
- }
- return false;
- }
- #endregion
- #region Is Unblockable
- public bool IsUnblockable
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
- {
- if (cardEffect is CannotBlockClass)
- {
- if (cardEffect.EffectName == "Can't Block")
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region Has Blocker
- public bool HasBlocker
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- #region Effects of permanents in play
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IBlockerEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IBlockerEffect)cardEffect).IsBlocker(this))
- {
- return true;
- }
- }
- }
- }
- }
- #endregion
- #region Effects of faceup security
- foreach (CardSource source in player.SecurityCards)
- {
- if (source.IsFlipped)
- continue;
- foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
- {
- if (cardEffect is IBlockerEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IBlockerEffect)cardEffect).IsBlocker(this))
- {
- return true;
- }
- }
- }
- }
- }
- #endregion
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IBlockerEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IBlockerEffect)cardEffect).IsBlocker(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- return false;
- }
- }
- #endregion
- #region Has Jamming
- public bool HasJamming
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeDestroyedByBattleEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (cardEffect.EffectName == "Jamming")
- {
- if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
- {
- return true;
- }
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeDestroyedByBattleEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (cardEffect.EffectName == "Jamming")
- {
- if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
- {
- return true;
- }
- }
- }
- }
- }
- #endregion
- }
- return false;
- }
- }
- #endregion
- #region Has Ice Clad
- public bool HasIceclad
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- #region Ice clad permanent effects
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
- {
- if (cardEffect is IIcecladEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IIcecladEffect)cardEffect).HasIceclad(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- #region Ice clad Player Effects
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IIcecladEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IIcecladEffect)cardEffect).HasIceclad(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- return false;
- }
- }
- #endregion
- #region Whether this permanent has Pierce
- public bool HasPierce
- {
- get
- {
- if (IsDigimon)
- {
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
- {
- if (cardEffect.EffectName == "Pierce")
- {
- return true;
- }
- if (cardEffect.EffectName == "Piercing")
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region 再起動を持つか
- public bool HasReboot
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IRebootEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IRebootEffect)cardEffect).HasReboot(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IRebootEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IRebootEffect)cardEffect).HasReboot(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- return false;
- }
- }
- #endregion
- #region 突進を持つか
- public bool HasRaid
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "Raid")
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region 速攻を持つか
- public bool HasRush
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IRushEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IRushEffect)cardEffect).HasRush(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IRushEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((IRushEffect)cardEffect).HasRush(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- return false;
- }
- }
- #endregion
- #region 道連れを持つか
- public bool HasRetaliation
- {
- get
- {
- if (RetaliationCount >= 1)
- {
- return true;
- }
- return false;
- }
- }
- #endregion
- #region 道連れを持つ個数
- public int RetaliationCount
- {
- get
- {
- int count = 0;
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "Retaliation")
- {
- if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
- {
- count++;
- }
- }
- }
- }
- return count;
- }
- }
- #endregion
- #region 不屈を持つか
- public bool HasFortitude
- {
- get
- {
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "Fortitude")
- {
- if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region Has Blitz
- public bool HasBlitz
- {
- get
- {
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
- {
- if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
- {
- if (cardEffect.EffectDiscription.Contains("Blitz"))
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region 回避を持つか
- public bool HasEvade
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
- {
- if (cardEffect is ActivateICardEffect)
- {
- Hashtable hashtable = new Hashtable()
- {
- {"Permanents", new List<Permanent>() { this }}
- };
- if (cardEffect.CanTrigger(hashtable))
- {
- if (cardEffect.EffectName == "Evade")
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region マインドリンクを持つか
- public bool HasMindLink
- {
- get
- {
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
- {
- if (cardEffect.EffectDiscription.Contains("Mind Link"))
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region 防壁を持つか
- public bool HasBarrier
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
- {
- if (cardEffect is ActivateICardEffect)
- {
- Hashtable hashtable = new Hashtable();
- hashtable.Add("Permanents", new List<Permanent>() { this });
- hashtable.Add("battle", new IBattle(null, null, null));
- if (cardEffect.CanTrigger(hashtable))
- {
- if (cardEffect.EffectName == "Barrier")
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region 連携を持つか
- public bool HasAlliance
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "Alliance")
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region Has Collision
- public bool HasCollision
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "Collision")
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region Has Partition
- public bool HasPartition
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "Partition")
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region 消滅時効化を持つか
- public bool HasOnDeletionEffect
- {
- get
- {
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
- {
- if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
- {
- if (cardEffect.IsOnDeletion)
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region バトルしているか
- public IBattle battle { get; set; } = null;
- #endregion
- #region Can Be Destroyed
- public bool CanBeDestroyed()
- {
- #region 消滅しない効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeDestroyedEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeDestroyedEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #endregion
- return true;
- }
- #endregion
- #region このデジモンが戦闘によって消滅するか
- public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
- {
- if (!CanBeDestroyed())
- {
- return false;
- }
- #region 戦闘で消滅しない効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeDestroyedByBattleEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeDestroyedByBattleEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #endregion
- return true;
- }
- #endregion
- #region このパーマネントが効果で消滅するか
- public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
- {
- if (this.TopCard != null)
- {
- if (this.TopCard.CanNotBeAffected(cardEffect))
- {
- return false;
- }
- if (!CanBeDestroyed())
- {
- return false;
- }
- #region 効果で消滅しない効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #endregion
- }
- return true;
- }
- #endregion
- #region Can Leave Field
- public bool CanBeRemoved()
- {
- #region Effect that never disappears
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Effects of permanents in play
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeRemovedEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotBeRemovedEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #endregion
- return true;
- }
- #endregion
- #region トークンかどうか
- public bool IsToken
- {
- get
- {
- if (TopCard != null)
- {
- if (TopCard.IsToken)
- {
- return true;
- }
- }
- return false;
- }
- }
- #endregion
- #region そのパーマネントが消滅・バウンス待機状態か
- public bool willBeRemoveField { get; set; } = false;
- #endregion
- #region Is a Digimon card
- public bool IsDigimon
- {
- get
- {
- if (TopCard != null)
- {
- if (TopCard.IsDigimon || TopCard.IsDigiEgg)
- {
- return true;
- }
- #region Effect of treating it as a Digimon
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Effects of permanents in play
- foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
- {
- if (cardEffect is ITreatAsDigimonEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ITreatAsDigimonEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- #endregion
- }
- return false;
- }
- }
- #endregion
- #region Is a Tamer card
- public bool IsTamer
- {
- get
- {
- if (TopCard != null)
- {
- if (TopCard.IsTamer)
- {
- return true;
- }
- }
- return false;
- }
- }
- #endregion
-
- #region Is an Option card
- public bool IsOption
- {
- get
- {
- if (TopCard != null)
- {
- if (TopCard.IsOption)
- {
- return true;
- }
- }
- return false;
- }
- }
- #endregion
- #region Levels handled by Jogress
- public List<int> Levels_ForJogress(CardSource cardSource)
- {
- List<int> levels = new List<int>();
- if (cardSource != null)
- {
- if (cardSource.HasLevel)
- {
- levels.Add(this.Level);
- }
- #region Effect of "adding levels handled by jogless evolution"
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Effects of permanents in play
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddJogressLevelsEffect)
- {
- if (cardEffect.CanUse(null))
- {
- foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
- {
- levels.Add(level);
- }
- }
- }
- }
- #endregion
- }
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddJogressLevelsEffect)
- {
- if (cardEffect.CanUse(null))
- {
- foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
- {
- levels.Add(level);
- }
- }
- }
- }
- #endregion
- }
- #endregion
- }
- return levels;
- }
- #endregion
- #region Names handled by Jogress
- public List<string> Names_ForDNA(CardSource cardSource)
- {
- List<string> names = new List<string>();
- if (cardSource != null)
- {
- foreach(string name in cardSource.CardNames)
- names.Add(name);
- #region Effect of "adding names handled by DNA evolution"
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Effects of permanents in play
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddDNANamesEffect)
- {
- if (cardEffect.CanUse(null))
- {
- foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
- {
- names.Add(name);
- }
- }
- }
- }
- #endregion
- }
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddDNANamesEffect)
- {
- if (cardEffect.CanUse(null))
- {
- foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
- {
- names.Add(name);
- }
- }
- }
- }
- #endregion
- }
- #endregion
- }
- return names;
- }
- #endregion
- #region バトルで消滅したか
- public bool IsDestroyedByBattle { get; set; } = false;
- #endregion
- #region 消滅に使用された効果
- public ICardEffect DestroyingEffect { get; set; } = null;
- #endregion
- #region 他のパーマネントの下に置くのに使用された効果
- public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
- #endregion
- #region 手札バウンス に使用された効果
- public ICardEffect HandBounceEffect { get; set; } = null;
- #endregion
- #region 山札バウンス に使用された効果
- public ICardEffect LibraryBounceEffect { get; set; } = null;
- #endregion
- #region 登場に使用された効果
- public ICardEffect PlayingEffect { get; set; } = null;
- #endregion
- #region 進化に使用された効果
- public ICardEffect DigivolvingEffect { get; set; } = null;
- #endregion
- #region Whether this digimon is placed in the trash by not having a DP
- public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
- #endregion
- #region Whether this permanent can suspend
- public bool CanSuspend
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- #region Effects of field permanents
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotSuspendEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
- {
- return false;
- }
- }
- }
- }
- }
- #endregion
- #region Effects of players
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotSuspendEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- return true;
- }
- }
- #endregion
- #region このデジモンのアタックの対象が変更できるか
- public bool CanSwitchAttackTarget
- {
- get
- {
- #region アタックの対象が変更できない効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotSwitchAttackTargetEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanNotSwitchAttackTargetEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
- {
- return false;
- }
- }
- }
- }
- #endregion
- }
- #endregion
- return true;
- }
- }
- #endregion
- #region このデジモンを場からデジクロス条件の代わりにできるか
- public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
- {
- #region デジクロス条件の代わりにできる効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region 場のパーマネントの効果
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanSelectDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanSelectDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- #endregion
- return false;
- }
- #endregion
- #region 登場した直後のLevel
- public int LevelJustAfterPlayed { get; set; } = -1;
- #endregion
- #region 登場した直後のPlay Cost
- public int PlayCostJustAfterPlayed { get; set; } = -1;
- #endregion
- #region 登場した直後のCardNames
- public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
- #endregion
- #region 進化した直後のCardNames
- public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
- #endregion
- #region 登場した直後のTraits
- public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
- #endregion
- #region 場を離れる直前のDP
- public int DPJustBeforeRemoveField { get; set; } = -1;
- #endregion
- #region 場を離れる直前のLevel
- public int LevelJustBeforeRemoveField { get; set; } = -1;
- #endregion
- #region 場を離れる直前のCost
- public int CostJustBeforeRemoveField { get; set; } = -1;
- #endregion
- #region 場を離れる直前のカード名
- public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
- #endregion
- #region Card Traits Just Before Removed Field
- public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
- #endregion
- #region バースト進化で手札に戻ったか
- public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
- #endregion
- #region バースト進化したか
- public bool IsBurstDigivolved { get; set; } = false;
- #endregion
- #region 効果で場に出たオプションか
- public bool IsPlayedOptionPermanent { get; set; } = false;
- #endregion
- #region 進化元を持たないか
- public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
- #endregion
- #region Digivolution cards' colors
- public List<CardColor> DigivolutionCardsColors
- {
- get
- {
- List<CardColor> cardColors = new List<CardColor>();
- foreach (CardSource cardSource in DigivolutionCards)
- {
- foreach (CardColor cardColor in cardSource.CardColors)
- {
- if (!cardColors.Contains(cardColor))
- {
- cardColors.Add(cardColor);
- }
- }
- }
- return cardColors.Distinct().ToList();
- }
- }
- #endregion
- #region Show "Unsuspend" effect object
- public void ShowUnsuspendEffect()
- {
- if (TopCard != null)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillUntapObject != null)
- {
- ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
- ShowingPermanentCard.WillUntapObject.SetActive(true);
- }
- }
- }
- }
- #endregion
- #region Show "Return to deck" effect object
- public void ShowDeckBounceEffect()
- {
- if (TopCard != null)
- {
- if (willBeRemoveField)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillBeDeckBounceObject != null)
- {
- ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
- ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
- }
- }
- }
- }
- }
- #endregion
- #region Hide "Return to deck" effect object
- public void HideDeckBounceEffect()
- {
- if (TopCard != null)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillBeDeckBounceObject != null)
- {
- ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
- }
- }
- }
- }
- #endregion
- #region Show "Return to hand" effect object
- public void ShowHandBounceEffect()
- {
- if (TopCard != null)
- {
- if (willBeRemoveField)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillBeHandBounceObject != null)
- {
- ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
- ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
- }
- }
- }
- }
- }
- #endregion
- #region Hide "Return to hand" effect object
- public void HideHandBounceEffect()
- {
- if (TopCard != null)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillBeHandBounceObject != null)
- {
- ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
- }
- }
- }
- }
- #endregion
- #region Show "Delete" effect object
- public void ShowDeleteEffect()
- {
- if (TopCard != null)
- {
- if (willBeRemoveField)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillBeDeletedObject != null)
- {
- ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
- ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
- }
- }
- }
- }
- }
- #endregion
- #region Hide "Delete" effect object
- public void HideDeleteEffect()
- {
- if (TopCard != null)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillBeDeletedObject != null)
- {
- ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
- }
- }
- }
- }
- #endregion
- #region Show "Remove Field" effect object
- public void ShowWillRemoveFieldEffect()
- {
- if (TopCard != null)
- {
- if (willBeRemoveField)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillRemoveFieldObject != null)
- {
- ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
- ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
- }
- }
- }
- }
- }
- #endregion
- #region Hide "Remove Field" effect object
- public void HideWillRemoveFieldEffect()
- {
- if (TopCard != null)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillRemoveFieldObject != null)
- {
- ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
- }
- }
- }
- }
- #endregion
- #region Show "Digivolution" effect object
- public void ShowWillEvolutionEffect()
- {
- if (TopCard != null)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillEvolutionObject != null)
- {
- ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
- ShowingPermanentCard.WillEvolutionObject.SetActive(true);
- }
- }
- }
- }
- #endregion
- #region Hide "Digivolution" effect object
- public void HideWillEvolutionEffect()
- {
- if (TopCard != null)
- {
- if (ShowingPermanentCard != null)
- {
- if (ShowingPermanentCard.WillEvolutionObject != null)
- {
- ShowingPermanentCard.WillEvolutionObject.SetActive(false);
- }
- }
- }
- }
- #endregion
- }
|