Permanent.cs 141 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using System.Linq;
  6. public class Permanent
  7. {
  8. public Permanent(List<CardSource> cardSources)
  9. {
  10. SetCardSources(cardSources);
  11. }
  12. public void SetCardSources(List<CardSource> cardSources)
  13. {
  14. List<CardSource> newCardSources = cardSources.Clone();
  15. //TODO: Attempted fix for random face up secuirty/flipped sources
  16. //newCardSources.Reverse();
  17. foreach (CardSource cardSource in newCardSources)
  18. {
  19. AddCardSource(cardSource);
  20. }
  21. }
  22. public FieldCardFrame PermanentFrame
  23. {
  24. get
  25. {
  26. if (TopCard != null)
  27. {
  28. int index = Array.IndexOf(TopCard.Owner.FieldPermanents, this);
  29. if (0 <= index && index <= TopCard.Owner.fieldCardFrames.Count - 1)
  30. {
  31. return TopCard.Owner.fieldCardFrames[index];
  32. }
  33. }
  34. return null;
  35. }
  36. }
  37. public bool oldIsTapped_playCard { get; set; }
  38. #region Level
  39. public int Level
  40. {
  41. get
  42. {
  43. int Level = 0;
  44. if (TopCard != null)
  45. {
  46. Level = TopCard.Level;
  47. if (!TopCard.HasLevel)
  48. {
  49. Level = 1145140;
  50. }
  51. #region レベルを変更する効果
  52. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  53. {
  54. foreach (Permanent permanent in player.GetFieldPermanents())
  55. {
  56. #region 場のパーマネントの効果
  57. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  58. {
  59. if (cardEffect is IChangePermanentLevelEffect)
  60. {
  61. if (cardEffect.CanUse(null))
  62. {
  63. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  64. }
  65. }
  66. }
  67. #endregion
  68. }
  69. #region プレイヤーの効果
  70. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  71. {
  72. if (cardEffect is IChangePermanentLevelEffect)
  73. {
  74. if (cardEffect.CanUse(null))
  75. {
  76. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  77. }
  78. }
  79. }
  80. #endregion
  81. }
  82. #endregion
  83. }
  84. return Level;
  85. }
  86. }
  87. #endregion
  88. #region Place all evolution sources in the trash
  89. public IEnumerator DiscardEvoRoots(bool ignoreOverflow = false, bool putToTrash = true)
  90. {
  91. List<CardSource> evoRoots = DigivolutionCards.Clone();
  92. List<CardSource> linkRoots = LinkedCards.Clone();
  93. if (!ignoreOverflow)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(evoRoots).Overflow());
  96. yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(linkRoots).Overflow());
  97. }
  98. foreach (CardSource cardSource1 in evoRoots)
  99. {
  100. if (putToTrash)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource1));
  103. }
  104. else
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource1));
  107. }
  108. }
  109. foreach (CardSource cardSource2 in linkRoots)
  110. {
  111. if (putToTrash)
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(cardSource2));
  114. }
  115. else
  116. {
  117. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource2));
  118. }
  119. }
  120. }
  121. #endregion
  122. #region Whether this permanent has DP
  123. public bool HasDP
  124. {
  125. get
  126. {
  127. if (TopCard == null)
  128. {
  129. return false;
  130. }
  131. if (!IsDigimon)
  132. {
  133. return false;
  134. }
  135. if (!TopCard.HasDP && TopCard.IsDigiEgg)
  136. {
  137. return false;
  138. }
  139. #region Effect of not having DP
  140. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  141. {
  142. foreach (Permanent permanent in player.GetFieldPermanents())
  143. {
  144. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  145. {
  146. if (cardEffect1 is IDontHaveDPEffect)
  147. {
  148. if (cardEffect1.CanUse(null))
  149. {
  150. if (((IDontHaveDPEffect)cardEffect1).DontHaveDP(this))
  151. {
  152. return false;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. return true;
  161. }
  162. }
  163. #endregion
  164. #region Base DP
  165. public int BaseDP
  166. {
  167. get
  168. {
  169. int BaseDP = 0;
  170. if (HasDP)
  171. {
  172. BaseDP = TopCard.BaseCardDP;
  173. BaseDP += TopCard.BaseDP;
  174. #region 基礎DPを変更する効果
  175. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  176. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  177. {
  178. foreach (Permanent permanent in player.GetFieldPermanents())
  179. {
  180. #region 場のパーマネントの効果
  181. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  182. {
  183. if (cardEffect is IChangeBaseDPEffect)
  184. {
  185. if (cardEffect.CanUse(null))
  186. {
  187. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  188. {
  189. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  190. {
  191. if (this.ImmuneFromDPMinus(cardEffect))
  192. {
  193. continue;
  194. }
  195. }
  196. if (!TopCard.CanNotBeAffected(cardEffect))
  197. {
  198. cardEffects_ChangeDP.Add(cardEffect);
  199. }
  200. }
  201. }
  202. }
  203. }
  204. #endregion
  205. }
  206. #region プレイヤーの効果
  207. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  208. {
  209. if (cardEffect is IChangeBaseDPEffect)
  210. {
  211. if (cardEffect.CanUse(null))
  212. {
  213. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  214. {
  215. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  216. {
  217. if (this.ImmuneFromDPMinus(cardEffect))
  218. {
  219. continue;
  220. }
  221. }
  222. if (!TopCard.CanNotBeAffected(cardEffect))
  223. {
  224. cardEffects_ChangeDP.Add(cardEffect);
  225. }
  226. }
  227. }
  228. }
  229. }
  230. #endregion
  231. }
  232. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  233. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  234. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  235. {
  236. if (cardEffect is IChangeBaseDPEffect)
  237. {
  238. if (cardEffect.CanUse(null))
  239. {
  240. if (((IChangeBaseDPEffect)cardEffect).IsUpDown())
  241. {
  242. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  243. }
  244. else
  245. {
  246. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  247. }
  248. }
  249. }
  250. }
  251. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  252. {
  253. if (cardEffect is IChangeBaseDPEffect)
  254. {
  255. if (cardEffect.CanUse(null))
  256. {
  257. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  258. }
  259. }
  260. }
  261. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown.OrderBy(cardEffect => cardEffect.ActivatedTime))
  262. {
  263. if (cardEffect is IChangeBaseDPEffect)
  264. {
  265. if (cardEffect.CanUse(null))
  266. {
  267. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  268. }
  269. }
  270. }
  271. #endregion
  272. if (BaseDP < 0)
  273. {
  274. BaseDP = 0;
  275. }
  276. }
  277. return BaseDP;
  278. }
  279. }
  280. #endregion
  281. #region DP
  282. public int GetDP(Permanent ignorePermanent = null)
  283. {
  284. int DP = -1;
  285. if (HasDP)
  286. {
  287. DP = BaseDP;
  288. #region DP By Effect
  289. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  290. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  291. {
  292. #region Effects of permanents in play
  293. foreach (Permanent permanent in player.GetFieldPermanents())
  294. {
  295. if (ignorePermanent != null)
  296. {
  297. if (permanent == ignorePermanent)
  298. continue;
  299. }
  300. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  301. {
  302. if (cardEffect is IChangeDPEffect)
  303. {
  304. if (cardEffect.CanUse(null))
  305. {
  306. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  307. {
  308. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  309. {
  310. if (this.ImmuneFromDPMinus(cardEffect))
  311. {
  312. continue;
  313. }
  314. }
  315. if (!TopCard.CanNotBeAffected(cardEffect))
  316. {
  317. cardEffects_ChangeDP.Add(cardEffect);
  318. }
  319. }
  320. }
  321. }
  322. }
  323. }
  324. #endregion
  325. #region Effects of face up security
  326. foreach (CardSource cardSource in player.SecurityCards)
  327. {
  328. if (cardSource.IsFlipped)
  329. continue;
  330. foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
  331. {
  332. if (cardEffect is IChangeDPEffect)
  333. {
  334. if (cardEffect.CanUse(null))
  335. {
  336. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  337. {
  338. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  339. {
  340. if (this.ImmuneFromDPMinus(cardEffect))
  341. {
  342. continue;
  343. }
  344. }
  345. if (!TopCard.CanNotBeAffected(cardEffect))
  346. {
  347. cardEffects_ChangeDP.Add(cardEffect);
  348. }
  349. }
  350. }
  351. }
  352. }
  353. }
  354. #endregion
  355. #region Player effect
  356. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  357. {
  358. if (cardEffect is IChangeDPEffect)
  359. {
  360. if (cardEffect.CanUse(null))
  361. {
  362. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  363. {
  364. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  365. {
  366. if (this.ImmuneFromDPMinus(cardEffect))
  367. {
  368. continue;
  369. }
  370. }
  371. if (!TopCard.CanNotBeAffected(cardEffect))
  372. {
  373. cardEffects_ChangeDP.Add(cardEffect);
  374. }
  375. }
  376. }
  377. }
  378. }
  379. #endregion
  380. }
  381. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  382. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  383. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  384. {
  385. if (cardEffect is IChangeDPEffect)
  386. {
  387. if (cardEffect.CanUse(null))
  388. {
  389. if (((IChangeDPEffect)cardEffect).IsUpDown())
  390. {
  391. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  392. }
  393. else
  394. {
  395. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  396. }
  397. }
  398. }
  399. }
  400. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  401. {
  402. if (cardEffect is IChangeDPEffect)
  403. {
  404. if (cardEffect.CanUse(null))
  405. {
  406. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  407. }
  408. }
  409. }
  410. DP += LinkedDP;
  411. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown.OrderBy(cardEffect => cardEffect.ActivatedTime))
  412. {
  413. if (cardEffect is IChangeDPEffect)
  414. {
  415. if (cardEffect.CanUse(null))
  416. {
  417. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  418. }
  419. }
  420. }
  421. #endregion
  422. #region DP Boosts
  423. foreach (DPBoost boost in Boosts)
  424. {
  425. DP += boost.DP;
  426. }
  427. #endregion
  428. if (DP < 0)
  429. {
  430. DP = 0;
  431. }
  432. }
  433. return DP;
  434. }
  435. public int DP
  436. {
  437. get
  438. {
  439. int DP = -1;
  440. if (HasDP)
  441. {
  442. DP = BaseDP;
  443. #region DP By Effect
  444. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  445. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  446. {
  447. #region Effects of permanents in play
  448. foreach (Permanent permanent in player.GetFieldPermanents())
  449. {
  450. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  451. {
  452. if (cardEffect is IChangeDPEffect)
  453. {
  454. if (cardEffect.CanUse(null))
  455. {
  456. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  457. {
  458. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  459. {
  460. if (this.ImmuneFromDPMinus(cardEffect))
  461. {
  462. continue;
  463. }
  464. }
  465. if (!TopCard.CanNotBeAffected(cardEffect))
  466. {
  467. cardEffects_ChangeDP.Add(cardEffect);
  468. }
  469. }
  470. }
  471. }
  472. }
  473. }
  474. #endregion
  475. #region Effects of face up security
  476. foreach (CardSource cardSource in player.SecurityCards)
  477. {
  478. if (cardSource.IsFlipped)
  479. continue;
  480. foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
  481. {
  482. if (cardEffect is IChangeDPEffect)
  483. {
  484. if (cardEffect.CanUse(null))
  485. {
  486. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  487. {
  488. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  489. {
  490. if (this.ImmuneFromDPMinus(cardEffect))
  491. {
  492. continue;
  493. }
  494. }
  495. if (!TopCard.CanNotBeAffected(cardEffect))
  496. {
  497. cardEffects_ChangeDP.Add(cardEffect);
  498. }
  499. }
  500. }
  501. }
  502. }
  503. }
  504. #endregion
  505. #region Player effect
  506. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  507. {
  508. if (cardEffect is IChangeDPEffect)
  509. {
  510. if (cardEffect.CanUse(null))
  511. {
  512. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  513. {
  514. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  515. {
  516. if (this.ImmuneFromDPMinus(cardEffect))
  517. {
  518. continue;
  519. }
  520. }
  521. if (!TopCard.CanNotBeAffected(cardEffect))
  522. {
  523. cardEffects_ChangeDP.Add(cardEffect);
  524. }
  525. }
  526. }
  527. }
  528. }
  529. #endregion
  530. }
  531. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  532. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  533. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  534. {
  535. if (cardEffect is IChangeDPEffect)
  536. {
  537. if (cardEffect.CanUse(null))
  538. {
  539. if (((IChangeDPEffect)cardEffect).IsUpDown())
  540. {
  541. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  542. }
  543. else
  544. {
  545. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  546. }
  547. }
  548. }
  549. }
  550. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  551. {
  552. if (cardEffect is IChangeDPEffect)
  553. {
  554. if (cardEffect.CanUse(null))
  555. {
  556. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  557. }
  558. }
  559. }
  560. DP += LinkedDP;
  561. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  562. {
  563. if (cardEffect is IChangeDPEffect)
  564. {
  565. if (cardEffect.CanUse(null))
  566. {
  567. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  568. }
  569. }
  570. }
  571. #endregion
  572. #region DP Boosts
  573. foreach(DPBoost boost in Boosts)
  574. {
  575. DP += boost.DP;
  576. }
  577. #endregion
  578. if (DP < 0)
  579. {
  580. DP = 0;
  581. }
  582. }
  583. return DP;
  584. }
  585. }
  586. public int LinkedDP { get; set; }
  587. public List<DPBoost> Boosts = new List<DPBoost>();
  588. public void AddBoost(DPBoost boost)
  589. {
  590. if (Boosts.Any(x => x.ID == boost.ID))
  591. Boosts.First(x => x.ID == boost.ID).DP = boost.DP;
  592. else
  593. Boosts.Add(boost);
  594. }
  595. public void RemoveBoost(string ID)
  596. {
  597. if (Boosts.Any(x => x.ID == ID))
  598. Boosts.Remove(Boosts.First(x => x.ID == ID));
  599. }
  600. public class DPBoost
  601. {
  602. public DPBoost(string id, int dp, Func<bool> cond)
  603. {
  604. ID = id;
  605. DP = dp;
  606. Condition = cond;
  607. }
  608. public string ID = "";
  609. public int DP = 0;
  610. public Func<bool> Condition = null;
  611. }
  612. #endregion
  613. #region Will it not receive negative DP effect?
  614. public bool ImmuneFromDPMinus(ICardEffect cardEffect)
  615. {
  616. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  617. {
  618. foreach (Permanent permanent in player.GetFieldPermanents())
  619. {
  620. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  621. {
  622. if (cardEffect1 is IImmuneFromDPMinusEffect)
  623. {
  624. if (cardEffect1.CanUse(null))
  625. {
  626. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  627. {
  628. return true;
  629. }
  630. }
  631. }
  632. }
  633. }
  634. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  635. {
  636. if (cardEffect1 is IImmuneFromDPMinusEffect)
  637. {
  638. if (cardEffect1.CanUse(null))
  639. {
  640. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  641. {
  642. return true;
  643. }
  644. }
  645. }
  646. }
  647. }
  648. return false;
  649. }
  650. #endregion
  651. #region Can be returned to your hand?
  652. public bool CannotReturnToHand(ICardEffect cardEffect)
  653. {
  654. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  655. {
  656. foreach (Permanent permanent in player.GetFieldPermanents())
  657. {
  658. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  659. {
  660. if (cardEffect1 is ICannotReturnToHandEffect)
  661. {
  662. if (cardEffect1.CanUse(null))
  663. {
  664. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  665. {
  666. return true;
  667. }
  668. }
  669. }
  670. }
  671. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  672. {
  673. if (cardEffect1 is ICannotReturnToHandEffect)
  674. {
  675. if (cardEffect1.CanUse(null))
  676. {
  677. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  678. {
  679. return true;
  680. }
  681. }
  682. }
  683. }
  684. }
  685. }
  686. return false;
  687. }
  688. #endregion
  689. #region Can be returned to deck?
  690. public bool CannotReturnToLibrary(ICardEffect cardEffect)
  691. {
  692. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  693. {
  694. foreach (Permanent permanent in player.GetFieldPermanents())
  695. {
  696. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  697. {
  698. if (cardEffect1 is ICannotReturnToLibraryEffect)
  699. {
  700. if (cardEffect1.CanUse(null))
  701. {
  702. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  703. {
  704. return true;
  705. }
  706. }
  707. }
  708. }
  709. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  710. {
  711. if (cardEffect1 is ICannotReturnToLibraryEffect)
  712. {
  713. if (cardEffect1.CanUse(null))
  714. {
  715. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  716. {
  717. return true;
  718. }
  719. }
  720. }
  721. }
  722. }
  723. }
  724. return false;
  725. }
  726. #endregion
  727. #region Immune From De-Digivolve
  728. public bool ImmuneFromDeDigivolve()
  729. {
  730. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  731. {
  732. foreach (Permanent permanent in player.GetFieldPermanents())
  733. {
  734. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  735. {
  736. if (cardEffect1 is IImmuneFromDeDigivolveEffect)
  737. {
  738. if (cardEffect1.CanUse(null))
  739. {
  740. if (((IImmuneFromDeDigivolveEffect)cardEffect1).ImmuneDeDigivolve(this))
  741. {
  742. return true;
  743. }
  744. }
  745. }
  746. }
  747. }
  748. }
  749. return false;
  750. }
  751. #endregion
  752. #region Immune From Trashing Stack
  753. public bool ImmuneFromStackTrashing(ICardEffect effect)
  754. {
  755. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  756. {
  757. foreach (Permanent permanent in player.GetFieldPermanents())
  758. {
  759. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  760. {
  761. if (cardEffect1 is IImmuneFromStackTrashingEffect)
  762. {
  763. if (cardEffect1.CanUse(null))
  764. {
  765. if (((IImmuneFromStackTrashingEffect)cardEffect1).ImmuneStackTrashing(this, effect))
  766. {
  767. return true;
  768. }
  769. }
  770. }
  771. }
  772. }
  773. }
  774. return false;
  775. }
  776. #endregion
  777. #region Card Sources
  778. public List<CardSource> cardSources = new List<CardSource>();
  779. #endregion
  780. #region Stacked Cards
  781. public List<CardSource> StackCards => cardSources.Filter(cardSource => !LinkedCards.Contains(cardSource));
  782. #endregion
  783. #region Digivolution Cards
  784. public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard && !LinkedCards.Contains(cardSource));
  785. #endregion
  786. #region DigivolutionOrLinkCards
  787. public List<CardSource> DigivolutionOrLinkCards => cardSources.Filter(cardSource => cardSource != TopCard);
  788. #endregion
  789. #region Linked Cards
  790. public int LinkedMax
  791. {
  792. get
  793. {
  794. int Max = 1;
  795. #region Effect of changing the number of sheets to undergo security check
  796. List<ICardEffect> cardEffects_ChangeLinkedMax = new List<ICardEffect>();
  797. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  798. {
  799. foreach (Permanent permanent in player.GetFieldPermanents())
  800. {
  801. #region Effects of permanents in play
  802. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  803. {
  804. if (cardEffect is IChangeLinkMaxEffect)
  805. {
  806. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  807. {
  808. if (cardEffect.CanUse(null))
  809. {
  810. if (!TopCard.CanNotBeAffected(cardEffect))
  811. {
  812. cardEffects_ChangeLinkedMax.Add(cardEffect);
  813. }
  814. }
  815. }
  816. }
  817. }
  818. #endregion
  819. }
  820. #region Effects of face up security
  821. foreach (CardSource cardSource in player.SecurityCards)
  822. {
  823. if (cardSource.IsFlipped)
  824. continue;
  825. foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
  826. {
  827. if (cardEffect is IChangeLinkMaxEffect)
  828. {
  829. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  830. {
  831. if (cardEffect.CanUse(null))
  832. {
  833. if (!TopCard.CanNotBeAffected(cardEffect))
  834. {
  835. cardEffects_ChangeLinkedMax.Add(cardEffect);
  836. }
  837. }
  838. }
  839. }
  840. }
  841. }
  842. #endregion
  843. #region player effect
  844. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  845. {
  846. if (cardEffect is IChangeLinkMaxEffect)
  847. {
  848. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  849. {
  850. if (cardEffect.CanUse(null))
  851. {
  852. if (!TopCard.CanNotBeAffected(cardEffect))
  853. {
  854. cardEffects_ChangeLinkedMax.Add(cardEffect);
  855. }
  856. }
  857. }
  858. }
  859. }
  860. #endregion
  861. }
  862. List<ICardEffect> cardEffects_ChangeLinkedMax_UpToConstant = new List<ICardEffect>();
  863. List<ICardEffect> cardEffects_ChangeLinkedMax_UpDownValue = new List<ICardEffect>();
  864. List<ICardEffect> cardEffects_ChangeLinkedMax_DownToConstant = new List<ICardEffect>();
  865. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax)
  866. {
  867. if (cardEffect is IChangeLinkMaxEffect)
  868. {
  869. if (cardEffect.CanUse(null))
  870. {
  871. switch (((IChangeLinkMaxEffect)cardEffect).isUpDown())
  872. {
  873. case CalculateOrder.UpToConstant:
  874. cardEffects_ChangeLinkedMax_UpToConstant.Add(cardEffect);
  875. break;
  876. case CalculateOrder.UpDownValue:
  877. cardEffects_ChangeLinkedMax_UpDownValue.Add(cardEffect);
  878. break;
  879. case CalculateOrder.DownToConstant:
  880. cardEffects_ChangeLinkedMax_DownToConstant.Add(cardEffect);
  881. break;
  882. }
  883. }
  884. }
  885. }
  886. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpToConstant)
  887. {
  888. if (cardEffect is IChangeLinkMaxEffect)
  889. {
  890. if (cardEffect.CanUse(null))
  891. {
  892. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  893. }
  894. }
  895. }
  896. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpDownValue)
  897. {
  898. if (cardEffect is IChangeLinkMaxEffect)
  899. {
  900. if (cardEffect.CanUse(null))
  901. {
  902. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  903. }
  904. }
  905. }
  906. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_DownToConstant)
  907. {
  908. if (cardEffect is IChangeLinkMaxEffect)
  909. {
  910. if (cardEffect.CanUse(null))
  911. {
  912. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  913. }
  914. }
  915. }
  916. #endregion
  917. return Max;
  918. }
  919. }
  920. public List<CardSource> LinkedCards = new List<CardSource>();
  921. #endregion
  922. #region Add Card Source
  923. public void AddCardSource(CardSource cardSource)
  924. {
  925. cardSources.Insert(0, cardSource);
  926. if (!cardSource.IsFlipped)
  927. cardSource.SetFace();
  928. else
  929. cardSource.SetReverse();
  930. }
  931. #endregion
  932. #region Add digivolution cards to top of sources
  933. /// <summary>
  934. /// 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
  935. /// </summary>
  936. /// <param name="addedDigivolutionCards"></param>
  937. /// <param name="cardEffect"></param>
  938. /// <param name="skipEffectAndActivateSkill"></param>
  939. /// <returns></returns>
  940. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  941. {
  942. List<CardSource> addedCards = new List<CardSource>();
  943. bool isFromSameDigimon = false;
  944. bool isFromDigimon = false;
  945. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  946. {
  947. if (cardSources.Contains(addedDigivolutionCard))
  948. {
  949. isFromSameDigimon = true;
  950. }
  951. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  952. {
  953. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  954. {
  955. isFromDigimon = true;
  956. }
  957. }
  958. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  959. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  960. {
  961. this.cardSources.Insert(1, addedDigivolutionCard);
  962. if (!addedDigivolutionCard.IsFlipped || addedDigivolutionCard.IsBeingRevealed || GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  963. addedDigivolutionCard.SetFace();
  964. addedCards.Add(addedDigivolutionCard);
  965. }
  966. }
  967. if (addedCards.Count >= 1)
  968. {
  969. if (ShowingPermanentCard != null)
  970. {
  971. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  972. }
  973. #region "進化元が増えた時"の効果
  974. #region Hashtable Setting
  975. Hashtable hashtable = new Hashtable()
  976. {
  977. {"Permanent", this},
  978. {"CardEffect", cardEffect},
  979. {"CardSources", addedCards},
  980. {"isFromSameDigimon", isFromSameDigimon},
  981. {"isFromDigimon", isFromDigimon},
  982. };
  983. #endregion
  984. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  985. #endregion
  986. }
  987. }
  988. #endregion
  989. #region Add digivolution cards to bottom of sources
  990. /// <summary>
  991. /// 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
  992. /// </summary>
  993. /// <param name="addedDigivolutionCards"></param>
  994. /// <param name="cardEffect"></param>
  995. /// <param name="skipEffectAndActivateSkill"></param>
  996. /// <returns></returns>
  997. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false, bool isFacedown = false)
  998. {
  999. List<CardSource> addedCards = new List<CardSource>();
  1000. bool isFromSameDigimon = false;
  1001. bool isFromDigimon = false;
  1002. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  1003. {
  1004. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  1005. {
  1006. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  1007. {
  1008. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  1009. {
  1010. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
  1011. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  1012. if (!placePermanent.Placed)
  1013. {
  1014. continue;
  1015. }
  1016. }
  1017. }
  1018. }
  1019. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  1020. {
  1021. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  1022. {
  1023. isFromDigimon = true;
  1024. }
  1025. }
  1026. if (cardSources.Contains(addedDigivolutionCard))
  1027. {
  1028. isFromSameDigimon = true;
  1029. if (LinkedCards.Contains(addedDigivolutionCard))
  1030. {
  1031. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(addedDigivolutionCard, trashCard: false));
  1032. }
  1033. else if (addedDigivolutionCard == TopCard)
  1034. {
  1035. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  1036. ShowingPermanentCard.ShowPermanentData(true);
  1037. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  1038. addedDigivolutionCard,
  1039. this));
  1040. }
  1041. }
  1042. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  1043. if (!IsToken && !addedDigivolutionCard.IsToken)
  1044. {
  1045. cardSources.Add(addedDigivolutionCard);
  1046. if (isFacedown)
  1047. addedDigivolutionCard.SetReverse();
  1048. else
  1049. addedDigivolutionCard.SetFace();
  1050. addedCards.Add(addedDigivolutionCard);
  1051. }
  1052. }
  1053. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  1054. {
  1055. if (ShowingPermanentCard != null)
  1056. {
  1057. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  1058. }
  1059. #region Effect of "when the number of evolution sources increases"
  1060. #region Hashtable Setting
  1061. Hashtable hashtable = new Hashtable()
  1062. {
  1063. {"Permanent", this},
  1064. {"CardEffect", cardEffect},
  1065. {"CardSources", addedCards},
  1066. {"isFromSameDigimon", isFromSameDigimon},
  1067. {"isFromDigimon", isFromDigimon},
  1068. };
  1069. #endregion
  1070. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  1071. #endregion
  1072. }
  1073. }
  1074. #endregion
  1075. #region Add Link cards
  1076. /// <summary>
  1077. /// 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
  1078. /// </summary>
  1079. /// <param name="addedLinkCards"></param>
  1080. /// <param name="cardEffect"></param>
  1081. /// <param name="skipEffectAndActivateSkill"></param>
  1082. /// <returns></returns>
  1083. public IEnumerator AddLinkCard(CardSource addedLinkCard, ICardEffect cardEffect)
  1084. {
  1085. bool addedCard = false;
  1086. bool isFromDigimon = false;
  1087. if (CardEffectCommons.IsExistOnBattleArea(addedLinkCard))
  1088. {
  1089. if (addedLinkCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  1090. {
  1091. isFromDigimon = true;
  1092. }
  1093. }
  1094. if (LinkedCards.Count >= LinkedMax)
  1095. {
  1096. if(LinkedMax > 1)
  1097. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(null,((LinkedCards.Count + 1) - LinkedMax)));
  1098. else
  1099. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(LinkedCards[0]));
  1100. }
  1101. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
  1102. if (!this.IsToken && !addedLinkCard.IsToken)
  1103. {
  1104. LinkedCards.Insert(0, addedLinkCard);
  1105. LinkedDP += addedLinkCard.LinkDP;
  1106. this.cardSources.Insert(1, addedLinkCard);
  1107. addedLinkCard.SetFace();
  1108. addedCard = true;
  1109. }
  1110. if (addedCard)
  1111. {
  1112. if (ShowingPermanentCard != null)
  1113. {
  1114. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  1115. }
  1116. #region Add Linked Card
  1117. #region Hashtable Setting
  1118. Hashtable hashtable = new Hashtable()
  1119. {
  1120. {"Permanent", this},
  1121. {"CardEffect", cardEffect},
  1122. {"Card", addedLinkCard},
  1123. {"isFromDigimon", isFromDigimon},
  1124. };
  1125. #endregion
  1126. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.WhenLinked));
  1127. #endregion
  1128. }
  1129. }
  1130. #endregion
  1131. #region RemoveCardSource
  1132. public IEnumerator RemoveCardSource(CardSource cardSource)
  1133. {
  1134. yield return null;
  1135. cardSources.Remove(cardSource);
  1136. }
  1137. #endregion
  1138. #region Remove Linked Card
  1139. public IEnumerator RemoveLinkedCard(CardSource cardSource, int removeCount = 0, bool trashCard = true)
  1140. {
  1141. if (LinkedCards.Contains(cardSource))
  1142. {
  1143. LinkedDP -= cardSource.LinkDP;
  1144. LinkedCards.Remove(cardSource);
  1145. yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(cardSource));
  1146. if (trashCard)
  1147. {
  1148. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource));
  1149. }
  1150. }
  1151. if(removeCount > 0)
  1152. {
  1153. int maxCount = Mathf.Min(removeCount, LinkedCards.Count);
  1154. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  1155. selectCardEffect.SetUp(
  1156. canTargetCondition: (CardSource) => true,
  1157. canTargetCondition_ByPreSelecetedList: null,
  1158. canEndSelectCondition: null,
  1159. canNoSelect: () => false,
  1160. selectCardCoroutine: null,
  1161. afterSelectCardCoroutine: null,
  1162. message: $"Select {maxCount} card to trash.",
  1163. maxCount: removeCount,
  1164. canEndNotMax: false,
  1165. isShowOpponent: true,
  1166. mode: SelectCardEffect.Mode.Discard,
  1167. root: SelectCardEffect.Root.Custom,
  1168. customRootCardList: LinkedCards,
  1169. canLookReverseCard: true,
  1170. selectPlayer: TopCard.Owner,
  1171. cardEffect: null);
  1172. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  1173. }
  1174. //TODO: Add event call if something was removed
  1175. }
  1176. #endregion
  1177. #region Top Card
  1178. public CardSource TopCard
  1179. {
  1180. get
  1181. {
  1182. if (cardSources.Count >= 1)
  1183. {
  1184. if (LinkedCards.Count > 0)
  1185. return cardSources.First(source => !LinkedCards.Contains(source));
  1186. else
  1187. return cardSources[0];
  1188. }
  1189. return null;
  1190. }
  1191. }
  1192. #endregion
  1193. #region Permanent effect list
  1194. #region このパーマネントの効果リスト
  1195. public List<ICardEffect> EffectList(EffectTiming timing)
  1196. {
  1197. return EffectList_ForCard(timing, TopCard);
  1198. }
  1199. #endregion
  1200. #region このポケモンの追加効果リスト
  1201. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  1202. {
  1203. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1204. if (TopCard != null)
  1205. {
  1206. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  1207. {
  1208. ICardEffect cardEffect = GetCardEffect(timing);
  1209. if (cardEffect != null)
  1210. {
  1211. _EffectList.Add(cardEffect);
  1212. }
  1213. }
  1214. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  1215. {
  1216. ICardEffect cardEffect = GetCardEffect(timing);
  1217. if (cardEffect != null)
  1218. {
  1219. _EffectList.Add(cardEffect);
  1220. }
  1221. }
  1222. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  1223. {
  1224. ICardEffect cardEffect = GetCardEffect(timing);
  1225. if (cardEffect != null)
  1226. {
  1227. _EffectList.Add(cardEffect);
  1228. }
  1229. }
  1230. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  1231. {
  1232. ICardEffect cardEffect = GetCardEffect(timing);
  1233. if (cardEffect != null)
  1234. {
  1235. _EffectList.Add(cardEffect);
  1236. }
  1237. }
  1238. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  1239. {
  1240. ICardEffect cardEffect = GetCardEffect(timing);
  1241. if (cardEffect != null)
  1242. {
  1243. _EffectList.Add(cardEffect);
  1244. }
  1245. }
  1246. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  1247. {
  1248. ICardEffect cardEffect = GetCardEffect(timing);
  1249. if (cardEffect != null)
  1250. {
  1251. _EffectList.Add(cardEffect);
  1252. }
  1253. }
  1254. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  1255. {
  1256. ICardEffect cardEffect = GetCardEffect(timing);
  1257. if (cardEffect != null)
  1258. {
  1259. _EffectList.Add(cardEffect);
  1260. }
  1261. }
  1262. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  1263. {
  1264. ICardEffect cardEffect = GetCardEffect(timing);
  1265. if (cardEffect != null)
  1266. {
  1267. _EffectList.Add(cardEffect);
  1268. }
  1269. }
  1270. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  1271. {
  1272. ICardEffect cardEffect = GetCardEffect(timing);
  1273. if (cardEffect != null)
  1274. {
  1275. _EffectList.Add(cardEffect);
  1276. }
  1277. }
  1278. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  1279. foreach (ICardEffect cardEffect in _EffectList)
  1280. {
  1281. if (cardEffect != null)
  1282. {
  1283. if (cardEffect.EffectSourceCard == null)
  1284. {
  1285. cardEffect.SetEffectSourceCard(TopCard);
  1286. }
  1287. cardEffect.SetIsInheritedEffect(false);
  1288. }
  1289. }
  1290. }
  1291. return _EffectList;
  1292. }
  1293. #endregion
  1294. #region このパーマネントの効果リスト(引数:CardSource)
  1295. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  1296. {
  1297. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1298. if (TopCard != null && _cardSource != null)
  1299. {
  1300. foreach (CardSource cardSource in cardSources)
  1301. {
  1302. if (cardSource != null)
  1303. {
  1304. if (!cardSource.IsFlipped)
  1305. {
  1306. bool isTopCard = cardSource == TopCard;
  1307. if (!isTopCard)
  1308. {
  1309. if (!IsDigimon)
  1310. {
  1311. continue;
  1312. }
  1313. }
  1314. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  1315. {
  1316. if (cardEffect != null)
  1317. {
  1318. #region Entity, Inherited and Link effects
  1319. if (cardEffect.IsInheritedEffect && !isTopCard)
  1320. {
  1321. _EffectList.Add(cardEffect);
  1322. continue;
  1323. }
  1324. if (cardEffect.IsLinkedEffect && cardSource.IsLinked)
  1325. {
  1326. _EffectList.Add(cardEffect);
  1327. continue;
  1328. }
  1329. if(isTopCard && !cardEffect.IsInheritedEffect && !cardEffect.IsLinkedEffect)
  1330. {
  1331. _EffectList.Add(cardEffect);
  1332. }
  1333. #endregion
  1334. }
  1335. }
  1336. }
  1337. }
  1338. }
  1339. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  1340. {
  1341. if (cardEffect != null)
  1342. {
  1343. _EffectList.Add(cardEffect);
  1344. }
  1345. }
  1346. foreach (ICardEffect cardEffect in _EffectList)
  1347. {
  1348. if (cardEffect != null)
  1349. {
  1350. if (cardEffect.EffectSourceCard == null)
  1351. {
  1352. cardEffect.SetEffectSourceCard(_cardSource);
  1353. }
  1354. }
  1355. }
  1356. }
  1357. return _EffectList;
  1358. }
  1359. #endregion
  1360. #region 自分のターン終了時に消える効果
  1361. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1362. #endregion
  1363. #region 自分のドローフェイズ終了時に消える効果
  1364. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  1365. #endregion
  1366. #region お互いのターン終了時に消える効果
  1367. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1368. #endregion
  1369. #region 相手のターン終了時に消える効果
  1370. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1371. #endregion
  1372. #region バトル終了時に消える効果
  1373. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  1374. #endregion
  1375. #region 攻撃終了時に消える効果
  1376. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  1377. #endregion
  1378. #region 自分のターン開始時に消える効果
  1379. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  1380. #endregion
  1381. #region 次にアンタップする時に消える効果
  1382. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  1383. #endregion
  1384. #region 場を離れるまで残る効果
  1385. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  1386. #endregion
  1387. #endregion
  1388. #region 起動型効果を宣言できるか
  1389. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  1390. #endregion
  1391. #region 宣言可能な起動型効果リスト
  1392. public List<ICardEffect> CanDeclareSkillList()
  1393. {
  1394. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  1395. if (TopCard != null)
  1396. {
  1397. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  1398. {
  1399. if (_cardEffect is ActivateICardEffect)
  1400. {
  1401. if (_cardEffect.CanUse(null))
  1402. {
  1403. CanDeclareSkillList.Add(_cardEffect);
  1404. }
  1405. }
  1406. }
  1407. }
  1408. return CanDeclareSkillList;
  1409. }
  1410. #endregion
  1411. #region このパーマネントが場に出たターン
  1412. public int EnterFieldTurnCount { get; set; } = -1;
  1413. #endregion
  1414. #region このパーマネントを表す場のオブジェクト
  1415. public FieldPermanentCard ShowingPermanentCard { get; set; }
  1416. #endregion
  1417. #region Whether this permanent can be selected by the effect
  1418. public bool CanSelectBySkill(ICardEffect skill)
  1419. {
  1420. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1421. {
  1422. #region Effects of field permanents
  1423. foreach (Permanent permanent in player.GetFieldPermanents())
  1424. {
  1425. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1426. {
  1427. if (cardEffect is ICanNotSelectBySkillEffect)
  1428. {
  1429. if (cardEffect.CanUse(null))
  1430. {
  1431. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  1432. {
  1433. return false;
  1434. }
  1435. }
  1436. }
  1437. }
  1438. }
  1439. #endregion
  1440. }
  1441. return true;
  1442. }
  1443. #endregion
  1444. #region Number of sheets to undergo security check
  1445. public int InvertSecutiryValue
  1446. {
  1447. get
  1448. {
  1449. int Invert = 0;
  1450. List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
  1451. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1452. {
  1453. foreach (Permanent permanent in player.GetFieldPermanents())
  1454. {
  1455. #region Effects of permanents in play
  1456. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1457. {
  1458. if (cardEffect is IInvertSAttackEffect)
  1459. {
  1460. if (cardEffect.CanUse(null))
  1461. {
  1462. if (!TopCard.CanNotBeAffected(cardEffect))
  1463. {
  1464. cardEffects_InvertStrike.Add(cardEffect);
  1465. }
  1466. }
  1467. }
  1468. }
  1469. #endregion
  1470. }
  1471. #region player effect
  1472. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1473. {
  1474. if (cardEffect is IInvertSAttackEffect)
  1475. {
  1476. if (cardEffect.CanUse(null))
  1477. {
  1478. if (!TopCard.CanNotBeAffected(cardEffect))
  1479. {
  1480. cardEffects_InvertStrike.Add(cardEffect);
  1481. }
  1482. }
  1483. }
  1484. }
  1485. #endregion
  1486. }
  1487. foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
  1488. {
  1489. Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
  1490. }
  1491. return Mathf.Clamp(Invert,-1,1);
  1492. }
  1493. }
  1494. public List<int> SecurityAttackChanges
  1495. {
  1496. get
  1497. {
  1498. List<int> SecurityAttackChanges = new List<int>();
  1499. int Strike = 1;
  1500. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1501. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1502. {
  1503. foreach (Permanent permanent in player.GetFieldPermanents())
  1504. {
  1505. #region 場のパーマネントの効果
  1506. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1507. {
  1508. if (cardEffect is IChangeSAttackEffect)
  1509. {
  1510. if (cardEffect.CanUse(null))
  1511. {
  1512. if (!TopCard.CanNotBeAffected(cardEffect))
  1513. {
  1514. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1515. {
  1516. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1517. }
  1518. }
  1519. }
  1520. }
  1521. }
  1522. #endregion
  1523. }
  1524. #region プレイヤーの効果
  1525. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1526. {
  1527. if (cardEffect is IChangeSAttackEffect)
  1528. {
  1529. if (cardEffect.CanUse(null))
  1530. {
  1531. if (!TopCard.CanNotBeAffected(cardEffect))
  1532. {
  1533. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1534. {
  1535. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1536. }
  1537. }
  1538. }
  1539. }
  1540. }
  1541. #endregion
  1542. }
  1543. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1544. {
  1545. if (cardEffect is IChangeSAttackEffect)
  1546. {
  1547. if (cardEffect.CanUse(null))
  1548. {
  1549. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
  1550. if (Strike1 != Strike)
  1551. {
  1552. SecurityAttackChanges.Add(Strike1 - Strike);
  1553. }
  1554. }
  1555. }
  1556. }
  1557. return SecurityAttackChanges;
  1558. }
  1559. }
  1560. public bool HasSecurityAttackChanges
  1561. {
  1562. get
  1563. {
  1564. if (!IsDigimon)
  1565. {
  1566. return false;
  1567. }
  1568. return SecurityAttackChanges.Count >= 1;
  1569. }
  1570. }
  1571. public int Strike_AllowMinus
  1572. {
  1573. get
  1574. {
  1575. int Strike = 1;
  1576. #region Effect of changing the number of sheets to undergo security check
  1577. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1578. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1579. {
  1580. foreach (Permanent permanent in player.GetFieldPermanents())
  1581. {
  1582. #region Effects of permanents in play
  1583. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1584. {
  1585. if (cardEffect is IChangeSAttackEffect)
  1586. {
  1587. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1588. {
  1589. if (cardEffect.CanUse(null))
  1590. {
  1591. if (!TopCard.CanNotBeAffected(cardEffect))
  1592. {
  1593. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1594. }
  1595. }
  1596. }
  1597. }
  1598. }
  1599. #endregion
  1600. }
  1601. #region player effect
  1602. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1603. {
  1604. if (cardEffect is IChangeSAttackEffect)
  1605. {
  1606. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1607. {
  1608. if (cardEffect.CanUse(null))
  1609. {
  1610. if (!TopCard.CanNotBeAffected(cardEffect))
  1611. {
  1612. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1613. }
  1614. }
  1615. }
  1616. }
  1617. }
  1618. #endregion
  1619. }
  1620. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1621. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1622. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1623. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1624. {
  1625. if (cardEffect is IChangeSAttackEffect)
  1626. {
  1627. if (cardEffect.CanUse(null))
  1628. {
  1629. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1630. {
  1631. case CalculateOrder.UpToConstant:
  1632. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1633. break;
  1634. case CalculateOrder.UpDownValue:
  1635. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1636. break;
  1637. case CalculateOrder.DownToConstant:
  1638. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1639. break;
  1640. }
  1641. }
  1642. }
  1643. }
  1644. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1645. {
  1646. if (cardEffect is IChangeSAttackEffect)
  1647. {
  1648. if (cardEffect.CanUse(null))
  1649. {
  1650. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1651. }
  1652. }
  1653. }
  1654. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1655. {
  1656. if (cardEffect is IChangeSAttackEffect)
  1657. {
  1658. if (cardEffect.CanUse(null))
  1659. {
  1660. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1661. }
  1662. }
  1663. }
  1664. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1665. {
  1666. if (cardEffect is IChangeSAttackEffect)
  1667. {
  1668. if (cardEffect.CanUse(null))
  1669. {
  1670. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1671. }
  1672. }
  1673. }
  1674. #endregion
  1675. return Strike;
  1676. }
  1677. }
  1678. public int Strike
  1679. {
  1680. get
  1681. {
  1682. int Strike = Strike_AllowMinus;
  1683. if (Strike < 0)
  1684. {
  1685. Strike = 0;
  1686. }
  1687. return Strike;
  1688. }
  1689. }
  1690. #endregion
  1691. #region このパーマネントがタップされているかどうか
  1692. public bool OldIsSuspended = false;
  1693. public bool IsSuspended = false;
  1694. public int DPWhenSuspended = 114514;
  1695. #endregion
  1696. #region Whether this permanent can unsuspend
  1697. public bool CanUnsuspend
  1698. {
  1699. get
  1700. {
  1701. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1702. {
  1703. #region Effects of field permanents
  1704. foreach (Permanent permanent in player.GetFieldPermanents())
  1705. {
  1706. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1707. {
  1708. if (cardEffect is ICanNotUnsuspendEffect)
  1709. {
  1710. if (cardEffect.CanUse(null))
  1711. {
  1712. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1713. {
  1714. return false;
  1715. }
  1716. }
  1717. }
  1718. }
  1719. }
  1720. #endregion
  1721. #region Effects of players
  1722. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1723. {
  1724. if (cardEffect is ICanNotUnsuspendEffect)
  1725. {
  1726. if (cardEffect.CanUse(null))
  1727. {
  1728. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1729. {
  1730. return false;
  1731. }
  1732. }
  1733. }
  1734. }
  1735. #endregion
  1736. }
  1737. return true;
  1738. }
  1739. }
  1740. #endregion
  1741. #region このパーマネントが移動できるかどうか
  1742. public bool CanMove
  1743. {
  1744. get
  1745. {
  1746. if (TopCard != null)
  1747. {
  1748. #region the effects of permanents
  1749. if (GManager.instance.turnStateMachine.gameContext.Players
  1750. .Map(player => player.GetFieldPermanents())
  1751. .Flat()
  1752. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1753. .Flat()
  1754. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1755. && cardEffect.CanUse(null)
  1756. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1757. {
  1758. return false;
  1759. }
  1760. #endregion
  1761. #region the effects of players
  1762. if (GManager.instance.turnStateMachine.gameContext.Players
  1763. .Map(player => player.EffectList(EffectTiming.None))
  1764. .Flat()
  1765. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1766. && cardEffect.CanUse(null)
  1767. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1768. {
  1769. return false;
  1770. }
  1771. #endregion
  1772. #region the effects of itself
  1773. if (this == null)
  1774. {
  1775. if (EffectList(EffectTiming.None)
  1776. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1777. && cardEffect.CanUse(null)
  1778. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1779. {
  1780. return false;
  1781. }
  1782. }
  1783. #endregion
  1784. if (TopCard.PermanentOfThisCard().PermanentFrame.isBreedingAreaFrame())
  1785. {
  1786. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1787. {
  1788. return false;
  1789. }
  1790. }
  1791. else
  1792. {
  1793. if (TopCard.Owner.GetBreedingAreaPermanents().Count > 0)
  1794. return false;
  1795. }
  1796. if (!IsDigimon)
  1797. return false;
  1798. if (TopCard.IsDigiEgg && DP <= 0)
  1799. return false;
  1800. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1801. {
  1802. return false;
  1803. }
  1804. }
  1805. else
  1806. {
  1807. return false;
  1808. }
  1809. return true;
  1810. }
  1811. }
  1812. #endregion
  1813. #region このパーマネントが攻撃できるかどうか
  1814. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false, bool isExecute = false)
  1815. {
  1816. // can not attack with empty cards
  1817. if (TopCard == null)
  1818. {
  1819. return false;
  1820. }
  1821. // can not attack during opponent's turn
  1822. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1823. {
  1824. return false;
  1825. }
  1826. //Can not attack during another attack
  1827. if (GManager.instance.attackProcess.IsAttacking)
  1828. return false;
  1829. // can not attack to player
  1830. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex, isExecute))
  1831. {
  1832. // can not attack to opponent's Digimon
  1833. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex, isExecute)) == 0)
  1834. {
  1835. return false;
  1836. }
  1837. }
  1838. return true;
  1839. }
  1840. #endregion
  1841. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1842. public bool CanBlock(Permanent AttackingPermanent)
  1843. {
  1844. if (TopCard == null)
  1845. {
  1846. return false;
  1847. }
  1848. if (!IsDigimon)
  1849. {
  1850. return false;
  1851. }
  1852. if (IsSuspended)
  1853. {
  1854. return false;
  1855. }
  1856. if (!CanSuspend)
  1857. {
  1858. return false;
  1859. }
  1860. if (PermanentFrame != null)
  1861. {
  1862. if (!PermanentFrame.IsBattleAreaFrame())
  1863. {
  1864. return false;
  1865. }
  1866. }
  1867. if (!AttackingPermanent.IsDigimon)
  1868. return false;
  1869. if (!AttackingPermanent.CanSwitchAttackTarget)
  1870. return false;
  1871. #region "Unblockable" effect
  1872. #region Effects of permanents in play
  1873. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1874. {
  1875. foreach (Permanent permanent in player.GetFieldPermanents())
  1876. {
  1877. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1878. {
  1879. if (cardEffect is ICannotBlockEffect)
  1880. {
  1881. if (cardEffect.CanUse(null))
  1882. {
  1883. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1884. {
  1885. return false;
  1886. }
  1887. }
  1888. }
  1889. }
  1890. }
  1891. }
  1892. #endregion
  1893. #region player effect
  1894. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1895. {
  1896. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1897. {
  1898. if (cardEffect is ICannotBlockEffect)
  1899. {
  1900. if (cardEffect.CanUse(null))
  1901. {
  1902. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1903. {
  1904. if (!TopCard.CanNotBeAffected(cardEffect))
  1905. {
  1906. return false;
  1907. }
  1908. }
  1909. }
  1910. }
  1911. }
  1912. }
  1913. #endregion
  1914. #endregion
  1915. return true;
  1916. }
  1917. #endregion
  1918. #region 対象のパーマネントを攻撃できるか
  1919. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false, bool isExecute = false)
  1920. {
  1921. if (TopCard != null)
  1922. {
  1923. if (!IsDigimon)
  1924. {
  1925. return false;
  1926. }
  1927. if (!withoutTap)
  1928. {
  1929. if (IsSuspended)
  1930. {
  1931. return false;
  1932. }
  1933. if (!CanSuspend)
  1934. {
  1935. return false;
  1936. }
  1937. }
  1938. if (PermanentFrame != null)
  1939. {
  1940. if (!PermanentFrame.IsBattleAreaFrame())
  1941. {
  1942. return false;
  1943. }
  1944. }
  1945. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1946. {
  1947. if (!HasRush && !isVortex)
  1948. {
  1949. return false;
  1950. }
  1951. }
  1952. #region 「対象の防御パーマネントを攻撃できない」効果
  1953. #region 場のパーマネントの効果
  1954. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1955. {
  1956. foreach (Permanent permanent in player.GetFieldPermanents())
  1957. {
  1958. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1959. {
  1960. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1961. {
  1962. if (cardEffect1.CanUse(null))
  1963. {
  1964. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1965. {
  1966. if (!TopCard.CanNotBeAffected(cardEffect1))
  1967. {
  1968. return false;
  1969. }
  1970. }
  1971. }
  1972. }
  1973. }
  1974. }
  1975. }
  1976. #endregion
  1977. #region プレイヤーの効果
  1978. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1979. {
  1980. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1981. {
  1982. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1983. {
  1984. if (cardEffect1.CanUse(null))
  1985. {
  1986. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1987. {
  1988. if (!TopCard.CanNotBeAffected(cardEffect1))
  1989. {
  1990. return false;
  1991. }
  1992. }
  1993. }
  1994. }
  1995. }
  1996. }
  1997. #endregion
  1998. #endregion
  1999. if (Defender != null)
  2000. {
  2001. if (Defender.TopCard != null)
  2002. {
  2003. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  2004. {
  2005. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  2006. {
  2007. if (Defender.IsSuspended || isExecute)
  2008. {
  2009. return true;
  2010. }
  2011. #region 「対象の防御パーマネントを攻撃できる」効果
  2012. #region 場のパーマネントの効果
  2013. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2014. {
  2015. foreach (Permanent permanent in player.GetFieldPermanents())
  2016. {
  2017. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2018. {
  2019. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  2020. {
  2021. if (cardEffect1.CanUse(null))
  2022. {
  2023. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  2024. {
  2025. return true;
  2026. }
  2027. }
  2028. }
  2029. }
  2030. }
  2031. }
  2032. #endregion
  2033. #region プレイヤーの効果
  2034. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2035. {
  2036. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2037. {
  2038. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  2039. {
  2040. if (cardEffect1.CanUse(null))
  2041. {
  2042. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  2043. {
  2044. return true;
  2045. }
  2046. }
  2047. }
  2048. }
  2049. }
  2050. #endregion
  2051. #endregion
  2052. }
  2053. }
  2054. }
  2055. }
  2056. else
  2057. {
  2058. return true;
  2059. }
  2060. }
  2061. return false;
  2062. }
  2063. #endregion
  2064. #region Is Unblockable
  2065. public bool IsUnblockable
  2066. {
  2067. get
  2068. {
  2069. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2070. {
  2071. if (cardEffect is CannotBlockClass)
  2072. {
  2073. if (cardEffect.EffectName == "Unblockable")
  2074. {
  2075. return true;
  2076. }
  2077. }
  2078. }
  2079. return false;
  2080. }
  2081. }
  2082. #endregion
  2083. #region Has Blocker
  2084. public bool HasBlocker
  2085. {
  2086. get
  2087. {
  2088. #region if attacking digimon has collision
  2089. if (GManager.instance.attackProcess.ActiveAttack() && CardEffectCommons.IsPermanentExistsOnBattleArea(this))
  2090. {
  2091. Permanent attackingPermanent = GManager.instance.attackProcess.AttackingPermanent;
  2092. if (attackingPermanent != null
  2093. && attackingPermanent.TopCard !=null
  2094. && attackingPermanent.TopCard.Owner != TopCard.Owner
  2095. && attackingPermanent.HasCollision)
  2096. {
  2097. ActivateClass fakeCollisionClass = new();
  2098. fakeCollisionClass.SetUpICardEffect("Collision", _ => true, attackingPermanent.TopCard);
  2099. if (!TopCard.CanNotBeAffected(fakeCollisionClass))//Check can be affected by opponent's Digimon effects
  2100. return true;
  2101. }
  2102. }
  2103. #endregion
  2104. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2105. {
  2106. #region Effects of permanents in play
  2107. foreach (Permanent permanent in player.GetFieldPermanents())
  2108. {
  2109. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2110. {
  2111. if (cardEffect is IBlockerEffect)
  2112. {
  2113. if (cardEffect.CanTrigger(null))
  2114. {
  2115. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2116. {
  2117. return true;
  2118. }
  2119. }
  2120. }
  2121. }
  2122. }
  2123. #endregion
  2124. #region Effects of faceup security
  2125. foreach (CardSource source in player.SecurityCards)
  2126. {
  2127. if (source.IsFlipped)
  2128. continue;
  2129. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2130. {
  2131. if (cardEffect is IBlockerEffect)
  2132. {
  2133. if (cardEffect.CanTrigger(null))
  2134. {
  2135. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2136. {
  2137. return true;
  2138. }
  2139. }
  2140. }
  2141. }
  2142. }
  2143. #endregion
  2144. #region プレイヤーの効果
  2145. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2146. {
  2147. if (cardEffect is IBlockerEffect)
  2148. {
  2149. if (cardEffect.CanTrigger(null))
  2150. {
  2151. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2152. {
  2153. return true;
  2154. }
  2155. }
  2156. }
  2157. }
  2158. #endregion
  2159. }
  2160. return false;
  2161. }
  2162. }
  2163. #endregion
  2164. #region Has Jamming
  2165. public bool HasJamming
  2166. {
  2167. get
  2168. {
  2169. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2170. {
  2171. foreach (Permanent permanent in player.GetFieldPermanents())
  2172. {
  2173. #region 場のパーマネントの効果
  2174. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2175. {
  2176. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2177. {
  2178. if (cardEffect.CanTrigger(null))
  2179. {
  2180. if (cardEffect.EffectName == "Jamming")
  2181. {
  2182. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  2183. {
  2184. return true;
  2185. }
  2186. }
  2187. }
  2188. }
  2189. }
  2190. #endregion
  2191. }
  2192. #region プレイヤーの効果
  2193. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2194. {
  2195. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2196. {
  2197. if (cardEffect.CanTrigger(null))
  2198. {
  2199. if (cardEffect.EffectName == "Jamming")
  2200. {
  2201. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  2202. {
  2203. return true;
  2204. }
  2205. }
  2206. }
  2207. }
  2208. }
  2209. #endregion
  2210. }
  2211. return false;
  2212. }
  2213. }
  2214. #endregion
  2215. #region Has Ice Clad
  2216. public bool HasIceclad
  2217. {
  2218. get
  2219. {
  2220. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2221. {
  2222. #region Ice clad permanent effects
  2223. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  2224. {
  2225. if (cardEffect is IIcecladEffect)
  2226. {
  2227. if (cardEffect.CanTrigger(null))
  2228. {
  2229. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2230. {
  2231. return true;
  2232. }
  2233. }
  2234. }
  2235. }
  2236. #endregion
  2237. #region Ice clad Player Effects
  2238. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2239. {
  2240. if (cardEffect is IIcecladEffect)
  2241. {
  2242. if (cardEffect.CanTrigger(null))
  2243. {
  2244. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2245. {
  2246. return true;
  2247. }
  2248. }
  2249. }
  2250. }
  2251. #endregion
  2252. }
  2253. return false;
  2254. }
  2255. }
  2256. #endregion
  2257. #region Whether this permanent has Pierce
  2258. public bool HasPierce
  2259. {
  2260. get
  2261. {
  2262. if (IsDigimon)
  2263. {
  2264. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  2265. {
  2266. if (cardEffect is ActivateICardEffect)
  2267. {
  2268. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  2269. {
  2270. if (cardEffect.EffectName == "Pierce")
  2271. {
  2272. return true;
  2273. }
  2274. if (cardEffect.EffectName == "Piercing")
  2275. {
  2276. return true;
  2277. }
  2278. }
  2279. }
  2280. }
  2281. }
  2282. return false;
  2283. }
  2284. }
  2285. #endregion
  2286. #region Has Reboot
  2287. public bool HasReboot
  2288. {
  2289. get
  2290. {
  2291. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2292. {
  2293. foreach (Permanent permanent in player.GetFieldPermanents())
  2294. {
  2295. #region 場のパーマネントの効果
  2296. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2297. {
  2298. if (cardEffect is IRebootEffect)
  2299. {
  2300. if (cardEffect.CanTrigger(null))
  2301. {
  2302. if (((IRebootEffect)cardEffect).HasReboot(this))
  2303. {
  2304. return true;
  2305. }
  2306. }
  2307. }
  2308. }
  2309. #endregion
  2310. }
  2311. #region Effects of faceup security
  2312. foreach (CardSource source in player.SecurityCards)
  2313. {
  2314. if (source.IsFlipped)
  2315. continue;
  2316. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2317. {
  2318. if (cardEffect is IRebootEffect)
  2319. {
  2320. if (cardEffect.CanTrigger(null))
  2321. {
  2322. if (((IRebootEffect)cardEffect).HasReboot(this))
  2323. {
  2324. return true;
  2325. }
  2326. }
  2327. }
  2328. }
  2329. }
  2330. #endregion
  2331. #region プレイヤーの効果
  2332. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2333. {
  2334. if (cardEffect is IRebootEffect)
  2335. {
  2336. if (cardEffect.CanTrigger(null))
  2337. {
  2338. if (((IRebootEffect)cardEffect).HasReboot(this))
  2339. {
  2340. return true;
  2341. }
  2342. }
  2343. }
  2344. }
  2345. #endregion
  2346. }
  2347. return false;
  2348. }
  2349. }
  2350. #endregion
  2351. #region Has Raid
  2352. public bool HasRaid
  2353. {
  2354. get
  2355. {
  2356. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2357. {
  2358. if (cardEffect is ActivateICardEffect)
  2359. {
  2360. if (cardEffect.EffectName == "Raid")
  2361. {
  2362. return true;
  2363. }
  2364. }
  2365. }
  2366. return false;
  2367. }
  2368. }
  2369. #endregion
  2370. #region Has Rush
  2371. public bool HasRush
  2372. {
  2373. get
  2374. {
  2375. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2376. {
  2377. foreach (Permanent permanent in player.GetFieldPermanents())
  2378. {
  2379. #region 場のパーマネントの効果
  2380. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2381. {
  2382. if (cardEffect is IRushEffect)
  2383. {
  2384. if (cardEffect.CanTrigger(null))
  2385. {
  2386. if (((IRushEffect)cardEffect).HasRush(this))
  2387. {
  2388. return true;
  2389. }
  2390. }
  2391. }
  2392. }
  2393. #endregion
  2394. }
  2395. #region Effects of Face-up Security
  2396. foreach (CardSource source in player.SecurityCards)
  2397. {
  2398. if (source.IsFlipped)
  2399. continue;
  2400. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2401. {
  2402. if (cardEffect is IRushEffect)
  2403. {
  2404. if (cardEffect.CanTrigger(null))
  2405. {
  2406. if (((IRushEffect)cardEffect).HasRush(this))
  2407. {
  2408. return true;
  2409. }
  2410. }
  2411. }
  2412. }
  2413. }
  2414. #endregion
  2415. #region プレイヤーの効果
  2416. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2417. {
  2418. if (cardEffect is IRushEffect)
  2419. {
  2420. if (cardEffect.CanTrigger(null))
  2421. {
  2422. if (((IRushEffect)cardEffect).HasRush(this))
  2423. {
  2424. return true;
  2425. }
  2426. }
  2427. }
  2428. }
  2429. #endregion
  2430. }
  2431. return false;
  2432. }
  2433. }
  2434. #endregion
  2435. #region Has Retaliation
  2436. public bool HasRetaliation
  2437. {
  2438. get
  2439. {
  2440. if (RetaliationCount >= 1)
  2441. {
  2442. return true;
  2443. }
  2444. return false;
  2445. }
  2446. }
  2447. #endregion
  2448. #region Retaliation Count
  2449. public int RetaliationCount
  2450. {
  2451. get
  2452. {
  2453. int count = 0;
  2454. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2455. {
  2456. if (cardEffect is ActivateICardEffect)
  2457. {
  2458. if (cardEffect.EffectName == "Retaliation")
  2459. {
  2460. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2461. {
  2462. count++;
  2463. }
  2464. }
  2465. }
  2466. }
  2467. return count;
  2468. }
  2469. }
  2470. #endregion
  2471. #region HasAscension
  2472. public bool HasAscension
  2473. {
  2474. get
  2475. {
  2476. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2477. {
  2478. if (cardEffect is ActivateICardEffect)
  2479. {
  2480. if (cardEffect.EffectName == "Ascension")
  2481. {
  2482. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2483. {
  2484. return true;
  2485. }
  2486. }
  2487. }
  2488. }
  2489. return false;
  2490. }
  2491. }
  2492. #endregion
  2493. #region Has Fortitude
  2494. public bool HasFortitude
  2495. {
  2496. get
  2497. {
  2498. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2499. {
  2500. if (cardEffect is ActivateICardEffect)
  2501. {
  2502. if (cardEffect.EffectName == "Fortitude")
  2503. {
  2504. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2505. {
  2506. return true;
  2507. }
  2508. }
  2509. }
  2510. }
  2511. return false;
  2512. }
  2513. }
  2514. #endregion
  2515. #region Has Blitz
  2516. public bool HasBlitz
  2517. {
  2518. get
  2519. {
  2520. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  2521. {
  2522. if (cardEffect is ActivateICardEffect)
  2523. {
  2524. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  2525. {
  2526. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2527. {
  2528. if (cardEffect.EffectDiscription.Contains("Blitz"))
  2529. {
  2530. return true;
  2531. }
  2532. }
  2533. }
  2534. }
  2535. }
  2536. return false;
  2537. }
  2538. }
  2539. #endregion
  2540. #region Has Evade
  2541. public bool HasEvade
  2542. {
  2543. get
  2544. {
  2545. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2546. {
  2547. if (cardEffect is ActivateICardEffect)
  2548. {
  2549. Hashtable hashtable = new Hashtable()
  2550. {
  2551. {"Permanents", new List<Permanent>() { this }}
  2552. };
  2553. if (cardEffect.CanTrigger(hashtable))
  2554. {
  2555. if (cardEffect.EffectName == "Evade")
  2556. {
  2557. return true;
  2558. }
  2559. }
  2560. }
  2561. }
  2562. return false;
  2563. }
  2564. }
  2565. #endregion
  2566. #region Has Mind Link
  2567. public bool HasMindLink
  2568. {
  2569. get
  2570. {
  2571. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  2572. {
  2573. if (cardEffect is ActivateICardEffect)
  2574. {
  2575. if (cardEffect.CanTrigger(null))
  2576. {
  2577. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2578. {
  2579. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2580. {
  2581. return true;
  2582. }
  2583. }
  2584. }
  2585. }
  2586. }
  2587. return false;
  2588. }
  2589. }
  2590. #endregion
  2591. #region Has Barrier
  2592. public bool HasBarrier
  2593. {
  2594. get
  2595. {
  2596. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2597. {
  2598. if (cardEffect is ActivateICardEffect)
  2599. {
  2600. Hashtable hashtable = new Hashtable();
  2601. hashtable.Add("Permanents", new List<Permanent>() { this });
  2602. hashtable.Add("battle", new IBattle(null, null, null));
  2603. if (cardEffect.CanTrigger(hashtable))
  2604. {
  2605. if (cardEffect.EffectName == "Barrier")
  2606. {
  2607. return true;
  2608. }
  2609. }
  2610. }
  2611. }
  2612. return false;
  2613. }
  2614. }
  2615. #endregion
  2616. #region Has Alliance
  2617. public bool HasAlliance
  2618. {
  2619. get
  2620. {
  2621. Hashtable hashtable = new Hashtable(){
  2622. {"AttackingPermanent", this}
  2623. };
  2624. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2625. {
  2626. foreach (Permanent permanent in player.GetFieldPermanents())
  2627. {
  2628. #region Permanent Effects
  2629. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2630. {
  2631. if (cardEffect.EffectName == "Alliance")
  2632. {
  2633. if (cardEffect.CanTrigger(hashtable))
  2634. {
  2635. return true;
  2636. }
  2637. }
  2638. }
  2639. #endregion
  2640. }
  2641. #region Effects of faceup security
  2642. foreach (CardSource source in player.SecurityCards)
  2643. {
  2644. if (source.IsFlipped)
  2645. continue;
  2646. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnAllyAttack))
  2647. {
  2648. if (cardEffect.EffectName == "Alliance")
  2649. {
  2650. if (cardEffect.CanTrigger(hashtable))
  2651. {
  2652. return true;
  2653. }
  2654. }
  2655. }
  2656. }
  2657. #endregion
  2658. #region Player Effects
  2659. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2660. {
  2661. if (cardEffect.EffectName == "Alliance")
  2662. {
  2663. if (cardEffect.CanTrigger(hashtable))
  2664. {
  2665. return true;
  2666. }
  2667. }
  2668. }
  2669. #endregion
  2670. }
  2671. return false;
  2672. }
  2673. }
  2674. #endregion
  2675. #region Has Collision
  2676. public bool HasCollision
  2677. {
  2678. get
  2679. {
  2680. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2681. {
  2682. foreach (Permanent permanent in player.GetFieldPermanents())
  2683. {
  2684. #region Permanent Effects
  2685. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnCounterTiming))
  2686. {
  2687. if (cardEffect is ICollisionEffect)
  2688. {
  2689. if (cardEffect.CanTrigger(null))
  2690. {
  2691. if (((ICollisionEffect)cardEffect).HasCollision(this))
  2692. {
  2693. return true;
  2694. }
  2695. }
  2696. }
  2697. }
  2698. #endregion
  2699. }
  2700. #region Effects of faceup security
  2701. foreach (CardSource source in player.SecurityCards)
  2702. {
  2703. if (source.IsFlipped)
  2704. continue;
  2705. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnCounterTiming))
  2706. {
  2707. if (cardEffect is ICollisionEffect)
  2708. {
  2709. if (cardEffect.CanTrigger(null))
  2710. {
  2711. if (((ICollisionEffect)cardEffect).HasCollision(this))
  2712. {
  2713. return true;
  2714. }
  2715. }
  2716. }
  2717. }
  2718. }
  2719. #endregion
  2720. #region Player Effects
  2721. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnCounterTiming))
  2722. {
  2723. if (cardEffect is ICollisionEffect)
  2724. {
  2725. if (cardEffect.CanTrigger(null))
  2726. {
  2727. if (((ICollisionEffect)cardEffect).HasCollision(this))
  2728. {
  2729. return true;
  2730. }
  2731. }
  2732. }
  2733. }
  2734. #endregion
  2735. }
  2736. return false;
  2737. }
  2738. }
  2739. #endregion
  2740. #region Has Partition
  2741. public bool HasPartition
  2742. {
  2743. get
  2744. {
  2745. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2746. {
  2747. if (cardEffect is ActivateICardEffect)
  2748. {
  2749. if (cardEffect.EffectName == "Partition")
  2750. {
  2751. return true;
  2752. }
  2753. }
  2754. }
  2755. return false;
  2756. }
  2757. }
  2758. #endregion
  2759. #region Has Scapegoat
  2760. public bool HasScapegoat
  2761. {
  2762. get
  2763. {
  2764. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2765. {
  2766. if (cardEffect is ActivateICardEffect)
  2767. {
  2768. if (cardEffect.EffectName == "<Scapegoat>")
  2769. {
  2770. return true;
  2771. }
  2772. }
  2773. }
  2774. return false;
  2775. }
  2776. }
  2777. #endregion
  2778. #region 消滅時効化を持つか
  2779. public bool HasOnDeletionEffect
  2780. {
  2781. get
  2782. {
  2783. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2784. {
  2785. if (cardEffect is ActivateICardEffect)
  2786. {
  2787. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2788. {
  2789. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2790. {
  2791. if (cardEffect.IsOnDeletion)
  2792. {
  2793. return true;
  2794. }
  2795. }
  2796. }
  2797. }
  2798. }
  2799. return false;
  2800. }
  2801. }
  2802. #endregion
  2803. #region バトルしているか
  2804. public IBattle battle { get; set; } = null;
  2805. #endregion
  2806. #region Can Be Destroyed
  2807. public bool CanBeDestroyed()
  2808. {
  2809. #region 消滅しない効果
  2810. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2811. {
  2812. foreach (Permanent permanent in player.GetFieldPermanents())
  2813. {
  2814. #region 場のパーマネントの効果
  2815. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2816. {
  2817. if (cardEffect is ICanNotBeDestroyedEffect)
  2818. {
  2819. if (cardEffect.CanUse(null))
  2820. {
  2821. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2822. {
  2823. return false;
  2824. }
  2825. }
  2826. }
  2827. }
  2828. #endregion
  2829. }
  2830. #region プレイヤーの効果
  2831. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2832. {
  2833. if (cardEffect is ICanNotBeDestroyedEffect)
  2834. {
  2835. if (cardEffect.CanUse(null))
  2836. {
  2837. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2838. {
  2839. return false;
  2840. }
  2841. }
  2842. }
  2843. }
  2844. #endregion
  2845. }
  2846. #endregion
  2847. return true;
  2848. }
  2849. #endregion
  2850. #region Can Be Destroyed By Battle
  2851. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2852. {
  2853. if (!CanBeDestroyed())
  2854. {
  2855. return false;
  2856. }
  2857. #region Given Effects
  2858. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2859. {
  2860. foreach (Permanent permanent in player.GetFieldPermanents())
  2861. {
  2862. #region Permanents
  2863. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2864. {
  2865. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2866. {
  2867. if (cardEffect.CanUse(null))
  2868. {
  2869. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2870. {
  2871. return false;
  2872. }
  2873. }
  2874. }
  2875. }
  2876. #endregion
  2877. }
  2878. #region Effects of faceup security
  2879. foreach (CardSource source in player.SecurityCards)
  2880. {
  2881. if (source.IsFlipped)
  2882. continue;
  2883. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2884. {
  2885. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2886. {
  2887. if (cardEffect.CanUse(null))
  2888. {
  2889. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2890. {
  2891. return false;
  2892. }
  2893. }
  2894. }
  2895. }
  2896. }
  2897. #endregion
  2898. #region Player Effects
  2899. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2900. {
  2901. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2902. {
  2903. if (cardEffect.CanUse(null))
  2904. {
  2905. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2906. {
  2907. return false;
  2908. }
  2909. }
  2910. }
  2911. }
  2912. #endregion
  2913. }
  2914. #endregion
  2915. return true;
  2916. }
  2917. #endregion
  2918. #region このパーマネントが効果で消滅するか
  2919. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2920. {
  2921. if (this.TopCard != null)
  2922. {
  2923. if (this.TopCard.CanNotBeAffected(cardEffect))
  2924. {
  2925. return false;
  2926. }
  2927. if (!CanBeDestroyed())
  2928. {
  2929. return false;
  2930. }
  2931. #region 効果で消滅しない効果
  2932. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2933. {
  2934. foreach (Permanent permanent in player.GetFieldPermanents())
  2935. {
  2936. #region 場のパーマネントの効果
  2937. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2938. {
  2939. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2940. {
  2941. if (cardEffect1.CanUse(null))
  2942. {
  2943. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2944. {
  2945. return false;
  2946. }
  2947. }
  2948. }
  2949. }
  2950. #endregion
  2951. }
  2952. #region プレイヤーの効果
  2953. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2954. {
  2955. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2956. {
  2957. if (cardEffect1.CanUse(null))
  2958. {
  2959. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2960. {
  2961. return false;
  2962. }
  2963. }
  2964. }
  2965. }
  2966. #endregion
  2967. }
  2968. #endregion
  2969. }
  2970. return true;
  2971. }
  2972. #endregion
  2973. #region Can Leave Field
  2974. public bool CanBeRemoved()
  2975. {
  2976. #region Effect that never disappears
  2977. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2978. {
  2979. foreach (Permanent permanent in player.GetFieldPermanents())
  2980. {
  2981. #region Effects of permanents in play
  2982. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2983. {
  2984. if (cardEffect is ICanNotBeRemovedEffect)
  2985. {
  2986. if (cardEffect.CanUse(null))
  2987. {
  2988. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2989. {
  2990. return false;
  2991. }
  2992. }
  2993. }
  2994. }
  2995. #endregion
  2996. }
  2997. #region player effect
  2998. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2999. {
  3000. if (cardEffect is ICanNotBeRemovedEffect)
  3001. {
  3002. if (cardEffect.CanUse(null))
  3003. {
  3004. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  3005. {
  3006. return false;
  3007. }
  3008. }
  3009. }
  3010. }
  3011. #endregion
  3012. }
  3013. #endregion
  3014. return true;
  3015. }
  3016. #endregion
  3017. #region トークンかどうか
  3018. public bool IsToken
  3019. {
  3020. get
  3021. {
  3022. if (TopCard != null)
  3023. {
  3024. if (TopCard.IsToken)
  3025. {
  3026. return true;
  3027. }
  3028. }
  3029. return false;
  3030. }
  3031. }
  3032. #endregion
  3033. #region そのパーマネントが消滅・バウンス待機状態か
  3034. public bool willBeRemoveField { get; set; } = false;
  3035. #endregion
  3036. #region Is a Digimon card
  3037. public bool IsDigimon
  3038. {
  3039. get
  3040. {
  3041. if (TopCard != null)
  3042. {
  3043. if (TopCard.IsFlipped)
  3044. return false;
  3045. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  3046. {
  3047. return true;
  3048. }
  3049. #region Effect on TopCard
  3050. foreach (ICardEffect cardEffect in TopCard.EffectList(EffectTiming.None))
  3051. {
  3052. if (cardEffect is ITreatAsDigimonEffect)
  3053. {
  3054. if (cardEffect.CanTrigger(null))
  3055. {
  3056. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  3057. {
  3058. return true;
  3059. }
  3060. }
  3061. }
  3062. }
  3063. #endregion
  3064. #region Effect of treating it as a Digimon
  3065. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3066. {
  3067. foreach (Permanent permanent in player.GetFieldPermanents())
  3068. {
  3069. #region Effects of permanents in play
  3070. 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
  3071. {
  3072. if (cardEffect is ITreatAsDigimonEffect)
  3073. {
  3074. if (cardEffect.CanTrigger(null))
  3075. {
  3076. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  3077. {
  3078. return true;
  3079. }
  3080. }
  3081. }
  3082. }
  3083. #endregion
  3084. }
  3085. #region player effect
  3086. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3087. {
  3088. if (cardEffect is ITreatAsDigimonEffect)
  3089. {
  3090. if (cardEffect.CanTrigger(null))
  3091. {
  3092. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  3093. {
  3094. return true;
  3095. }
  3096. }
  3097. }
  3098. }
  3099. #endregion
  3100. }
  3101. #endregion
  3102. }
  3103. return false;
  3104. }
  3105. }
  3106. #endregion
  3107. #region Is a Tamer card
  3108. public bool IsTamer
  3109. {
  3110. get
  3111. {
  3112. if (TopCard != null)
  3113. {
  3114. if (TopCard.IsFlipped)
  3115. return false;
  3116. if (TopCard.IsTamer)
  3117. {
  3118. return true;
  3119. }
  3120. }
  3121. return false;
  3122. }
  3123. }
  3124. #endregion
  3125. #region Is an Option card
  3126. public bool IsOption
  3127. {
  3128. get
  3129. {
  3130. if (TopCard != null)
  3131. {
  3132. if (TopCard.IsOption && !TopCard.IsDigimon) //DualCard is never an option while it is a permanent
  3133. {
  3134. return true;
  3135. }
  3136. }
  3137. return false;
  3138. }
  3139. }
  3140. #endregion
  3141. #region Levels handled by Jogress
  3142. public List<int> Levels_ForJogress(CardSource cardSource)
  3143. {
  3144. List<int> levels = new List<int>();
  3145. if (cardSource != null)
  3146. {
  3147. if (cardSource.HasLevel)
  3148. {
  3149. levels.Add(this.Level);
  3150. }
  3151. #region Effect of "adding levels handled by jogless evolution"
  3152. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3153. {
  3154. foreach (Permanent permanent in player.GetFieldPermanents())
  3155. {
  3156. #region Effects of permanents in play
  3157. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3158. {
  3159. if (cardEffect is IAddJogressLevelsEffect)
  3160. {
  3161. if (cardEffect.CanUse(null))
  3162. {
  3163. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  3164. {
  3165. levels.Add(level);
  3166. }
  3167. }
  3168. }
  3169. }
  3170. #endregion
  3171. }
  3172. #region player effect
  3173. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3174. {
  3175. if (cardEffect is IAddJogressLevelsEffect)
  3176. {
  3177. if (cardEffect.CanUse(null))
  3178. {
  3179. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  3180. {
  3181. levels.Add(level);
  3182. }
  3183. }
  3184. }
  3185. }
  3186. #endregion
  3187. }
  3188. #endregion
  3189. }
  3190. return levels;
  3191. }
  3192. #endregion
  3193. #region Names handled by Jogress
  3194. public List<string> Names_ForDNA(CardSource cardSource)
  3195. {
  3196. List<string> names = new List<string>();
  3197. if (cardSource != null)
  3198. {
  3199. foreach(string name in cardSource.CardNames)
  3200. names.Add(name);
  3201. #region Effect of "adding names handled by DNA evolution"
  3202. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3203. {
  3204. foreach (Permanent permanent in player.GetFieldPermanents())
  3205. {
  3206. #region Effects of permanents in play
  3207. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3208. {
  3209. if (cardEffect is IAddDNANamesEffect)
  3210. {
  3211. if (cardEffect.CanUse(null))
  3212. {
  3213. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  3214. {
  3215. names.Add(name);
  3216. }
  3217. }
  3218. }
  3219. }
  3220. #endregion
  3221. }
  3222. #region player effect
  3223. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3224. {
  3225. if (cardEffect is IAddDNANamesEffect)
  3226. {
  3227. if (cardEffect.CanUse(null))
  3228. {
  3229. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  3230. {
  3231. names.Add(name);
  3232. }
  3233. }
  3234. }
  3235. }
  3236. #endregion
  3237. }
  3238. #endregion
  3239. }
  3240. return names;
  3241. }
  3242. #endregion
  3243. #region バトルで消滅したか
  3244. public bool IsDestroyedByBattle { get; set; } = false;
  3245. #endregion
  3246. #region 消滅に使用された効果
  3247. public ICardEffect DestroyingEffect { get; set; } = null;
  3248. #endregion
  3249. #region 他のパーマネントの下に置くのに使用された効果
  3250. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  3251. #endregion
  3252. #region 手札バウンス に使用された効果
  3253. public ICardEffect HandBounceEffect { get; set; } = null;
  3254. #endregion
  3255. #region 山札バウンス に使用された効果
  3256. public ICardEffect LibraryBounceEffect { get; set; } = null;
  3257. #endregion
  3258. #region 登場に使用された効果
  3259. public ICardEffect PlayingEffect { get; set; } = null;
  3260. #endregion
  3261. #region 進化に使用された効果
  3262. public ICardEffect DigivolvingEffect { get; set; } = null;
  3263. #endregion
  3264. #region Whether this digimon is placed in the trash by not having a DP
  3265. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  3266. #endregion
  3267. #region Whether this permanent can suspend
  3268. public bool CanSuspend
  3269. {
  3270. get
  3271. {
  3272. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  3273. {
  3274. #region Effects of field permanents
  3275. foreach (Permanent permanent in player.GetFieldPermanents())
  3276. {
  3277. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3278. {
  3279. if (cardEffect is ICanNotSuspendEffect)
  3280. {
  3281. if (cardEffect.CanUse(null))
  3282. {
  3283. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  3284. {
  3285. return false;
  3286. }
  3287. }
  3288. }
  3289. }
  3290. }
  3291. #endregion
  3292. #region Effects of players
  3293. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3294. {
  3295. if (cardEffect is ICanNotSuspendEffect)
  3296. {
  3297. if (cardEffect.CanUse(null))
  3298. {
  3299. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  3300. {
  3301. return false;
  3302. }
  3303. }
  3304. }
  3305. }
  3306. #endregion
  3307. }
  3308. return true;
  3309. }
  3310. }
  3311. #endregion
  3312. #region このデジモンのアタックの対象が変更できるか
  3313. public bool CanSwitchAttackTarget
  3314. {
  3315. get
  3316. {
  3317. #region アタックの対象が変更できない効果
  3318. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3319. {
  3320. foreach (Permanent permanent in player.GetFieldPermanents())
  3321. {
  3322. #region 場のパーマネントの効果
  3323. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3324. {
  3325. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3326. {
  3327. if (cardEffect.CanUse(null))
  3328. {
  3329. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3330. {
  3331. return false;
  3332. }
  3333. }
  3334. }
  3335. }
  3336. #endregion
  3337. }
  3338. #region プレイヤーの効果
  3339. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3340. {
  3341. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3342. {
  3343. if (cardEffect.CanUse(null))
  3344. {
  3345. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3346. {
  3347. return false;
  3348. }
  3349. }
  3350. }
  3351. }
  3352. #endregion
  3353. }
  3354. #endregion
  3355. return true;
  3356. }
  3357. }
  3358. #endregion
  3359. #region このデジモンを場からデジクロス条件の代わりにできるか
  3360. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  3361. {
  3362. #region デジクロス条件の代わりにできる効果
  3363. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3364. {
  3365. foreach (Permanent permanent in player.GetFieldPermanents())
  3366. {
  3367. #region 場のパーマネントの効果
  3368. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3369. {
  3370. if (cardEffect is ICanSelectDigiXrosEffect)
  3371. {
  3372. if (cardEffect.CanUse(null))
  3373. {
  3374. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3375. {
  3376. return true;
  3377. }
  3378. }
  3379. }
  3380. }
  3381. #endregion
  3382. }
  3383. #region プレイヤーの効果
  3384. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3385. {
  3386. if (cardEffect is ICanSelectDigiXrosEffect)
  3387. {
  3388. if (cardEffect.CanUse(null))
  3389. {
  3390. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3391. {
  3392. return true;
  3393. }
  3394. }
  3395. }
  3396. }
  3397. #endregion
  3398. }
  3399. #endregion
  3400. return false;
  3401. }
  3402. #endregion
  3403. #region Can Substitue for Assembly
  3404. public bool CanSubstituteForAssemblyCondition(CardSource cardSource)
  3405. {
  3406. #region Effects that can be used in place of Assembly conditions
  3407. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3408. {
  3409. foreach (Permanent permanent in player.GetFieldPermanents())
  3410. {
  3411. #region Effects of permanents in play
  3412. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3413. {
  3414. if (cardEffect is ICanSelectAssemblyEffect)
  3415. {
  3416. if (cardEffect.CanUse(null))
  3417. {
  3418. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3419. {
  3420. return true;
  3421. }
  3422. }
  3423. }
  3424. }
  3425. #endregion
  3426. }
  3427. #region player effect
  3428. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3429. {
  3430. if (cardEffect is ICanSelectAssemblyEffect)
  3431. {
  3432. if (cardEffect.CanUse(null))
  3433. {
  3434. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3435. {
  3436. return true;
  3437. }
  3438. }
  3439. }
  3440. }
  3441. #endregion
  3442. }
  3443. #endregion
  3444. return false;
  3445. }
  3446. #endregion
  3447. #region 登場した直後のLevel
  3448. public int LevelJustAfterPlayed { get; set; } = -1;
  3449. #endregion
  3450. #region 登場した直後のPlay Cost
  3451. public int PlayCostJustAfterPlayed { get; set; } = -1;
  3452. #endregion
  3453. #region 登場した直後のCardNames
  3454. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  3455. #endregion
  3456. #region 進化した直後のCardNames
  3457. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  3458. #endregion
  3459. #region 登場した直後のTraits
  3460. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  3461. #endregion
  3462. #region 場を離れる直前のDP
  3463. public int DPJustBeforeRemoveField { get; set; } = -1;
  3464. #endregion
  3465. #region 場を離れる直前のLevel
  3466. public int LevelJustBeforeRemoveField { get; set; } = -1;
  3467. #endregion
  3468. #region 場を離れる直前のCost
  3469. public int CostJustBeforeRemoveField { get; set; } = -1;
  3470. #endregion
  3471. #region 場を離れる直前のカード名
  3472. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  3473. #endregion
  3474. #region Card Traits Just Before Removed Field
  3475. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  3476. #endregion
  3477. #region バースト進化で手札に戻ったか
  3478. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  3479. #endregion
  3480. #region Is Linked Card Added as Source By App Fusion
  3481. public bool IsAddedAsSourceByAppFusion { get; set; } = false;
  3482. #endregion
  3483. #region バースト進化したか
  3484. public bool IsBurstDigivolved { get; set; } = false;
  3485. #endregion
  3486. #region Did it App Fusion?
  3487. public bool IsAppFusion { get; set; } = false;
  3488. #endregion
  3489. #region 効果で場に出たオプションか
  3490. public bool IsPlayedOptionPermanent { get; set; } = false;
  3491. #endregion
  3492. #region 進化元を持たないか
  3493. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  3494. #endregion
  3495. #region Has face down Digivolution Cards
  3496. public bool HasFaceDownDigivolutionCards => DigivolutionCards.Any(x => x.IsFlipped);
  3497. #endregion
  3498. #region Has No Link Cards
  3499. public bool HasNoLinkCards => LinkedCards.Count == 0;
  3500. #endregion
  3501. #region Digivolution cards' colors
  3502. public List<CardColor> DigivolutionCardsColors
  3503. {
  3504. get
  3505. {
  3506. List<CardColor> cardColors = new List<CardColor>();
  3507. foreach (CardSource cardSource in DigivolutionCards)
  3508. {
  3509. if (cardSource.IsFlipped)
  3510. continue;
  3511. foreach (CardColor cardColor in cardSource.CardColors)
  3512. {
  3513. if (!cardColors.Contains(cardColor))
  3514. {
  3515. cardColors.Add(cardColor);
  3516. }
  3517. }
  3518. foreach (CardColor cardColor in cardSource.DualCardColors)
  3519. {
  3520. if (!cardColors.Contains(cardColor))
  3521. {
  3522. cardColors.Add(cardColor);
  3523. }
  3524. }
  3525. }
  3526. return cardColors.Distinct().ToList();
  3527. }
  3528. }
  3529. #endregion
  3530. #region Show "Unsuspend" effect object
  3531. public void ShowUnsuspendEffect()
  3532. {
  3533. if (TopCard != null)
  3534. {
  3535. if (ShowingPermanentCard != null)
  3536. {
  3537. if (ShowingPermanentCard.WillUntapObject != null)
  3538. {
  3539. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  3540. ShowingPermanentCard.WillUntapObject.SetActive(true);
  3541. }
  3542. }
  3543. }
  3544. }
  3545. #endregion
  3546. #region Show "Return to deck" effect object
  3547. public void ShowDeckBounceEffect()
  3548. {
  3549. if (TopCard != null)
  3550. {
  3551. if (willBeRemoveField)
  3552. {
  3553. if (ShowingPermanentCard != null)
  3554. {
  3555. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3556. {
  3557. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  3558. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  3559. }
  3560. }
  3561. }
  3562. }
  3563. }
  3564. #endregion
  3565. #region Hide "Return to deck" effect object
  3566. public void HideDeckBounceEffect()
  3567. {
  3568. if (TopCard != null)
  3569. {
  3570. if (ShowingPermanentCard != null)
  3571. {
  3572. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3573. {
  3574. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  3575. }
  3576. }
  3577. }
  3578. }
  3579. #endregion
  3580. #region Show "Return to hand" effect object
  3581. public void ShowHandBounceEffect()
  3582. {
  3583. if (TopCard != null)
  3584. {
  3585. if (willBeRemoveField)
  3586. {
  3587. if (ShowingPermanentCard != null)
  3588. {
  3589. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3590. {
  3591. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  3592. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  3593. }
  3594. }
  3595. }
  3596. }
  3597. }
  3598. #endregion
  3599. #region Hide "Return to hand" effect object
  3600. public void HideHandBounceEffect()
  3601. {
  3602. if (TopCard != null)
  3603. {
  3604. if (ShowingPermanentCard != null)
  3605. {
  3606. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3607. {
  3608. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  3609. }
  3610. }
  3611. }
  3612. }
  3613. #endregion
  3614. #region Show "Delete" effect object
  3615. public void ShowDeleteEffect()
  3616. {
  3617. if (TopCard != null)
  3618. {
  3619. if (willBeRemoveField)
  3620. {
  3621. if (ShowingPermanentCard != null)
  3622. {
  3623. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3624. {
  3625. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  3626. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  3627. }
  3628. }
  3629. }
  3630. }
  3631. }
  3632. #endregion
  3633. #region Hide "Delete" effect object
  3634. public void HideDeleteEffect()
  3635. {
  3636. if (TopCard != null)
  3637. {
  3638. if (ShowingPermanentCard != null)
  3639. {
  3640. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3641. {
  3642. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  3643. }
  3644. }
  3645. }
  3646. }
  3647. #endregion
  3648. #region Show "Remove Field" effect object
  3649. public void ShowWillRemoveFieldEffect()
  3650. {
  3651. if (TopCard != null)
  3652. {
  3653. if (willBeRemoveField)
  3654. {
  3655. if (ShowingPermanentCard != null)
  3656. {
  3657. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3658. {
  3659. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  3660. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  3661. }
  3662. }
  3663. }
  3664. }
  3665. }
  3666. #endregion
  3667. #region Hide "Remove Field" effect object
  3668. public void HideWillRemoveFieldEffect()
  3669. {
  3670. if (TopCard != null)
  3671. {
  3672. if (ShowingPermanentCard != null)
  3673. {
  3674. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3675. {
  3676. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  3677. }
  3678. }
  3679. }
  3680. }
  3681. #endregion
  3682. #region Show "Digivolution" effect object
  3683. public void ShowWillEvolutionEffect()
  3684. {
  3685. if (TopCard != null)
  3686. {
  3687. if (ShowingPermanentCard != null)
  3688. {
  3689. if (ShowingPermanentCard.WillEvolutionObject != null)
  3690. {
  3691. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  3692. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  3693. }
  3694. }
  3695. }
  3696. }
  3697. #endregion
  3698. #region Hide "Digivolution" effect object
  3699. public void HideWillEvolutionEffect()
  3700. {
  3701. if (TopCard != null)
  3702. {
  3703. if (ShowingPermanentCard != null)
  3704. {
  3705. if (ShowingPermanentCard.WillEvolutionObject != null)
  3706. {
  3707. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  3708. }
  3709. }
  3710. }
  3711. }
  3712. #endregion
  3713. }