Permanent.cs 110 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320
  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. newCardSources.Reverse();
  16. foreach (CardSource cardSource in newCardSources)
  17. {
  18. AddCardSource(cardSource);
  19. }
  20. }
  21. public FieldCardFrame PermanentFrame
  22. {
  23. get
  24. {
  25. if (TopCard != null)
  26. {
  27. int index = Array.IndexOf(TopCard.Owner.FieldPermanents, this);
  28. if (0 <= index && index <= TopCard.Owner.fieldCardFrames.Count - 1)
  29. {
  30. return TopCard.Owner.fieldCardFrames[index];
  31. }
  32. }
  33. return null;
  34. }
  35. }
  36. public bool oldIsTapped_playCard { get; set; }
  37. #region Level
  38. public int Level
  39. {
  40. get
  41. {
  42. int Level = 0;
  43. if (TopCard != null)
  44. {
  45. Level = TopCard.Level;
  46. if (!TopCard.HasLevel)
  47. {
  48. Level = 1145140;
  49. }
  50. #region レベルを変更する効果
  51. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  52. {
  53. foreach (Permanent permanent in player.GetFieldPermanents())
  54. {
  55. #region 場のパーマネントの効果
  56. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  57. {
  58. if (cardEffect is IChangePermanentLevelEffect)
  59. {
  60. if (cardEffect.CanUse(null))
  61. {
  62. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  63. }
  64. }
  65. }
  66. #endregion
  67. }
  68. #region プレイヤーの効果
  69. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  70. {
  71. if (cardEffect is IChangePermanentLevelEffect)
  72. {
  73. if (cardEffect.CanUse(null))
  74. {
  75. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  76. }
  77. }
  78. }
  79. #endregion
  80. }
  81. #endregion
  82. }
  83. return Level;
  84. }
  85. }
  86. #endregion
  87. #region Place all evolution sources in the trash
  88. public IEnumerator DiscardEvoRoots(bool ignoreOverflow = false, bool putToTrash = true)
  89. {
  90. List<CardSource> evoRoots = DigivolutionCards.Clone();
  91. if (!ignoreOverflow)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(evoRoots).Overflow());
  94. }
  95. foreach (CardSource cardSource1 in evoRoots)
  96. {
  97. if (putToTrash)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource1));
  100. }
  101. else
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource1));
  104. }
  105. }
  106. }
  107. #endregion
  108. #region Whether this permanent has DP
  109. public bool HasDP
  110. {
  111. get
  112. {
  113. if (TopCard == null)
  114. {
  115. return false;
  116. }
  117. if (!IsDigimon)
  118. {
  119. return false;
  120. }
  121. if (!TopCard.HasDP && TopCard.IsDigiEgg)
  122. {
  123. return false;
  124. }
  125. #region Effect of not having DP
  126. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  127. {
  128. foreach (Permanent permanent in player.GetFieldPermanents())
  129. {
  130. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  131. {
  132. if (cardEffect1 is IDontHaveDPEffect)
  133. {
  134. if (cardEffect1.CanUse(null))
  135. {
  136. if (((IDontHaveDPEffect)cardEffect1).DontHaveDP(this))
  137. {
  138. return false;
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. #endregion
  146. return true;
  147. }
  148. }
  149. #endregion
  150. #region Base DP
  151. public int BaseDP
  152. {
  153. get
  154. {
  155. int BaseDP = 0;
  156. if (HasDP)
  157. {
  158. BaseDP = TopCard.BaseCardDP;
  159. #region 基礎DPを変更する効果
  160. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  161. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  162. {
  163. foreach (Permanent permanent in player.GetFieldPermanents())
  164. {
  165. #region 場のパーマネントの効果
  166. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  167. {
  168. if (cardEffect is IChangeBaseDPEffect)
  169. {
  170. if (cardEffect.CanUse(null))
  171. {
  172. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  173. {
  174. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  175. {
  176. if (this.ImmuneFromDPMinus(cardEffect))
  177. {
  178. continue;
  179. }
  180. }
  181. if (!TopCard.CanNotBeAffected(cardEffect))
  182. {
  183. cardEffects_ChangeDP.Add(cardEffect);
  184. }
  185. }
  186. }
  187. }
  188. }
  189. #endregion
  190. }
  191. #region プレイヤーの効果
  192. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  193. {
  194. if (cardEffect is IChangeBaseDPEffect)
  195. {
  196. if (cardEffect.CanUse(null))
  197. {
  198. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  199. {
  200. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  201. {
  202. if (this.ImmuneFromDPMinus(cardEffect))
  203. {
  204. continue;
  205. }
  206. }
  207. if (!TopCard.CanNotBeAffected(cardEffect))
  208. {
  209. cardEffects_ChangeDP.Add(cardEffect);
  210. }
  211. }
  212. }
  213. }
  214. }
  215. #endregion
  216. }
  217. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  218. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  219. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  220. {
  221. if (cardEffect is IChangeBaseDPEffect)
  222. {
  223. if (cardEffect.CanUse(null))
  224. {
  225. if (((IChangeBaseDPEffect)cardEffect).IsUpDown())
  226. {
  227. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  228. }
  229. else
  230. {
  231. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  232. }
  233. }
  234. }
  235. }
  236. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  237. {
  238. if (cardEffect is IChangeBaseDPEffect)
  239. {
  240. if (cardEffect.CanUse(null))
  241. {
  242. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  243. }
  244. }
  245. }
  246. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  247. {
  248. if (cardEffect is IChangeBaseDPEffect)
  249. {
  250. if (cardEffect.CanUse(null))
  251. {
  252. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  253. }
  254. }
  255. }
  256. #endregion
  257. if (BaseDP < 0)
  258. {
  259. BaseDP = 0;
  260. }
  261. }
  262. return BaseDP;
  263. }
  264. }
  265. #endregion
  266. #region DP
  267. public int DP
  268. {
  269. get
  270. {
  271. int DP = -1;
  272. if (HasDP)
  273. {
  274. DP = BaseDP;
  275. #region DPを変更する効果
  276. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  277. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  278. {
  279. #region Effects of permanents in play
  280. foreach (Permanent permanent in player.GetFieldPermanents())
  281. {
  282. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  283. {
  284. if (cardEffect is IChangeDPEffect)
  285. {
  286. if (cardEffect.CanUse(null))
  287. {
  288. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  289. {
  290. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  291. {
  292. if (this.ImmuneFromDPMinus(cardEffect))
  293. {
  294. continue;
  295. }
  296. }
  297. if (!TopCard.CanNotBeAffected(cardEffect))
  298. {
  299. cardEffects_ChangeDP.Add(cardEffect);
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. #endregion
  307. #region Effects of face up security
  308. foreach (CardSource cardSource in player.SecurityCards)
  309. {
  310. if (cardSource.IsFlipped)
  311. continue;
  312. foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
  313. {
  314. if (cardEffect is IChangeDPEffect)
  315. {
  316. if (cardEffect.CanUse(null))
  317. {
  318. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  319. {
  320. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  321. {
  322. if (this.ImmuneFromDPMinus(cardEffect))
  323. {
  324. continue;
  325. }
  326. }
  327. if (!TopCard.CanNotBeAffected(cardEffect))
  328. {
  329. cardEffects_ChangeDP.Add(cardEffect);
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. #endregion
  337. #region Player effect
  338. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  339. {
  340. if (cardEffect is IChangeDPEffect)
  341. {
  342. if (cardEffect.CanUse(null))
  343. {
  344. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  345. {
  346. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  347. {
  348. if (this.ImmuneFromDPMinus(cardEffect))
  349. {
  350. continue;
  351. }
  352. }
  353. if (!TopCard.CanNotBeAffected(cardEffect))
  354. {
  355. cardEffects_ChangeDP.Add(cardEffect);
  356. }
  357. }
  358. }
  359. }
  360. }
  361. #endregion
  362. }
  363. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  364. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  365. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  366. {
  367. if (cardEffect is IChangeDPEffect)
  368. {
  369. if (cardEffect.CanUse(null))
  370. {
  371. if (((IChangeDPEffect)cardEffect).IsUpDown())
  372. {
  373. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  374. }
  375. else
  376. {
  377. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  378. }
  379. }
  380. }
  381. }
  382. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  383. {
  384. if (cardEffect is IChangeDPEffect)
  385. {
  386. if (cardEffect.CanUse(null))
  387. {
  388. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  389. }
  390. }
  391. }
  392. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  393. {
  394. if (cardEffect is IChangeDPEffect)
  395. {
  396. if (cardEffect.CanUse(null))
  397. {
  398. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  399. }
  400. }
  401. }
  402. #endregion
  403. if (DP < 0)
  404. {
  405. DP = 0;
  406. }
  407. }
  408. return DP;
  409. }
  410. }
  411. #endregion
  412. #region Will it not receive negative DP effect?
  413. public bool ImmuneFromDPMinus(ICardEffect cardEffect)
  414. {
  415. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  416. {
  417. foreach (Permanent permanent in player.GetFieldPermanents())
  418. {
  419. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  420. {
  421. if (cardEffect1 is IImmuneFromDPMinusEffect)
  422. {
  423. if (cardEffect1.CanUse(null))
  424. {
  425. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  426. {
  427. return true;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  434. {
  435. if (cardEffect1 is IImmuneFromDPMinusEffect)
  436. {
  437. if (cardEffect1.CanUse(null))
  438. {
  439. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  440. {
  441. return true;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. return false;
  448. }
  449. #endregion
  450. #region Can be returned to your hand?
  451. public bool CannotReturnToHand(ICardEffect cardEffect)
  452. {
  453. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  454. {
  455. foreach (Permanent permanent in player.GetFieldPermanents())
  456. {
  457. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  458. {
  459. if (cardEffect1 is ICannotReturnToHandEffect)
  460. {
  461. if (cardEffect1.CanUse(null))
  462. {
  463. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  464. {
  465. return true;
  466. }
  467. }
  468. }
  469. }
  470. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  471. {
  472. if (cardEffect1 is ICannotReturnToHandEffect)
  473. {
  474. if (cardEffect1.CanUse(null))
  475. {
  476. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  477. {
  478. return true;
  479. }
  480. }
  481. }
  482. }
  483. }
  484. }
  485. return false;
  486. }
  487. #endregion
  488. #region Can be returned to deck?
  489. public bool CannotReturnToLibrary(ICardEffect cardEffect)
  490. {
  491. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  492. {
  493. foreach (Permanent permanent in player.GetFieldPermanents())
  494. {
  495. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  496. {
  497. if (cardEffect1 is ICannotReturnToLibraryEffect)
  498. {
  499. if (cardEffect1.CanUse(null))
  500. {
  501. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  502. {
  503. return true;
  504. }
  505. }
  506. }
  507. }
  508. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  509. {
  510. if (cardEffect1 is ICannotReturnToLibraryEffect)
  511. {
  512. if (cardEffect1.CanUse(null))
  513. {
  514. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  515. {
  516. return true;
  517. }
  518. }
  519. }
  520. }
  521. }
  522. }
  523. return false;
  524. }
  525. #endregion
  526. #region 退化を受けないか
  527. public bool ImmuneFromDeDigivolve()
  528. {
  529. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  530. {
  531. foreach (Permanent permanent in player.GetFieldPermanents())
  532. {
  533. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  534. {
  535. if (cardEffect1 is IImmuneFromDeDigivolveEffect)
  536. {
  537. if (cardEffect1.CanUse(null))
  538. {
  539. if (((IImmuneFromDeDigivolveEffect)cardEffect1).ImmuneDeDigivolve(this))
  540. {
  541. return true;
  542. }
  543. }
  544. }
  545. }
  546. }
  547. }
  548. return false;
  549. }
  550. #endregion
  551. #region このパーマネントの持つカードリスト
  552. public List<CardSource> cardSources = new List<CardSource>();
  553. #endregion
  554. #region 一番上以外のカード
  555. public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard);
  556. #endregion
  557. #region パーマネントのカードリストにカードを追加
  558. public void AddCardSource(CardSource cardSource)
  559. {
  560. cardSources.Insert(0, cardSource);
  561. cardSource.SetFace();
  562. }
  563. #endregion
  564. #region Add digivolution cards to top of sources
  565. /// <summary>
  566. /// 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
  567. /// </summary>
  568. /// <param name="addedDigivolutionCards"></param>
  569. /// <param name="cardEffect"></param>
  570. /// <param name="skipEffectAndActivateSkill"></param>
  571. /// <returns></returns>
  572. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  573. {
  574. List<CardSource> addedCards = new List<CardSource>();
  575. bool isFromSameDigimon = false;
  576. bool isFromDigimon = false;
  577. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  578. {
  579. if (cardSources.Contains(addedDigivolutionCard))
  580. {
  581. isFromSameDigimon = true;
  582. }
  583. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  584. {
  585. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  586. {
  587. isFromDigimon = true;
  588. }
  589. }
  590. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  591. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  592. {
  593. this.cardSources.Insert(1, addedDigivolutionCard);
  594. addedDigivolutionCard.SetFace();
  595. addedCards.Add(addedDigivolutionCard);
  596. }
  597. }
  598. if (addedCards.Count >= 1)
  599. {
  600. if (ShowingPermanentCard != null)
  601. {
  602. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  603. }
  604. #region "進化元が増えた時"の効果
  605. #region Hashtable Setting
  606. Hashtable hashtable = new Hashtable()
  607. {
  608. {"Permanent", this},
  609. {"CardEffect", cardEffect},
  610. {"CardSources", addedCards},
  611. {"isFromSameDigimon", isFromSameDigimon},
  612. {"isFromDigimon", isFromDigimon},
  613. };
  614. #endregion
  615. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  616. #endregion
  617. }
  618. }
  619. #endregion
  620. #region Add digivolution cards to bottom of sources
  621. /// <summary>
  622. /// 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
  623. /// </summary>
  624. /// <param name="addedDigivolutionCards"></param>
  625. /// <param name="cardEffect"></param>
  626. /// <param name="skipEffectAndActivateSkill"></param>
  627. /// <returns></returns>
  628. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false)
  629. {
  630. List<CardSource> addedCards = new List<CardSource>();
  631. bool isFromSameDigimon = false;
  632. bool isFromDigimon = false;
  633. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  634. {
  635. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  636. {
  637. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  638. {
  639. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  640. {
  641. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
  642. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  643. if (!placePermanent.Placed)
  644. {
  645. continue;
  646. }
  647. }
  648. }
  649. }
  650. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  651. {
  652. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  653. {
  654. isFromDigimon = true;
  655. }
  656. }
  657. if (cardSources.Contains(addedDigivolutionCard))
  658. {
  659. isFromSameDigimon = true;
  660. if (addedDigivolutionCard == TopCard)
  661. {
  662. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  663. ShowingPermanentCard.ShowPermanentData(true);
  664. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  665. addedDigivolutionCard,
  666. this));
  667. }
  668. }
  669. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  670. if (!IsToken && !addedDigivolutionCard.IsToken)
  671. {
  672. cardSources.Add(addedDigivolutionCard);
  673. addedDigivolutionCard.SetFace();
  674. addedCards.Add(addedDigivolutionCard);
  675. }
  676. }
  677. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  678. {
  679. if (ShowingPermanentCard != null)
  680. {
  681. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  682. }
  683. #region Effect of "when the number of evolution sources increases"
  684. #region Hashtable Setting
  685. Hashtable hashtable = new Hashtable()
  686. {
  687. {"Permanent", this},
  688. {"CardEffect", cardEffect},
  689. {"CardSources", addedCards},
  690. {"isFromSameDigimon", isFromSameDigimon},
  691. {"isFromDigimon", isFromDigimon},
  692. };
  693. #endregion
  694. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  695. #endregion
  696. }
  697. }
  698. #endregion
  699. #region パーマネントのカードリストからカードを除く
  700. public IEnumerator RemoveCardSource(CardSource cardSource)
  701. {
  702. yield return null;
  703. cardSources.Remove(cardSource);
  704. }
  705. #endregion
  706. #region このパーマネントの一番上のカード
  707. public CardSource TopCard
  708. {
  709. get
  710. {
  711. if (cardSources.Count >= 1)
  712. {
  713. return cardSources[0];
  714. }
  715. return null;
  716. }
  717. }
  718. #endregion
  719. #region Permanent effect list
  720. #region このパーマネントの効果リスト
  721. public List<ICardEffect> EffectList(EffectTiming timing)
  722. {
  723. return EffectList_ForCard(timing, TopCard);
  724. }
  725. #endregion
  726. #region このポケモンの追加効果リスト
  727. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  728. {
  729. List<ICardEffect> _EffectList = new List<ICardEffect>();
  730. if (TopCard != null)
  731. {
  732. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  733. {
  734. ICardEffect cardEffect = GetCardEffect(timing);
  735. if (cardEffect != null)
  736. {
  737. _EffectList.Add(cardEffect);
  738. }
  739. }
  740. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  741. {
  742. ICardEffect cardEffect = GetCardEffect(timing);
  743. if (cardEffect != null)
  744. {
  745. _EffectList.Add(cardEffect);
  746. }
  747. }
  748. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  749. {
  750. ICardEffect cardEffect = GetCardEffect(timing);
  751. if (cardEffect != null)
  752. {
  753. _EffectList.Add(cardEffect);
  754. }
  755. }
  756. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  757. {
  758. ICardEffect cardEffect = GetCardEffect(timing);
  759. if (cardEffect != null)
  760. {
  761. _EffectList.Add(cardEffect);
  762. }
  763. }
  764. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  765. {
  766. ICardEffect cardEffect = GetCardEffect(timing);
  767. if (cardEffect != null)
  768. {
  769. _EffectList.Add(cardEffect);
  770. }
  771. }
  772. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  773. {
  774. ICardEffect cardEffect = GetCardEffect(timing);
  775. if (cardEffect != null)
  776. {
  777. _EffectList.Add(cardEffect);
  778. }
  779. }
  780. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  781. {
  782. ICardEffect cardEffect = GetCardEffect(timing);
  783. if (cardEffect != null)
  784. {
  785. _EffectList.Add(cardEffect);
  786. }
  787. }
  788. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  789. {
  790. ICardEffect cardEffect = GetCardEffect(timing);
  791. if (cardEffect != null)
  792. {
  793. _EffectList.Add(cardEffect);
  794. }
  795. }
  796. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  797. {
  798. ICardEffect cardEffect = GetCardEffect(timing);
  799. if (cardEffect != null)
  800. {
  801. _EffectList.Add(cardEffect);
  802. }
  803. }
  804. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  805. foreach (ICardEffect cardEffect in _EffectList)
  806. {
  807. if (cardEffect != null)
  808. {
  809. if (cardEffect.EffectSourceCard == null)
  810. {
  811. cardEffect.SetEffectSourceCard(TopCard);
  812. }
  813. cardEffect.SetIsInheritedEffect(false);
  814. }
  815. }
  816. }
  817. return _EffectList;
  818. }
  819. #endregion
  820. #region このパーマネントの効果リスト(引数:CardSource)
  821. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  822. {
  823. List<ICardEffect> _EffectList = new List<ICardEffect>();
  824. if (TopCard != null && _cardSource != null)
  825. {
  826. foreach (CardSource cardSource in cardSources)
  827. {
  828. if (cardSource != null)
  829. {
  830. if (!cardSource.IsFlipped)
  831. {
  832. bool isTopCard = cardSource == TopCard;
  833. if (!isTopCard)
  834. {
  835. if (!IsDigimon)
  836. {
  837. continue;
  838. }
  839. }
  840. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  841. {
  842. if (cardEffect != null)
  843. {
  844. if (isTopCard == cardEffect.IsInheritedEffect)
  845. {
  846. continue;
  847. }
  848. _EffectList.Add(cardEffect);
  849. }
  850. }
  851. }
  852. }
  853. }
  854. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  855. {
  856. if (cardEffect != null)
  857. {
  858. _EffectList.Add(cardEffect);
  859. }
  860. }
  861. foreach (ICardEffect cardEffect in _EffectList)
  862. {
  863. if (cardEffect != null)
  864. {
  865. if (cardEffect.EffectSourceCard == null)
  866. {
  867. cardEffect.SetEffectSourceCard(_cardSource);
  868. }
  869. }
  870. }
  871. }
  872. return _EffectList;
  873. }
  874. #endregion
  875. #region 自分のターン終了時に消える効果
  876. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  877. #endregion
  878. #region 自分のドローフェイズ終了時に消える効果
  879. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  880. #endregion
  881. #region お互いのターン終了時に消える効果
  882. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  883. #endregion
  884. #region 相手のターン終了時に消える効果
  885. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  886. #endregion
  887. #region バトル終了時に消える効果
  888. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  889. #endregion
  890. #region 攻撃終了時に消える効果
  891. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  892. #endregion
  893. #region 自分のターン開始時に消える効果
  894. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  895. #endregion
  896. #region 次にアンタップする時に消える効果
  897. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  898. #endregion
  899. #region 場を離れるまで残る効果
  900. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  901. #endregion
  902. #endregion
  903. #region 起動型効果を宣言できるか
  904. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  905. #endregion
  906. #region 宣言可能な起動型効果リスト
  907. public List<ICardEffect> CanDeclareSkillList()
  908. {
  909. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  910. if (TopCard != null)
  911. {
  912. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  913. {
  914. if (_cardEffect is ActivateICardEffect)
  915. {
  916. if (_cardEffect.CanUse(null))
  917. {
  918. CanDeclareSkillList.Add(_cardEffect);
  919. }
  920. }
  921. }
  922. }
  923. return CanDeclareSkillList;
  924. }
  925. #endregion
  926. #region このパーマネントが場に出たターン
  927. public int EnterFieldTurnCount { get; set; } = -1;
  928. #endregion
  929. #region このパーマネントを表す場のオブジェクト
  930. public FieldPermanentCard ShowingPermanentCard { get; set; }
  931. #endregion
  932. #region Whether this permanent can be selected by the effect
  933. public bool CanSelectBySkill(ICardEffect skill)
  934. {
  935. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  936. {
  937. #region Effects of field permanents
  938. foreach (Permanent permanent in player.GetFieldPermanents())
  939. {
  940. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  941. {
  942. if (cardEffect is ICanNotSelectBySkillEffect)
  943. {
  944. if (cardEffect.CanUse(null))
  945. {
  946. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  947. {
  948. return false;
  949. }
  950. }
  951. }
  952. }
  953. }
  954. #endregion
  955. }
  956. return true;
  957. }
  958. #endregion
  959. #region Number of sheets to undergo security check
  960. public int InvertSecutiryValue
  961. {
  962. get
  963. {
  964. int Invert = 0;
  965. List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
  966. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  967. {
  968. foreach (Permanent permanent in player.GetFieldPermanents())
  969. {
  970. #region Effects of permanents in play
  971. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  972. {
  973. if (cardEffect is IInvertSAttackEffect)
  974. {
  975. if (cardEffect.CanUse(null))
  976. {
  977. if (!TopCard.CanNotBeAffected(cardEffect))
  978. {
  979. cardEffects_InvertStrike.Add(cardEffect);
  980. }
  981. }
  982. }
  983. }
  984. #endregion
  985. }
  986. #region player effect
  987. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  988. {
  989. if (cardEffect is IInvertSAttackEffect)
  990. {
  991. if (cardEffect.CanUse(null))
  992. {
  993. if (!TopCard.CanNotBeAffected(cardEffect))
  994. {
  995. cardEffects_InvertStrike.Add(cardEffect);
  996. }
  997. }
  998. }
  999. }
  1000. #endregion
  1001. }
  1002. foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
  1003. {
  1004. Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
  1005. }
  1006. return Mathf.Clamp(Invert,-1,1);
  1007. }
  1008. }
  1009. public List<int> SecurityAttackChanges
  1010. {
  1011. get
  1012. {
  1013. List<int> SecurityAttackChanges = new List<int>();
  1014. int Strike = 1;
  1015. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1016. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1017. {
  1018. foreach (Permanent permanent in player.GetFieldPermanents())
  1019. {
  1020. #region 場のパーマネントの効果
  1021. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1022. {
  1023. if (cardEffect is IChangeSAttackEffect)
  1024. {
  1025. if (cardEffect.CanUse(null))
  1026. {
  1027. if (!TopCard.CanNotBeAffected(cardEffect))
  1028. {
  1029. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1030. {
  1031. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1032. }
  1033. }
  1034. }
  1035. }
  1036. }
  1037. #endregion
  1038. }
  1039. #region プレイヤーの効果
  1040. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1041. {
  1042. if (cardEffect is IChangeSAttackEffect)
  1043. {
  1044. if (cardEffect.CanUse(null))
  1045. {
  1046. if (!TopCard.CanNotBeAffected(cardEffect))
  1047. {
  1048. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1049. {
  1050. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1051. }
  1052. }
  1053. }
  1054. }
  1055. }
  1056. #endregion
  1057. }
  1058. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1059. {
  1060. if (cardEffect is IChangeSAttackEffect)
  1061. {
  1062. if (cardEffect.CanUse(null))
  1063. {
  1064. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
  1065. if (Strike1 != Strike)
  1066. {
  1067. SecurityAttackChanges.Add(Strike1 - Strike);
  1068. }
  1069. }
  1070. }
  1071. }
  1072. return SecurityAttackChanges;
  1073. }
  1074. }
  1075. public bool HasSecurityAttackChanges
  1076. {
  1077. get
  1078. {
  1079. if (!IsDigimon)
  1080. {
  1081. return false;
  1082. }
  1083. return SecurityAttackChanges.Count >= 1;
  1084. }
  1085. }
  1086. public int Strike_AllowMinus
  1087. {
  1088. get
  1089. {
  1090. int Strike = 1;
  1091. #region Effect of changing the number of sheets to undergo security check
  1092. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1093. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1094. {
  1095. foreach (Permanent permanent in player.GetFieldPermanents())
  1096. {
  1097. #region Effects of permanents in play
  1098. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1099. {
  1100. if (cardEffect is IChangeSAttackEffect)
  1101. {
  1102. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1103. {
  1104. if (cardEffect.CanUse(null))
  1105. {
  1106. if (!TopCard.CanNotBeAffected(cardEffect))
  1107. {
  1108. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. #endregion
  1115. }
  1116. #region player effect
  1117. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1118. {
  1119. if (cardEffect is IChangeSAttackEffect)
  1120. {
  1121. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1122. {
  1123. if (cardEffect.CanUse(null))
  1124. {
  1125. if (!TopCard.CanNotBeAffected(cardEffect))
  1126. {
  1127. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1128. }
  1129. }
  1130. }
  1131. }
  1132. }
  1133. #endregion
  1134. }
  1135. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1136. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1137. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1138. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1139. {
  1140. if (cardEffect is IChangeSAttackEffect)
  1141. {
  1142. if (cardEffect.CanUse(null))
  1143. {
  1144. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1145. {
  1146. case CalculateOrder.UpToConstant:
  1147. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1148. break;
  1149. case CalculateOrder.UpDownValue:
  1150. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1151. break;
  1152. case CalculateOrder.DownToConstant:
  1153. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1154. break;
  1155. }
  1156. }
  1157. }
  1158. }
  1159. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1160. {
  1161. if (cardEffect is IChangeSAttackEffect)
  1162. {
  1163. if (cardEffect.CanUse(null))
  1164. {
  1165. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1166. }
  1167. }
  1168. }
  1169. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1170. {
  1171. if (cardEffect is IChangeSAttackEffect)
  1172. {
  1173. if (cardEffect.CanUse(null))
  1174. {
  1175. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1176. }
  1177. }
  1178. }
  1179. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1180. {
  1181. if (cardEffect is IChangeSAttackEffect)
  1182. {
  1183. if (cardEffect.CanUse(null))
  1184. {
  1185. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1186. }
  1187. }
  1188. }
  1189. #endregion
  1190. return Strike;
  1191. }
  1192. }
  1193. public int Strike
  1194. {
  1195. get
  1196. {
  1197. int Strike = Strike_AllowMinus;
  1198. if (Strike < 0)
  1199. {
  1200. Strike = 0;
  1201. }
  1202. return Strike;
  1203. }
  1204. }
  1205. #endregion
  1206. #region このパーマネントがタップされているかどうか
  1207. public bool OldIsSuspended = false;
  1208. public bool IsSuspended = false;
  1209. public int DPWhenSuspended = 114514;
  1210. #endregion
  1211. #region Whether this permanent can unsuspend
  1212. public bool CanUnsuspend
  1213. {
  1214. get
  1215. {
  1216. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1217. {
  1218. #region Effects of field permanents
  1219. foreach (Permanent permanent in player.GetFieldPermanents())
  1220. {
  1221. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1222. {
  1223. if (cardEffect is ICanNotUnsuspendEffect)
  1224. {
  1225. if (cardEffect.CanUse(null))
  1226. {
  1227. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1228. {
  1229. return false;
  1230. }
  1231. }
  1232. }
  1233. }
  1234. }
  1235. #endregion
  1236. #region Effects of players
  1237. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1238. {
  1239. if (cardEffect is ICanNotUnsuspendEffect)
  1240. {
  1241. if (cardEffect.CanUse(null))
  1242. {
  1243. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1244. {
  1245. return false;
  1246. }
  1247. }
  1248. }
  1249. }
  1250. #endregion
  1251. }
  1252. return true;
  1253. }
  1254. }
  1255. #endregion
  1256. #region このパーマネントが移動できるかどうか
  1257. public bool CanMove
  1258. {
  1259. get
  1260. {
  1261. if (TopCard != null)
  1262. {
  1263. #region the effects of permanents
  1264. if (GManager.instance.turnStateMachine.gameContext.Players
  1265. .Map(player => player.GetFieldPermanents())
  1266. .Flat()
  1267. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1268. .Flat()
  1269. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1270. && cardEffect.CanUse(null)
  1271. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1272. {
  1273. return false;
  1274. }
  1275. #endregion
  1276. #region the effects of players
  1277. if (GManager.instance.turnStateMachine.gameContext.Players
  1278. .Map(player => player.EffectList(EffectTiming.None))
  1279. .Flat()
  1280. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1281. && cardEffect.CanUse(null)
  1282. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1283. {
  1284. return false;
  1285. }
  1286. #endregion
  1287. #region the effects of itself
  1288. if (this == null)
  1289. {
  1290. if (EffectList(EffectTiming.None)
  1291. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1292. && cardEffect.CanUse(null)
  1293. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1294. {
  1295. return false;
  1296. }
  1297. }
  1298. #endregion
  1299. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1300. {
  1301. return false;
  1302. }
  1303. if (!IsDigimon)
  1304. return false;
  1305. if (TopCard.IsDigiEgg && DP <= 0)
  1306. return false;
  1307. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1308. {
  1309. return false;
  1310. }
  1311. }
  1312. else
  1313. {
  1314. return false;
  1315. }
  1316. return true;
  1317. }
  1318. }
  1319. #endregion
  1320. #region このパーマネントが攻撃できるかどうか
  1321. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1322. {
  1323. // can not attack with empty cards
  1324. if (TopCard == null)
  1325. {
  1326. return false;
  1327. }
  1328. // can not attack during opponent's turn
  1329. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1330. {
  1331. return false;
  1332. }
  1333. // can not attack to player
  1334. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex))
  1335. {
  1336. // can not attack to opponent's Digimon
  1337. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex)) == 0)
  1338. {
  1339. return false;
  1340. }
  1341. }
  1342. return true;
  1343. }
  1344. #endregion
  1345. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1346. public bool CanBlock(Permanent AttackingPermanent)
  1347. {
  1348. if (TopCard == null)
  1349. {
  1350. return false;
  1351. }
  1352. if (!IsDigimon)
  1353. {
  1354. return false;
  1355. }
  1356. if (IsSuspended)
  1357. {
  1358. return false;
  1359. }
  1360. if (!CanSuspend)
  1361. {
  1362. return false;
  1363. }
  1364. if (PermanentFrame != null)
  1365. {
  1366. if (!PermanentFrame.IsBattleAreaFrame())
  1367. {
  1368. return false;
  1369. }
  1370. }
  1371. if (!AttackingPermanent.CanSwitchAttackTarget)
  1372. return false;
  1373. #region "Unblockable" effect
  1374. #region Effects of permanents in play
  1375. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1376. {
  1377. foreach (Permanent permanent in player.GetFieldPermanents())
  1378. {
  1379. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1380. {
  1381. if (cardEffect is ICannotBlockEffect)
  1382. {
  1383. if (cardEffect.CanUse(null))
  1384. {
  1385. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1386. {
  1387. return false;
  1388. }
  1389. }
  1390. }
  1391. }
  1392. }
  1393. }
  1394. #endregion
  1395. #region player effect
  1396. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1397. {
  1398. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1399. {
  1400. if (cardEffect is ICannotBlockEffect)
  1401. {
  1402. if (cardEffect.CanUse(null))
  1403. {
  1404. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1405. {
  1406. if (!TopCard.CanNotBeAffected(cardEffect))
  1407. {
  1408. return false;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. }
  1414. }
  1415. #endregion
  1416. #endregion
  1417. return true;
  1418. }
  1419. #endregion
  1420. #region 対象のパーマネントを攻撃できるか
  1421. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1422. {
  1423. if (TopCard != null)
  1424. {
  1425. if (!IsDigimon)
  1426. {
  1427. return false;
  1428. }
  1429. if (!withoutTap)
  1430. {
  1431. if (IsSuspended)
  1432. {
  1433. return false;
  1434. }
  1435. if (!CanSuspend)
  1436. {
  1437. return false;
  1438. }
  1439. }
  1440. if (PermanentFrame != null)
  1441. {
  1442. if (!PermanentFrame.IsBattleAreaFrame())
  1443. {
  1444. return false;
  1445. }
  1446. }
  1447. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1448. {
  1449. if (!HasRush && !isVortex)
  1450. {
  1451. return false;
  1452. }
  1453. }
  1454. #region 「対象の防御パーマネントを攻撃できない」効果
  1455. #region 場のパーマネントの効果
  1456. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1457. {
  1458. foreach (Permanent permanent in player.GetFieldPermanents())
  1459. {
  1460. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1461. {
  1462. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1463. {
  1464. if (cardEffect1.CanUse(null))
  1465. {
  1466. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1467. {
  1468. if (!TopCard.CanNotBeAffected(cardEffect1))
  1469. {
  1470. return false;
  1471. }
  1472. }
  1473. }
  1474. }
  1475. }
  1476. }
  1477. }
  1478. #endregion
  1479. #region プレイヤーの効果
  1480. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1481. {
  1482. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1483. {
  1484. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1485. {
  1486. if (cardEffect1.CanUse(null))
  1487. {
  1488. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1489. {
  1490. if (!TopCard.CanNotBeAffected(cardEffect1))
  1491. {
  1492. return false;
  1493. }
  1494. }
  1495. }
  1496. }
  1497. }
  1498. }
  1499. #endregion
  1500. #endregion
  1501. if (Defender != null)
  1502. {
  1503. if (Defender.TopCard != null)
  1504. {
  1505. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1506. {
  1507. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1508. {
  1509. if (Defender.IsSuspended)
  1510. {
  1511. return true;
  1512. }
  1513. #region 「対象の防御パーマネントを攻撃できる」効果
  1514. #region 場のパーマネントの効果
  1515. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1516. {
  1517. foreach (Permanent permanent in player.GetFieldPermanents())
  1518. {
  1519. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1520. {
  1521. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1522. {
  1523. if (cardEffect1.CanUse(null))
  1524. {
  1525. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1526. {
  1527. return true;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. }
  1533. }
  1534. #endregion
  1535. #region プレイヤーの効果
  1536. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1537. {
  1538. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1539. {
  1540. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1541. {
  1542. if (cardEffect1.CanUse(null))
  1543. {
  1544. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1545. {
  1546. return true;
  1547. }
  1548. }
  1549. }
  1550. }
  1551. }
  1552. #endregion
  1553. #endregion
  1554. }
  1555. }
  1556. }
  1557. }
  1558. else
  1559. {
  1560. return true;
  1561. }
  1562. }
  1563. return false;
  1564. }
  1565. #endregion
  1566. #region Is Unblockable
  1567. public bool IsUnblockable
  1568. {
  1569. get
  1570. {
  1571. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1572. {
  1573. if (cardEffect is CannotBlockClass)
  1574. {
  1575. if (cardEffect.EffectName == "Can't Block")
  1576. {
  1577. return true;
  1578. }
  1579. }
  1580. }
  1581. return false;
  1582. }
  1583. }
  1584. #endregion
  1585. #region Has Blocker
  1586. public bool HasBlocker
  1587. {
  1588. get
  1589. {
  1590. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1591. {
  1592. #region Effects of permanents in play
  1593. foreach (Permanent permanent in player.GetFieldPermanents())
  1594. {
  1595. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1596. {
  1597. if (cardEffect is IBlockerEffect)
  1598. {
  1599. if (cardEffect.CanTrigger(null))
  1600. {
  1601. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1602. {
  1603. return true;
  1604. }
  1605. }
  1606. }
  1607. }
  1608. }
  1609. #endregion
  1610. #region Effects of faceup security
  1611. foreach (CardSource source in player.SecurityCards)
  1612. {
  1613. if (source.IsFlipped)
  1614. continue;
  1615. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  1616. {
  1617. if (cardEffect is IBlockerEffect)
  1618. {
  1619. if (cardEffect.CanTrigger(null))
  1620. {
  1621. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1622. {
  1623. return true;
  1624. }
  1625. }
  1626. }
  1627. }
  1628. }
  1629. #endregion
  1630. #region プレイヤーの効果
  1631. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1632. {
  1633. if (cardEffect is IBlockerEffect)
  1634. {
  1635. if (cardEffect.CanTrigger(null))
  1636. {
  1637. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1638. {
  1639. return true;
  1640. }
  1641. }
  1642. }
  1643. }
  1644. #endregion
  1645. }
  1646. return false;
  1647. }
  1648. }
  1649. #endregion
  1650. #region Has Jamming
  1651. public bool HasJamming
  1652. {
  1653. get
  1654. {
  1655. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1656. {
  1657. foreach (Permanent permanent in player.GetFieldPermanents())
  1658. {
  1659. #region 場のパーマネントの効果
  1660. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1661. {
  1662. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1663. {
  1664. if (cardEffect.CanTrigger(null))
  1665. {
  1666. if (cardEffect.EffectName == "Jamming")
  1667. {
  1668. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1669. {
  1670. return true;
  1671. }
  1672. }
  1673. }
  1674. }
  1675. }
  1676. #endregion
  1677. }
  1678. #region プレイヤーの効果
  1679. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1680. {
  1681. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1682. {
  1683. if (cardEffect.CanTrigger(null))
  1684. {
  1685. if (cardEffect.EffectName == "Jamming")
  1686. {
  1687. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1688. {
  1689. return true;
  1690. }
  1691. }
  1692. }
  1693. }
  1694. }
  1695. #endregion
  1696. }
  1697. return false;
  1698. }
  1699. }
  1700. #endregion
  1701. #region Has Ice Clad
  1702. public bool HasIceclad
  1703. {
  1704. get
  1705. {
  1706. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1707. {
  1708. #region Ice clad permanent effects
  1709. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  1710. {
  1711. if (cardEffect is IIcecladEffect)
  1712. {
  1713. if (cardEffect.CanTrigger(null))
  1714. {
  1715. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1716. {
  1717. return true;
  1718. }
  1719. }
  1720. }
  1721. }
  1722. #endregion
  1723. #region Ice clad Player Effects
  1724. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1725. {
  1726. if (cardEffect is IIcecladEffect)
  1727. {
  1728. if (cardEffect.CanTrigger(null))
  1729. {
  1730. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1731. {
  1732. return true;
  1733. }
  1734. }
  1735. }
  1736. }
  1737. #endregion
  1738. }
  1739. return false;
  1740. }
  1741. }
  1742. #endregion
  1743. #region Whether this permanent has Pierce
  1744. public bool HasPierce
  1745. {
  1746. get
  1747. {
  1748. if (IsDigimon)
  1749. {
  1750. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  1751. {
  1752. if (cardEffect is ActivateICardEffect)
  1753. {
  1754. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  1755. {
  1756. if (cardEffect.EffectName == "Pierce")
  1757. {
  1758. return true;
  1759. }
  1760. if (cardEffect.EffectName == "Piercing")
  1761. {
  1762. return true;
  1763. }
  1764. }
  1765. }
  1766. }
  1767. }
  1768. return false;
  1769. }
  1770. }
  1771. #endregion
  1772. #region Has Reboot
  1773. public bool HasReboot
  1774. {
  1775. get
  1776. {
  1777. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1778. {
  1779. foreach (Permanent permanent in player.GetFieldPermanents())
  1780. {
  1781. #region 場のパーマネントの効果
  1782. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1783. {
  1784. if (cardEffect is IRebootEffect)
  1785. {
  1786. if (cardEffect.CanTrigger(null))
  1787. {
  1788. if (((IRebootEffect)cardEffect).HasReboot(this))
  1789. {
  1790. return true;
  1791. }
  1792. }
  1793. }
  1794. }
  1795. #endregion
  1796. }
  1797. #region プレイヤーの効果
  1798. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1799. {
  1800. if (cardEffect is IRebootEffect)
  1801. {
  1802. if (cardEffect.CanTrigger(null))
  1803. {
  1804. if (((IRebootEffect)cardEffect).HasReboot(this))
  1805. {
  1806. return true;
  1807. }
  1808. }
  1809. }
  1810. }
  1811. #endregion
  1812. }
  1813. return false;
  1814. }
  1815. }
  1816. #endregion
  1817. #region Has Raid
  1818. public bool HasRaid
  1819. {
  1820. get
  1821. {
  1822. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1823. {
  1824. if (cardEffect is ActivateICardEffect)
  1825. {
  1826. if (cardEffect.EffectName == "Raid")
  1827. {
  1828. return true;
  1829. }
  1830. }
  1831. }
  1832. return false;
  1833. }
  1834. }
  1835. #endregion
  1836. #region Has Rush
  1837. public bool HasRush
  1838. {
  1839. get
  1840. {
  1841. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1842. {
  1843. foreach (Permanent permanent in player.GetFieldPermanents())
  1844. {
  1845. #region 場のパーマネントの効果
  1846. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1847. {
  1848. if (cardEffect is IRushEffect)
  1849. {
  1850. if (cardEffect.CanTrigger(null))
  1851. {
  1852. if (((IRushEffect)cardEffect).HasRush(this))
  1853. {
  1854. return true;
  1855. }
  1856. }
  1857. }
  1858. }
  1859. #endregion
  1860. }
  1861. #region プレイヤーの効果
  1862. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1863. {
  1864. if (cardEffect is IRushEffect)
  1865. {
  1866. if (cardEffect.CanTrigger(null))
  1867. {
  1868. if (((IRushEffect)cardEffect).HasRush(this))
  1869. {
  1870. return true;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. #endregion
  1876. }
  1877. return false;
  1878. }
  1879. }
  1880. #endregion
  1881. #region Has Retaliation
  1882. public bool HasRetaliation
  1883. {
  1884. get
  1885. {
  1886. if (RetaliationCount >= 1)
  1887. {
  1888. return true;
  1889. }
  1890. return false;
  1891. }
  1892. }
  1893. #endregion
  1894. #region 道連れを持つ個数
  1895. public int RetaliationCount
  1896. {
  1897. get
  1898. {
  1899. int count = 0;
  1900. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1901. {
  1902. if (cardEffect is ActivateICardEffect)
  1903. {
  1904. if (cardEffect.EffectName == "Retaliation")
  1905. {
  1906. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1907. {
  1908. count++;
  1909. }
  1910. }
  1911. }
  1912. }
  1913. return count;
  1914. }
  1915. }
  1916. #endregion
  1917. #region Has Fortitude
  1918. public bool HasFortitude
  1919. {
  1920. get
  1921. {
  1922. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1923. {
  1924. if (cardEffect is ActivateICardEffect)
  1925. {
  1926. if (cardEffect.EffectName == "Fortitude")
  1927. {
  1928. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1929. {
  1930. return true;
  1931. }
  1932. }
  1933. }
  1934. }
  1935. return false;
  1936. }
  1937. }
  1938. #endregion
  1939. #region Has Blitz
  1940. public bool HasBlitz
  1941. {
  1942. get
  1943. {
  1944. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  1945. {
  1946. if (cardEffect is ActivateICardEffect)
  1947. {
  1948. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  1949. {
  1950. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1951. {
  1952. if (cardEffect.EffectDiscription.Contains("Blitz"))
  1953. {
  1954. return true;
  1955. }
  1956. }
  1957. }
  1958. }
  1959. }
  1960. return false;
  1961. }
  1962. }
  1963. #endregion
  1964. #region Has Evade
  1965. public bool HasEvade
  1966. {
  1967. get
  1968. {
  1969. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1970. {
  1971. if (cardEffect is ActivateICardEffect)
  1972. {
  1973. Hashtable hashtable = new Hashtable()
  1974. {
  1975. {"Permanents", new List<Permanent>() { this }}
  1976. };
  1977. if (cardEffect.CanTrigger(hashtable))
  1978. {
  1979. if (cardEffect.EffectName == "Evade")
  1980. {
  1981. return true;
  1982. }
  1983. }
  1984. }
  1985. }
  1986. return false;
  1987. }
  1988. }
  1989. #endregion
  1990. #region Has Mind Link
  1991. public bool HasMindLink
  1992. {
  1993. get
  1994. {
  1995. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  1996. {
  1997. if (cardEffect is ActivateICardEffect)
  1998. {
  1999. if (cardEffect.CanTrigger(null))
  2000. {
  2001. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2002. {
  2003. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2004. {
  2005. return true;
  2006. }
  2007. }
  2008. }
  2009. }
  2010. }
  2011. return false;
  2012. }
  2013. }
  2014. #endregion
  2015. #region Has Barrier
  2016. public bool HasBarrier
  2017. {
  2018. get
  2019. {
  2020. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2021. {
  2022. if (cardEffect is ActivateICardEffect)
  2023. {
  2024. Hashtable hashtable = new Hashtable();
  2025. hashtable.Add("Permanents", new List<Permanent>() { this });
  2026. hashtable.Add("battle", new IBattle(null, null, null));
  2027. if (cardEffect.CanTrigger(hashtable))
  2028. {
  2029. if (cardEffect.EffectName == "Barrier")
  2030. {
  2031. return true;
  2032. }
  2033. }
  2034. }
  2035. }
  2036. return false;
  2037. }
  2038. }
  2039. #endregion
  2040. #region Has Alliance
  2041. public bool HasAlliance
  2042. {
  2043. get
  2044. {
  2045. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2046. {
  2047. foreach (Permanent permanent in player.GetFieldPermanents())
  2048. {
  2049. #region Permanent Effects
  2050. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2051. {
  2052. if (cardEffect is IAllianceEffect)
  2053. {
  2054. if (cardEffect.CanTrigger(null))
  2055. {
  2056. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2057. {
  2058. return true;
  2059. }
  2060. }
  2061. }
  2062. }
  2063. #endregion
  2064. }
  2065. #region Player Effects
  2066. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2067. {
  2068. if (cardEffect is IAllianceEffect)
  2069. {
  2070. if (cardEffect.CanTrigger(null))
  2071. {
  2072. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2073. {
  2074. return true;
  2075. }
  2076. }
  2077. }
  2078. }
  2079. #endregion
  2080. }
  2081. return false;
  2082. }
  2083. }
  2084. #endregion
  2085. #region Has Collision
  2086. public bool HasCollision
  2087. {
  2088. get
  2089. {
  2090. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2091. {
  2092. if (cardEffect is ActivateICardEffect)
  2093. {
  2094. if (cardEffect.EffectName == "Collision")
  2095. {
  2096. return true;
  2097. }
  2098. }
  2099. }
  2100. return false;
  2101. }
  2102. }
  2103. #endregion
  2104. #region Has Partition
  2105. public bool HasPartition
  2106. {
  2107. get
  2108. {
  2109. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2110. {
  2111. if (cardEffect is ActivateICardEffect)
  2112. {
  2113. if (cardEffect.EffectName == "Partition")
  2114. {
  2115. return true;
  2116. }
  2117. }
  2118. }
  2119. return false;
  2120. }
  2121. }
  2122. #endregion
  2123. #region 消滅時効化を持つか
  2124. public bool HasOnDeletionEffect
  2125. {
  2126. get
  2127. {
  2128. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2129. {
  2130. if (cardEffect is ActivateICardEffect)
  2131. {
  2132. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2133. {
  2134. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2135. {
  2136. if (cardEffect.IsOnDeletion)
  2137. {
  2138. return true;
  2139. }
  2140. }
  2141. }
  2142. }
  2143. }
  2144. return false;
  2145. }
  2146. }
  2147. #endregion
  2148. #region バトルしているか
  2149. public IBattle battle { get; set; } = null;
  2150. #endregion
  2151. #region Can Be Destroyed
  2152. public bool CanBeDestroyed()
  2153. {
  2154. #region 消滅しない効果
  2155. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2156. {
  2157. foreach (Permanent permanent in player.GetFieldPermanents())
  2158. {
  2159. #region 場のパーマネントの効果
  2160. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2161. {
  2162. if (cardEffect is ICanNotBeDestroyedEffect)
  2163. {
  2164. if (cardEffect.CanUse(null))
  2165. {
  2166. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2167. {
  2168. return false;
  2169. }
  2170. }
  2171. }
  2172. }
  2173. #endregion
  2174. }
  2175. #region プレイヤーの効果
  2176. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2177. {
  2178. if (cardEffect is ICanNotBeDestroyedEffect)
  2179. {
  2180. if (cardEffect.CanUse(null))
  2181. {
  2182. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2183. {
  2184. return false;
  2185. }
  2186. }
  2187. }
  2188. }
  2189. #endregion
  2190. }
  2191. #endregion
  2192. return true;
  2193. }
  2194. #endregion
  2195. #region このデジモンが戦闘によって消滅するか
  2196. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2197. {
  2198. if (!CanBeDestroyed())
  2199. {
  2200. return false;
  2201. }
  2202. #region 戦闘で消滅しない効果
  2203. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2204. {
  2205. foreach (Permanent permanent in player.GetFieldPermanents())
  2206. {
  2207. #region 場のパーマネントの効果
  2208. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2209. {
  2210. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2211. {
  2212. if (cardEffect.CanUse(null))
  2213. {
  2214. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2215. {
  2216. return false;
  2217. }
  2218. }
  2219. }
  2220. }
  2221. #endregion
  2222. }
  2223. #region プレイヤーの効果
  2224. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2225. {
  2226. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2227. {
  2228. if (cardEffect.CanUse(null))
  2229. {
  2230. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2231. {
  2232. return false;
  2233. }
  2234. }
  2235. }
  2236. }
  2237. #endregion
  2238. }
  2239. #endregion
  2240. return true;
  2241. }
  2242. #endregion
  2243. #region このパーマネントが効果で消滅するか
  2244. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2245. {
  2246. if (this.TopCard != null)
  2247. {
  2248. if (this.TopCard.CanNotBeAffected(cardEffect))
  2249. {
  2250. return false;
  2251. }
  2252. if (!CanBeDestroyed())
  2253. {
  2254. return false;
  2255. }
  2256. #region 効果で消滅しない効果
  2257. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2258. {
  2259. foreach (Permanent permanent in player.GetFieldPermanents())
  2260. {
  2261. #region 場のパーマネントの効果
  2262. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2263. {
  2264. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2265. {
  2266. if (cardEffect1.CanUse(null))
  2267. {
  2268. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2269. {
  2270. return false;
  2271. }
  2272. }
  2273. }
  2274. }
  2275. #endregion
  2276. }
  2277. #region プレイヤーの効果
  2278. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2279. {
  2280. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2281. {
  2282. if (cardEffect1.CanUse(null))
  2283. {
  2284. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2285. {
  2286. return false;
  2287. }
  2288. }
  2289. }
  2290. }
  2291. #endregion
  2292. }
  2293. #endregion
  2294. }
  2295. return true;
  2296. }
  2297. #endregion
  2298. #region Can Leave Field
  2299. public bool CanBeRemoved()
  2300. {
  2301. #region Effect that never disappears
  2302. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2303. {
  2304. foreach (Permanent permanent in player.GetFieldPermanents())
  2305. {
  2306. #region Effects of permanents in play
  2307. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2308. {
  2309. if (cardEffect is ICanNotBeRemovedEffect)
  2310. {
  2311. if (cardEffect.CanUse(null))
  2312. {
  2313. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2314. {
  2315. return false;
  2316. }
  2317. }
  2318. }
  2319. }
  2320. #endregion
  2321. }
  2322. #region player effect
  2323. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2324. {
  2325. if (cardEffect is ICanNotBeRemovedEffect)
  2326. {
  2327. if (cardEffect.CanUse(null))
  2328. {
  2329. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2330. {
  2331. return false;
  2332. }
  2333. }
  2334. }
  2335. }
  2336. #endregion
  2337. }
  2338. #endregion
  2339. return true;
  2340. }
  2341. #endregion
  2342. #region トークンかどうか
  2343. public bool IsToken
  2344. {
  2345. get
  2346. {
  2347. if (TopCard != null)
  2348. {
  2349. if (TopCard.IsToken)
  2350. {
  2351. return true;
  2352. }
  2353. }
  2354. return false;
  2355. }
  2356. }
  2357. #endregion
  2358. #region そのパーマネントが消滅・バウンス待機状態か
  2359. public bool willBeRemoveField { get; set; } = false;
  2360. #endregion
  2361. #region Is a Digimon card
  2362. public bool IsDigimon
  2363. {
  2364. get
  2365. {
  2366. if (TopCard != null)
  2367. {
  2368. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2369. {
  2370. return true;
  2371. }
  2372. #region Effect of treating it as a Digimon
  2373. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2374. {
  2375. foreach (Permanent permanent in player.GetFieldPermanents())
  2376. {
  2377. #region Effects of permanents in play
  2378. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2379. {
  2380. if (cardEffect is ITreatAsDigimonEffect)
  2381. {
  2382. if (cardEffect.CanTrigger(null))
  2383. {
  2384. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2385. {
  2386. return true;
  2387. }
  2388. }
  2389. }
  2390. }
  2391. #endregion
  2392. }
  2393. #region player effect
  2394. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2395. {
  2396. if (cardEffect is ITreatAsDigimonEffect)
  2397. {
  2398. if (cardEffect.CanTrigger(null))
  2399. {
  2400. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2401. {
  2402. return true;
  2403. }
  2404. }
  2405. }
  2406. }
  2407. #endregion
  2408. }
  2409. #endregion
  2410. }
  2411. return false;
  2412. }
  2413. }
  2414. #endregion
  2415. #region Is a Tamer card
  2416. public bool IsTamer
  2417. {
  2418. get
  2419. {
  2420. if (TopCard != null)
  2421. {
  2422. if (TopCard.IsTamer)
  2423. {
  2424. return true;
  2425. }
  2426. }
  2427. return false;
  2428. }
  2429. }
  2430. #endregion
  2431. #region Is an Option card
  2432. public bool IsOption
  2433. {
  2434. get
  2435. {
  2436. if (TopCard != null)
  2437. {
  2438. if (TopCard.IsOption)
  2439. {
  2440. return true;
  2441. }
  2442. }
  2443. return false;
  2444. }
  2445. }
  2446. #endregion
  2447. #region Levels handled by Jogress
  2448. public List<int> Levels_ForJogress(CardSource cardSource)
  2449. {
  2450. List<int> levels = new List<int>();
  2451. if (cardSource != null)
  2452. {
  2453. if (cardSource.HasLevel)
  2454. {
  2455. levels.Add(this.Level);
  2456. }
  2457. #region Effect of "adding levels handled by jogless evolution"
  2458. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2459. {
  2460. foreach (Permanent permanent in player.GetFieldPermanents())
  2461. {
  2462. #region Effects of permanents in play
  2463. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2464. {
  2465. if (cardEffect is IAddJogressLevelsEffect)
  2466. {
  2467. if (cardEffect.CanUse(null))
  2468. {
  2469. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2470. {
  2471. levels.Add(level);
  2472. }
  2473. }
  2474. }
  2475. }
  2476. #endregion
  2477. }
  2478. #region player effect
  2479. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2480. {
  2481. if (cardEffect is IAddJogressLevelsEffect)
  2482. {
  2483. if (cardEffect.CanUse(null))
  2484. {
  2485. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2486. {
  2487. levels.Add(level);
  2488. }
  2489. }
  2490. }
  2491. }
  2492. #endregion
  2493. }
  2494. #endregion
  2495. }
  2496. return levels;
  2497. }
  2498. #endregion
  2499. #region Names handled by Jogress
  2500. public List<string> Names_ForDNA(CardSource cardSource)
  2501. {
  2502. List<string> names = new List<string>();
  2503. if (cardSource != null)
  2504. {
  2505. foreach(string name in cardSource.CardNames)
  2506. names.Add(name);
  2507. #region Effect of "adding names handled by DNA evolution"
  2508. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2509. {
  2510. foreach (Permanent permanent in player.GetFieldPermanents())
  2511. {
  2512. #region Effects of permanents in play
  2513. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2514. {
  2515. if (cardEffect is IAddDNANamesEffect)
  2516. {
  2517. if (cardEffect.CanUse(null))
  2518. {
  2519. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2520. {
  2521. names.Add(name);
  2522. }
  2523. }
  2524. }
  2525. }
  2526. #endregion
  2527. }
  2528. #region player effect
  2529. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2530. {
  2531. if (cardEffect is IAddDNANamesEffect)
  2532. {
  2533. if (cardEffect.CanUse(null))
  2534. {
  2535. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2536. {
  2537. names.Add(name);
  2538. }
  2539. }
  2540. }
  2541. }
  2542. #endregion
  2543. }
  2544. #endregion
  2545. }
  2546. return names;
  2547. }
  2548. #endregion
  2549. #region バトルで消滅したか
  2550. public bool IsDestroyedByBattle { get; set; } = false;
  2551. #endregion
  2552. #region 消滅に使用された効果
  2553. public ICardEffect DestroyingEffect { get; set; } = null;
  2554. #endregion
  2555. #region 他のパーマネントの下に置くのに使用された効果
  2556. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2557. #endregion
  2558. #region 手札バウンス に使用された効果
  2559. public ICardEffect HandBounceEffect { get; set; } = null;
  2560. #endregion
  2561. #region 山札バウンス に使用された効果
  2562. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2563. #endregion
  2564. #region 登場に使用された効果
  2565. public ICardEffect PlayingEffect { get; set; } = null;
  2566. #endregion
  2567. #region 進化に使用された効果
  2568. public ICardEffect DigivolvingEffect { get; set; } = null;
  2569. #endregion
  2570. #region Whether this digimon is placed in the trash by not having a DP
  2571. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2572. #endregion
  2573. #region Whether this permanent can suspend
  2574. public bool CanSuspend
  2575. {
  2576. get
  2577. {
  2578. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2579. {
  2580. #region Effects of field permanents
  2581. foreach (Permanent permanent in player.GetFieldPermanents())
  2582. {
  2583. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2584. {
  2585. if (cardEffect is ICanNotSuspendEffect)
  2586. {
  2587. if (cardEffect.CanUse(null))
  2588. {
  2589. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2590. {
  2591. return false;
  2592. }
  2593. }
  2594. }
  2595. }
  2596. }
  2597. #endregion
  2598. #region Effects of players
  2599. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2600. {
  2601. if (cardEffect is ICanNotSuspendEffect)
  2602. {
  2603. if (cardEffect.CanUse(null))
  2604. {
  2605. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2606. {
  2607. return false;
  2608. }
  2609. }
  2610. }
  2611. }
  2612. #endregion
  2613. }
  2614. return true;
  2615. }
  2616. }
  2617. #endregion
  2618. #region このデジモンのアタックの対象が変更できるか
  2619. public bool CanSwitchAttackTarget
  2620. {
  2621. get
  2622. {
  2623. #region アタックの対象が変更できない効果
  2624. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2625. {
  2626. foreach (Permanent permanent in player.GetFieldPermanents())
  2627. {
  2628. #region 場のパーマネントの効果
  2629. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2630. {
  2631. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2632. {
  2633. if (cardEffect.CanUse(null))
  2634. {
  2635. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2636. {
  2637. return false;
  2638. }
  2639. }
  2640. }
  2641. }
  2642. #endregion
  2643. }
  2644. #region プレイヤーの効果
  2645. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2646. {
  2647. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2648. {
  2649. if (cardEffect.CanUse(null))
  2650. {
  2651. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2652. {
  2653. return false;
  2654. }
  2655. }
  2656. }
  2657. }
  2658. #endregion
  2659. }
  2660. #endregion
  2661. return true;
  2662. }
  2663. }
  2664. #endregion
  2665. #region このデジモンを場からデジクロス条件の代わりにできるか
  2666. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  2667. {
  2668. #region デジクロス条件の代わりにできる効果
  2669. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2670. {
  2671. foreach (Permanent permanent in player.GetFieldPermanents())
  2672. {
  2673. #region 場のパーマネントの効果
  2674. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2675. {
  2676. if (cardEffect is ICanSelectDigiXrosEffect)
  2677. {
  2678. if (cardEffect.CanUse(null))
  2679. {
  2680. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2681. {
  2682. return true;
  2683. }
  2684. }
  2685. }
  2686. }
  2687. #endregion
  2688. }
  2689. #region プレイヤーの効果
  2690. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2691. {
  2692. if (cardEffect is ICanSelectDigiXrosEffect)
  2693. {
  2694. if (cardEffect.CanUse(null))
  2695. {
  2696. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2697. {
  2698. return true;
  2699. }
  2700. }
  2701. }
  2702. }
  2703. #endregion
  2704. }
  2705. #endregion
  2706. return false;
  2707. }
  2708. #endregion
  2709. #region 登場した直後のLevel
  2710. public int LevelJustAfterPlayed { get; set; } = -1;
  2711. #endregion
  2712. #region 登場した直後のPlay Cost
  2713. public int PlayCostJustAfterPlayed { get; set; } = -1;
  2714. #endregion
  2715. #region 登場した直後のCardNames
  2716. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  2717. #endregion
  2718. #region 進化した直後のCardNames
  2719. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  2720. #endregion
  2721. #region 登場した直後のTraits
  2722. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  2723. #endregion
  2724. #region 場を離れる直前のDP
  2725. public int DPJustBeforeRemoveField { get; set; } = -1;
  2726. #endregion
  2727. #region 場を離れる直前のLevel
  2728. public int LevelJustBeforeRemoveField { get; set; } = -1;
  2729. #endregion
  2730. #region 場を離れる直前のCost
  2731. public int CostJustBeforeRemoveField { get; set; } = -1;
  2732. #endregion
  2733. #region 場を離れる直前のカード名
  2734. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  2735. #endregion
  2736. #region Card Traits Just Before Removed Field
  2737. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  2738. #endregion
  2739. #region バースト進化で手札に戻ったか
  2740. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  2741. #endregion
  2742. #region バースト進化したか
  2743. public bool IsBurstDigivolved { get; set; } = false;
  2744. #endregion
  2745. #region 効果で場に出たオプションか
  2746. public bool IsPlayedOptionPermanent { get; set; } = false;
  2747. #endregion
  2748. #region 進化元を持たないか
  2749. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  2750. #endregion
  2751. #region Digivolution cards' colors
  2752. public List<CardColor> DigivolutionCardsColors
  2753. {
  2754. get
  2755. {
  2756. List<CardColor> cardColors = new List<CardColor>();
  2757. foreach (CardSource cardSource in DigivolutionCards)
  2758. {
  2759. foreach (CardColor cardColor in cardSource.CardColors)
  2760. {
  2761. if (!cardColors.Contains(cardColor))
  2762. {
  2763. cardColors.Add(cardColor);
  2764. }
  2765. }
  2766. }
  2767. return cardColors.Distinct().ToList();
  2768. }
  2769. }
  2770. #endregion
  2771. #region Show "Unsuspend" effect object
  2772. public void ShowUnsuspendEffect()
  2773. {
  2774. if (TopCard != null)
  2775. {
  2776. if (ShowingPermanentCard != null)
  2777. {
  2778. if (ShowingPermanentCard.WillUntapObject != null)
  2779. {
  2780. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  2781. ShowingPermanentCard.WillUntapObject.SetActive(true);
  2782. }
  2783. }
  2784. }
  2785. }
  2786. #endregion
  2787. #region Show "Return to deck" effect object
  2788. public void ShowDeckBounceEffect()
  2789. {
  2790. if (TopCard != null)
  2791. {
  2792. if (willBeRemoveField)
  2793. {
  2794. if (ShowingPermanentCard != null)
  2795. {
  2796. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2797. {
  2798. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  2799. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  2800. }
  2801. }
  2802. }
  2803. }
  2804. }
  2805. #endregion
  2806. #region Hide "Return to deck" effect object
  2807. public void HideDeckBounceEffect()
  2808. {
  2809. if (TopCard != null)
  2810. {
  2811. if (ShowingPermanentCard != null)
  2812. {
  2813. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2814. {
  2815. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  2816. }
  2817. }
  2818. }
  2819. }
  2820. #endregion
  2821. #region Show "Return to hand" effect object
  2822. public void ShowHandBounceEffect()
  2823. {
  2824. if (TopCard != null)
  2825. {
  2826. if (willBeRemoveField)
  2827. {
  2828. if (ShowingPermanentCard != null)
  2829. {
  2830. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2831. {
  2832. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  2833. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  2834. }
  2835. }
  2836. }
  2837. }
  2838. }
  2839. #endregion
  2840. #region Hide "Return to hand" effect object
  2841. public void HideHandBounceEffect()
  2842. {
  2843. if (TopCard != null)
  2844. {
  2845. if (ShowingPermanentCard != null)
  2846. {
  2847. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2848. {
  2849. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  2850. }
  2851. }
  2852. }
  2853. }
  2854. #endregion
  2855. #region Show "Delete" effect object
  2856. public void ShowDeleteEffect()
  2857. {
  2858. if (TopCard != null)
  2859. {
  2860. if (willBeRemoveField)
  2861. {
  2862. if (ShowingPermanentCard != null)
  2863. {
  2864. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2865. {
  2866. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  2867. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  2868. }
  2869. }
  2870. }
  2871. }
  2872. }
  2873. #endregion
  2874. #region Hide "Delete" effect object
  2875. public void HideDeleteEffect()
  2876. {
  2877. if (TopCard != null)
  2878. {
  2879. if (ShowingPermanentCard != null)
  2880. {
  2881. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2882. {
  2883. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  2884. }
  2885. }
  2886. }
  2887. }
  2888. #endregion
  2889. #region Show "Remove Field" effect object
  2890. public void ShowWillRemoveFieldEffect()
  2891. {
  2892. if (TopCard != null)
  2893. {
  2894. if (willBeRemoveField)
  2895. {
  2896. if (ShowingPermanentCard != null)
  2897. {
  2898. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2899. {
  2900. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  2901. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  2902. }
  2903. }
  2904. }
  2905. }
  2906. }
  2907. #endregion
  2908. #region Hide "Remove Field" effect object
  2909. public void HideWillRemoveFieldEffect()
  2910. {
  2911. if (TopCard != null)
  2912. {
  2913. if (ShowingPermanentCard != null)
  2914. {
  2915. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2916. {
  2917. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  2918. }
  2919. }
  2920. }
  2921. }
  2922. #endregion
  2923. #region Show "Digivolution" effect object
  2924. public void ShowWillEvolutionEffect()
  2925. {
  2926. if (TopCard != null)
  2927. {
  2928. if (ShowingPermanentCard != null)
  2929. {
  2930. if (ShowingPermanentCard.WillEvolutionObject != null)
  2931. {
  2932. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  2933. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  2934. }
  2935. }
  2936. }
  2937. }
  2938. #endregion
  2939. #region Hide "Digivolution" effect object
  2940. public void HideWillEvolutionEffect()
  2941. {
  2942. if (TopCard != null)
  2943. {
  2944. if (ShowingPermanentCard != null)
  2945. {
  2946. if (ShowingPermanentCard.WillEvolutionObject != null)
  2947. {
  2948. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  2949. }
  2950. }
  2951. }
  2952. }
  2953. #endregion
  2954. }