Permanent.cs 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319
  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 || TopCard.IsDigiEgg)
  1304. {
  1305. return false;
  1306. }
  1307. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1308. {
  1309. return false;
  1310. }
  1311. }
  1312. else
  1313. {
  1314. return false;
  1315. }
  1316. return true;
  1317. }
  1318. }
  1319. #endregion
  1320. #region このパーマネントが攻撃できるかどうか
  1321. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1322. {
  1323. // can not attack with empty cards
  1324. if (TopCard == null)
  1325. {
  1326. return false;
  1327. }
  1328. // can not attack during opponent's turn
  1329. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1330. {
  1331. return false;
  1332. }
  1333. // can not attack to player
  1334. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex))
  1335. {
  1336. // can not attack to opponent's Digimon
  1337. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex)) == 0)
  1338. {
  1339. return false;
  1340. }
  1341. }
  1342. return true;
  1343. }
  1344. #endregion
  1345. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1346. public bool CanBlock(Permanent AttackingPermanent)
  1347. {
  1348. if (TopCard == null)
  1349. {
  1350. return false;
  1351. }
  1352. if (!IsDigimon)
  1353. {
  1354. return false;
  1355. }
  1356. if (IsSuspended)
  1357. {
  1358. return false;
  1359. }
  1360. if (!CanSuspend)
  1361. {
  1362. return false;
  1363. }
  1364. if (PermanentFrame != null)
  1365. {
  1366. if (!PermanentFrame.IsBattleAreaFrame())
  1367. {
  1368. return false;
  1369. }
  1370. }
  1371. if (!AttackingPermanent.CanSwitchAttackTarget)
  1372. return false;
  1373. #region "Unblockable" effect
  1374. #region Effects of permanents in play
  1375. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1376. {
  1377. foreach (Permanent permanent in player.GetFieldPermanents())
  1378. {
  1379. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1380. {
  1381. if (cardEffect is ICannotBlockEffect)
  1382. {
  1383. if (cardEffect.CanUse(null))
  1384. {
  1385. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1386. {
  1387. return false;
  1388. }
  1389. }
  1390. }
  1391. }
  1392. }
  1393. }
  1394. #endregion
  1395. #region player effect
  1396. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1397. {
  1398. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1399. {
  1400. if (cardEffect is ICannotBlockEffect)
  1401. {
  1402. if (cardEffect.CanUse(null))
  1403. {
  1404. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1405. {
  1406. if (!TopCard.CanNotBeAffected(cardEffect))
  1407. {
  1408. return false;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. }
  1414. }
  1415. #endregion
  1416. #endregion
  1417. return true;
  1418. }
  1419. #endregion
  1420. #region 対象のパーマネントを攻撃できるか
  1421. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1422. {
  1423. if (TopCard != null)
  1424. {
  1425. if (!IsDigimon)
  1426. {
  1427. return false;
  1428. }
  1429. if (!withoutTap)
  1430. {
  1431. if (IsSuspended)
  1432. {
  1433. return false;
  1434. }
  1435. if (!CanSuspend)
  1436. {
  1437. return false;
  1438. }
  1439. }
  1440. if (PermanentFrame != null)
  1441. {
  1442. if (!PermanentFrame.IsBattleAreaFrame())
  1443. {
  1444. return false;
  1445. }
  1446. }
  1447. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1448. {
  1449. if (!HasRush && !isVortex)
  1450. {
  1451. return false;
  1452. }
  1453. }
  1454. #region 「対象の防御パーマネントを攻撃できない」効果
  1455. #region 場のパーマネントの効果
  1456. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1457. {
  1458. foreach (Permanent permanent in player.GetFieldPermanents())
  1459. {
  1460. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1461. {
  1462. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1463. {
  1464. if (cardEffect1.CanUse(null))
  1465. {
  1466. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1467. {
  1468. if (!TopCard.CanNotBeAffected(cardEffect1))
  1469. {
  1470. return false;
  1471. }
  1472. }
  1473. }
  1474. }
  1475. }
  1476. }
  1477. }
  1478. #endregion
  1479. #region プレイヤーの効果
  1480. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1481. {
  1482. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1483. {
  1484. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1485. {
  1486. if (cardEffect1.CanUse(null))
  1487. {
  1488. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1489. {
  1490. if (!TopCard.CanNotBeAffected(cardEffect1))
  1491. {
  1492. return false;
  1493. }
  1494. }
  1495. }
  1496. }
  1497. }
  1498. }
  1499. #endregion
  1500. #endregion
  1501. if (Defender != null)
  1502. {
  1503. if (Defender.TopCard != null)
  1504. {
  1505. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1506. {
  1507. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1508. {
  1509. if (Defender.IsSuspended)
  1510. {
  1511. return true;
  1512. }
  1513. #region 「対象の防御パーマネントを攻撃できる」効果
  1514. #region 場のパーマネントの効果
  1515. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1516. {
  1517. foreach (Permanent permanent in player.GetFieldPermanents())
  1518. {
  1519. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1520. {
  1521. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1522. {
  1523. if (cardEffect1.CanUse(null))
  1524. {
  1525. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1526. {
  1527. return true;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. }
  1533. }
  1534. #endregion
  1535. #region プレイヤーの効果
  1536. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1537. {
  1538. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1539. {
  1540. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1541. {
  1542. if (cardEffect1.CanUse(null))
  1543. {
  1544. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1545. {
  1546. return true;
  1547. }
  1548. }
  1549. }
  1550. }
  1551. }
  1552. #endregion
  1553. #endregion
  1554. }
  1555. }
  1556. }
  1557. }
  1558. else
  1559. {
  1560. return true;
  1561. }
  1562. }
  1563. return false;
  1564. }
  1565. #endregion
  1566. #region Is Unblockable
  1567. public bool IsUnblockable
  1568. {
  1569. get
  1570. {
  1571. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1572. {
  1573. if (cardEffect is CannotBlockClass)
  1574. {
  1575. if (cardEffect.EffectName == "Can't Block")
  1576. {
  1577. return true;
  1578. }
  1579. }
  1580. }
  1581. return false;
  1582. }
  1583. }
  1584. #endregion
  1585. #region Has Blocker
  1586. public bool HasBlocker
  1587. {
  1588. get
  1589. {
  1590. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1591. {
  1592. #region Effects of permanents in play
  1593. foreach (Permanent permanent in player.GetFieldPermanents())
  1594. {
  1595. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1596. {
  1597. if (cardEffect is IBlockerEffect)
  1598. {
  1599. if (cardEffect.CanTrigger(null))
  1600. {
  1601. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1602. {
  1603. return true;
  1604. }
  1605. }
  1606. }
  1607. }
  1608. }
  1609. #endregion
  1610. #region Effects of faceup security
  1611. foreach (CardSource source in player.SecurityCards)
  1612. {
  1613. if (source.IsFlipped)
  1614. continue;
  1615. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  1616. {
  1617. if (cardEffect is IBlockerEffect)
  1618. {
  1619. if (cardEffect.CanTrigger(null))
  1620. {
  1621. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1622. {
  1623. return true;
  1624. }
  1625. }
  1626. }
  1627. }
  1628. }
  1629. #endregion
  1630. #region プレイヤーの効果
  1631. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1632. {
  1633. if (cardEffect is IBlockerEffect)
  1634. {
  1635. if (cardEffect.CanTrigger(null))
  1636. {
  1637. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1638. {
  1639. return true;
  1640. }
  1641. }
  1642. }
  1643. }
  1644. #endregion
  1645. }
  1646. return false;
  1647. }
  1648. }
  1649. #endregion
  1650. #region Has Jamming
  1651. public bool HasJamming
  1652. {
  1653. get
  1654. {
  1655. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1656. {
  1657. foreach (Permanent permanent in player.GetFieldPermanents())
  1658. {
  1659. #region 場のパーマネントの効果
  1660. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1661. {
  1662. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1663. {
  1664. if (cardEffect.CanTrigger(null))
  1665. {
  1666. if (cardEffect.EffectName == "Jamming")
  1667. {
  1668. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1669. {
  1670. return true;
  1671. }
  1672. }
  1673. }
  1674. }
  1675. }
  1676. #endregion
  1677. }
  1678. #region プレイヤーの効果
  1679. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1680. {
  1681. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1682. {
  1683. if (cardEffect.CanTrigger(null))
  1684. {
  1685. if (cardEffect.EffectName == "Jamming")
  1686. {
  1687. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1688. {
  1689. return true;
  1690. }
  1691. }
  1692. }
  1693. }
  1694. }
  1695. #endregion
  1696. }
  1697. return false;
  1698. }
  1699. }
  1700. #endregion
  1701. #region Has Ice Clad
  1702. public bool HasIceclad
  1703. {
  1704. get
  1705. {
  1706. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1707. {
  1708. #region Ice clad permanent effects
  1709. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  1710. {
  1711. if (cardEffect is IIcecladEffect)
  1712. {
  1713. if (cardEffect.CanTrigger(null))
  1714. {
  1715. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1716. {
  1717. return true;
  1718. }
  1719. }
  1720. }
  1721. }
  1722. #endregion
  1723. #region Ice clad Player Effects
  1724. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1725. {
  1726. if (cardEffect is IIcecladEffect)
  1727. {
  1728. if (cardEffect.CanTrigger(null))
  1729. {
  1730. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1731. {
  1732. return true;
  1733. }
  1734. }
  1735. }
  1736. }
  1737. #endregion
  1738. }
  1739. return false;
  1740. }
  1741. }
  1742. #endregion
  1743. #region Whether this permanent has Pierce
  1744. public bool HasPierce
  1745. {
  1746. get
  1747. {
  1748. if (IsDigimon)
  1749. {
  1750. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  1751. {
  1752. if (cardEffect is ActivateICardEffect)
  1753. {
  1754. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  1755. {
  1756. if (cardEffect.EffectName == "Pierce")
  1757. {
  1758. return true;
  1759. }
  1760. if (cardEffect.EffectName == "Piercing")
  1761. {
  1762. return true;
  1763. }
  1764. }
  1765. }
  1766. }
  1767. }
  1768. return false;
  1769. }
  1770. }
  1771. #endregion
  1772. #region Has Reboot
  1773. public bool HasReboot
  1774. {
  1775. get
  1776. {
  1777. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1778. {
  1779. foreach (Permanent permanent in player.GetFieldPermanents())
  1780. {
  1781. #region 場のパーマネントの効果
  1782. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1783. {
  1784. if (cardEffect is IRebootEffect)
  1785. {
  1786. if (cardEffect.CanTrigger(null))
  1787. {
  1788. if (((IRebootEffect)cardEffect).HasReboot(this))
  1789. {
  1790. return true;
  1791. }
  1792. }
  1793. }
  1794. }
  1795. #endregion
  1796. }
  1797. #region プレイヤーの効果
  1798. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1799. {
  1800. if (cardEffect is IRebootEffect)
  1801. {
  1802. if (cardEffect.CanTrigger(null))
  1803. {
  1804. if (((IRebootEffect)cardEffect).HasReboot(this))
  1805. {
  1806. return true;
  1807. }
  1808. }
  1809. }
  1810. }
  1811. #endregion
  1812. }
  1813. return false;
  1814. }
  1815. }
  1816. #endregion
  1817. #region Has Raid
  1818. public bool HasRaid
  1819. {
  1820. get
  1821. {
  1822. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1823. {
  1824. if (cardEffect is ActivateICardEffect)
  1825. {
  1826. if (cardEffect.EffectName == "Raid")
  1827. {
  1828. return true;
  1829. }
  1830. }
  1831. }
  1832. return false;
  1833. }
  1834. }
  1835. #endregion
  1836. #region Has Rush
  1837. public bool HasRush
  1838. {
  1839. get
  1840. {
  1841. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1842. {
  1843. foreach (Permanent permanent in player.GetFieldPermanents())
  1844. {
  1845. #region 場のパーマネントの効果
  1846. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1847. {
  1848. if (cardEffect is IRushEffect)
  1849. {
  1850. if (cardEffect.CanTrigger(null))
  1851. {
  1852. if (((IRushEffect)cardEffect).HasRush(this))
  1853. {
  1854. return true;
  1855. }
  1856. }
  1857. }
  1858. }
  1859. #endregion
  1860. }
  1861. #region プレイヤーの効果
  1862. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1863. {
  1864. if (cardEffect is IRushEffect)
  1865. {
  1866. if (cardEffect.CanTrigger(null))
  1867. {
  1868. if (((IRushEffect)cardEffect).HasRush(this))
  1869. {
  1870. return true;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. #endregion
  1876. }
  1877. return false;
  1878. }
  1879. }
  1880. #endregion
  1881. #region Has Retaliation
  1882. public bool HasRetaliation
  1883. {
  1884. get
  1885. {
  1886. if (RetaliationCount >= 1)
  1887. {
  1888. return true;
  1889. }
  1890. return false;
  1891. }
  1892. }
  1893. #endregion
  1894. #region 道連れを持つ個数
  1895. public int RetaliationCount
  1896. {
  1897. get
  1898. {
  1899. int count = 0;
  1900. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1901. {
  1902. if (cardEffect is ActivateICardEffect)
  1903. {
  1904. if (cardEffect.EffectName == "Retaliation")
  1905. {
  1906. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1907. {
  1908. count++;
  1909. }
  1910. }
  1911. }
  1912. }
  1913. return count;
  1914. }
  1915. }
  1916. #endregion
  1917. #region Has Fortitude
  1918. public bool HasFortitude
  1919. {
  1920. get
  1921. {
  1922. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1923. {
  1924. if (cardEffect is ActivateICardEffect)
  1925. {
  1926. if (cardEffect.EffectName == "Fortitude")
  1927. {
  1928. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1929. {
  1930. return true;
  1931. }
  1932. }
  1933. }
  1934. }
  1935. return false;
  1936. }
  1937. }
  1938. #endregion
  1939. #region Has Blitz
  1940. public bool HasBlitz
  1941. {
  1942. get
  1943. {
  1944. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  1945. {
  1946. if (cardEffect is ActivateICardEffect)
  1947. {
  1948. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  1949. {
  1950. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1951. {
  1952. if (cardEffect.EffectDiscription.Contains("Blitz"))
  1953. {
  1954. return true;
  1955. }
  1956. }
  1957. }
  1958. }
  1959. }
  1960. return false;
  1961. }
  1962. }
  1963. #endregion
  1964. #region Has Evade
  1965. public bool HasEvade
  1966. {
  1967. get
  1968. {
  1969. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1970. {
  1971. if (cardEffect is ActivateICardEffect)
  1972. {
  1973. Hashtable hashtable = new Hashtable()
  1974. {
  1975. {"Permanents", new List<Permanent>() { this }}
  1976. };
  1977. if (cardEffect.CanTrigger(hashtable))
  1978. {
  1979. if (cardEffect.EffectName == "Evade")
  1980. {
  1981. return true;
  1982. }
  1983. }
  1984. }
  1985. }
  1986. return false;
  1987. }
  1988. }
  1989. #endregion
  1990. #region Has Mind Link
  1991. public bool HasMindLink
  1992. {
  1993. get
  1994. {
  1995. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  1996. {
  1997. if (cardEffect is ActivateICardEffect)
  1998. {
  1999. if (cardEffect.CanTrigger(null))
  2000. {
  2001. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2002. {
  2003. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2004. {
  2005. return true;
  2006. }
  2007. }
  2008. }
  2009. }
  2010. }
  2011. return false;
  2012. }
  2013. }
  2014. #endregion
  2015. #region Has Barrier
  2016. public bool HasBarrier
  2017. {
  2018. get
  2019. {
  2020. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2021. {
  2022. if (cardEffect is ActivateICardEffect)
  2023. {
  2024. Hashtable hashtable = new Hashtable();
  2025. hashtable.Add("Permanents", new List<Permanent>() { this });
  2026. hashtable.Add("battle", new IBattle(null, null, null));
  2027. if (cardEffect.CanTrigger(hashtable))
  2028. {
  2029. if (cardEffect.EffectName == "Barrier")
  2030. {
  2031. return true;
  2032. }
  2033. }
  2034. }
  2035. }
  2036. return false;
  2037. }
  2038. }
  2039. #endregion
  2040. #region Has Alliance
  2041. public bool HasAlliance
  2042. {
  2043. get
  2044. {
  2045. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2046. {
  2047. foreach (Permanent permanent in player.GetFieldPermanents())
  2048. {
  2049. #region Permanent Effects
  2050. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2051. {
  2052. if (cardEffect is IAllianceEffect)
  2053. {
  2054. if (cardEffect.CanTrigger(null))
  2055. {
  2056. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2057. {
  2058. return true;
  2059. }
  2060. }
  2061. }
  2062. }
  2063. #endregion
  2064. }
  2065. #region Player Effects
  2066. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2067. {
  2068. if (cardEffect is IAllianceEffect)
  2069. {
  2070. if (cardEffect.CanTrigger(null))
  2071. {
  2072. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2073. {
  2074. return true;
  2075. }
  2076. }
  2077. }
  2078. }
  2079. #endregion
  2080. }
  2081. return false;
  2082. }
  2083. }
  2084. #endregion
  2085. #region Has Collision
  2086. public bool HasCollision
  2087. {
  2088. get
  2089. {
  2090. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2091. {
  2092. if (cardEffect is ActivateICardEffect)
  2093. {
  2094. if (cardEffect.EffectName == "Collision")
  2095. {
  2096. return true;
  2097. }
  2098. }
  2099. }
  2100. return false;
  2101. }
  2102. }
  2103. #endregion
  2104. #region Has Partition
  2105. public bool HasPartition
  2106. {
  2107. get
  2108. {
  2109. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2110. {
  2111. if (cardEffect is ActivateICardEffect)
  2112. {
  2113. if (cardEffect.EffectName == "Partition")
  2114. {
  2115. return true;
  2116. }
  2117. }
  2118. }
  2119. return false;
  2120. }
  2121. }
  2122. #endregion
  2123. #region 消滅時効化を持つか
  2124. public bool HasOnDeletionEffect
  2125. {
  2126. get
  2127. {
  2128. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2129. {
  2130. if (cardEffect is ActivateICardEffect)
  2131. {
  2132. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2133. {
  2134. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2135. {
  2136. if (cardEffect.IsOnDeletion)
  2137. {
  2138. return true;
  2139. }
  2140. }
  2141. }
  2142. }
  2143. }
  2144. return false;
  2145. }
  2146. }
  2147. #endregion
  2148. #region バトルしているか
  2149. public IBattle battle { get; set; } = null;
  2150. #endregion
  2151. #region Can Be Destroyed
  2152. public bool CanBeDestroyed()
  2153. {
  2154. #region 消滅しない効果
  2155. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2156. {
  2157. foreach (Permanent permanent in player.GetFieldPermanents())
  2158. {
  2159. #region 場のパーマネントの効果
  2160. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2161. {
  2162. if (cardEffect is ICanNotBeDestroyedEffect)
  2163. {
  2164. if (cardEffect.CanUse(null))
  2165. {
  2166. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2167. {
  2168. return false;
  2169. }
  2170. }
  2171. }
  2172. }
  2173. #endregion
  2174. }
  2175. #region プレイヤーの効果
  2176. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2177. {
  2178. if (cardEffect is ICanNotBeDestroyedEffect)
  2179. {
  2180. if (cardEffect.CanUse(null))
  2181. {
  2182. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2183. {
  2184. return false;
  2185. }
  2186. }
  2187. }
  2188. }
  2189. #endregion
  2190. }
  2191. #endregion
  2192. return true;
  2193. }
  2194. #endregion
  2195. #region このデジモンが戦闘によって消滅するか
  2196. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2197. {
  2198. if (!CanBeDestroyed())
  2199. {
  2200. return false;
  2201. }
  2202. #region 戦闘で消滅しない効果
  2203. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2204. {
  2205. foreach (Permanent permanent in player.GetFieldPermanents())
  2206. {
  2207. #region 場のパーマネントの効果
  2208. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2209. {
  2210. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2211. {
  2212. if (cardEffect.CanUse(null))
  2213. {
  2214. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2215. {
  2216. return false;
  2217. }
  2218. }
  2219. }
  2220. }
  2221. #endregion
  2222. }
  2223. #region プレイヤーの効果
  2224. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2225. {
  2226. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2227. {
  2228. if (cardEffect.CanUse(null))
  2229. {
  2230. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2231. {
  2232. return false;
  2233. }
  2234. }
  2235. }
  2236. }
  2237. #endregion
  2238. }
  2239. #endregion
  2240. return true;
  2241. }
  2242. #endregion
  2243. #region このパーマネントが効果で消滅するか
  2244. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2245. {
  2246. if (this.TopCard != null)
  2247. {
  2248. if (this.TopCard.CanNotBeAffected(cardEffect))
  2249. {
  2250. return false;
  2251. }
  2252. if (!CanBeDestroyed())
  2253. {
  2254. return false;
  2255. }
  2256. #region 効果で消滅しない効果
  2257. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2258. {
  2259. foreach (Permanent permanent in player.GetFieldPermanents())
  2260. {
  2261. #region 場のパーマネントの効果
  2262. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2263. {
  2264. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2265. {
  2266. if (cardEffect1.CanUse(null))
  2267. {
  2268. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2269. {
  2270. return false;
  2271. }
  2272. }
  2273. }
  2274. }
  2275. #endregion
  2276. }
  2277. #region プレイヤーの効果
  2278. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2279. {
  2280. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2281. {
  2282. if (cardEffect1.CanUse(null))
  2283. {
  2284. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2285. {
  2286. return false;
  2287. }
  2288. }
  2289. }
  2290. }
  2291. #endregion
  2292. }
  2293. #endregion
  2294. }
  2295. return true;
  2296. }
  2297. #endregion
  2298. #region Can Leave Field
  2299. public bool CanBeRemoved()
  2300. {
  2301. #region Effect that never disappears
  2302. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2303. {
  2304. foreach (Permanent permanent in player.GetFieldPermanents())
  2305. {
  2306. #region Effects of permanents in play
  2307. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2308. {
  2309. if (cardEffect is ICanNotBeRemovedEffect)
  2310. {
  2311. if (cardEffect.CanUse(null))
  2312. {
  2313. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2314. {
  2315. return false;
  2316. }
  2317. }
  2318. }
  2319. }
  2320. #endregion
  2321. }
  2322. #region player effect
  2323. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2324. {
  2325. if (cardEffect is ICanNotBeRemovedEffect)
  2326. {
  2327. if (cardEffect.CanUse(null))
  2328. {
  2329. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2330. {
  2331. return false;
  2332. }
  2333. }
  2334. }
  2335. }
  2336. #endregion
  2337. }
  2338. #endregion
  2339. return true;
  2340. }
  2341. #endregion
  2342. #region トークンかどうか
  2343. public bool IsToken
  2344. {
  2345. get
  2346. {
  2347. if (TopCard != null)
  2348. {
  2349. if (TopCard.IsToken)
  2350. {
  2351. return true;
  2352. }
  2353. }
  2354. return false;
  2355. }
  2356. }
  2357. #endregion
  2358. #region そのパーマネントが消滅・バウンス待機状態か
  2359. public bool willBeRemoveField { get; set; } = false;
  2360. #endregion
  2361. #region Is a Digimon card
  2362. public bool IsDigimon
  2363. {
  2364. get
  2365. {
  2366. if (TopCard != null)
  2367. {
  2368. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2369. {
  2370. return true;
  2371. }
  2372. #region Effect of treating it as a Digimon
  2373. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2374. {
  2375. foreach (Permanent permanent in player.GetFieldPermanents())
  2376. {
  2377. #region Effects of permanents in play
  2378. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2379. {
  2380. if (cardEffect is ITreatAsDigimonEffect)
  2381. {
  2382. if (cardEffect.CanTrigger(null))
  2383. {
  2384. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2385. {
  2386. return true;
  2387. }
  2388. }
  2389. }
  2390. }
  2391. #endregion
  2392. }
  2393. #region player effect
  2394. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2395. {
  2396. if (cardEffect is ITreatAsDigimonEffect)
  2397. {
  2398. if (cardEffect.CanTrigger(null))
  2399. {
  2400. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2401. {
  2402. return true;
  2403. }
  2404. }
  2405. }
  2406. }
  2407. #endregion
  2408. }
  2409. #endregion
  2410. }
  2411. return false;
  2412. }
  2413. }
  2414. #endregion
  2415. #region Is a Tamer card
  2416. public bool IsTamer
  2417. {
  2418. get
  2419. {
  2420. if (TopCard != null)
  2421. {
  2422. if (TopCard.IsTamer)
  2423. {
  2424. return true;
  2425. }
  2426. }
  2427. return false;
  2428. }
  2429. }
  2430. #endregion
  2431. #region Is an Option card
  2432. public bool IsOption
  2433. {
  2434. get
  2435. {
  2436. if (TopCard != null)
  2437. {
  2438. if (TopCard.IsOption)
  2439. {
  2440. return true;
  2441. }
  2442. }
  2443. return false;
  2444. }
  2445. }
  2446. #endregion
  2447. #region Levels handled by Jogress
  2448. public List<int> Levels_ForJogress(CardSource cardSource)
  2449. {
  2450. List<int> levels = new List<int>();
  2451. if (cardSource != null)
  2452. {
  2453. if (cardSource.HasLevel)
  2454. {
  2455. levels.Add(this.Level);
  2456. }
  2457. #region Effect of "adding levels handled by jogless evolution"
  2458. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2459. {
  2460. foreach (Permanent permanent in player.GetFieldPermanents())
  2461. {
  2462. #region Effects of permanents in play
  2463. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2464. {
  2465. if (cardEffect is IAddJogressLevelsEffect)
  2466. {
  2467. if (cardEffect.CanUse(null))
  2468. {
  2469. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2470. {
  2471. levels.Add(level);
  2472. }
  2473. }
  2474. }
  2475. }
  2476. #endregion
  2477. }
  2478. #region player effect
  2479. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2480. {
  2481. if (cardEffect is IAddJogressLevelsEffect)
  2482. {
  2483. if (cardEffect.CanUse(null))
  2484. {
  2485. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2486. {
  2487. levels.Add(level);
  2488. }
  2489. }
  2490. }
  2491. }
  2492. #endregion
  2493. }
  2494. #endregion
  2495. }
  2496. return levels;
  2497. }
  2498. #endregion
  2499. #region Names handled by Jogress
  2500. public List<string> Names_ForDNA(CardSource cardSource)
  2501. {
  2502. List<string> names = new List<string>();
  2503. if (cardSource != null)
  2504. {
  2505. foreach(string name in cardSource.CardNames)
  2506. names.Add(name);
  2507. #region Effect of "adding names handled by DNA evolution"
  2508. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2509. {
  2510. foreach (Permanent permanent in player.GetFieldPermanents())
  2511. {
  2512. #region Effects of permanents in play
  2513. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2514. {
  2515. if (cardEffect is IAddDNANamesEffect)
  2516. {
  2517. if (cardEffect.CanUse(null))
  2518. {
  2519. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2520. {
  2521. names.Add(name);
  2522. }
  2523. }
  2524. }
  2525. }
  2526. #endregion
  2527. }
  2528. #region player effect
  2529. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2530. {
  2531. if (cardEffect is IAddDNANamesEffect)
  2532. {
  2533. if (cardEffect.CanUse(null))
  2534. {
  2535. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2536. {
  2537. names.Add(name);
  2538. }
  2539. }
  2540. }
  2541. }
  2542. #endregion
  2543. }
  2544. #endregion
  2545. }
  2546. return names;
  2547. }
  2548. #endregion
  2549. #region バトルで消滅したか
  2550. public bool IsDestroyedByBattle { get; set; } = false;
  2551. #endregion
  2552. #region 消滅に使用された効果
  2553. public ICardEffect DestroyingEffect { get; set; } = null;
  2554. #endregion
  2555. #region 他のパーマネントの下に置くのに使用された効果
  2556. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2557. #endregion
  2558. #region 手札バウンス に使用された効果
  2559. public ICardEffect HandBounceEffect { get; set; } = null;
  2560. #endregion
  2561. #region 山札バウンス に使用された効果
  2562. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2563. #endregion
  2564. #region 登場に使用された効果
  2565. public ICardEffect PlayingEffect { get; set; } = null;
  2566. #endregion
  2567. #region 進化に使用された効果
  2568. public ICardEffect DigivolvingEffect { get; set; } = null;
  2569. #endregion
  2570. #region Whether this digimon is placed in the trash by not having a DP
  2571. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2572. #endregion
  2573. #region Whether this permanent can suspend
  2574. public bool CanSuspend
  2575. {
  2576. get
  2577. {
  2578. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2579. {
  2580. #region Effects of field permanents
  2581. foreach (Permanent permanent in player.GetFieldPermanents())
  2582. {
  2583. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2584. {
  2585. if (cardEffect is ICanNotSuspendEffect)
  2586. {
  2587. if (cardEffect.CanUse(null))
  2588. {
  2589. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2590. {
  2591. return false;
  2592. }
  2593. }
  2594. }
  2595. }
  2596. }
  2597. #endregion
  2598. #region Effects of players
  2599. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2600. {
  2601. if (cardEffect is ICanNotSuspendEffect)
  2602. {
  2603. if (cardEffect.CanUse(null))
  2604. {
  2605. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2606. {
  2607. return false;
  2608. }
  2609. }
  2610. }
  2611. }
  2612. #endregion
  2613. }
  2614. return true;
  2615. }
  2616. }
  2617. #endregion
  2618. #region このデジモンのアタックの対象が変更できるか
  2619. public bool CanSwitchAttackTarget
  2620. {
  2621. get
  2622. {
  2623. #region アタックの対象が変更できない効果
  2624. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2625. {
  2626. foreach (Permanent permanent in player.GetFieldPermanents())
  2627. {
  2628. #region 場のパーマネントの効果
  2629. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2630. {
  2631. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2632. {
  2633. if (cardEffect.CanUse(null))
  2634. {
  2635. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2636. {
  2637. return false;
  2638. }
  2639. }
  2640. }
  2641. }
  2642. #endregion
  2643. }
  2644. #region プレイヤーの効果
  2645. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2646. {
  2647. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2648. {
  2649. if (cardEffect.CanUse(null))
  2650. {
  2651. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2652. {
  2653. return false;
  2654. }
  2655. }
  2656. }
  2657. }
  2658. #endregion
  2659. }
  2660. #endregion
  2661. return true;
  2662. }
  2663. }
  2664. #endregion
  2665. #region このデジモンを場からデジクロス条件の代わりにできるか
  2666. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  2667. {
  2668. #region デジクロス条件の代わりにできる効果
  2669. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2670. {
  2671. foreach (Permanent permanent in player.GetFieldPermanents())
  2672. {
  2673. #region 場のパーマネントの効果
  2674. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2675. {
  2676. if (cardEffect is ICanSelectDigiXrosEffect)
  2677. {
  2678. if (cardEffect.CanUse(null))
  2679. {
  2680. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2681. {
  2682. return true;
  2683. }
  2684. }
  2685. }
  2686. }
  2687. #endregion
  2688. }
  2689. #region プレイヤーの効果
  2690. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2691. {
  2692. if (cardEffect is ICanSelectDigiXrosEffect)
  2693. {
  2694. if (cardEffect.CanUse(null))
  2695. {
  2696. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2697. {
  2698. return true;
  2699. }
  2700. }
  2701. }
  2702. }
  2703. #endregion
  2704. }
  2705. #endregion
  2706. return false;
  2707. }
  2708. #endregion
  2709. #region 登場した直後のLevel
  2710. public int LevelJustAfterPlayed { get; set; } = -1;
  2711. #endregion
  2712. #region 登場した直後のPlay Cost
  2713. public int PlayCostJustAfterPlayed { get; set; } = -1;
  2714. #endregion
  2715. #region 登場した直後のCardNames
  2716. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  2717. #endregion
  2718. #region 進化した直後のCardNames
  2719. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  2720. #endregion
  2721. #region 登場した直後のTraits
  2722. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  2723. #endregion
  2724. #region 場を離れる直前のDP
  2725. public int DPJustBeforeRemoveField { get; set; } = -1;
  2726. #endregion
  2727. #region 場を離れる直前のLevel
  2728. public int LevelJustBeforeRemoveField { get; set; } = -1;
  2729. #endregion
  2730. #region 場を離れる直前のCost
  2731. public int CostJustBeforeRemoveField { get; set; } = -1;
  2732. #endregion
  2733. #region 場を離れる直前のカード名
  2734. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  2735. #endregion
  2736. #region Card Traits Just Before Removed Field
  2737. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  2738. #endregion
  2739. #region バースト進化で手札に戻ったか
  2740. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  2741. #endregion
  2742. #region バースト進化したか
  2743. public bool IsBurstDigivolved { get; set; } = false;
  2744. #endregion
  2745. #region 効果で場に出たオプションか
  2746. public bool IsPlayedOptionPermanent { get; set; } = false;
  2747. #endregion
  2748. #region 進化元を持たないか
  2749. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  2750. #endregion
  2751. #region Digivolution cards' colors
  2752. public List<CardColor> DigivolutionCardsColors
  2753. {
  2754. get
  2755. {
  2756. List<CardColor> cardColors = new List<CardColor>();
  2757. foreach (CardSource cardSource in DigivolutionCards)
  2758. {
  2759. foreach (CardColor cardColor in cardSource.CardColors)
  2760. {
  2761. if (!cardColors.Contains(cardColor))
  2762. {
  2763. cardColors.Add(cardColor);
  2764. }
  2765. }
  2766. }
  2767. return cardColors.Distinct().ToList();
  2768. }
  2769. }
  2770. #endregion
  2771. #region Show "Unsuspend" effect object
  2772. public void ShowUnsuspendEffect()
  2773. {
  2774. if (TopCard != null)
  2775. {
  2776. if (ShowingPermanentCard != null)
  2777. {
  2778. if (ShowingPermanentCard.WillUntapObject != null)
  2779. {
  2780. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  2781. ShowingPermanentCard.WillUntapObject.SetActive(true);
  2782. }
  2783. }
  2784. }
  2785. }
  2786. #endregion
  2787. #region Show "Return to deck" effect object
  2788. public void ShowDeckBounceEffect()
  2789. {
  2790. if (TopCard != null)
  2791. {
  2792. if (willBeRemoveField)
  2793. {
  2794. if (ShowingPermanentCard != null)
  2795. {
  2796. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2797. {
  2798. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  2799. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  2800. }
  2801. }
  2802. }
  2803. }
  2804. }
  2805. #endregion
  2806. #region Hide "Return to deck" effect object
  2807. public void HideDeckBounceEffect()
  2808. {
  2809. if (TopCard != null)
  2810. {
  2811. if (ShowingPermanentCard != null)
  2812. {
  2813. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2814. {
  2815. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  2816. }
  2817. }
  2818. }
  2819. }
  2820. #endregion
  2821. #region Show "Return to hand" effect object
  2822. public void ShowHandBounceEffect()
  2823. {
  2824. if (TopCard != null)
  2825. {
  2826. if (willBeRemoveField)
  2827. {
  2828. if (ShowingPermanentCard != null)
  2829. {
  2830. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2831. {
  2832. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  2833. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  2834. }
  2835. }
  2836. }
  2837. }
  2838. }
  2839. #endregion
  2840. #region Hide "Return to hand" effect object
  2841. public void HideHandBounceEffect()
  2842. {
  2843. if (TopCard != null)
  2844. {
  2845. if (ShowingPermanentCard != null)
  2846. {
  2847. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2848. {
  2849. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  2850. }
  2851. }
  2852. }
  2853. }
  2854. #endregion
  2855. #region Show "Delete" effect object
  2856. public void ShowDeleteEffect()
  2857. {
  2858. if (TopCard != null)
  2859. {
  2860. if (willBeRemoveField)
  2861. {
  2862. if (ShowingPermanentCard != null)
  2863. {
  2864. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2865. {
  2866. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  2867. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  2868. }
  2869. }
  2870. }
  2871. }
  2872. }
  2873. #endregion
  2874. #region Hide "Delete" effect object
  2875. public void HideDeleteEffect()
  2876. {
  2877. if (TopCard != null)
  2878. {
  2879. if (ShowingPermanentCard != null)
  2880. {
  2881. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2882. {
  2883. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  2884. }
  2885. }
  2886. }
  2887. }
  2888. #endregion
  2889. #region Show "Remove Field" effect object
  2890. public void ShowWillRemoveFieldEffect()
  2891. {
  2892. if (TopCard != null)
  2893. {
  2894. if (willBeRemoveField)
  2895. {
  2896. if (ShowingPermanentCard != null)
  2897. {
  2898. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2899. {
  2900. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  2901. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  2902. }
  2903. }
  2904. }
  2905. }
  2906. }
  2907. #endregion
  2908. #region Hide "Remove Field" effect object
  2909. public void HideWillRemoveFieldEffect()
  2910. {
  2911. if (TopCard != null)
  2912. {
  2913. if (ShowingPermanentCard != null)
  2914. {
  2915. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2916. {
  2917. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  2918. }
  2919. }
  2920. }
  2921. }
  2922. #endregion
  2923. #region Show "Digivolution" effect object
  2924. public void ShowWillEvolutionEffect()
  2925. {
  2926. if (TopCard != null)
  2927. {
  2928. if (ShowingPermanentCard != null)
  2929. {
  2930. if (ShowingPermanentCard.WillEvolutionObject != null)
  2931. {
  2932. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  2933. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  2934. }
  2935. }
  2936. }
  2937. }
  2938. #endregion
  2939. #region Hide "Digivolution" effect object
  2940. public void HideWillEvolutionEffect()
  2941. {
  2942. if (TopCard != null)
  2943. {
  2944. if (ShowingPermanentCard != null)
  2945. {
  2946. if (ShowingPermanentCard.WillEvolutionObject != null)
  2947. {
  2948. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  2949. }
  2950. }
  2951. }
  2952. }
  2953. #endregion
  2954. }