Permanent.cs 120 KB

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