Permanent.cs 135 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028
  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)
  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)
  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 Linked Cards
  787. public int LinkedMax
  788. {
  789. get
  790. {
  791. int Max = 1;
  792. #region Effect of changing the number of sheets to undergo security check
  793. List<ICardEffect> cardEffects_ChangeLinkedMax = new List<ICardEffect>();
  794. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  795. {
  796. foreach (Permanent permanent in player.GetFieldPermanents())
  797. {
  798. #region Effects of permanents in play
  799. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  800. {
  801. if (cardEffect is IChangeLinkMaxEffect)
  802. {
  803. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  804. {
  805. if (cardEffect.CanUse(null))
  806. {
  807. if (!TopCard.CanNotBeAffected(cardEffect))
  808. {
  809. cardEffects_ChangeLinkedMax.Add(cardEffect);
  810. }
  811. }
  812. }
  813. }
  814. }
  815. #endregion
  816. }
  817. #region player effect
  818. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  819. {
  820. if (cardEffect is IChangeLinkMaxEffect)
  821. {
  822. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  823. {
  824. if (cardEffect.CanUse(null))
  825. {
  826. if (!TopCard.CanNotBeAffected(cardEffect))
  827. {
  828. cardEffects_ChangeLinkedMax.Add(cardEffect);
  829. }
  830. }
  831. }
  832. }
  833. }
  834. #endregion
  835. }
  836. List<ICardEffect> cardEffects_ChangeLinkedMax_UpToConstant = new List<ICardEffect>();
  837. List<ICardEffect> cardEffects_ChangeLinkedMax_UpDownValue = new List<ICardEffect>();
  838. List<ICardEffect> cardEffects_ChangeLinkedMax_DownToConstant = new List<ICardEffect>();
  839. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax)
  840. {
  841. if (cardEffect is IChangeLinkMaxEffect)
  842. {
  843. if (cardEffect.CanUse(null))
  844. {
  845. switch (((IChangeLinkMaxEffect)cardEffect).isUpDown())
  846. {
  847. case CalculateOrder.UpToConstant:
  848. cardEffects_ChangeLinkedMax_UpToConstant.Add(cardEffect);
  849. break;
  850. case CalculateOrder.UpDownValue:
  851. cardEffects_ChangeLinkedMax_UpDownValue.Add(cardEffect);
  852. break;
  853. case CalculateOrder.DownToConstant:
  854. cardEffects_ChangeLinkedMax_DownToConstant.Add(cardEffect);
  855. break;
  856. }
  857. }
  858. }
  859. }
  860. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpToConstant)
  861. {
  862. if (cardEffect is IChangeLinkMaxEffect)
  863. {
  864. if (cardEffect.CanUse(null))
  865. {
  866. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  867. }
  868. }
  869. }
  870. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpDownValue)
  871. {
  872. if (cardEffect is IChangeLinkMaxEffect)
  873. {
  874. if (cardEffect.CanUse(null))
  875. {
  876. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  877. }
  878. }
  879. }
  880. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_DownToConstant)
  881. {
  882. if (cardEffect is IChangeLinkMaxEffect)
  883. {
  884. if (cardEffect.CanUse(null))
  885. {
  886. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  887. }
  888. }
  889. }
  890. #endregion
  891. return Max;
  892. }
  893. }
  894. public List<CardSource> LinkedCards = new List<CardSource>();
  895. #endregion
  896. #region Add Card Source
  897. public void AddCardSource(CardSource cardSource)
  898. {
  899. cardSources.Insert(0, cardSource);
  900. if (!cardSource.IsFlipped)
  901. cardSource.SetFace();
  902. else
  903. cardSource.SetReverse();
  904. }
  905. #endregion
  906. #region Add digivolution cards to top of sources
  907. /// <summary>
  908. /// 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
  909. /// </summary>
  910. /// <param name="addedDigivolutionCards"></param>
  911. /// <param name="cardEffect"></param>
  912. /// <param name="skipEffectAndActivateSkill"></param>
  913. /// <returns></returns>
  914. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  915. {
  916. List<CardSource> addedCards = new List<CardSource>();
  917. bool isFromSameDigimon = false;
  918. bool isFromDigimon = false;
  919. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  920. {
  921. if (cardSources.Contains(addedDigivolutionCard))
  922. {
  923. isFromSameDigimon = true;
  924. }
  925. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  926. {
  927. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  928. {
  929. isFromDigimon = true;
  930. }
  931. }
  932. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  933. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  934. {
  935. this.cardSources.Insert(1, addedDigivolutionCard);
  936. if (!addedDigivolutionCard.IsFlipped || addedDigivolutionCard.IsBeingRevealed || GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  937. addedDigivolutionCard.SetFace();
  938. addedCards.Add(addedDigivolutionCard);
  939. }
  940. }
  941. if (addedCards.Count >= 1)
  942. {
  943. if (ShowingPermanentCard != null)
  944. {
  945. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  946. }
  947. #region "進化元が増えた時"の効果
  948. #region Hashtable Setting
  949. Hashtable hashtable = new Hashtable()
  950. {
  951. {"Permanent", this},
  952. {"CardEffect", cardEffect},
  953. {"CardSources", addedCards},
  954. {"isFromSameDigimon", isFromSameDigimon},
  955. {"isFromDigimon", isFromDigimon},
  956. };
  957. #endregion
  958. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  959. #endregion
  960. }
  961. }
  962. #endregion
  963. #region Add digivolution cards to bottom of sources
  964. /// <summary>
  965. /// 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
  966. /// </summary>
  967. /// <param name="addedDigivolutionCards"></param>
  968. /// <param name="cardEffect"></param>
  969. /// <param name="skipEffectAndActivateSkill"></param>
  970. /// <returns></returns>
  971. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false, bool isFacedown = false)
  972. {
  973. List<CardSource> addedCards = new List<CardSource>();
  974. bool isFromSameDigimon = false;
  975. bool isFromDigimon = false;
  976. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  977. {
  978. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  979. {
  980. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  981. {
  982. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  983. {
  984. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
  985. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  986. if (!placePermanent.Placed)
  987. {
  988. continue;
  989. }
  990. }
  991. }
  992. }
  993. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  994. {
  995. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  996. {
  997. isFromDigimon = true;
  998. }
  999. }
  1000. if (cardSources.Contains(addedDigivolutionCard))
  1001. {
  1002. isFromSameDigimon = true;
  1003. if (LinkedCards.Contains(addedDigivolutionCard))
  1004. {
  1005. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(addedDigivolutionCard, trashCard: false));
  1006. }
  1007. else if (addedDigivolutionCard == TopCard)
  1008. {
  1009. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  1010. ShowingPermanentCard.ShowPermanentData(true);
  1011. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  1012. addedDigivolutionCard,
  1013. this));
  1014. }
  1015. }
  1016. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  1017. if (!IsToken && !addedDigivolutionCard.IsToken)
  1018. {
  1019. cardSources.Add(addedDigivolutionCard);
  1020. if (isFacedown)
  1021. addedDigivolutionCard.SetReverse();
  1022. else
  1023. addedDigivolutionCard.SetFace();
  1024. addedCards.Add(addedDigivolutionCard);
  1025. }
  1026. }
  1027. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  1028. {
  1029. if (ShowingPermanentCard != null)
  1030. {
  1031. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  1032. }
  1033. #region Effect of "when the number of evolution sources increases"
  1034. #region Hashtable Setting
  1035. Hashtable hashtable = new Hashtable()
  1036. {
  1037. {"Permanent", this},
  1038. {"CardEffect", cardEffect},
  1039. {"CardSources", addedCards},
  1040. {"isFromSameDigimon", isFromSameDigimon},
  1041. {"isFromDigimon", isFromDigimon},
  1042. };
  1043. #endregion
  1044. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  1045. #endregion
  1046. }
  1047. }
  1048. #endregion
  1049. #region Add Link cards
  1050. /// <summary>
  1051. /// 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
  1052. /// </summary>
  1053. /// <param name="addedLinkCards"></param>
  1054. /// <param name="cardEffect"></param>
  1055. /// <param name="skipEffectAndActivateSkill"></param>
  1056. /// <returns></returns>
  1057. public IEnumerator AddLinkCard(CardSource addedLinkCard, ICardEffect cardEffect)
  1058. {
  1059. bool addedCard = false;
  1060. bool isFromDigimon = false;
  1061. if (CardEffectCommons.IsExistOnBattleArea(addedLinkCard))
  1062. {
  1063. if (addedLinkCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  1064. {
  1065. isFromDigimon = true;
  1066. }
  1067. }
  1068. if (LinkedCards.Count >= LinkedMax)
  1069. {
  1070. if(LinkedMax > 1)
  1071. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(null,((LinkedCards.Count + 1) - LinkedMax)));
  1072. else
  1073. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(LinkedCards[0]));
  1074. }
  1075. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
  1076. if (!this.IsToken && !addedLinkCard.IsToken)
  1077. {
  1078. LinkedCards.Insert(0, addedLinkCard);
  1079. LinkedDP += addedLinkCard.LinkDP;
  1080. this.cardSources.Insert(1, addedLinkCard);
  1081. addedLinkCard.SetFace();
  1082. addedCard = true;
  1083. }
  1084. if (addedCard)
  1085. {
  1086. if (ShowingPermanentCard != null)
  1087. {
  1088. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  1089. }
  1090. #region Add Linked Card
  1091. #region Hashtable Setting
  1092. Hashtable hashtable = new Hashtable()
  1093. {
  1094. {"Permanent", this},
  1095. {"CardEffect", cardEffect},
  1096. {"Card", addedLinkCard},
  1097. {"isFromDigimon", isFromDigimon},
  1098. };
  1099. #endregion
  1100. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.WhenLinked));
  1101. #endregion
  1102. }
  1103. }
  1104. #endregion
  1105. #region RemoveCardSource
  1106. public IEnumerator RemoveCardSource(CardSource cardSource)
  1107. {
  1108. yield return null;
  1109. cardSources.Remove(cardSource);
  1110. }
  1111. #endregion
  1112. #region Remove Linked Card
  1113. public IEnumerator RemoveLinkedCard(CardSource cardSource, int removeCount = 0, bool trashCard = true)
  1114. {
  1115. if (LinkedCards.Contains(cardSource))
  1116. {
  1117. LinkedDP -= cardSource.LinkDP;
  1118. LinkedCards.Remove(cardSource);
  1119. yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(cardSource));
  1120. if (trashCard)
  1121. {
  1122. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource));
  1123. }
  1124. }
  1125. if(removeCount > 0)
  1126. {
  1127. int maxCount = Mathf.Min(removeCount, LinkedCards.Count);
  1128. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  1129. selectCardEffect.SetUp(
  1130. canTargetCondition: (CardSource) => true,
  1131. canTargetCondition_ByPreSelecetedList: null,
  1132. canEndSelectCondition: null,
  1133. canNoSelect: () => false,
  1134. selectCardCoroutine: null,
  1135. afterSelectCardCoroutine: null,
  1136. message: $"Select {maxCount} card to trash.",
  1137. maxCount: removeCount,
  1138. canEndNotMax: false,
  1139. isShowOpponent: true,
  1140. mode: SelectCardEffect.Mode.Discard,
  1141. root: SelectCardEffect.Root.Custom,
  1142. customRootCardList: LinkedCards,
  1143. canLookReverseCard: true,
  1144. selectPlayer: TopCard.Owner,
  1145. cardEffect: null);
  1146. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  1147. }
  1148. //TODO: Add event call if something was removed
  1149. }
  1150. #endregion
  1151. #region Top Card
  1152. public CardSource TopCard
  1153. {
  1154. get
  1155. {
  1156. if (cardSources.Count >= 1)
  1157. {
  1158. if (LinkedCards.Count > 0)
  1159. return cardSources.First(source => !LinkedCards.Contains(source));
  1160. else
  1161. return cardSources[0];
  1162. }
  1163. return null;
  1164. }
  1165. }
  1166. #endregion
  1167. #region Permanent effect list
  1168. #region このパーマネントの効果リスト
  1169. public List<ICardEffect> EffectList(EffectTiming timing)
  1170. {
  1171. return EffectList_ForCard(timing, TopCard);
  1172. }
  1173. #endregion
  1174. #region このポケモンの追加効果リスト
  1175. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  1176. {
  1177. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1178. if (TopCard != null)
  1179. {
  1180. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  1181. {
  1182. ICardEffect cardEffect = GetCardEffect(timing);
  1183. if (cardEffect != null)
  1184. {
  1185. _EffectList.Add(cardEffect);
  1186. }
  1187. }
  1188. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  1189. {
  1190. ICardEffect cardEffect = GetCardEffect(timing);
  1191. if (cardEffect != null)
  1192. {
  1193. _EffectList.Add(cardEffect);
  1194. }
  1195. }
  1196. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  1197. {
  1198. ICardEffect cardEffect = GetCardEffect(timing);
  1199. if (cardEffect != null)
  1200. {
  1201. _EffectList.Add(cardEffect);
  1202. }
  1203. }
  1204. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  1205. {
  1206. ICardEffect cardEffect = GetCardEffect(timing);
  1207. if (cardEffect != null)
  1208. {
  1209. _EffectList.Add(cardEffect);
  1210. }
  1211. }
  1212. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  1213. {
  1214. ICardEffect cardEffect = GetCardEffect(timing);
  1215. if (cardEffect != null)
  1216. {
  1217. _EffectList.Add(cardEffect);
  1218. }
  1219. }
  1220. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  1221. {
  1222. ICardEffect cardEffect = GetCardEffect(timing);
  1223. if (cardEffect != null)
  1224. {
  1225. _EffectList.Add(cardEffect);
  1226. }
  1227. }
  1228. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  1229. {
  1230. ICardEffect cardEffect = GetCardEffect(timing);
  1231. if (cardEffect != null)
  1232. {
  1233. _EffectList.Add(cardEffect);
  1234. }
  1235. }
  1236. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  1237. {
  1238. ICardEffect cardEffect = GetCardEffect(timing);
  1239. if (cardEffect != null)
  1240. {
  1241. _EffectList.Add(cardEffect);
  1242. }
  1243. }
  1244. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  1245. {
  1246. ICardEffect cardEffect = GetCardEffect(timing);
  1247. if (cardEffect != null)
  1248. {
  1249. _EffectList.Add(cardEffect);
  1250. }
  1251. }
  1252. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  1253. foreach (ICardEffect cardEffect in _EffectList)
  1254. {
  1255. if (cardEffect != null)
  1256. {
  1257. if (cardEffect.EffectSourceCard == null)
  1258. {
  1259. cardEffect.SetEffectSourceCard(TopCard);
  1260. }
  1261. cardEffect.SetIsInheritedEffect(false);
  1262. }
  1263. }
  1264. }
  1265. return _EffectList;
  1266. }
  1267. #endregion
  1268. #region このパーマネントの効果リスト(引数:CardSource)
  1269. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  1270. {
  1271. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1272. if (TopCard != null && _cardSource != null)
  1273. {
  1274. foreach (CardSource cardSource in cardSources)
  1275. {
  1276. if (cardSource != null)
  1277. {
  1278. if (!cardSource.IsFlipped)
  1279. {
  1280. bool isTopCard = cardSource == TopCard;
  1281. if (!isTopCard)
  1282. {
  1283. if (!IsDigimon)
  1284. {
  1285. continue;
  1286. }
  1287. }
  1288. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  1289. {
  1290. if (cardEffect != null)
  1291. {
  1292. #region Entity, Inherited and Link effects
  1293. if (cardEffect.IsInheritedEffect && !isTopCard)
  1294. {
  1295. _EffectList.Add(cardEffect);
  1296. continue;
  1297. }
  1298. if (cardEffect.IsLinkedEffect && cardSource.IsLinked)
  1299. {
  1300. _EffectList.Add(cardEffect);
  1301. continue;
  1302. }
  1303. if(isTopCard && !cardEffect.IsInheritedEffect && !cardEffect.IsLinkedEffect)
  1304. {
  1305. _EffectList.Add(cardEffect);
  1306. }
  1307. #endregion
  1308. }
  1309. }
  1310. }
  1311. }
  1312. }
  1313. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  1314. {
  1315. if (cardEffect != null)
  1316. {
  1317. _EffectList.Add(cardEffect);
  1318. }
  1319. }
  1320. foreach (ICardEffect cardEffect in _EffectList)
  1321. {
  1322. if (cardEffect != null)
  1323. {
  1324. if (cardEffect.EffectSourceCard == null)
  1325. {
  1326. cardEffect.SetEffectSourceCard(_cardSource);
  1327. }
  1328. }
  1329. }
  1330. }
  1331. return _EffectList;
  1332. }
  1333. #endregion
  1334. #region 自分のターン終了時に消える効果
  1335. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1336. #endregion
  1337. #region 自分のドローフェイズ終了時に消える効果
  1338. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  1339. #endregion
  1340. #region お互いのターン終了時に消える効果
  1341. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1342. #endregion
  1343. #region 相手のターン終了時に消える効果
  1344. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1345. #endregion
  1346. #region バトル終了時に消える効果
  1347. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  1348. #endregion
  1349. #region 攻撃終了時に消える効果
  1350. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  1351. #endregion
  1352. #region 自分のターン開始時に消える効果
  1353. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  1354. #endregion
  1355. #region 次にアンタップする時に消える効果
  1356. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  1357. #endregion
  1358. #region 場を離れるまで残る効果
  1359. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  1360. #endregion
  1361. #endregion
  1362. #region 起動型効果を宣言できるか
  1363. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  1364. #endregion
  1365. #region 宣言可能な起動型効果リスト
  1366. public List<ICardEffect> CanDeclareSkillList()
  1367. {
  1368. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  1369. if (TopCard != null)
  1370. {
  1371. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  1372. {
  1373. if (_cardEffect is ActivateICardEffect)
  1374. {
  1375. if (_cardEffect.CanUse(null))
  1376. {
  1377. CanDeclareSkillList.Add(_cardEffect);
  1378. }
  1379. }
  1380. }
  1381. }
  1382. return CanDeclareSkillList;
  1383. }
  1384. #endregion
  1385. #region このパーマネントが場に出たターン
  1386. public int EnterFieldTurnCount { get; set; } = -1;
  1387. #endregion
  1388. #region このパーマネントを表す場のオブジェクト
  1389. public FieldPermanentCard ShowingPermanentCard { get; set; }
  1390. #endregion
  1391. #region Whether this permanent can be selected by the effect
  1392. public bool CanSelectBySkill(ICardEffect skill)
  1393. {
  1394. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1395. {
  1396. #region Effects of field permanents
  1397. foreach (Permanent permanent in player.GetFieldPermanents())
  1398. {
  1399. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1400. {
  1401. if (cardEffect is ICanNotSelectBySkillEffect)
  1402. {
  1403. if (cardEffect.CanUse(null))
  1404. {
  1405. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  1406. {
  1407. return false;
  1408. }
  1409. }
  1410. }
  1411. }
  1412. }
  1413. #endregion
  1414. }
  1415. return true;
  1416. }
  1417. #endregion
  1418. #region Number of sheets to undergo security check
  1419. public int InvertSecutiryValue
  1420. {
  1421. get
  1422. {
  1423. int Invert = 0;
  1424. List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
  1425. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1426. {
  1427. foreach (Permanent permanent in player.GetFieldPermanents())
  1428. {
  1429. #region Effects of permanents in play
  1430. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1431. {
  1432. if (cardEffect is IInvertSAttackEffect)
  1433. {
  1434. if (cardEffect.CanUse(null))
  1435. {
  1436. if (!TopCard.CanNotBeAffected(cardEffect))
  1437. {
  1438. cardEffects_InvertStrike.Add(cardEffect);
  1439. }
  1440. }
  1441. }
  1442. }
  1443. #endregion
  1444. }
  1445. #region player effect
  1446. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1447. {
  1448. if (cardEffect is IInvertSAttackEffect)
  1449. {
  1450. if (cardEffect.CanUse(null))
  1451. {
  1452. if (!TopCard.CanNotBeAffected(cardEffect))
  1453. {
  1454. cardEffects_InvertStrike.Add(cardEffect);
  1455. }
  1456. }
  1457. }
  1458. }
  1459. #endregion
  1460. }
  1461. foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
  1462. {
  1463. Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
  1464. }
  1465. return Mathf.Clamp(Invert,-1,1);
  1466. }
  1467. }
  1468. public List<int> SecurityAttackChanges
  1469. {
  1470. get
  1471. {
  1472. List<int> SecurityAttackChanges = new List<int>();
  1473. int Strike = 1;
  1474. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1475. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1476. {
  1477. foreach (Permanent permanent in player.GetFieldPermanents())
  1478. {
  1479. #region 場のパーマネントの効果
  1480. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1481. {
  1482. if (cardEffect is IChangeSAttackEffect)
  1483. {
  1484. if (cardEffect.CanUse(null))
  1485. {
  1486. if (!TopCard.CanNotBeAffected(cardEffect))
  1487. {
  1488. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1489. {
  1490. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1491. }
  1492. }
  1493. }
  1494. }
  1495. }
  1496. #endregion
  1497. }
  1498. #region プレイヤーの効果
  1499. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1500. {
  1501. if (cardEffect is IChangeSAttackEffect)
  1502. {
  1503. if (cardEffect.CanUse(null))
  1504. {
  1505. if (!TopCard.CanNotBeAffected(cardEffect))
  1506. {
  1507. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1508. {
  1509. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1510. }
  1511. }
  1512. }
  1513. }
  1514. }
  1515. #endregion
  1516. }
  1517. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1518. {
  1519. if (cardEffect is IChangeSAttackEffect)
  1520. {
  1521. if (cardEffect.CanUse(null))
  1522. {
  1523. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
  1524. if (Strike1 != Strike)
  1525. {
  1526. SecurityAttackChanges.Add(Strike1 - Strike);
  1527. }
  1528. }
  1529. }
  1530. }
  1531. return SecurityAttackChanges;
  1532. }
  1533. }
  1534. public bool HasSecurityAttackChanges
  1535. {
  1536. get
  1537. {
  1538. if (!IsDigimon)
  1539. {
  1540. return false;
  1541. }
  1542. return SecurityAttackChanges.Count >= 1;
  1543. }
  1544. }
  1545. public int Strike_AllowMinus
  1546. {
  1547. get
  1548. {
  1549. int Strike = 1;
  1550. #region Effect of changing the number of sheets to undergo security check
  1551. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1552. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1553. {
  1554. foreach (Permanent permanent in player.GetFieldPermanents())
  1555. {
  1556. #region Effects of permanents in play
  1557. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1558. {
  1559. if (cardEffect is IChangeSAttackEffect)
  1560. {
  1561. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1562. {
  1563. if (cardEffect.CanUse(null))
  1564. {
  1565. if (!TopCard.CanNotBeAffected(cardEffect))
  1566. {
  1567. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1568. }
  1569. }
  1570. }
  1571. }
  1572. }
  1573. #endregion
  1574. }
  1575. #region player effect
  1576. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1577. {
  1578. if (cardEffect is IChangeSAttackEffect)
  1579. {
  1580. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1581. {
  1582. if (cardEffect.CanUse(null))
  1583. {
  1584. if (!TopCard.CanNotBeAffected(cardEffect))
  1585. {
  1586. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1587. }
  1588. }
  1589. }
  1590. }
  1591. }
  1592. #endregion
  1593. }
  1594. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1595. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1596. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1597. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1598. {
  1599. if (cardEffect is IChangeSAttackEffect)
  1600. {
  1601. if (cardEffect.CanUse(null))
  1602. {
  1603. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1604. {
  1605. case CalculateOrder.UpToConstant:
  1606. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1607. break;
  1608. case CalculateOrder.UpDownValue:
  1609. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1610. break;
  1611. case CalculateOrder.DownToConstant:
  1612. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1613. break;
  1614. }
  1615. }
  1616. }
  1617. }
  1618. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1619. {
  1620. if (cardEffect is IChangeSAttackEffect)
  1621. {
  1622. if (cardEffect.CanUse(null))
  1623. {
  1624. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1625. }
  1626. }
  1627. }
  1628. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1629. {
  1630. if (cardEffect is IChangeSAttackEffect)
  1631. {
  1632. if (cardEffect.CanUse(null))
  1633. {
  1634. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1635. }
  1636. }
  1637. }
  1638. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1639. {
  1640. if (cardEffect is IChangeSAttackEffect)
  1641. {
  1642. if (cardEffect.CanUse(null))
  1643. {
  1644. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1645. }
  1646. }
  1647. }
  1648. #endregion
  1649. return Strike;
  1650. }
  1651. }
  1652. public int Strike
  1653. {
  1654. get
  1655. {
  1656. int Strike = Strike_AllowMinus;
  1657. if (Strike < 0)
  1658. {
  1659. Strike = 0;
  1660. }
  1661. return Strike;
  1662. }
  1663. }
  1664. #endregion
  1665. #region このパーマネントがタップされているかどうか
  1666. public bool OldIsSuspended = false;
  1667. public bool IsSuspended = false;
  1668. public int DPWhenSuspended = 114514;
  1669. #endregion
  1670. #region Whether this permanent can unsuspend
  1671. public bool CanUnsuspend
  1672. {
  1673. get
  1674. {
  1675. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1676. {
  1677. #region Effects of field permanents
  1678. foreach (Permanent permanent in player.GetFieldPermanents())
  1679. {
  1680. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1681. {
  1682. if (cardEffect is ICanNotUnsuspendEffect)
  1683. {
  1684. if (cardEffect.CanUse(null))
  1685. {
  1686. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1687. {
  1688. return false;
  1689. }
  1690. }
  1691. }
  1692. }
  1693. }
  1694. #endregion
  1695. #region Effects of players
  1696. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1697. {
  1698. if (cardEffect is ICanNotUnsuspendEffect)
  1699. {
  1700. if (cardEffect.CanUse(null))
  1701. {
  1702. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1703. {
  1704. return false;
  1705. }
  1706. }
  1707. }
  1708. }
  1709. #endregion
  1710. }
  1711. return true;
  1712. }
  1713. }
  1714. #endregion
  1715. #region このパーマネントが移動できるかどうか
  1716. public bool CanMove
  1717. {
  1718. get
  1719. {
  1720. if (TopCard != null)
  1721. {
  1722. #region the effects of permanents
  1723. if (GManager.instance.turnStateMachine.gameContext.Players
  1724. .Map(player => player.GetFieldPermanents())
  1725. .Flat()
  1726. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1727. .Flat()
  1728. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1729. && cardEffect.CanUse(null)
  1730. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1731. {
  1732. return false;
  1733. }
  1734. #endregion
  1735. #region the effects of players
  1736. if (GManager.instance.turnStateMachine.gameContext.Players
  1737. .Map(player => player.EffectList(EffectTiming.None))
  1738. .Flat()
  1739. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1740. && cardEffect.CanUse(null)
  1741. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1742. {
  1743. return false;
  1744. }
  1745. #endregion
  1746. #region the effects of itself
  1747. if (this == null)
  1748. {
  1749. if (EffectList(EffectTiming.None)
  1750. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1751. && cardEffect.CanUse(null)
  1752. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1753. {
  1754. return false;
  1755. }
  1756. }
  1757. #endregion
  1758. if (TopCard.PermanentOfThisCard().PermanentFrame.isBreedingAreaFrame())
  1759. {
  1760. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1761. {
  1762. return false;
  1763. }
  1764. }
  1765. else
  1766. {
  1767. if (TopCard.Owner.GetBreedingAreaPermanents().Count > 0)
  1768. return false;
  1769. }
  1770. if (!IsDigimon)
  1771. return false;
  1772. if (TopCard.IsDigiEgg && DP <= 0)
  1773. return false;
  1774. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1775. {
  1776. return false;
  1777. }
  1778. }
  1779. else
  1780. {
  1781. return false;
  1782. }
  1783. return true;
  1784. }
  1785. }
  1786. #endregion
  1787. #region このパーマネントが攻撃できるかどうか
  1788. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false, bool isExecute = false)
  1789. {
  1790. // can not attack with empty cards
  1791. if (TopCard == null)
  1792. {
  1793. return false;
  1794. }
  1795. // can not attack during opponent's turn
  1796. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1797. {
  1798. return false;
  1799. }
  1800. //Can not attack during another attack
  1801. if (GManager.instance.attackProcess.IsAttacking)
  1802. return false;
  1803. // can not attack to player
  1804. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex, isExecute))
  1805. {
  1806. // can not attack to opponent's Digimon
  1807. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex, isExecute)) == 0)
  1808. {
  1809. return false;
  1810. }
  1811. }
  1812. return true;
  1813. }
  1814. #endregion
  1815. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1816. public bool CanBlock(Permanent AttackingPermanent)
  1817. {
  1818. if (TopCard == null)
  1819. {
  1820. return false;
  1821. }
  1822. if (!IsDigimon)
  1823. {
  1824. return false;
  1825. }
  1826. if (IsSuspended)
  1827. {
  1828. return false;
  1829. }
  1830. if (!CanSuspend)
  1831. {
  1832. return false;
  1833. }
  1834. if (PermanentFrame != null)
  1835. {
  1836. if (!PermanentFrame.IsBattleAreaFrame())
  1837. {
  1838. return false;
  1839. }
  1840. }
  1841. if (!AttackingPermanent.IsDigimon)
  1842. return false;
  1843. if (!AttackingPermanent.CanSwitchAttackTarget)
  1844. return false;
  1845. #region "Unblockable" effect
  1846. #region Effects of permanents in play
  1847. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1848. {
  1849. foreach (Permanent permanent in player.GetFieldPermanents())
  1850. {
  1851. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1852. {
  1853. if (cardEffect is ICannotBlockEffect)
  1854. {
  1855. if (cardEffect.CanUse(null))
  1856. {
  1857. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1858. {
  1859. return false;
  1860. }
  1861. }
  1862. }
  1863. }
  1864. }
  1865. }
  1866. #endregion
  1867. #region player effect
  1868. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1869. {
  1870. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1871. {
  1872. if (cardEffect is ICannotBlockEffect)
  1873. {
  1874. if (cardEffect.CanUse(null))
  1875. {
  1876. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1877. {
  1878. if (!TopCard.CanNotBeAffected(cardEffect))
  1879. {
  1880. return false;
  1881. }
  1882. }
  1883. }
  1884. }
  1885. }
  1886. }
  1887. #endregion
  1888. #endregion
  1889. return true;
  1890. }
  1891. #endregion
  1892. #region 対象のパーマネントを攻撃できるか
  1893. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false, bool isExecute = false)
  1894. {
  1895. if (TopCard != null)
  1896. {
  1897. if (!IsDigimon)
  1898. {
  1899. return false;
  1900. }
  1901. if (!withoutTap)
  1902. {
  1903. if (IsSuspended)
  1904. {
  1905. return false;
  1906. }
  1907. if (!CanSuspend)
  1908. {
  1909. return false;
  1910. }
  1911. }
  1912. if (PermanentFrame != null)
  1913. {
  1914. if (!PermanentFrame.IsBattleAreaFrame())
  1915. {
  1916. return false;
  1917. }
  1918. }
  1919. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1920. {
  1921. if (!HasRush && !isVortex)
  1922. {
  1923. return false;
  1924. }
  1925. }
  1926. #region 「対象の防御パーマネントを攻撃できない」効果
  1927. #region 場のパーマネントの効果
  1928. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1929. {
  1930. foreach (Permanent permanent in player.GetFieldPermanents())
  1931. {
  1932. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1933. {
  1934. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1935. {
  1936. if (cardEffect1.CanUse(null))
  1937. {
  1938. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1939. {
  1940. if (!TopCard.CanNotBeAffected(cardEffect1))
  1941. {
  1942. return false;
  1943. }
  1944. }
  1945. }
  1946. }
  1947. }
  1948. }
  1949. }
  1950. #endregion
  1951. #region プレイヤーの効果
  1952. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1953. {
  1954. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1955. {
  1956. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1957. {
  1958. if (cardEffect1.CanUse(null))
  1959. {
  1960. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1961. {
  1962. if (!TopCard.CanNotBeAffected(cardEffect1))
  1963. {
  1964. return false;
  1965. }
  1966. }
  1967. }
  1968. }
  1969. }
  1970. }
  1971. #endregion
  1972. #endregion
  1973. if (Defender != null)
  1974. {
  1975. if (Defender.TopCard != null)
  1976. {
  1977. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1978. {
  1979. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1980. {
  1981. if (Defender.IsSuspended || isExecute)
  1982. {
  1983. return true;
  1984. }
  1985. #region 「対象の防御パーマネントを攻撃できる」効果
  1986. #region 場のパーマネントの効果
  1987. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1988. {
  1989. foreach (Permanent permanent in player.GetFieldPermanents())
  1990. {
  1991. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1992. {
  1993. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1994. {
  1995. if (cardEffect1.CanUse(null))
  1996. {
  1997. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1998. {
  1999. return true;
  2000. }
  2001. }
  2002. }
  2003. }
  2004. }
  2005. }
  2006. #endregion
  2007. #region プレイヤーの効果
  2008. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2009. {
  2010. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2011. {
  2012. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  2013. {
  2014. if (cardEffect1.CanUse(null))
  2015. {
  2016. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  2017. {
  2018. return true;
  2019. }
  2020. }
  2021. }
  2022. }
  2023. }
  2024. #endregion
  2025. #endregion
  2026. }
  2027. }
  2028. }
  2029. }
  2030. else
  2031. {
  2032. return true;
  2033. }
  2034. }
  2035. return false;
  2036. }
  2037. #endregion
  2038. #region Is Unblockable
  2039. public bool IsUnblockable
  2040. {
  2041. get
  2042. {
  2043. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2044. {
  2045. if (cardEffect is CannotBlockClass)
  2046. {
  2047. if (cardEffect.EffectName == "Unblockable")
  2048. {
  2049. return true;
  2050. }
  2051. }
  2052. }
  2053. return false;
  2054. }
  2055. }
  2056. #endregion
  2057. #region Has Blocker
  2058. public bool HasBlocker
  2059. {
  2060. get
  2061. {
  2062. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2063. {
  2064. #region Effects of permanents in play
  2065. foreach (Permanent permanent in player.GetFieldPermanents())
  2066. {
  2067. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2068. {
  2069. if (cardEffect is IBlockerEffect)
  2070. {
  2071. if (cardEffect.CanTrigger(null))
  2072. {
  2073. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2074. {
  2075. return true;
  2076. }
  2077. }
  2078. }
  2079. }
  2080. }
  2081. #endregion
  2082. #region Effects of faceup security
  2083. foreach (CardSource source in player.SecurityCards)
  2084. {
  2085. if (source.IsFlipped)
  2086. continue;
  2087. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2088. {
  2089. if (cardEffect is IBlockerEffect)
  2090. {
  2091. if (cardEffect.CanTrigger(null))
  2092. {
  2093. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2094. {
  2095. return true;
  2096. }
  2097. }
  2098. }
  2099. }
  2100. }
  2101. #endregion
  2102. #region プレイヤーの効果
  2103. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2104. {
  2105. if (cardEffect is IBlockerEffect)
  2106. {
  2107. if (cardEffect.CanTrigger(null))
  2108. {
  2109. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2110. {
  2111. return true;
  2112. }
  2113. }
  2114. }
  2115. }
  2116. #endregion
  2117. }
  2118. return false;
  2119. }
  2120. }
  2121. #endregion
  2122. #region Has Jamming
  2123. public bool HasJamming
  2124. {
  2125. get
  2126. {
  2127. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2128. {
  2129. foreach (Permanent permanent in player.GetFieldPermanents())
  2130. {
  2131. #region 場のパーマネントの効果
  2132. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2133. {
  2134. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2135. {
  2136. if (cardEffect.CanTrigger(null))
  2137. {
  2138. if (cardEffect.EffectName == "Jamming")
  2139. {
  2140. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  2141. {
  2142. return true;
  2143. }
  2144. }
  2145. }
  2146. }
  2147. }
  2148. #endregion
  2149. }
  2150. #region プレイヤーの効果
  2151. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2152. {
  2153. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2154. {
  2155. if (cardEffect.CanTrigger(null))
  2156. {
  2157. if (cardEffect.EffectName == "Jamming")
  2158. {
  2159. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  2160. {
  2161. return true;
  2162. }
  2163. }
  2164. }
  2165. }
  2166. }
  2167. #endregion
  2168. }
  2169. return false;
  2170. }
  2171. }
  2172. #endregion
  2173. #region Has Ice Clad
  2174. public bool HasIceclad
  2175. {
  2176. get
  2177. {
  2178. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2179. {
  2180. #region Ice clad permanent effects
  2181. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  2182. {
  2183. if (cardEffect is IIcecladEffect)
  2184. {
  2185. if (cardEffect.CanTrigger(null))
  2186. {
  2187. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2188. {
  2189. return true;
  2190. }
  2191. }
  2192. }
  2193. }
  2194. #endregion
  2195. #region Ice clad Player Effects
  2196. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2197. {
  2198. if (cardEffect is IIcecladEffect)
  2199. {
  2200. if (cardEffect.CanTrigger(null))
  2201. {
  2202. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2203. {
  2204. return true;
  2205. }
  2206. }
  2207. }
  2208. }
  2209. #endregion
  2210. }
  2211. return false;
  2212. }
  2213. }
  2214. #endregion
  2215. #region Whether this permanent has Pierce
  2216. public bool HasPierce
  2217. {
  2218. get
  2219. {
  2220. if (IsDigimon)
  2221. {
  2222. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  2223. {
  2224. if (cardEffect is ActivateICardEffect)
  2225. {
  2226. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  2227. {
  2228. if (cardEffect.EffectName == "Pierce")
  2229. {
  2230. return true;
  2231. }
  2232. if (cardEffect.EffectName == "Piercing")
  2233. {
  2234. return true;
  2235. }
  2236. }
  2237. }
  2238. }
  2239. }
  2240. return false;
  2241. }
  2242. }
  2243. #endregion
  2244. #region Has Reboot
  2245. public bool HasReboot
  2246. {
  2247. get
  2248. {
  2249. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2250. {
  2251. foreach (Permanent permanent in player.GetFieldPermanents())
  2252. {
  2253. #region 場のパーマネントの効果
  2254. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2255. {
  2256. if (cardEffect is IRebootEffect)
  2257. {
  2258. if (cardEffect.CanTrigger(null))
  2259. {
  2260. if (((IRebootEffect)cardEffect).HasReboot(this))
  2261. {
  2262. return true;
  2263. }
  2264. }
  2265. }
  2266. }
  2267. #endregion
  2268. }
  2269. #region Effects of faceup security
  2270. foreach (CardSource source in player.SecurityCards)
  2271. {
  2272. if (source.IsFlipped)
  2273. continue;
  2274. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2275. {
  2276. if (cardEffect is IRebootEffect)
  2277. {
  2278. if (cardEffect.CanTrigger(null))
  2279. {
  2280. if (((IRebootEffect)cardEffect).HasReboot(this))
  2281. {
  2282. return true;
  2283. }
  2284. }
  2285. }
  2286. }
  2287. }
  2288. #endregion
  2289. #region プレイヤーの効果
  2290. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2291. {
  2292. if (cardEffect is IRebootEffect)
  2293. {
  2294. if (cardEffect.CanTrigger(null))
  2295. {
  2296. if (((IRebootEffect)cardEffect).HasReboot(this))
  2297. {
  2298. return true;
  2299. }
  2300. }
  2301. }
  2302. }
  2303. #endregion
  2304. }
  2305. return false;
  2306. }
  2307. }
  2308. #endregion
  2309. #region Has Raid
  2310. public bool HasRaid
  2311. {
  2312. get
  2313. {
  2314. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2315. {
  2316. if (cardEffect is ActivateICardEffect)
  2317. {
  2318. if (cardEffect.EffectName == "Raid")
  2319. {
  2320. return true;
  2321. }
  2322. }
  2323. }
  2324. return false;
  2325. }
  2326. }
  2327. #endregion
  2328. #region Has Rush
  2329. public bool HasRush
  2330. {
  2331. get
  2332. {
  2333. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2334. {
  2335. foreach (Permanent permanent in player.GetFieldPermanents())
  2336. {
  2337. #region 場のパーマネントの効果
  2338. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2339. {
  2340. if (cardEffect is IRushEffect)
  2341. {
  2342. if (cardEffect.CanTrigger(null))
  2343. {
  2344. if (((IRushEffect)cardEffect).HasRush(this))
  2345. {
  2346. return true;
  2347. }
  2348. }
  2349. }
  2350. }
  2351. #endregion
  2352. }
  2353. #region プレイヤーの効果
  2354. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2355. {
  2356. if (cardEffect is IRushEffect)
  2357. {
  2358. if (cardEffect.CanTrigger(null))
  2359. {
  2360. if (((IRushEffect)cardEffect).HasRush(this))
  2361. {
  2362. return true;
  2363. }
  2364. }
  2365. }
  2366. }
  2367. #endregion
  2368. }
  2369. return false;
  2370. }
  2371. }
  2372. #endregion
  2373. #region Has Retaliation
  2374. public bool HasRetaliation
  2375. {
  2376. get
  2377. {
  2378. if (RetaliationCount >= 1)
  2379. {
  2380. return true;
  2381. }
  2382. return false;
  2383. }
  2384. }
  2385. #endregion
  2386. #region Retaliation Count
  2387. public int RetaliationCount
  2388. {
  2389. get
  2390. {
  2391. int count = 0;
  2392. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2393. {
  2394. if (cardEffect is ActivateICardEffect)
  2395. {
  2396. if (cardEffect.EffectName == "Retaliation")
  2397. {
  2398. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2399. {
  2400. count++;
  2401. }
  2402. }
  2403. }
  2404. }
  2405. return count;
  2406. }
  2407. }
  2408. #endregion
  2409. #region Has Fortitude
  2410. public bool HasFortitude
  2411. {
  2412. get
  2413. {
  2414. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2415. {
  2416. if (cardEffect is ActivateICardEffect)
  2417. {
  2418. if (cardEffect.EffectName == "Fortitude")
  2419. {
  2420. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2421. {
  2422. return true;
  2423. }
  2424. }
  2425. }
  2426. }
  2427. return false;
  2428. }
  2429. }
  2430. #endregion
  2431. #region Has Blitz
  2432. public bool HasBlitz
  2433. {
  2434. get
  2435. {
  2436. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  2437. {
  2438. if (cardEffect is ActivateICardEffect)
  2439. {
  2440. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  2441. {
  2442. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2443. {
  2444. if (cardEffect.EffectDiscription.Contains("Blitz"))
  2445. {
  2446. return true;
  2447. }
  2448. }
  2449. }
  2450. }
  2451. }
  2452. return false;
  2453. }
  2454. }
  2455. #endregion
  2456. #region Has Evade
  2457. public bool HasEvade
  2458. {
  2459. get
  2460. {
  2461. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2462. {
  2463. if (cardEffect is ActivateICardEffect)
  2464. {
  2465. Hashtable hashtable = new Hashtable()
  2466. {
  2467. {"Permanents", new List<Permanent>() { this }}
  2468. };
  2469. if (cardEffect.CanTrigger(hashtable))
  2470. {
  2471. if (cardEffect.EffectName == "Evade")
  2472. {
  2473. return true;
  2474. }
  2475. }
  2476. }
  2477. }
  2478. return false;
  2479. }
  2480. }
  2481. #endregion
  2482. #region Has Mind Link
  2483. public bool HasMindLink
  2484. {
  2485. get
  2486. {
  2487. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  2488. {
  2489. if (cardEffect is ActivateICardEffect)
  2490. {
  2491. if (cardEffect.CanTrigger(null))
  2492. {
  2493. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2494. {
  2495. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2496. {
  2497. return true;
  2498. }
  2499. }
  2500. }
  2501. }
  2502. }
  2503. return false;
  2504. }
  2505. }
  2506. #endregion
  2507. #region Has Barrier
  2508. public bool HasBarrier
  2509. {
  2510. get
  2511. {
  2512. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2513. {
  2514. if (cardEffect is ActivateICardEffect)
  2515. {
  2516. Hashtable hashtable = new Hashtable();
  2517. hashtable.Add("Permanents", new List<Permanent>() { this });
  2518. hashtable.Add("battle", new IBattle(null, null, null));
  2519. if (cardEffect.CanTrigger(hashtable))
  2520. {
  2521. if (cardEffect.EffectName == "Barrier")
  2522. {
  2523. return true;
  2524. }
  2525. }
  2526. }
  2527. }
  2528. return false;
  2529. }
  2530. }
  2531. #endregion
  2532. #region Has Alliance
  2533. public bool HasAlliance
  2534. {
  2535. get
  2536. {
  2537. Hashtable hashtable = new Hashtable(){
  2538. {"AttackingPermanent", this}
  2539. };
  2540. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2541. {
  2542. foreach (Permanent permanent in player.GetFieldPermanents())
  2543. {
  2544. #region Permanent Effects
  2545. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2546. {
  2547. if (cardEffect.EffectName == "Alliance")
  2548. {
  2549. if (cardEffect.CanTrigger(hashtable))
  2550. {
  2551. return true;
  2552. }
  2553. }
  2554. }
  2555. #endregion
  2556. }
  2557. #region Effects of faceup security
  2558. foreach (CardSource source in player.SecurityCards)
  2559. {
  2560. if (source.IsFlipped)
  2561. continue;
  2562. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnAllyAttack))
  2563. {
  2564. if (cardEffect.EffectName == "Alliance")
  2565. {
  2566. if (cardEffect.CanTrigger(hashtable))
  2567. {
  2568. return true;
  2569. }
  2570. }
  2571. }
  2572. }
  2573. #endregion
  2574. #region Player Effects
  2575. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2576. {
  2577. if (cardEffect.EffectName == "Alliance")
  2578. {
  2579. if (cardEffect.CanTrigger(hashtable))
  2580. {
  2581. return true;
  2582. }
  2583. }
  2584. }
  2585. #endregion
  2586. }
  2587. return false;
  2588. }
  2589. }
  2590. #endregion
  2591. #region Has Collision
  2592. public bool HasCollision
  2593. {
  2594. get
  2595. {
  2596. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2597. {
  2598. if (cardEffect is ActivateICardEffect)
  2599. {
  2600. if (cardEffect.EffectName == "Collision")
  2601. {
  2602. return true;
  2603. }
  2604. }
  2605. }
  2606. return false;
  2607. }
  2608. }
  2609. #endregion
  2610. #region Has Partition
  2611. public bool HasPartition
  2612. {
  2613. get
  2614. {
  2615. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2616. {
  2617. if (cardEffect is ActivateICardEffect)
  2618. {
  2619. if (cardEffect.EffectName == "Partition")
  2620. {
  2621. return true;
  2622. }
  2623. }
  2624. }
  2625. return false;
  2626. }
  2627. }
  2628. #endregion
  2629. #region Has Scapegoat
  2630. public bool HasScapegoat
  2631. {
  2632. get
  2633. {
  2634. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2635. {
  2636. if (cardEffect is ActivateICardEffect)
  2637. {
  2638. if (cardEffect.EffectName == "<Scapegoat>")
  2639. {
  2640. return true;
  2641. }
  2642. }
  2643. }
  2644. return false;
  2645. }
  2646. }
  2647. #endregion
  2648. #region 消滅時効化を持つか
  2649. public bool HasOnDeletionEffect
  2650. {
  2651. get
  2652. {
  2653. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2654. {
  2655. if (cardEffect is ActivateICardEffect)
  2656. {
  2657. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2658. {
  2659. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2660. {
  2661. if (cardEffect.IsOnDeletion)
  2662. {
  2663. return true;
  2664. }
  2665. }
  2666. }
  2667. }
  2668. }
  2669. return false;
  2670. }
  2671. }
  2672. #endregion
  2673. #region バトルしているか
  2674. public IBattle battle { get; set; } = null;
  2675. #endregion
  2676. #region Can Be Destroyed
  2677. public bool CanBeDestroyed()
  2678. {
  2679. #region 消滅しない効果
  2680. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2681. {
  2682. foreach (Permanent permanent in player.GetFieldPermanents())
  2683. {
  2684. #region 場のパーマネントの効果
  2685. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2686. {
  2687. if (cardEffect is ICanNotBeDestroyedEffect)
  2688. {
  2689. if (cardEffect.CanUse(null))
  2690. {
  2691. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2692. {
  2693. return false;
  2694. }
  2695. }
  2696. }
  2697. }
  2698. #endregion
  2699. }
  2700. #region プレイヤーの効果
  2701. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2702. {
  2703. if (cardEffect is ICanNotBeDestroyedEffect)
  2704. {
  2705. if (cardEffect.CanUse(null))
  2706. {
  2707. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2708. {
  2709. return false;
  2710. }
  2711. }
  2712. }
  2713. }
  2714. #endregion
  2715. }
  2716. #endregion
  2717. return true;
  2718. }
  2719. #endregion
  2720. #region Can Be Destroyed By Battle
  2721. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2722. {
  2723. if (!CanBeDestroyed())
  2724. {
  2725. return false;
  2726. }
  2727. #region Given Effects
  2728. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2729. {
  2730. foreach (Permanent permanent in player.GetFieldPermanents())
  2731. {
  2732. #region Permanents
  2733. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2734. {
  2735. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2736. {
  2737. if (cardEffect.CanUse(null))
  2738. {
  2739. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2740. {
  2741. return false;
  2742. }
  2743. }
  2744. }
  2745. }
  2746. #endregion
  2747. }
  2748. #region Effects of faceup security
  2749. foreach (CardSource source in player.SecurityCards)
  2750. {
  2751. if (source.IsFlipped)
  2752. continue;
  2753. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2754. {
  2755. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2756. {
  2757. if (cardEffect.CanUse(null))
  2758. {
  2759. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2760. {
  2761. return false;
  2762. }
  2763. }
  2764. }
  2765. }
  2766. }
  2767. #endregion
  2768. #region Player Effects
  2769. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2770. {
  2771. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2772. {
  2773. if (cardEffect.CanUse(null))
  2774. {
  2775. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2776. {
  2777. return false;
  2778. }
  2779. }
  2780. }
  2781. }
  2782. #endregion
  2783. }
  2784. #endregion
  2785. return true;
  2786. }
  2787. #endregion
  2788. #region このパーマネントが効果で消滅するか
  2789. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2790. {
  2791. if (this.TopCard != null)
  2792. {
  2793. if (this.TopCard.CanNotBeAffected(cardEffect))
  2794. {
  2795. return false;
  2796. }
  2797. if (!CanBeDestroyed())
  2798. {
  2799. return false;
  2800. }
  2801. #region 効果で消滅しない効果
  2802. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2803. {
  2804. foreach (Permanent permanent in player.GetFieldPermanents())
  2805. {
  2806. #region 場のパーマネントの効果
  2807. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2808. {
  2809. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2810. {
  2811. if (cardEffect1.CanUse(null))
  2812. {
  2813. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2814. {
  2815. return false;
  2816. }
  2817. }
  2818. }
  2819. }
  2820. #endregion
  2821. }
  2822. #region プレイヤーの効果
  2823. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2824. {
  2825. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2826. {
  2827. if (cardEffect1.CanUse(null))
  2828. {
  2829. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2830. {
  2831. return false;
  2832. }
  2833. }
  2834. }
  2835. }
  2836. #endregion
  2837. }
  2838. #endregion
  2839. }
  2840. return true;
  2841. }
  2842. #endregion
  2843. #region Can Leave Field
  2844. public bool CanBeRemoved()
  2845. {
  2846. #region Effect that never disappears
  2847. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2848. {
  2849. foreach (Permanent permanent in player.GetFieldPermanents())
  2850. {
  2851. #region Effects of permanents in play
  2852. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2853. {
  2854. if (cardEffect is ICanNotBeRemovedEffect)
  2855. {
  2856. if (cardEffect.CanUse(null))
  2857. {
  2858. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2859. {
  2860. return false;
  2861. }
  2862. }
  2863. }
  2864. }
  2865. #endregion
  2866. }
  2867. #region player effect
  2868. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2869. {
  2870. if (cardEffect is ICanNotBeRemovedEffect)
  2871. {
  2872. if (cardEffect.CanUse(null))
  2873. {
  2874. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2875. {
  2876. return false;
  2877. }
  2878. }
  2879. }
  2880. }
  2881. #endregion
  2882. }
  2883. #endregion
  2884. return true;
  2885. }
  2886. #endregion
  2887. #region トークンかどうか
  2888. public bool IsToken
  2889. {
  2890. get
  2891. {
  2892. if (TopCard != null)
  2893. {
  2894. if (TopCard.IsToken)
  2895. {
  2896. return true;
  2897. }
  2898. }
  2899. return false;
  2900. }
  2901. }
  2902. #endregion
  2903. #region そのパーマネントが消滅・バウンス待機状態か
  2904. public bool willBeRemoveField { get; set; } = false;
  2905. #endregion
  2906. #region Is a Digimon card
  2907. public bool IsDigimon
  2908. {
  2909. get
  2910. {
  2911. if (TopCard != null)
  2912. {
  2913. if (TopCard.IsFlipped)
  2914. return false;
  2915. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2916. {
  2917. return true;
  2918. }
  2919. #region Effect of treating it as a Digimon
  2920. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2921. {
  2922. foreach (Permanent permanent in player.GetFieldPermanents())
  2923. {
  2924. #region Effects of permanents in play
  2925. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2926. {
  2927. if (cardEffect is ITreatAsDigimonEffect)
  2928. {
  2929. if (cardEffect.CanTrigger(null))
  2930. {
  2931. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2932. {
  2933. return true;
  2934. }
  2935. }
  2936. }
  2937. }
  2938. #endregion
  2939. }
  2940. #region player effect
  2941. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2942. {
  2943. if (cardEffect is ITreatAsDigimonEffect)
  2944. {
  2945. if (cardEffect.CanTrigger(null))
  2946. {
  2947. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2948. {
  2949. return true;
  2950. }
  2951. }
  2952. }
  2953. }
  2954. #endregion
  2955. }
  2956. #endregion
  2957. }
  2958. return false;
  2959. }
  2960. }
  2961. #endregion
  2962. #region Is a Tamer card
  2963. public bool IsTamer
  2964. {
  2965. get
  2966. {
  2967. if (TopCard != null)
  2968. {
  2969. if (TopCard.IsFlipped)
  2970. return false;
  2971. if (TopCard.IsTamer)
  2972. {
  2973. return true;
  2974. }
  2975. }
  2976. return false;
  2977. }
  2978. }
  2979. #endregion
  2980. #region Is an Option card
  2981. public bool IsOption
  2982. {
  2983. get
  2984. {
  2985. if (TopCard != null)
  2986. {
  2987. if (TopCard.IsOption)
  2988. {
  2989. return true;
  2990. }
  2991. }
  2992. return false;
  2993. }
  2994. }
  2995. #endregion
  2996. #region Levels handled by Jogress
  2997. public List<int> Levels_ForJogress(CardSource cardSource)
  2998. {
  2999. List<int> levels = new List<int>();
  3000. if (cardSource != null)
  3001. {
  3002. if (cardSource.HasLevel)
  3003. {
  3004. levels.Add(this.Level);
  3005. }
  3006. #region Effect of "adding levels handled by jogless evolution"
  3007. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3008. {
  3009. foreach (Permanent permanent in player.GetFieldPermanents())
  3010. {
  3011. #region Effects of permanents in play
  3012. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3013. {
  3014. if (cardEffect is IAddJogressLevelsEffect)
  3015. {
  3016. if (cardEffect.CanUse(null))
  3017. {
  3018. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  3019. {
  3020. levels.Add(level);
  3021. }
  3022. }
  3023. }
  3024. }
  3025. #endregion
  3026. }
  3027. #region player effect
  3028. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3029. {
  3030. if (cardEffect is IAddJogressLevelsEffect)
  3031. {
  3032. if (cardEffect.CanUse(null))
  3033. {
  3034. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  3035. {
  3036. levels.Add(level);
  3037. }
  3038. }
  3039. }
  3040. }
  3041. #endregion
  3042. }
  3043. #endregion
  3044. }
  3045. return levels;
  3046. }
  3047. #endregion
  3048. #region Names handled by Jogress
  3049. public List<string> Names_ForDNA(CardSource cardSource)
  3050. {
  3051. List<string> names = new List<string>();
  3052. if (cardSource != null)
  3053. {
  3054. foreach(string name in cardSource.CardNames)
  3055. names.Add(name);
  3056. #region Effect of "adding names handled by DNA evolution"
  3057. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3058. {
  3059. foreach (Permanent permanent in player.GetFieldPermanents())
  3060. {
  3061. #region Effects of permanents in play
  3062. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3063. {
  3064. if (cardEffect is IAddDNANamesEffect)
  3065. {
  3066. if (cardEffect.CanUse(null))
  3067. {
  3068. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  3069. {
  3070. names.Add(name);
  3071. }
  3072. }
  3073. }
  3074. }
  3075. #endregion
  3076. }
  3077. #region player effect
  3078. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3079. {
  3080. if (cardEffect is IAddDNANamesEffect)
  3081. {
  3082. if (cardEffect.CanUse(null))
  3083. {
  3084. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  3085. {
  3086. names.Add(name);
  3087. }
  3088. }
  3089. }
  3090. }
  3091. #endregion
  3092. }
  3093. #endregion
  3094. }
  3095. return names;
  3096. }
  3097. #endregion
  3098. #region バトルで消滅したか
  3099. public bool IsDestroyedByBattle { get; set; } = false;
  3100. #endregion
  3101. #region 消滅に使用された効果
  3102. public ICardEffect DestroyingEffect { get; set; } = null;
  3103. #endregion
  3104. #region 他のパーマネントの下に置くのに使用された効果
  3105. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  3106. #endregion
  3107. #region 手札バウンス に使用された効果
  3108. public ICardEffect HandBounceEffect { get; set; } = null;
  3109. #endregion
  3110. #region 山札バウンス に使用された効果
  3111. public ICardEffect LibraryBounceEffect { get; set; } = null;
  3112. #endregion
  3113. #region 登場に使用された効果
  3114. public ICardEffect PlayingEffect { get; set; } = null;
  3115. #endregion
  3116. #region 進化に使用された効果
  3117. public ICardEffect DigivolvingEffect { get; set; } = null;
  3118. #endregion
  3119. #region Whether this digimon is placed in the trash by not having a DP
  3120. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  3121. #endregion
  3122. #region Whether this permanent can suspend
  3123. public bool CanSuspend
  3124. {
  3125. get
  3126. {
  3127. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  3128. {
  3129. #region Effects of field permanents
  3130. foreach (Permanent permanent in player.GetFieldPermanents())
  3131. {
  3132. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3133. {
  3134. if (cardEffect is ICanNotSuspendEffect)
  3135. {
  3136. if (cardEffect.CanUse(null))
  3137. {
  3138. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  3139. {
  3140. return false;
  3141. }
  3142. }
  3143. }
  3144. }
  3145. }
  3146. #endregion
  3147. #region Effects of players
  3148. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3149. {
  3150. if (cardEffect is ICanNotSuspendEffect)
  3151. {
  3152. if (cardEffect.CanUse(null))
  3153. {
  3154. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  3155. {
  3156. return false;
  3157. }
  3158. }
  3159. }
  3160. }
  3161. #endregion
  3162. }
  3163. return true;
  3164. }
  3165. }
  3166. #endregion
  3167. #region このデジモンのアタックの対象が変更できるか
  3168. public bool CanSwitchAttackTarget
  3169. {
  3170. get
  3171. {
  3172. #region アタックの対象が変更できない効果
  3173. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3174. {
  3175. foreach (Permanent permanent in player.GetFieldPermanents())
  3176. {
  3177. #region 場のパーマネントの効果
  3178. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3179. {
  3180. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3181. {
  3182. if (cardEffect.CanUse(null))
  3183. {
  3184. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3185. {
  3186. return false;
  3187. }
  3188. }
  3189. }
  3190. }
  3191. #endregion
  3192. }
  3193. #region プレイヤーの効果
  3194. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3195. {
  3196. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3197. {
  3198. if (cardEffect.CanUse(null))
  3199. {
  3200. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3201. {
  3202. return false;
  3203. }
  3204. }
  3205. }
  3206. }
  3207. #endregion
  3208. }
  3209. #endregion
  3210. return true;
  3211. }
  3212. }
  3213. #endregion
  3214. #region このデジモンを場からデジクロス条件の代わりにできるか
  3215. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  3216. {
  3217. #region デジクロス条件の代わりにできる効果
  3218. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3219. {
  3220. foreach (Permanent permanent in player.GetFieldPermanents())
  3221. {
  3222. #region 場のパーマネントの効果
  3223. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3224. {
  3225. if (cardEffect is ICanSelectDigiXrosEffect)
  3226. {
  3227. if (cardEffect.CanUse(null))
  3228. {
  3229. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3230. {
  3231. return true;
  3232. }
  3233. }
  3234. }
  3235. }
  3236. #endregion
  3237. }
  3238. #region プレイヤーの効果
  3239. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3240. {
  3241. if (cardEffect is ICanSelectDigiXrosEffect)
  3242. {
  3243. if (cardEffect.CanUse(null))
  3244. {
  3245. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3246. {
  3247. return true;
  3248. }
  3249. }
  3250. }
  3251. }
  3252. #endregion
  3253. }
  3254. #endregion
  3255. return false;
  3256. }
  3257. #endregion
  3258. #region Can Substitue for Assembly
  3259. public bool CanSubstituteForAssemblyCondition(CardSource cardSource)
  3260. {
  3261. #region Effects that can be used in place of Assembly conditions
  3262. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3263. {
  3264. foreach (Permanent permanent in player.GetFieldPermanents())
  3265. {
  3266. #region Effects of permanents in play
  3267. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3268. {
  3269. if (cardEffect is ICanSelectAssemblyEffect)
  3270. {
  3271. if (cardEffect.CanUse(null))
  3272. {
  3273. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3274. {
  3275. return true;
  3276. }
  3277. }
  3278. }
  3279. }
  3280. #endregion
  3281. }
  3282. #region player effect
  3283. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3284. {
  3285. if (cardEffect is ICanSelectAssemblyEffect)
  3286. {
  3287. if (cardEffect.CanUse(null))
  3288. {
  3289. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3290. {
  3291. return true;
  3292. }
  3293. }
  3294. }
  3295. }
  3296. #endregion
  3297. }
  3298. #endregion
  3299. return false;
  3300. }
  3301. #endregion
  3302. #region 登場した直後のLevel
  3303. public int LevelJustAfterPlayed { get; set; } = -1;
  3304. #endregion
  3305. #region 登場した直後のPlay Cost
  3306. public int PlayCostJustAfterPlayed { get; set; } = -1;
  3307. #endregion
  3308. #region 登場した直後のCardNames
  3309. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  3310. #endregion
  3311. #region 進化した直後のCardNames
  3312. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  3313. #endregion
  3314. #region 登場した直後のTraits
  3315. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  3316. #endregion
  3317. #region 場を離れる直前のDP
  3318. public int DPJustBeforeRemoveField { get; set; } = -1;
  3319. #endregion
  3320. #region 場を離れる直前のLevel
  3321. public int LevelJustBeforeRemoveField { get; set; } = -1;
  3322. #endregion
  3323. #region 場を離れる直前のCost
  3324. public int CostJustBeforeRemoveField { get; set; } = -1;
  3325. #endregion
  3326. #region 場を離れる直前のカード名
  3327. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  3328. #endregion
  3329. #region Card Traits Just Before Removed Field
  3330. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  3331. #endregion
  3332. #region バースト進化で手札に戻ったか
  3333. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  3334. #endregion
  3335. #region Is Linked Card Added as Source By App Fusion
  3336. public bool IsAddedAsSourceByAppFusion { get; set; } = false;
  3337. #endregion
  3338. #region バースト進化したか
  3339. public bool IsBurstDigivolved { get; set; } = false;
  3340. #endregion
  3341. #region Did it App Fusion?
  3342. public bool IsAppFusion { get; set; } = false;
  3343. #endregion
  3344. #region 効果で場に出たオプションか
  3345. public bool IsPlayedOptionPermanent { get; set; } = false;
  3346. #endregion
  3347. #region 進化元を持たないか
  3348. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  3349. #endregion
  3350. #region Has face down Digivolution Cards
  3351. public bool HasFaceDownDigivolutionCards => DigivolutionCards.Any(x => x.IsFlipped);
  3352. #endregion
  3353. #region Has No Link Cards
  3354. public bool HasNoLinkCards => LinkedCards.Count == 0;
  3355. #endregion
  3356. #region Digivolution cards' colors
  3357. public List<CardColor> DigivolutionCardsColors
  3358. {
  3359. get
  3360. {
  3361. List<CardColor> cardColors = new List<CardColor>();
  3362. foreach (CardSource cardSource in DigivolutionCards)
  3363. {
  3364. if (cardSource.IsFlipped)
  3365. continue;
  3366. foreach (CardColor cardColor in cardSource.CardColors)
  3367. {
  3368. if (!cardColors.Contains(cardColor))
  3369. {
  3370. cardColors.Add(cardColor);
  3371. }
  3372. }
  3373. foreach (CardColor cardColor in cardSource.DualCardColors)
  3374. {
  3375. if (!cardColors.Contains(cardColor))
  3376. {
  3377. cardColors.Add(cardColor);
  3378. }
  3379. }
  3380. }
  3381. return cardColors.Distinct().ToList();
  3382. }
  3383. }
  3384. #endregion
  3385. #region Show "Unsuspend" effect object
  3386. public void ShowUnsuspendEffect()
  3387. {
  3388. if (TopCard != null)
  3389. {
  3390. if (ShowingPermanentCard != null)
  3391. {
  3392. if (ShowingPermanentCard.WillUntapObject != null)
  3393. {
  3394. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  3395. ShowingPermanentCard.WillUntapObject.SetActive(true);
  3396. }
  3397. }
  3398. }
  3399. }
  3400. #endregion
  3401. #region Show "Return to deck" effect object
  3402. public void ShowDeckBounceEffect()
  3403. {
  3404. if (TopCard != null)
  3405. {
  3406. if (willBeRemoveField)
  3407. {
  3408. if (ShowingPermanentCard != null)
  3409. {
  3410. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3411. {
  3412. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  3413. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  3414. }
  3415. }
  3416. }
  3417. }
  3418. }
  3419. #endregion
  3420. #region Hide "Return to deck" effect object
  3421. public void HideDeckBounceEffect()
  3422. {
  3423. if (TopCard != null)
  3424. {
  3425. if (ShowingPermanentCard != null)
  3426. {
  3427. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3428. {
  3429. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  3430. }
  3431. }
  3432. }
  3433. }
  3434. #endregion
  3435. #region Show "Return to hand" effect object
  3436. public void ShowHandBounceEffect()
  3437. {
  3438. if (TopCard != null)
  3439. {
  3440. if (willBeRemoveField)
  3441. {
  3442. if (ShowingPermanentCard != null)
  3443. {
  3444. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3445. {
  3446. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  3447. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  3448. }
  3449. }
  3450. }
  3451. }
  3452. }
  3453. #endregion
  3454. #region Hide "Return to hand" effect object
  3455. public void HideHandBounceEffect()
  3456. {
  3457. if (TopCard != null)
  3458. {
  3459. if (ShowingPermanentCard != null)
  3460. {
  3461. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3462. {
  3463. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  3464. }
  3465. }
  3466. }
  3467. }
  3468. #endregion
  3469. #region Show "Delete" effect object
  3470. public void ShowDeleteEffect()
  3471. {
  3472. if (TopCard != null)
  3473. {
  3474. if (willBeRemoveField)
  3475. {
  3476. if (ShowingPermanentCard != null)
  3477. {
  3478. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3479. {
  3480. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  3481. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  3482. }
  3483. }
  3484. }
  3485. }
  3486. }
  3487. #endregion
  3488. #region Hide "Delete" effect object
  3489. public void HideDeleteEffect()
  3490. {
  3491. if (TopCard != null)
  3492. {
  3493. if (ShowingPermanentCard != null)
  3494. {
  3495. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3496. {
  3497. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  3498. }
  3499. }
  3500. }
  3501. }
  3502. #endregion
  3503. #region Show "Remove Field" effect object
  3504. public void ShowWillRemoveFieldEffect()
  3505. {
  3506. if (TopCard != null)
  3507. {
  3508. if (willBeRemoveField)
  3509. {
  3510. if (ShowingPermanentCard != null)
  3511. {
  3512. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3513. {
  3514. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  3515. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  3516. }
  3517. }
  3518. }
  3519. }
  3520. }
  3521. #endregion
  3522. #region Hide "Remove Field" effect object
  3523. public void HideWillRemoveFieldEffect()
  3524. {
  3525. if (TopCard != null)
  3526. {
  3527. if (ShowingPermanentCard != null)
  3528. {
  3529. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3530. {
  3531. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  3532. }
  3533. }
  3534. }
  3535. }
  3536. #endregion
  3537. #region Show "Digivolution" effect object
  3538. public void ShowWillEvolutionEffect()
  3539. {
  3540. if (TopCard != null)
  3541. {
  3542. if (ShowingPermanentCard != null)
  3543. {
  3544. if (ShowingPermanentCard.WillEvolutionObject != null)
  3545. {
  3546. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  3547. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  3548. }
  3549. }
  3550. }
  3551. }
  3552. #endregion
  3553. #region Hide "Digivolution" effect object
  3554. public void HideWillEvolutionEffect()
  3555. {
  3556. if (TopCard != null)
  3557. {
  3558. if (ShowingPermanentCard != null)
  3559. {
  3560. if (ShowingPermanentCard.WillEvolutionObject != null)
  3561. {
  3562. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  3563. }
  3564. }
  3565. }
  3566. }
  3567. #endregion
  3568. }