Permanent.cs 121 KB

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