| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211 |
- 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();
- //TODO: Attempted fix for random face up secuirty/flipped sources
- //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();
- List<CardSource> linkRoots = LinkedCards.Clone();
- if (!ignoreOverflow)
- {
- yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(evoRoots).Overflow());
- yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(linkRoots).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));
- }
- }
- foreach (CardSource cardSource2 in linkRoots)
- {
- if (putToTrash)
- {
- yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(cardSource2));
- }
- else
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource2));
- }
- }
- }
- #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;
- BaseDP += TopCard.BaseDP;
- #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.OrderBy(cardEffect => cardEffect.ActivatedTime))
- {
- 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 GetDP(Permanent ignorePermanent = null)
- {
- int DP = -1;
- if (HasDP)
- {
- DP = BaseDP;
- #region DP By Effect
- 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())
- {
- if (ignorePermanent != null)
- {
- if (permanent == ignorePermanent)
- continue;
- }
- 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);
- }
- }
- }
-
- DP += LinkedDP;
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown.OrderBy(cardEffect => cardEffect.ActivatedTime))
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
- }
- }
- }
- #endregion
- #region DP Boosts
- foreach (DPBoost boost in Boosts)
- {
- DP += boost.DP;
- }
- #endregion
- if (DP < 0)
- {
- DP = 0;
- }
- }
- return DP;
- }
- public int DP
- {
- get
- {
- int DP = -1;
- if (HasDP)
- {
- DP = BaseDP;
- #region DP By Effect
- 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);
- }
- }
- }
-
- DP += LinkedDP;
- foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
- {
- if (cardEffect is IChangeDPEffect)
- {
- if (cardEffect.CanUse(null))
- {
- DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
- }
- }
- }
- #endregion
- #region DP Boosts
- foreach(DPBoost boost in Boosts)
- {
- DP += boost.DP;
- }
- #endregion
- if (DP < 0)
- {
- DP = 0;
- }
- }
- return DP;
- }
- }
- public int LinkedDP { get; set; }
- public List<DPBoost> Boosts = new List<DPBoost>();
- public void AddBoost(DPBoost boost)
- {
- if (Boosts.Any(x => x.ID == boost.ID))
- Boosts.First(x => x.ID == boost.ID).DP = boost.DP;
- else
- Boosts.Add(boost);
- }
- public void RemoveBoost(string ID)
- {
- if (Boosts.Any(x => x.ID == ID))
- Boosts.Remove(Boosts.First(x => x.ID == ID));
- }
- public class DPBoost
- {
- public DPBoost(string id, int dp, Func<bool> cond)
- {
- ID = id;
- DP = dp;
- Condition = cond;
- }
- public string ID = "";
- public int DP = 0;
- public Func<bool> Condition = null;
- }
- #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 Color of the permanent
- public bool HasPermanentColor(CardColor color)
- {
- if (TopCard == null) return false;
- return TopCard.CardColors.Contains(color);
- }
- #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 Immune From De-Digivolve
- 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 Immune From Trashing Stack
- public bool ImmuneFromStackTrashing(ICardEffect effect)
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
- {
- foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is IImmuneFromStackTrashingEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((IImmuneFromStackTrashingEffect)cardEffect1).ImmuneStackTrashing(this, effect))
- {
- return true;
- }
- }
- }
- }
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect1 is IImmuneFromStackTrashingEffect)
- {
- if (cardEffect1.CanUse(null))
- {
- if (((IImmuneFromStackTrashingEffect)cardEffect1).ImmuneStackTrashing(this, effect))
- {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region Card Sources
- public List<CardSource> cardSources = new List<CardSource>();
- #endregion
- #region Stacked Cards
- public List<CardSource> StackCards => cardSources.Filter(cardSource => !LinkedCards.Contains(cardSource));
- #endregion
- #region Digivolution Cards
- public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard && !LinkedCards.Contains(cardSource));
- #endregion
- #region DigivolutionOrLinkCards
- public List<CardSource> DigivolutionOrLinkCards => cardSources.Filter(cardSource => cardSource != TopCard);
- #endregion
- #region Linked Cards
- public int LinkedMax
- {
- get
- {
- int Max = 1;
- #region Effect of changing the number of sheets to undergo security check
- List<ICardEffect> cardEffects_ChangeLinkedMax = 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 IChangeLinkMaxEffect)
- {
- if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeLinkedMax.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 IChangeLinkMaxEffect)
- {
- if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeLinkedMax.Add(cardEffect);
- }
- }
- }
- }
- }
- }
- #endregion
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IChangeLinkMaxEffect)
- {
- if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
- {
- if (cardEffect.CanUse(null))
- {
- if (!TopCard.CanNotBeAffected(cardEffect))
- {
- cardEffects_ChangeLinkedMax.Add(cardEffect);
- }
- }
- }
- }
- }
- #endregion
- }
- List<ICardEffect> cardEffects_ChangeLinkedMax_UpToConstant = new List<ICardEffect>();
- List<ICardEffect> cardEffects_ChangeLinkedMax_UpDownValue = new List<ICardEffect>();
- List<ICardEffect> cardEffects_ChangeLinkedMax_DownToConstant = new List<ICardEffect>();
- foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax)
- {
- if (cardEffect is IChangeLinkMaxEffect)
- {
- if (cardEffect.CanUse(null))
- {
- switch (((IChangeLinkMaxEffect)cardEffect).isUpDown())
- {
- case CalculateOrder.UpToConstant:
- cardEffects_ChangeLinkedMax_UpToConstant.Add(cardEffect);
- break;
- case CalculateOrder.UpDownValue:
- cardEffects_ChangeLinkedMax_UpDownValue.Add(cardEffect);
- break;
- case CalculateOrder.DownToConstant:
- cardEffects_ChangeLinkedMax_DownToConstant.Add(cardEffect);
- break;
- }
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpToConstant)
- {
- if (cardEffect is IChangeLinkMaxEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpDownValue)
- {
- if (cardEffect is IChangeLinkMaxEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
- }
- }
- }
- foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_DownToConstant)
- {
- if (cardEffect is IChangeLinkMaxEffect)
- {
- if (cardEffect.CanUse(null))
- {
- Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
- }
- }
- }
- #endregion
- return Max;
- }
- }
- public List<CardSource> LinkedCards = new List<CardSource>();
- #endregion
- #region Add Card Source
- public void AddCardSource(CardSource cardSource)
- {
- cardSources.Insert(0, cardSource);
- if (!cardSource.IsFlipped)
- cardSource.SetFace();
- else
- cardSource.SetReverse();
- }
- #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);
- if (!addedDigivolutionCard.IsFlipped || addedDigivolutionCard.IsBeingRevealed || GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
- 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, bool isFacedown = 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 (LinkedCards.Contains(addedDigivolutionCard))
- {
- yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(addedDigivolutionCard, trashCard: false));
- }
- else 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);
- if (isFacedown)
- addedDigivolutionCard.SetReverse();
- else
- 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 Add Link cards
- /// <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 IPlacePermanentToLinkCards
- /// </summary>
- /// <param name="addedLinkCards"></param>
- /// <param name="cardEffect"></param>
- /// <param name="skipEffectAndActivateSkill"></param>
- /// <returns></returns>
- public IEnumerator AddLinkCard(CardSource addedLinkCard, ICardEffect cardEffect)
- {
- bool addedCard = false;
- bool isFromDigimon = false;
- if (CardEffectCommons.IsExistOnBattleArea(addedLinkCard))
- {
- if (addedLinkCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
- {
- isFromDigimon = true;
- }
- }
- if (LinkedCards.Count >= LinkedMax)
- {
- if(LinkedMax > 1)
- yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(null,((LinkedCards.Count + 1) - LinkedMax)));
- else
- yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(LinkedCards[0]));
- }
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
- if (!this.IsToken && !addedLinkCard.IsToken)
- {
- LinkedCards.Insert(0, addedLinkCard);
- LinkedDP += addedLinkCard.LinkDP;
- this.cardSources.Insert(1, addedLinkCard);
- addedLinkCard.SetFace();
- addedCard = true;
- }
- if (addedCard)
- {
- if (ShowingPermanentCard != null)
- {
- yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
- }
- #region Add Linked Card
- #region Hashtable Setting
- Hashtable hashtable = new Hashtable()
- {
- {"Permanent", this},
- {"CardEffect", cardEffect},
- {"Card", addedLinkCard},
- {"isFromDigimon", isFromDigimon},
- };
- #endregion
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.WhenLinked));
- #endregion
- }
- }
- #endregion
- #region RemoveCardSource
- public IEnumerator RemoveCardSource(CardSource cardSource)
- {
- yield return null;
- cardSources.Remove(cardSource);
- }
- #endregion
- #region Remove Linked Card
- public IEnumerator RemoveLinkedCard(CardSource cardSource, int removeCount = 0, bool trashCard = true)
- {
- if (LinkedCards.Contains(cardSource))
- {
- LinkedDP -= cardSource.LinkDP;
- LinkedCards.Remove(cardSource);
- yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(cardSource));
- if (trashCard)
- {
- yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource));
- }
- }
- if(removeCount > 0)
- {
- int maxCount = Mathf.Min(removeCount, LinkedCards.Count);
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: (CardSource) => true,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => false,
- selectCardCoroutine: null,
- afterSelectCardCoroutine: null,
- message: $"Select {maxCount} card to trash.",
- maxCount: removeCount,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Discard,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: LinkedCards,
- canLookReverseCard: true,
- selectPlayer: TopCard.Owner,
- cardEffect: null);
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- }
- //TODO: Add event call if something was removed
- }
- #endregion
- #region Top Card
- public CardSource TopCard
- {
- get
- {
- if (cardSources.Count >= 1)
- {
- if (LinkedCards.Count > 0)
- return cardSources.First(source => !LinkedCards.Contains(source));
- else
- 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)
- {
- #region Entity, Inherited and Link effects
- if (cardEffect.IsInheritedEffect && !isTopCard)
- {
- _EffectList.Add(cardEffect);
- continue;
- }
- if (cardEffect.IsLinkedEffect && cardSource.IsLinked)
- {
- _EffectList.Add(cardEffect);
- continue;
- }
- if(isTopCard && !cardEffect.IsInheritedEffect && !cardEffect.IsLinkedEffect)
- {
- _EffectList.Add(cardEffect);
- }
-
- #endregion
- }
- }
- }
- }
- }
- 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 ICanNotMoveEffect
- && cardEffect.CanUse(null)
- && ((ICanNotMoveEffect)cardEffect).CanNotMove(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 ICanNotMoveEffect
- && cardEffect.CanUse(null)
- && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
- {
- return false;
- }
- #endregion
- #region the effects of itself
- if (this == null)
- {
- if (EffectList(EffectTiming.None)
- .Some(cardEffect => cardEffect is ICanNotMoveEffect
- && cardEffect.CanUse(null)
- && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
- {
- return false;
- }
- }
- #endregion
- if (TopCard.PermanentOfThisCard().PermanentFrame.isBreedingAreaFrame())
- {
- if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
- {
- return false;
- }
- }
- else
- {
- if (TopCard.Owner.GetBreedingAreaPermanents().Count > 0)
- return false;
- }
- if (!IsDigimon)
- return false;
- if (TopCard.IsDigiEgg && 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, bool isExecute = 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 during another attack
- if (GManager.instance.attackProcess.IsAttacking)
- return false;
- // can not attack to player
- if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex, isExecute))
- {
- // can not attack to opponent's Digimon
- if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex, isExecute)) == 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.IsDigimon)
- 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, bool isExecute = 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 || isExecute)
- {
- 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 == "Unblockable")
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region Has Blocker
- public bool HasBlocker
- {
- get
- {
- #region if attacking digimon has collision
- if (GManager.instance.attackProcess.ActiveAttack() && CardEffectCommons.IsPermanentExistsOnBattleArea(this))
- {
- Permanent attackingPermanent = GManager.instance.attackProcess.AttackingPermanent;
- if (attackingPermanent != null
- && attackingPermanent.TopCard != null
- && attackingPermanent.TopCard.Owner != TopCard.Owner
- && attackingPermanent.HasCollision)
- {
- ActivateClass fakeCollisionClass = new();
- fakeCollisionClass.SetIsDigimonEffect(true);
- fakeCollisionClass.SetUpICardEffect("Collision", _ => true, attackingPermanent.TopCard);
-
- if (!TopCard.CanNotBeAffected(fakeCollisionClass))//Check can be affected by opponent's Digimon effects
- return true;
- }
- }
- #endregion
- 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 Has Reboot
- 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 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 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 Has Raid
- 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 Has Rush
- 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 Effects of Face-up Security
- foreach (CardSource source in player.SecurityCards)
- {
- if (source.IsFlipped)
- continue;
- foreach (ICardEffect cardEffect in source.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 Has Retaliation
- public bool HasRetaliation
- {
- get
- {
- if (RetaliationCount >= 1)
- {
- return true;
- }
- return false;
- }
- }
- #endregion
- #region Retaliation Count
- 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 HasAscension
- public bool HasAscension
- {
- get
- {
- foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "Ascension")
- {
- if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region Has Fortitude
- 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 Has Evade
- 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 Has Mind Link
- 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 Has Barrier
- 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 Has Alliance
- public bool HasAlliance
- {
- get
- {
- Hashtable hashtable = new Hashtable(){
- {"AttackingPermanent", this}
- };
-
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Permanent Effects
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
- {
- if (cardEffect.EffectName == "Alliance")
- {
- if (cardEffect.CanTrigger(hashtable))
- {
- 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.OnAllyAttack))
- {
- if (cardEffect.EffectName == "Alliance")
- {
- if (cardEffect.CanTrigger(hashtable))
- {
- return true;
- }
- }
- }
- }
- #endregion
- #region Player Effects
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
- {
- if (cardEffect.EffectName == "Alliance")
- {
- if (cardEffect.CanTrigger(hashtable))
- {
- return true;
- }
- }
- }
- #endregion
- }
- return false;
- }
- }
- #endregion
- #region Has Collision
- public bool HasCollision
- {
- get
- {
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Permanent Effects
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnCounterTiming))
- {
- if (cardEffect is ICollisionEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((ICollisionEffect)cardEffect).HasCollision(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.OnCounterTiming))
- {
- if (cardEffect is ICollisionEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((ICollisionEffect)cardEffect).HasCollision(this))
- {
- return true;
- }
- }
- }
- }
- }
- #endregion
- #region Player Effects
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnCounterTiming))
- {
- if (cardEffect is ICollisionEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((ICollisionEffect)cardEffect).HasCollision(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- 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 Has Scapegoat
- public bool HasScapegoat
- {
- get
- {
- foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
- {
- if (cardEffect is ActivateICardEffect)
- {
- if (cardEffect.EffectName == "<Scapegoat>")
- {
- 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 Can Be Destroyed By Battle
- public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
- {
- if (!CanBeDestroyed())
- {
- return false;
- }
- #region Given Effects
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- foreach (Permanent permanent in player.GetFieldPermanents())
- {
- #region Permanents
- 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 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 ICanNotBeDestroyedByBattleEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
- {
- return false;
- }
- }
- }
- }
- }
- #endregion
- #region Player Effects
- 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.IsFlipped)
- return false;
- if (TopCard.IsDigimon || TopCard.IsDigiEgg)
- {
- return true;
- }
- #region Effect on TopCard
- foreach (ICardEffect cardEffect in TopCard.EffectList(EffectTiming.None))
- {
- if (cardEffect is ITreatAsDigimonEffect)
- {
- if (cardEffect.CanTrigger(null))
- {
- if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- #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))//This can never be EffectList, as EffectList_forCard checks Isdigimon and this causes a stack overflow
- {
- 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.IsFlipped)
- return false;
- if (TopCard.IsTamer)
- {
- return true;
- }
- }
- return false;
- }
- }
- #endregion
-
- #region Is an Option card
- public bool IsOption
- {
- get
- {
- if (TopCard != null)
- {
- if (TopCard.IsOption && !TopCard.IsDigimon) //DualCard is never an option while it is a permanent
- {
- 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 Can Substitue for Assembly
- public bool CanSubstituteForAssemblyCondition(CardSource cardSource)
- {
- #region Effects that can be used in place of Assembly conditions
- 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 ICanSelectAssemblyEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
- {
- return true;
- }
- }
- }
- }
- #endregion
- }
- #region player effect
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is ICanSelectAssemblyEffect)
- {
- if (cardEffect.CanUse(null))
- {
- if (((ICanSelectAssemblyEffect)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 Is Linked Card Added as Source By App Fusion
- public bool IsAddedAsSourceByAppFusion { get; set; } = false;
- #endregion
- #region バースト進化したか
- public bool IsBurstDigivolved { get; set; } = false;
- #endregion
- #region Did it App Fusion?
- public bool IsAppFusion { get; set; } = false;
- #endregion
- #region 効果で場に出たオプションか
- public bool IsPlayedOptionPermanent { get; set; } = false;
- #endregion
- #region 進化元を持たないか
- public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
- #endregion
- #region Has face down Digivolution Cards
- public bool HasFaceDownDigivolutionCards => DigivolutionCards.Any(x => x.IsFlipped);
- #endregion
- #region Has No Link Cards
- public bool HasNoLinkCards => LinkedCards.Count == 0;
- #endregion
- #region Digivolution cards' colors
- public List<CardColor> DigivolutionCardsColors
- {
- get
- {
- List<CardColor> cardColors = new List<CardColor>();
- foreach (CardSource cardSource in DigivolutionCards)
- {
- if (cardSource.IsFlipped)
- continue;
- foreach (CardColor cardColor in cardSource.CardColors)
- {
- if (!cardColors.Contains(cardColor))
- {
- cardColors.Add(cardColor);
- }
- }
- foreach (CardColor cardColor in cardSource.DualCardColors)
- {
- 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
- }
|