Permanent.cs 94 KB

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