Permanent.cs 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960
  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. foreach (Permanent permanent in player.GetFieldPermanents())
  280. {
  281. #region 場のパーマネントの効果
  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. #endregion
  306. }
  307. #region プレイヤーの効果
  308. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  309. {
  310. if (cardEffect is IChangeDPEffect)
  311. {
  312. if (cardEffect.CanUse(null))
  313. {
  314. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  315. {
  316. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  317. {
  318. if (this.ImmuneFromDPMinus(cardEffect))
  319. {
  320. continue;
  321. }
  322. }
  323. if (!TopCard.CanNotBeAffected(cardEffect))
  324. {
  325. cardEffects_ChangeDP.Add(cardEffect);
  326. }
  327. }
  328. }
  329. }
  330. }
  331. #endregion
  332. }
  333. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  334. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  335. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  336. {
  337. if (cardEffect is IChangeDPEffect)
  338. {
  339. if (cardEffect.CanUse(null))
  340. {
  341. if (((IChangeDPEffect)cardEffect).IsUpDown())
  342. {
  343. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  344. }
  345. else
  346. {
  347. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  348. }
  349. }
  350. }
  351. }
  352. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  353. {
  354. if (cardEffect is IChangeDPEffect)
  355. {
  356. if (cardEffect.CanUse(null))
  357. {
  358. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  359. }
  360. }
  361. }
  362. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  363. {
  364. if (cardEffect is IChangeDPEffect)
  365. {
  366. if (cardEffect.CanUse(null))
  367. {
  368. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  369. }
  370. }
  371. }
  372. #endregion
  373. if (DP < 0)
  374. {
  375. DP = 0;
  376. }
  377. }
  378. return DP;
  379. }
  380. }
  381. #endregion
  382. #region Will it not receive negative DP effect?
  383. public bool ImmuneFromDPMinus(ICardEffect cardEffect)
  384. {
  385. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  386. {
  387. foreach (Permanent permanent in player.GetFieldPermanents())
  388. {
  389. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  390. {
  391. if (cardEffect1 is IImmuneFromDPMinusEffect)
  392. {
  393. if (cardEffect1.CanUse(null))
  394. {
  395. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  396. {
  397. return true;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  404. {
  405. if (cardEffect1 is IImmuneFromDPMinusEffect)
  406. {
  407. if (cardEffect1.CanUse(null))
  408. {
  409. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  410. {
  411. return true;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. return false;
  418. }
  419. #endregion
  420. #region Can be returned to your hand?
  421. public bool CannotReturnToHand(ICardEffect cardEffect)
  422. {
  423. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  424. {
  425. foreach (Permanent permanent in player.GetFieldPermanents())
  426. {
  427. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  428. {
  429. if (cardEffect1 is ICannotReturnToHandEffect)
  430. {
  431. if (cardEffect1.CanUse(null))
  432. {
  433. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  434. {
  435. return true;
  436. }
  437. }
  438. }
  439. }
  440. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  441. {
  442. if (cardEffect1 is ICannotReturnToHandEffect)
  443. {
  444. if (cardEffect1.CanUse(null))
  445. {
  446. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  447. {
  448. return true;
  449. }
  450. }
  451. }
  452. }
  453. }
  454. }
  455. return false;
  456. }
  457. #endregion
  458. #region Can be returned to deck?
  459. public bool CannotReturnToLibrary(ICardEffect cardEffect)
  460. {
  461. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  462. {
  463. foreach (Permanent permanent in player.GetFieldPermanents())
  464. {
  465. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  466. {
  467. if (cardEffect1 is ICannotReturnToLibraryEffect)
  468. {
  469. if (cardEffect1.CanUse(null))
  470. {
  471. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  472. {
  473. return true;
  474. }
  475. }
  476. }
  477. }
  478. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  479. {
  480. if (cardEffect1 is ICannotReturnToLibraryEffect)
  481. {
  482. if (cardEffect1.CanUse(null))
  483. {
  484. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  485. {
  486. return true;
  487. }
  488. }
  489. }
  490. }
  491. }
  492. }
  493. return false;
  494. }
  495. #endregion
  496. #region 退化を受けないか
  497. public bool ImmuneFromDeDigivolve()
  498. {
  499. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  500. {
  501. foreach (Permanent permanent in player.GetFieldPermanents())
  502. {
  503. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  504. {
  505. if (cardEffect1 is IImmuneFromDeDigivolveEffect)
  506. {
  507. if (cardEffect1.CanUse(null))
  508. {
  509. if (((IImmuneFromDeDigivolveEffect)cardEffect1).ImmuneDeDigivolve(this))
  510. {
  511. return true;
  512. }
  513. }
  514. }
  515. }
  516. }
  517. }
  518. return false;
  519. }
  520. #endregion
  521. #region このパーマネントの持つカードリスト
  522. public List<CardSource> cardSources = new List<CardSource>();
  523. #endregion
  524. #region 一番上以外のカード
  525. public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard);
  526. #endregion
  527. #region パーマネントのカードリストにカードを追加
  528. public void AddCardSource(CardSource cardSource)
  529. {
  530. cardSources.Insert(0, cardSource);
  531. cardSource.SetFace();
  532. }
  533. #endregion
  534. #region 進化元の一番上に置く
  535. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  536. {
  537. List<CardSource> addedCards = new List<CardSource>();
  538. bool isFromSameDigimon = false;
  539. bool isFromDigimon = false;
  540. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  541. {
  542. if (cardSources.Contains(addedDigivolutionCard))
  543. {
  544. isFromSameDigimon = true;
  545. }
  546. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  547. {
  548. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  549. {
  550. isFromDigimon = true;
  551. }
  552. }
  553. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  554. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  555. {
  556. this.cardSources.Insert(1, addedDigivolutionCard);
  557. addedDigivolutionCard.SetFace();
  558. addedCards.Add(addedDigivolutionCard);
  559. }
  560. }
  561. if (addedCards.Count >= 1)
  562. {
  563. if (ShowingPermanentCard != null)
  564. {
  565. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  566. }
  567. #region "進化元が増えた時"の効果
  568. #region Hashtable Setting
  569. Hashtable hashtable = new Hashtable()
  570. {
  571. {"Permanent", this},
  572. {"CardEffect", cardEffect},
  573. {"CardSources", addedCards},
  574. {"isFromSameDigimon", isFromSameDigimon},
  575. {"isFromDigimon", isFromDigimon},
  576. };
  577. #endregion
  578. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  579. #endregion
  580. }
  581. }
  582. #endregion
  583. #region 進化元の一番下に置く
  584. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false)
  585. {
  586. List<CardSource> addedCards = new List<CardSource>();
  587. bool isFromSameDigimon = false;
  588. bool isFromDigimon = false;
  589. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  590. {
  591. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  592. {
  593. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  594. {
  595. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  596. {
  597. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill = true);
  598. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  599. if (!placePermanent.Placed)
  600. {
  601. continue;
  602. }
  603. }
  604. }
  605. }
  606. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  607. {
  608. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  609. {
  610. isFromDigimon = true;
  611. }
  612. }
  613. if (cardSources.Contains(addedDigivolutionCard))
  614. {
  615. isFromSameDigimon = true;
  616. if (addedDigivolutionCard == TopCard)
  617. {
  618. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  619. ShowingPermanentCard.ShowPermanentData(true);
  620. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  621. addedDigivolutionCard,
  622. this));
  623. }
  624. }
  625. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  626. if (!IsToken && !addedDigivolutionCard.IsToken)
  627. {
  628. cardSources.Add(addedDigivolutionCard);
  629. addedDigivolutionCard.SetFace();
  630. addedCards.Add(addedDigivolutionCard);
  631. }
  632. }
  633. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  634. {
  635. if (ShowingPermanentCard != null)
  636. {
  637. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  638. }
  639. #region "進化元が増えた時"の効果
  640. #region Hashtable Setting
  641. Hashtable hashtable = new Hashtable()
  642. {
  643. {"Permanent", this},
  644. {"CardEffect", cardEffect},
  645. {"CardSources", addedCards},
  646. {"isFromSameDigimon", isFromSameDigimon},
  647. {"isFromDigimon", isFromDigimon},
  648. };
  649. #endregion
  650. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  651. #endregion
  652. }
  653. }
  654. #endregion
  655. #region パーマネントのカードリストからカードを除く
  656. public IEnumerator RemoveCardSource(CardSource cardSource)
  657. {
  658. yield return null;
  659. cardSources.Remove(cardSource);
  660. }
  661. #endregion
  662. #region このパーマネントの一番上のカード
  663. public CardSource TopCard
  664. {
  665. get
  666. {
  667. if (cardSources.Count >= 1)
  668. {
  669. return cardSources[0];
  670. }
  671. return null;
  672. }
  673. }
  674. #endregion
  675. #region Permanent effect list
  676. #region このパーマネントの効果リスト
  677. public List<ICardEffect> EffectList(EffectTiming timing)
  678. {
  679. return EffectList_ForCard(timing, TopCard);
  680. }
  681. #endregion
  682. #region このポケモンの追加効果リスト
  683. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  684. {
  685. List<ICardEffect> _EffectList = new List<ICardEffect>();
  686. if (TopCard != null)
  687. {
  688. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  689. {
  690. ICardEffect cardEffect = GetCardEffect(timing);
  691. if (cardEffect != null)
  692. {
  693. _EffectList.Add(cardEffect);
  694. }
  695. }
  696. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  697. {
  698. ICardEffect cardEffect = GetCardEffect(timing);
  699. if (cardEffect != null)
  700. {
  701. _EffectList.Add(cardEffect);
  702. }
  703. }
  704. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  705. {
  706. ICardEffect cardEffect = GetCardEffect(timing);
  707. if (cardEffect != null)
  708. {
  709. _EffectList.Add(cardEffect);
  710. }
  711. }
  712. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  713. {
  714. ICardEffect cardEffect = GetCardEffect(timing);
  715. if (cardEffect != null)
  716. {
  717. _EffectList.Add(cardEffect);
  718. }
  719. }
  720. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  721. {
  722. ICardEffect cardEffect = GetCardEffect(timing);
  723. if (cardEffect != null)
  724. {
  725. _EffectList.Add(cardEffect);
  726. }
  727. }
  728. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  729. {
  730. ICardEffect cardEffect = GetCardEffect(timing);
  731. if (cardEffect != null)
  732. {
  733. _EffectList.Add(cardEffect);
  734. }
  735. }
  736. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  737. {
  738. ICardEffect cardEffect = GetCardEffect(timing);
  739. if (cardEffect != null)
  740. {
  741. _EffectList.Add(cardEffect);
  742. }
  743. }
  744. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  745. {
  746. ICardEffect cardEffect = GetCardEffect(timing);
  747. if (cardEffect != null)
  748. {
  749. _EffectList.Add(cardEffect);
  750. }
  751. }
  752. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  753. {
  754. ICardEffect cardEffect = GetCardEffect(timing);
  755. if (cardEffect != null)
  756. {
  757. _EffectList.Add(cardEffect);
  758. }
  759. }
  760. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  761. foreach (ICardEffect cardEffect in _EffectList)
  762. {
  763. if (cardEffect != null)
  764. {
  765. if (cardEffect.EffectSourceCard == null)
  766. {
  767. cardEffect.SetEffectSourceCard(TopCard);
  768. }
  769. cardEffect.SetIsInheritedEffect(false);
  770. }
  771. }
  772. }
  773. return _EffectList;
  774. }
  775. #endregion
  776. #region このパーマネントの効果リスト(引数:CardSource)
  777. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  778. {
  779. List<ICardEffect> _EffectList = new List<ICardEffect>();
  780. if (TopCard != null && _cardSource != null)
  781. {
  782. foreach (CardSource cardSource in cardSources)
  783. {
  784. if (cardSource != null)
  785. {
  786. if (!cardSource.IsFlipped)
  787. {
  788. bool isTopCard = cardSource == TopCard;
  789. if (!isTopCard)
  790. {
  791. if (!IsDigimon)
  792. {
  793. continue;
  794. }
  795. }
  796. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  797. {
  798. if (cardEffect != null)
  799. {
  800. if (isTopCard == cardEffect.IsInheritedEffect)
  801. {
  802. continue;
  803. }
  804. _EffectList.Add(cardEffect);
  805. }
  806. }
  807. }
  808. }
  809. }
  810. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  811. {
  812. if (cardEffect != null)
  813. {
  814. _EffectList.Add(cardEffect);
  815. }
  816. }
  817. foreach (ICardEffect cardEffect in _EffectList)
  818. {
  819. if (cardEffect != null)
  820. {
  821. if (cardEffect.EffectSourceCard == null)
  822. {
  823. cardEffect.SetEffectSourceCard(_cardSource);
  824. }
  825. }
  826. }
  827. }
  828. return _EffectList;
  829. }
  830. #endregion
  831. #region 自分のターン終了時に消える効果
  832. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  833. #endregion
  834. #region 自分のドローフェイズ終了時に消える効果
  835. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  836. #endregion
  837. #region お互いのターン終了時に消える効果
  838. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  839. #endregion
  840. #region 相手のターン終了時に消える効果
  841. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  842. #endregion
  843. #region バトル終了時に消える効果
  844. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  845. #endregion
  846. #region 攻撃終了時に消える効果
  847. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  848. #endregion
  849. #region 自分のターン開始時に消える効果
  850. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  851. #endregion
  852. #region 次にアンタップする時に消える効果
  853. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  854. #endregion
  855. #region 場を離れるまで残る効果
  856. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  857. #endregion
  858. #endregion
  859. #region 起動型効果を宣言できるか
  860. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  861. #endregion
  862. #region 宣言可能な起動型効果リスト
  863. public List<ICardEffect> CanDeclareSkillList()
  864. {
  865. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  866. if (TopCard != null)
  867. {
  868. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  869. {
  870. if (_cardEffect is ActivateICardEffect)
  871. {
  872. if (_cardEffect.CanUse(null))
  873. {
  874. CanDeclareSkillList.Add(_cardEffect);
  875. }
  876. }
  877. }
  878. }
  879. return CanDeclareSkillList;
  880. }
  881. #endregion
  882. #region このパーマネントが場に出たターン
  883. public int EnterFieldTurnCount { get; set; } = -1;
  884. #endregion
  885. #region このパーマネントを表す場のオブジェクト
  886. public FieldPermanentCard ShowingPermanentCard { get; set; }
  887. #endregion
  888. #region Whether this permanent can be selected by the effect
  889. public bool CanSelectBySkill(ICardEffect skill)
  890. {
  891. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  892. {
  893. #region Effects of field permanents
  894. foreach (Permanent permanent in player.GetFieldPermanents())
  895. {
  896. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  897. {
  898. if (cardEffect is ICanNotSelectBySkillEffect)
  899. {
  900. if (cardEffect.CanUse(null))
  901. {
  902. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  903. {
  904. return false;
  905. }
  906. }
  907. }
  908. }
  909. }
  910. #endregion
  911. }
  912. return true;
  913. }
  914. #endregion
  915. #region セキュリティチェックを行う枚数
  916. public List<int> SecurityAttackChanges
  917. {
  918. get
  919. {
  920. List<int> SecurityAttackChanges = new List<int>();
  921. int Strike = 1;
  922. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  923. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  924. {
  925. foreach (Permanent permanent in player.GetFieldPermanents())
  926. {
  927. #region 場のパーマネントの効果
  928. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  929. {
  930. if (cardEffect is IChangeSAttackEffect)
  931. {
  932. if (cardEffect.CanUse(null))
  933. {
  934. if (!TopCard.CanNotBeAffected(cardEffect))
  935. {
  936. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  937. {
  938. cardEffects_ChangeDirectStrike.Add(cardEffect);
  939. }
  940. }
  941. }
  942. }
  943. }
  944. #endregion
  945. }
  946. #region プレイヤーの効果
  947. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  948. {
  949. if (cardEffect is IChangeSAttackEffect)
  950. {
  951. if (cardEffect.CanUse(null))
  952. {
  953. if (!TopCard.CanNotBeAffected(cardEffect))
  954. {
  955. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  956. {
  957. cardEffects_ChangeDirectStrike.Add(cardEffect);
  958. }
  959. }
  960. }
  961. }
  962. }
  963. #endregion
  964. }
  965. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  966. {
  967. if (cardEffect is IChangeSAttackEffect)
  968. {
  969. if (cardEffect.CanUse(null))
  970. {
  971. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this);
  972. if (Strike1 != Strike)
  973. {
  974. SecurityAttackChanges.Add(Strike1 - Strike);
  975. }
  976. }
  977. }
  978. }
  979. return SecurityAttackChanges;
  980. }
  981. }
  982. public bool HasSecurityAttackChanges
  983. {
  984. get
  985. {
  986. if (!IsDigimon)
  987. {
  988. return false;
  989. }
  990. return SecurityAttackChanges.Count >= 1;
  991. }
  992. }
  993. public int Strike_AllowMinus
  994. {
  995. get
  996. {
  997. int Strike = 1;
  998. #region セキュリティチェックを行う枚数を変更する効果
  999. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1000. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1001. {
  1002. foreach (Permanent permanent in player.GetFieldPermanents())
  1003. {
  1004. #region 場のパーマネントの効果
  1005. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1006. {
  1007. if (cardEffect is IChangeSAttackEffect)
  1008. {
  1009. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1010. {
  1011. if (cardEffect.CanUse(null))
  1012. {
  1013. if (!TopCard.CanNotBeAffected(cardEffect))
  1014. {
  1015. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1016. }
  1017. }
  1018. }
  1019. }
  1020. }
  1021. #endregion
  1022. }
  1023. #region プレイヤーの効果
  1024. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1025. {
  1026. if (cardEffect is IChangeSAttackEffect)
  1027. {
  1028. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1029. {
  1030. if (cardEffect.CanUse(null))
  1031. {
  1032. if (!TopCard.CanNotBeAffected(cardEffect))
  1033. {
  1034. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1035. }
  1036. }
  1037. }
  1038. }
  1039. }
  1040. #endregion
  1041. }
  1042. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1043. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1044. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1045. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1046. {
  1047. if (cardEffect is IChangeSAttackEffect)
  1048. {
  1049. if (cardEffect.CanUse(null))
  1050. {
  1051. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1052. {
  1053. case CalculateOrder.UpToConstant:
  1054. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1055. break;
  1056. case CalculateOrder.UpDownValue:
  1057. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1058. break;
  1059. case CalculateOrder.DownToConstant:
  1060. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1061. break;
  1062. }
  1063. }
  1064. }
  1065. }
  1066. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1067. {
  1068. if (cardEffect is IChangeSAttackEffect)
  1069. {
  1070. if (cardEffect.CanUse(null))
  1071. {
  1072. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this);
  1073. }
  1074. }
  1075. }
  1076. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1077. {
  1078. if (cardEffect is IChangeSAttackEffect)
  1079. {
  1080. if (cardEffect.CanUse(null))
  1081. {
  1082. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this);
  1083. }
  1084. }
  1085. }
  1086. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1087. {
  1088. if (cardEffect is IChangeSAttackEffect)
  1089. {
  1090. if (cardEffect.CanUse(null))
  1091. {
  1092. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this);
  1093. }
  1094. }
  1095. }
  1096. #endregion
  1097. return Strike;
  1098. }
  1099. }
  1100. public int Strike
  1101. {
  1102. get
  1103. {
  1104. int Strike = Strike_AllowMinus;
  1105. if (Strike < 0)
  1106. {
  1107. Strike = 0;
  1108. }
  1109. return Strike;
  1110. }
  1111. }
  1112. #endregion
  1113. #region このパーマネントがタップされているかどうか
  1114. public bool OldIsSuspended = false;
  1115. public bool IsSuspended = false;
  1116. public int DPWhenSuspended = 114514;
  1117. #endregion
  1118. #region Whether this permanent can unsuspend
  1119. public bool CanUnsuspend
  1120. {
  1121. get
  1122. {
  1123. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1124. {
  1125. #region Effects of field permanents
  1126. foreach (Permanent permanent in player.GetFieldPermanents())
  1127. {
  1128. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1129. {
  1130. if (cardEffect is ICanNotUnsuspendEffect)
  1131. {
  1132. if (cardEffect.CanUse(null))
  1133. {
  1134. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1135. {
  1136. return false;
  1137. }
  1138. }
  1139. }
  1140. }
  1141. }
  1142. #endregion
  1143. #region Effects of players
  1144. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1145. {
  1146. if (cardEffect is ICanNotUnsuspendEffect)
  1147. {
  1148. if (cardEffect.CanUse(null))
  1149. {
  1150. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1151. {
  1152. return false;
  1153. }
  1154. }
  1155. }
  1156. }
  1157. #endregion
  1158. }
  1159. return true;
  1160. }
  1161. }
  1162. #endregion
  1163. #region このパーマネントが移動できるかどうか
  1164. public bool CanMove
  1165. {
  1166. get
  1167. {
  1168. if (TopCard != null)
  1169. {
  1170. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1171. {
  1172. return false;
  1173. }
  1174. if (!IsDigimon)
  1175. {
  1176. return false;
  1177. }
  1178. if (DP <= 0)
  1179. {
  1180. return false;
  1181. }
  1182. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1183. {
  1184. return false;
  1185. }
  1186. }
  1187. else
  1188. {
  1189. return false;
  1190. }
  1191. return true;
  1192. }
  1193. }
  1194. #endregion
  1195. #region このパーマネントが攻撃できるかどうか
  1196. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false)
  1197. {
  1198. // can not attack with empty cards
  1199. if (TopCard == null)
  1200. {
  1201. return false;
  1202. }
  1203. // can not attack during opponent's turn
  1204. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1205. {
  1206. return false;
  1207. }
  1208. // can not attack to player
  1209. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap))
  1210. {
  1211. // can not attack to opponent's Digimon
  1212. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap)) == 0)
  1213. {
  1214. return false;
  1215. }
  1216. }
  1217. return true;
  1218. }
  1219. #endregion
  1220. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1221. public bool CanBlock(Permanent AttackingPermanent)
  1222. {
  1223. if (TopCard == null)
  1224. {
  1225. return false;
  1226. }
  1227. if (!IsDigimon)
  1228. {
  1229. return false;
  1230. }
  1231. if (IsSuspended)
  1232. {
  1233. return false;
  1234. }
  1235. if (!CanSuspend)
  1236. {
  1237. return false;
  1238. }
  1239. if (PermanentFrame != null)
  1240. {
  1241. if (!PermanentFrame.IsBattleAreaFrame())
  1242. {
  1243. return false;
  1244. }
  1245. }
  1246. #region "Unblockable" effect
  1247. #region Effects of permanents in play
  1248. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1249. {
  1250. foreach (Permanent permanent in player.GetFieldPermanents())
  1251. {
  1252. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1253. {
  1254. if (cardEffect is ICannotBlockEffect)
  1255. {
  1256. if (cardEffect.CanUse(null))
  1257. {
  1258. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1259. {
  1260. return false;
  1261. }
  1262. }
  1263. }
  1264. }
  1265. }
  1266. }
  1267. #endregion
  1268. #region player effect
  1269. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1270. {
  1271. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1272. {
  1273. if (cardEffect is ICannotBlockEffect)
  1274. {
  1275. if (cardEffect.CanUse(null))
  1276. {
  1277. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1278. {
  1279. if (!TopCard.CanNotBeAffected(cardEffect))
  1280. {
  1281. return false;
  1282. }
  1283. }
  1284. }
  1285. }
  1286. }
  1287. }
  1288. #endregion
  1289. #endregion
  1290. return true;
  1291. }
  1292. #endregion
  1293. #region 対象のパーマネントを攻撃できるか
  1294. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false)
  1295. {
  1296. if (TopCard != null)
  1297. {
  1298. if (!IsDigimon)
  1299. {
  1300. return false;
  1301. }
  1302. if (!withoutTap)
  1303. {
  1304. if (IsSuspended)
  1305. {
  1306. return false;
  1307. }
  1308. if (!CanSuspend)
  1309. {
  1310. return false;
  1311. }
  1312. }
  1313. if (PermanentFrame != null)
  1314. {
  1315. if (!PermanentFrame.IsBattleAreaFrame())
  1316. {
  1317. return false;
  1318. }
  1319. }
  1320. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1321. {
  1322. if (!HasRush)
  1323. {
  1324. return false;
  1325. }
  1326. }
  1327. #region 「対象の防御パーマネントを攻撃できない」効果
  1328. #region 場のパーマネントの効果
  1329. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1330. {
  1331. foreach (Permanent permanent in player.GetFieldPermanents())
  1332. {
  1333. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1334. {
  1335. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1336. {
  1337. if (cardEffect1.CanUse(null))
  1338. {
  1339. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1340. {
  1341. if (!TopCard.CanNotBeAffected(cardEffect1))
  1342. {
  1343. return false;
  1344. }
  1345. }
  1346. }
  1347. }
  1348. }
  1349. }
  1350. }
  1351. #endregion
  1352. #region プレイヤーの効果
  1353. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1354. {
  1355. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1356. {
  1357. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1358. {
  1359. if (cardEffect1.CanUse(null))
  1360. {
  1361. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1362. {
  1363. if (!TopCard.CanNotBeAffected(cardEffect1))
  1364. {
  1365. return false;
  1366. }
  1367. }
  1368. }
  1369. }
  1370. }
  1371. }
  1372. #endregion
  1373. #endregion
  1374. if (Defender != null)
  1375. {
  1376. if (Defender.TopCard != null)
  1377. {
  1378. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1379. {
  1380. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1381. {
  1382. if (Defender.IsSuspended)
  1383. {
  1384. return true;
  1385. }
  1386. #region 「対象の防御パーマネントを攻撃できる」効果
  1387. #region 場のパーマネントの効果
  1388. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1389. {
  1390. foreach (Permanent permanent in player.GetFieldPermanents())
  1391. {
  1392. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1393. {
  1394. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1395. {
  1396. if (cardEffect1.CanUse(null))
  1397. {
  1398. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1399. {
  1400. return true;
  1401. }
  1402. }
  1403. }
  1404. }
  1405. }
  1406. }
  1407. #endregion
  1408. #region プレイヤーの効果
  1409. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1410. {
  1411. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1412. {
  1413. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1414. {
  1415. if (cardEffect1.CanUse(null))
  1416. {
  1417. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1418. {
  1419. return true;
  1420. }
  1421. }
  1422. }
  1423. }
  1424. }
  1425. #endregion
  1426. #endregion
  1427. }
  1428. }
  1429. }
  1430. }
  1431. else
  1432. {
  1433. return true;
  1434. }
  1435. }
  1436. return false;
  1437. }
  1438. #endregion
  1439. #region Is Unblockable
  1440. public bool IsUnblockable
  1441. {
  1442. get
  1443. {
  1444. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1445. {
  1446. if (cardEffect is CannotBlockClass)
  1447. {
  1448. if (cardEffect.EffectName == "Can't Block")
  1449. {
  1450. return true;
  1451. }
  1452. }
  1453. }
  1454. return false;
  1455. }
  1456. }
  1457. #endregion
  1458. #region Has Blocker
  1459. public bool HasBlocker
  1460. {
  1461. get
  1462. {
  1463. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1464. {
  1465. foreach (Permanent permanent in player.GetFieldPermanents())
  1466. {
  1467. #region 場のパーマネントの効果
  1468. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1469. {
  1470. if (cardEffect is IBlockerEffect)
  1471. {
  1472. if (cardEffect.CanTrigger(null))
  1473. {
  1474. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1475. {
  1476. return true;
  1477. }
  1478. }
  1479. }
  1480. }
  1481. #endregion
  1482. }
  1483. #region プレイヤーの効果
  1484. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1485. {
  1486. if (cardEffect is IBlockerEffect)
  1487. {
  1488. if (cardEffect.CanTrigger(null))
  1489. {
  1490. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1491. {
  1492. return true;
  1493. }
  1494. }
  1495. }
  1496. }
  1497. #endregion
  1498. }
  1499. return false;
  1500. }
  1501. }
  1502. #endregion
  1503. #region Has Jamming
  1504. public bool HasJamming
  1505. {
  1506. get
  1507. {
  1508. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1509. {
  1510. foreach (Permanent permanent in player.GetFieldPermanents())
  1511. {
  1512. #region 場のパーマネントの効果
  1513. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1514. {
  1515. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1516. {
  1517. if (cardEffect.CanTrigger(null))
  1518. {
  1519. if (cardEffect.EffectName == "Jamming")
  1520. {
  1521. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1522. {
  1523. return true;
  1524. }
  1525. }
  1526. }
  1527. }
  1528. }
  1529. #endregion
  1530. }
  1531. #region プレイヤーの効果
  1532. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1533. {
  1534. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1535. {
  1536. if (cardEffect.CanTrigger(null))
  1537. {
  1538. if (cardEffect.EffectName == "Jamming")
  1539. {
  1540. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1541. {
  1542. return true;
  1543. }
  1544. }
  1545. }
  1546. }
  1547. }
  1548. #endregion
  1549. }
  1550. return false;
  1551. }
  1552. }
  1553. #endregion
  1554. #region Whether this permanent has Pierce
  1555. public bool HasPierce
  1556. {
  1557. get
  1558. {
  1559. if (IsDigimon)
  1560. {
  1561. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  1562. {
  1563. if (cardEffect is ActivateICardEffect)
  1564. {
  1565. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  1566. {
  1567. if (cardEffect.EffectName == "Pierce")
  1568. {
  1569. return true;
  1570. }
  1571. if (cardEffect.EffectName == "Piercing")
  1572. {
  1573. return true;
  1574. }
  1575. }
  1576. }
  1577. }
  1578. }
  1579. return false;
  1580. }
  1581. }
  1582. #endregion
  1583. #region 再起動を持つか
  1584. public bool HasReboot
  1585. {
  1586. get
  1587. {
  1588. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1589. {
  1590. foreach (Permanent permanent in player.GetFieldPermanents())
  1591. {
  1592. #region 場のパーマネントの効果
  1593. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1594. {
  1595. if (cardEffect is IRebootEffect)
  1596. {
  1597. if (cardEffect.CanTrigger(null))
  1598. {
  1599. if (((IRebootEffect)cardEffect).HasReboot(this))
  1600. {
  1601. return true;
  1602. }
  1603. }
  1604. }
  1605. }
  1606. #endregion
  1607. }
  1608. #region プレイヤーの効果
  1609. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1610. {
  1611. if (cardEffect is IRebootEffect)
  1612. {
  1613. if (cardEffect.CanTrigger(null))
  1614. {
  1615. if (((IRebootEffect)cardEffect).HasReboot(this))
  1616. {
  1617. return true;
  1618. }
  1619. }
  1620. }
  1621. }
  1622. #endregion
  1623. }
  1624. return false;
  1625. }
  1626. }
  1627. #endregion
  1628. #region 突進を持つか
  1629. public bool HasRaid
  1630. {
  1631. get
  1632. {
  1633. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1634. {
  1635. if (cardEffect is ActivateICardEffect)
  1636. {
  1637. if (cardEffect.EffectName == "Raid")
  1638. {
  1639. return true;
  1640. }
  1641. }
  1642. }
  1643. return false;
  1644. }
  1645. }
  1646. #endregion
  1647. #region 速攻を持つか
  1648. public bool HasRush
  1649. {
  1650. get
  1651. {
  1652. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1653. {
  1654. foreach (Permanent permanent in player.GetFieldPermanents())
  1655. {
  1656. #region 場のパーマネントの効果
  1657. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1658. {
  1659. if (cardEffect is IRushEffect)
  1660. {
  1661. if (cardEffect.CanTrigger(null))
  1662. {
  1663. if (((IRushEffect)cardEffect).HasRush(this))
  1664. {
  1665. return true;
  1666. }
  1667. }
  1668. }
  1669. }
  1670. #endregion
  1671. }
  1672. #region プレイヤーの効果
  1673. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1674. {
  1675. if (cardEffect is IRushEffect)
  1676. {
  1677. if (cardEffect.CanTrigger(null))
  1678. {
  1679. if (((IRushEffect)cardEffect).HasRush(this))
  1680. {
  1681. return true;
  1682. }
  1683. }
  1684. }
  1685. }
  1686. #endregion
  1687. }
  1688. return false;
  1689. }
  1690. }
  1691. #endregion
  1692. #region 道連れを持つか
  1693. public bool HasRetaliation
  1694. {
  1695. get
  1696. {
  1697. if (RetaliationCount >= 1)
  1698. {
  1699. return true;
  1700. }
  1701. return false;
  1702. }
  1703. }
  1704. #endregion
  1705. #region 道連れを持つ個数
  1706. public int RetaliationCount
  1707. {
  1708. get
  1709. {
  1710. int count = 0;
  1711. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1712. {
  1713. if (cardEffect is ActivateICardEffect)
  1714. {
  1715. if (cardEffect.EffectName == "Retaliation")
  1716. {
  1717. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1718. {
  1719. count++;
  1720. }
  1721. }
  1722. }
  1723. }
  1724. return count;
  1725. }
  1726. }
  1727. #endregion
  1728. #region 不屈を持つか
  1729. public bool HasFortitude
  1730. {
  1731. get
  1732. {
  1733. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1734. {
  1735. if (cardEffect is ActivateICardEffect)
  1736. {
  1737. if (cardEffect.EffectName == "Fortitude")
  1738. {
  1739. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1740. {
  1741. return true;
  1742. }
  1743. }
  1744. }
  1745. }
  1746. return false;
  1747. }
  1748. }
  1749. #endregion
  1750. #region Has Blitz
  1751. public bool HasBlitz
  1752. {
  1753. get
  1754. {
  1755. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  1756. {
  1757. if (cardEffect is ActivateICardEffect)
  1758. {
  1759. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  1760. {
  1761. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1762. {
  1763. if (cardEffect.EffectDiscription.Contains("Blitz"))
  1764. {
  1765. return true;
  1766. }
  1767. }
  1768. }
  1769. }
  1770. }
  1771. return false;
  1772. }
  1773. }
  1774. #endregion
  1775. #region 回避を持つか
  1776. public bool HasEvade
  1777. {
  1778. get
  1779. {
  1780. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1781. {
  1782. if (cardEffect is ActivateICardEffect)
  1783. {
  1784. Hashtable hashtable = new Hashtable()
  1785. {
  1786. {"Permanents", new List<Permanent>() { this }}
  1787. };
  1788. if (cardEffect.CanTrigger(hashtable))
  1789. {
  1790. if (cardEffect.EffectName == "Evade")
  1791. {
  1792. return true;
  1793. }
  1794. }
  1795. }
  1796. }
  1797. return false;
  1798. }
  1799. }
  1800. #endregion
  1801. #region マインドリンクを持つか
  1802. public bool HasMindLink
  1803. {
  1804. get
  1805. {
  1806. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  1807. {
  1808. if (cardEffect is ActivateICardEffect)
  1809. {
  1810. if (cardEffect.CanTrigger(null))
  1811. {
  1812. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  1813. {
  1814. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  1815. {
  1816. return true;
  1817. }
  1818. }
  1819. }
  1820. }
  1821. }
  1822. return false;
  1823. }
  1824. }
  1825. #endregion
  1826. #region 防壁を持つか
  1827. public bool HasBarrier
  1828. {
  1829. get
  1830. {
  1831. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1832. {
  1833. if (cardEffect is ActivateICardEffect)
  1834. {
  1835. Hashtable hashtable = new Hashtable();
  1836. hashtable.Add("Permanents", new List<Permanent>() { this });
  1837. hashtable.Add("battle", new IBattle(null, null, null));
  1838. if (cardEffect.CanTrigger(hashtable))
  1839. {
  1840. if (cardEffect.EffectName == "Barrier")
  1841. {
  1842. return true;
  1843. }
  1844. }
  1845. }
  1846. }
  1847. return false;
  1848. }
  1849. }
  1850. #endregion
  1851. #region 連携を持つか
  1852. public bool HasAlliance
  1853. {
  1854. get
  1855. {
  1856. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1857. {
  1858. if (cardEffect is ActivateICardEffect)
  1859. {
  1860. if (cardEffect.EffectName == "Alliance")
  1861. {
  1862. return true;
  1863. }
  1864. }
  1865. }
  1866. return false;
  1867. }
  1868. }
  1869. #endregion
  1870. #region Has Collision
  1871. public bool HasCollision
  1872. {
  1873. get
  1874. {
  1875. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1876. {
  1877. if (cardEffect is ActivateICardEffect)
  1878. {
  1879. if (cardEffect.EffectName == "Collision")
  1880. {
  1881. return true;
  1882. }
  1883. }
  1884. }
  1885. return false;
  1886. }
  1887. }
  1888. #endregion
  1889. #region Has Partition
  1890. public bool HasPartition
  1891. {
  1892. get
  1893. {
  1894. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1895. {
  1896. if (cardEffect is ActivateICardEffect)
  1897. {
  1898. if (cardEffect.EffectName == "Partition")
  1899. {
  1900. return true;
  1901. }
  1902. }
  1903. }
  1904. return false;
  1905. }
  1906. }
  1907. #endregion
  1908. #region 消滅時効化を持つか
  1909. public bool HasOnDeletionEffect
  1910. {
  1911. get
  1912. {
  1913. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1914. {
  1915. if (cardEffect is ActivateICardEffect)
  1916. {
  1917. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1918. {
  1919. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1920. {
  1921. if (cardEffect.IsOnDeletion)
  1922. {
  1923. return true;
  1924. }
  1925. }
  1926. }
  1927. }
  1928. }
  1929. return false;
  1930. }
  1931. }
  1932. #endregion
  1933. #region バトルしているか
  1934. public IBattle battle { get; set; } = null;
  1935. #endregion
  1936. #region このデジモンが消滅するか
  1937. public bool CanBeDestroyed()
  1938. {
  1939. #region 消滅しない効果
  1940. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1941. {
  1942. foreach (Permanent permanent in player.GetFieldPermanents())
  1943. {
  1944. #region 場のパーマネントの効果
  1945. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1946. {
  1947. if (cardEffect is ICanNotBeDestroyedEffect)
  1948. {
  1949. if (cardEffect.CanUse(null))
  1950. {
  1951. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  1952. {
  1953. return false;
  1954. }
  1955. }
  1956. }
  1957. }
  1958. #endregion
  1959. }
  1960. #region プレイヤーの効果
  1961. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1962. {
  1963. if (cardEffect is ICanNotBeDestroyedEffect)
  1964. {
  1965. if (cardEffect.CanUse(null))
  1966. {
  1967. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  1968. {
  1969. return false;
  1970. }
  1971. }
  1972. }
  1973. }
  1974. #endregion
  1975. }
  1976. #endregion
  1977. return true;
  1978. }
  1979. #endregion
  1980. #region このデジモンが戦闘によって消滅するか
  1981. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  1982. {
  1983. if (!CanBeDestroyed())
  1984. {
  1985. return false;
  1986. }
  1987. #region 戦闘で消滅しない効果
  1988. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1989. {
  1990. foreach (Permanent permanent in player.GetFieldPermanents())
  1991. {
  1992. #region 場のパーマネントの効果
  1993. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1994. {
  1995. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1996. {
  1997. if (cardEffect.CanUse(null))
  1998. {
  1999. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2000. {
  2001. return false;
  2002. }
  2003. }
  2004. }
  2005. }
  2006. #endregion
  2007. }
  2008. #region プレイヤーの効果
  2009. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2010. {
  2011. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2012. {
  2013. if (cardEffect.CanUse(null))
  2014. {
  2015. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2016. {
  2017. return false;
  2018. }
  2019. }
  2020. }
  2021. }
  2022. #endregion
  2023. }
  2024. #endregion
  2025. return true;
  2026. }
  2027. #endregion
  2028. #region このパーマネントが効果で消滅するか
  2029. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2030. {
  2031. if (this.TopCard != null)
  2032. {
  2033. if (this.TopCard.CanNotBeAffected(cardEffect))
  2034. {
  2035. return false;
  2036. }
  2037. if (!CanBeDestroyed())
  2038. {
  2039. return false;
  2040. }
  2041. #region 効果で消滅しない効果
  2042. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2043. {
  2044. foreach (Permanent permanent in player.GetFieldPermanents())
  2045. {
  2046. #region 場のパーマネントの効果
  2047. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2048. {
  2049. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2050. {
  2051. if (cardEffect1.CanUse(null))
  2052. {
  2053. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2054. {
  2055. return false;
  2056. }
  2057. }
  2058. }
  2059. }
  2060. #endregion
  2061. }
  2062. #region プレイヤーの効果
  2063. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2064. {
  2065. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2066. {
  2067. if (cardEffect1.CanUse(null))
  2068. {
  2069. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2070. {
  2071. return false;
  2072. }
  2073. }
  2074. }
  2075. }
  2076. #endregion
  2077. }
  2078. #endregion
  2079. }
  2080. return true;
  2081. }
  2082. #endregion
  2083. #region トークンかどうか
  2084. public bool IsToken
  2085. {
  2086. get
  2087. {
  2088. if (TopCard != null)
  2089. {
  2090. if (TopCard.IsToken)
  2091. {
  2092. return true;
  2093. }
  2094. }
  2095. return false;
  2096. }
  2097. }
  2098. #endregion
  2099. #region そのパーマネントが消滅・バウンス待機状態か
  2100. public bool willBeRemoveField { get; set; } = false;
  2101. #endregion
  2102. #region このパーマネントがデジモンか
  2103. public bool IsDigimon
  2104. {
  2105. get
  2106. {
  2107. if (TopCard != null)
  2108. {
  2109. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2110. {
  2111. return true;
  2112. }
  2113. #region Effect of treating it as a Digimon
  2114. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2115. {
  2116. foreach (Permanent permanent in player.GetFieldPermanents())
  2117. {
  2118. #region Effects of permanents in play
  2119. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2120. {
  2121. if (cardEffect is ITreatAsDigimonEffect)
  2122. {
  2123. if (cardEffect.CanTrigger(null))
  2124. {
  2125. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2126. {
  2127. return true;
  2128. }
  2129. }
  2130. }
  2131. }
  2132. #endregion
  2133. }
  2134. #region player effect
  2135. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2136. {
  2137. if (cardEffect is ITreatAsDigimonEffect)
  2138. {
  2139. if (cardEffect.CanTrigger(null))
  2140. {
  2141. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2142. {
  2143. return true;
  2144. }
  2145. }
  2146. }
  2147. }
  2148. #endregion
  2149. }
  2150. #endregion
  2151. }
  2152. return false;
  2153. }
  2154. }
  2155. #endregion
  2156. #region このパーマネントがテイマーか
  2157. public bool IsTamer
  2158. {
  2159. get
  2160. {
  2161. if (TopCard != null)
  2162. {
  2163. if (TopCard.IsTamer)
  2164. {
  2165. return true;
  2166. }
  2167. }
  2168. return false;
  2169. }
  2170. }
  2171. #endregion
  2172. #region ジョグレスで扱うレベル
  2173. public List<int> Levels_ForJogress(CardSource cardSource)
  2174. {
  2175. List<int> levels = new List<int>();
  2176. if (cardSource != null)
  2177. {
  2178. if (cardSource.HasLevel)
  2179. {
  2180. levels.Add(this.Level);
  2181. }
  2182. #region "ジョグレス進化で扱うレベルを追加する"効果
  2183. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2184. {
  2185. foreach (Permanent permanent in player.GetFieldPermanents())
  2186. {
  2187. #region 場のパーマネントの効果
  2188. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2189. {
  2190. if (cardEffect is IAddJogressLevelsEffect)
  2191. {
  2192. if (cardEffect.CanUse(null))
  2193. {
  2194. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2195. {
  2196. levels.Add(level);
  2197. }
  2198. }
  2199. }
  2200. }
  2201. #endregion
  2202. }
  2203. #region プレイヤーの効果
  2204. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2205. {
  2206. if (cardEffect is IAddJogressLevelsEffect)
  2207. {
  2208. if (cardEffect.CanUse(null))
  2209. {
  2210. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2211. {
  2212. levels.Add(level);
  2213. }
  2214. }
  2215. }
  2216. }
  2217. #endregion
  2218. }
  2219. #endregion
  2220. }
  2221. return levels;
  2222. }
  2223. #endregion
  2224. #region バトルで消滅したか
  2225. public bool IsDestroyedByBattle { get; set; } = false;
  2226. #endregion
  2227. #region 消滅に使用された効果
  2228. public ICardEffect DestroyingEffect { get; set; } = null;
  2229. #endregion
  2230. #region 他のパーマネントの下に置くのに使用された効果
  2231. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2232. #endregion
  2233. #region 手札バウンス に使用された効果
  2234. public ICardEffect HandBounceEffect { get; set; } = null;
  2235. #endregion
  2236. #region 山札バウンス に使用された効果
  2237. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2238. #endregion
  2239. #region 登場に使用された効果
  2240. public ICardEffect PlayingEffect { get; set; } = null;
  2241. #endregion
  2242. #region 進化に使用された効果
  2243. public ICardEffect DigivolvingEffect { get; set; } = null;
  2244. #endregion
  2245. #region Whether this digimon is placed in the trash by not having a DP
  2246. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2247. #endregion
  2248. #region Whether this permanent can suspend
  2249. public bool CanSuspend
  2250. {
  2251. get
  2252. {
  2253. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2254. {
  2255. #region Effects of field permanents
  2256. foreach (Permanent permanent in player.GetFieldPermanents())
  2257. {
  2258. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2259. {
  2260. if (cardEffect is ICanNotSuspendEffect)
  2261. {
  2262. if (cardEffect.CanUse(null))
  2263. {
  2264. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2265. {
  2266. return false;
  2267. }
  2268. }
  2269. }
  2270. }
  2271. }
  2272. #endregion
  2273. #region Effects of players
  2274. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2275. {
  2276. if (cardEffect is ICanNotSuspendEffect)
  2277. {
  2278. if (cardEffect.CanUse(null))
  2279. {
  2280. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2281. {
  2282. return false;
  2283. }
  2284. }
  2285. }
  2286. }
  2287. #endregion
  2288. }
  2289. return true;
  2290. }
  2291. }
  2292. #endregion
  2293. #region このデジモンのアタックの対象が変更できるか
  2294. public bool CanSwitchAttackTarget
  2295. {
  2296. get
  2297. {
  2298. #region アタックの対象が変更できない効果
  2299. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2300. {
  2301. foreach (Permanent permanent in player.GetFieldPermanents())
  2302. {
  2303. #region 場のパーマネントの効果
  2304. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2305. {
  2306. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2307. {
  2308. if (cardEffect.CanUse(null))
  2309. {
  2310. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2311. {
  2312. return false;
  2313. }
  2314. }
  2315. }
  2316. }
  2317. #endregion
  2318. }
  2319. #region プレイヤーの効果
  2320. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2321. {
  2322. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2323. {
  2324. if (cardEffect.CanUse(null))
  2325. {
  2326. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2327. {
  2328. return false;
  2329. }
  2330. }
  2331. }
  2332. }
  2333. #endregion
  2334. }
  2335. #endregion
  2336. return true;
  2337. }
  2338. }
  2339. #endregion
  2340. #region このデジモンを場からデジクロス条件の代わりにできるか
  2341. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  2342. {
  2343. #region デジクロス条件の代わりにできる効果
  2344. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2345. {
  2346. foreach (Permanent permanent in player.GetFieldPermanents())
  2347. {
  2348. #region 場のパーマネントの効果
  2349. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2350. {
  2351. if (cardEffect is ICanSelectDigiXrosEffect)
  2352. {
  2353. if (cardEffect.CanUse(null))
  2354. {
  2355. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2356. {
  2357. return true;
  2358. }
  2359. }
  2360. }
  2361. }
  2362. #endregion
  2363. }
  2364. #region プレイヤーの効果
  2365. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2366. {
  2367. if (cardEffect is ICanSelectDigiXrosEffect)
  2368. {
  2369. if (cardEffect.CanUse(null))
  2370. {
  2371. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2372. {
  2373. return true;
  2374. }
  2375. }
  2376. }
  2377. }
  2378. #endregion
  2379. }
  2380. #endregion
  2381. return false;
  2382. }
  2383. #endregion
  2384. #region 登場した直後のLevel
  2385. public int LevelJustAfterPlayed { get; set; } = -1;
  2386. #endregion
  2387. #region 登場した直後のPlay Cost
  2388. public int PlayCostJustAfterPlayed { get; set; } = -1;
  2389. #endregion
  2390. #region 登場した直後のCardNames
  2391. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  2392. #endregion
  2393. #region 進化した直後のCardNames
  2394. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  2395. #endregion
  2396. #region 登場した直後のTraits
  2397. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  2398. #endregion
  2399. #region 場を離れる直前のDP
  2400. public int DPJustBeforeRemoveField { get; set; } = -1;
  2401. #endregion
  2402. #region 場を離れる直前のLevel
  2403. public int LevelJustBeforeRemoveField { get; set; } = -1;
  2404. #endregion
  2405. #region 場を離れる直前のCost
  2406. public int CostJustBeforeRemoveField { get; set; } = -1;
  2407. #endregion
  2408. #region 場を離れる直前のカード名
  2409. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  2410. #endregion
  2411. #region バースト進化で手札に戻ったか
  2412. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  2413. #endregion
  2414. #region バースト進化したか
  2415. public bool IsBurstDigivolved { get; set; } = false;
  2416. #endregion
  2417. #region 効果で場に出たオプションか
  2418. public bool IsPlayedOptionPermanent { get; set; } = false;
  2419. #endregion
  2420. #region 進化元を持たないか
  2421. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  2422. #endregion
  2423. #region Digivolution cards' colors
  2424. public List<CardColor> DigivolutionCardsColors
  2425. {
  2426. get
  2427. {
  2428. List<CardColor> cardColors = new List<CardColor>();
  2429. foreach (CardSource cardSource in DigivolutionCards)
  2430. {
  2431. foreach (CardColor cardColor in cardSource.CardColors)
  2432. {
  2433. if (!cardColors.Contains(cardColor))
  2434. {
  2435. cardColors.Add(cardColor);
  2436. }
  2437. }
  2438. }
  2439. return cardColors.Distinct().ToList();
  2440. }
  2441. }
  2442. #endregion
  2443. #region Show "Unsuspend" effect object
  2444. public void ShowUnsuspendEffect()
  2445. {
  2446. if (TopCard != null)
  2447. {
  2448. if (ShowingPermanentCard != null)
  2449. {
  2450. if (ShowingPermanentCard.WillUntapObject != null)
  2451. {
  2452. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  2453. ShowingPermanentCard.WillUntapObject.SetActive(true);
  2454. }
  2455. }
  2456. }
  2457. }
  2458. #endregion
  2459. #region Show "Return to deck" effect object
  2460. public void ShowDeckBounceEffect()
  2461. {
  2462. if (TopCard != null)
  2463. {
  2464. if (willBeRemoveField)
  2465. {
  2466. if (ShowingPermanentCard != null)
  2467. {
  2468. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2469. {
  2470. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  2471. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  2472. }
  2473. }
  2474. }
  2475. }
  2476. }
  2477. #endregion
  2478. #region Hide "Return to deck" effect object
  2479. public void HideDeckBounceEffect()
  2480. {
  2481. if (TopCard != null)
  2482. {
  2483. if (ShowingPermanentCard != null)
  2484. {
  2485. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2486. {
  2487. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  2488. }
  2489. }
  2490. }
  2491. }
  2492. #endregion
  2493. #region Show "Return to hand" effect object
  2494. public void ShowHandBounceEffect()
  2495. {
  2496. if (TopCard != null)
  2497. {
  2498. if (willBeRemoveField)
  2499. {
  2500. if (ShowingPermanentCard != null)
  2501. {
  2502. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2503. {
  2504. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  2505. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  2506. }
  2507. }
  2508. }
  2509. }
  2510. }
  2511. #endregion
  2512. #region Hide "Return to hand" effect object
  2513. public void HideHandBounceEffect()
  2514. {
  2515. if (TopCard != null)
  2516. {
  2517. if (ShowingPermanentCard != null)
  2518. {
  2519. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2520. {
  2521. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  2522. }
  2523. }
  2524. }
  2525. }
  2526. #endregion
  2527. #region Show "Delete" effect object
  2528. public void ShowDeleteEffect()
  2529. {
  2530. if (TopCard != null)
  2531. {
  2532. if (willBeRemoveField)
  2533. {
  2534. if (ShowingPermanentCard != null)
  2535. {
  2536. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2537. {
  2538. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  2539. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  2540. }
  2541. }
  2542. }
  2543. }
  2544. }
  2545. #endregion
  2546. #region Hide "Delete" effect object
  2547. public void HideDeleteEffect()
  2548. {
  2549. if (TopCard != null)
  2550. {
  2551. if (ShowingPermanentCard != null)
  2552. {
  2553. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2554. {
  2555. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  2556. }
  2557. }
  2558. }
  2559. }
  2560. #endregion
  2561. #region Show "Remove Field" effect object
  2562. public void ShowWillRemoveFieldEffect()
  2563. {
  2564. if (TopCard != null)
  2565. {
  2566. if (willBeRemoveField)
  2567. {
  2568. if (ShowingPermanentCard != null)
  2569. {
  2570. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2571. {
  2572. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  2573. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  2574. }
  2575. }
  2576. }
  2577. }
  2578. }
  2579. #endregion
  2580. #region Hide "Remove Field" effect object
  2581. public void HideWillRemoveFieldEffect()
  2582. {
  2583. if (TopCard != null)
  2584. {
  2585. if (ShowingPermanentCard != null)
  2586. {
  2587. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2588. {
  2589. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  2590. }
  2591. }
  2592. }
  2593. }
  2594. #endregion
  2595. #region Show "Digivolution" effect object
  2596. public void ShowWillEvolutionEffect()
  2597. {
  2598. if (TopCard != null)
  2599. {
  2600. if (ShowingPermanentCard != null)
  2601. {
  2602. if (ShowingPermanentCard.WillEvolutionObject != null)
  2603. {
  2604. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  2605. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  2606. }
  2607. }
  2608. }
  2609. }
  2610. #endregion
  2611. #region Hide "Digivolution" effect object
  2612. public void HideWillEvolutionEffect()
  2613. {
  2614. if (TopCard != null)
  2615. {
  2616. if (ShowingPermanentCard != null)
  2617. {
  2618. if (ShowingPermanentCard.WillEvolutionObject != null)
  2619. {
  2620. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  2621. }
  2622. }
  2623. }
  2624. }
  2625. #endregion
  2626. }