Permanent.cs 111 KB

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