Permanent.cs 108 KB

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