Permanent.cs 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using System.Linq;
  6. public class Permanent
  7. {
  8. public Permanent(List<CardSource> cardSources)
  9. {
  10. SetCardSources(cardSources);
  11. }
  12. public void SetCardSources(List<CardSource> cardSources)
  13. {
  14. List<CardSource> newCardSources = cardSources.Clone();
  15. newCardSources.Reverse();
  16. foreach (CardSource cardSource in newCardSources)
  17. {
  18. AddCardSource(cardSource);
  19. }
  20. }
  21. public FieldCardFrame PermanentFrame
  22. {
  23. get
  24. {
  25. if (TopCard != null)
  26. {
  27. int index = Array.IndexOf(TopCard.Owner.FieldPermanents, this);
  28. if (0 <= index && index <= TopCard.Owner.fieldCardFrames.Count - 1)
  29. {
  30. return TopCard.Owner.fieldCardFrames[index];
  31. }
  32. }
  33. return null;
  34. }
  35. }
  36. public bool oldIsTapped_playCard { get; set; }
  37. #region Level
  38. public int Level
  39. {
  40. get
  41. {
  42. int Level = 0;
  43. if (TopCard != null)
  44. {
  45. Level = TopCard.Level;
  46. if (!TopCard.HasLevel)
  47. {
  48. Level = 1145140;
  49. }
  50. #region レベルを変更する効果
  51. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  52. {
  53. foreach (Permanent permanent in player.GetFieldPermanents())
  54. {
  55. #region 場のパーマネントの効果
  56. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  57. {
  58. if (cardEffect is IChangePermanentLevelEffect)
  59. {
  60. if (cardEffect.CanUse(null))
  61. {
  62. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  63. }
  64. }
  65. }
  66. #endregion
  67. }
  68. #region プレイヤーの効果
  69. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  70. {
  71. if (cardEffect is IChangePermanentLevelEffect)
  72. {
  73. if (cardEffect.CanUse(null))
  74. {
  75. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  76. }
  77. }
  78. }
  79. #endregion
  80. }
  81. #endregion
  82. }
  83. return Level;
  84. }
  85. }
  86. #endregion
  87. #region Place all evolution sources in the trash
  88. public IEnumerator DiscardEvoRoots(bool ignoreOverflow = false, bool putToTrash = true)
  89. {
  90. List<CardSource> evoRoots = DigivolutionCards.Clone();
  91. if (!ignoreOverflow)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(evoRoots).Overflow());
  94. }
  95. foreach (CardSource cardSource1 in evoRoots)
  96. {
  97. if (putToTrash)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource1));
  100. }
  101. else
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource1));
  104. }
  105. }
  106. }
  107. #endregion
  108. #region Whether this permanent has DP
  109. public bool HasDP
  110. {
  111. get
  112. {
  113. if (TopCard == null)
  114. {
  115. return false;
  116. }
  117. if (!IsDigimon)
  118. {
  119. return false;
  120. }
  121. if (!TopCard.HasDP && TopCard.IsDigiEgg)
  122. {
  123. return false;
  124. }
  125. #region Effect of not having DP
  126. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  127. {
  128. foreach (Permanent permanent in player.GetFieldPermanents())
  129. {
  130. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  131. {
  132. if (cardEffect1 is IDontHaveDPEffect)
  133. {
  134. if (cardEffect1.CanUse(null))
  135. {
  136. if (((IDontHaveDPEffect)cardEffect1).DontHaveDP(this))
  137. {
  138. return false;
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. #endregion
  146. return true;
  147. }
  148. }
  149. #endregion
  150. #region Base DP
  151. public int BaseDP
  152. {
  153. get
  154. {
  155. int BaseDP = 0;
  156. if (HasDP)
  157. {
  158. BaseDP = TopCard.BaseCardDP;
  159. #region 基礎DPを変更する効果
  160. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  161. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  162. {
  163. foreach (Permanent permanent in player.GetFieldPermanents())
  164. {
  165. #region 場のパーマネントの効果
  166. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  167. {
  168. if (cardEffect is IChangeBaseDPEffect)
  169. {
  170. if (cardEffect.CanUse(null))
  171. {
  172. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  173. {
  174. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  175. {
  176. if (this.ImmuneFromDPMinus(cardEffect))
  177. {
  178. continue;
  179. }
  180. }
  181. if (!TopCard.CanNotBeAffected(cardEffect))
  182. {
  183. cardEffects_ChangeDP.Add(cardEffect);
  184. }
  185. }
  186. }
  187. }
  188. }
  189. #endregion
  190. }
  191. #region プレイヤーの効果
  192. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  193. {
  194. if (cardEffect is IChangeBaseDPEffect)
  195. {
  196. if (cardEffect.CanUse(null))
  197. {
  198. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  199. {
  200. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  201. {
  202. if (this.ImmuneFromDPMinus(cardEffect))
  203. {
  204. continue;
  205. }
  206. }
  207. if (!TopCard.CanNotBeAffected(cardEffect))
  208. {
  209. cardEffects_ChangeDP.Add(cardEffect);
  210. }
  211. }
  212. }
  213. }
  214. }
  215. #endregion
  216. }
  217. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  218. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  219. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  220. {
  221. if (cardEffect is IChangeBaseDPEffect)
  222. {
  223. if (cardEffect.CanUse(null))
  224. {
  225. if (((IChangeBaseDPEffect)cardEffect).IsUpDown())
  226. {
  227. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  228. }
  229. else
  230. {
  231. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  232. }
  233. }
  234. }
  235. }
  236. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  237. {
  238. if (cardEffect is IChangeBaseDPEffect)
  239. {
  240. if (cardEffect.CanUse(null))
  241. {
  242. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  243. }
  244. }
  245. }
  246. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  247. {
  248. if (cardEffect is IChangeBaseDPEffect)
  249. {
  250. if (cardEffect.CanUse(null))
  251. {
  252. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  253. }
  254. }
  255. }
  256. #endregion
  257. if (BaseDP < 0)
  258. {
  259. BaseDP = 0;
  260. }
  261. }
  262. return BaseDP;
  263. }
  264. }
  265. #endregion
  266. #region DP
  267. public int DP
  268. {
  269. get
  270. {
  271. int DP = -1;
  272. if (HasDP)
  273. {
  274. DP = BaseDP;
  275. #region DPを変更する効果
  276. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  277. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  278. {
  279. 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 Permanent effect list
  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 "Unblockable" effect
  1224. #region Effects of permanents in play
  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. return false;
  1238. if (!TopCard.CanNotBeAffected(cardEffect))
  1239. {
  1240. return false;
  1241. }
  1242. }
  1243. }
  1244. }
  1245. }
  1246. }
  1247. }
  1248. #endregion
  1249. #region player effect
  1250. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1251. {
  1252. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1253. {
  1254. if (cardEffect is ICannotBlockEffect)
  1255. {
  1256. if (cardEffect.CanUse(null))
  1257. {
  1258. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1259. {
  1260. if (!TopCard.CanNotBeAffected(cardEffect))
  1261. {
  1262. return false;
  1263. }
  1264. }
  1265. }
  1266. }
  1267. }
  1268. }
  1269. #endregion
  1270. #endregion
  1271. return true;
  1272. }
  1273. #endregion
  1274. #region 対象のパーマネントを攻撃できるか
  1275. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false)
  1276. {
  1277. if (TopCard != null)
  1278. {
  1279. if (!IsDigimon)
  1280. {
  1281. return false;
  1282. }
  1283. if (!withoutTap)
  1284. {
  1285. if (IsSuspended)
  1286. {
  1287. return false;
  1288. }
  1289. if (!CanSuspend)
  1290. {
  1291. return false;
  1292. }
  1293. }
  1294. if (PermanentFrame != null)
  1295. {
  1296. if (!PermanentFrame.IsBattleAreaFrame())
  1297. {
  1298. return false;
  1299. }
  1300. }
  1301. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1302. {
  1303. if (!HasRush)
  1304. {
  1305. return false;
  1306. }
  1307. }
  1308. #region 「対象の防御パーマネントを攻撃できない」効果
  1309. #region 場のパーマネントの効果
  1310. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1311. {
  1312. foreach (Permanent permanent in player.GetFieldPermanents())
  1313. {
  1314. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1315. {
  1316. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1317. {
  1318. if (cardEffect1.CanUse(null))
  1319. {
  1320. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1321. {
  1322. if (!TopCard.CanNotBeAffected(cardEffect1))
  1323. {
  1324. return false;
  1325. }
  1326. }
  1327. }
  1328. }
  1329. }
  1330. }
  1331. }
  1332. #endregion
  1333. #region プレイヤーの効果
  1334. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1335. {
  1336. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1337. {
  1338. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1339. {
  1340. if (cardEffect1.CanUse(null))
  1341. {
  1342. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1343. {
  1344. if (!TopCard.CanNotBeAffected(cardEffect1))
  1345. {
  1346. return false;
  1347. }
  1348. }
  1349. }
  1350. }
  1351. }
  1352. }
  1353. #endregion
  1354. #endregion
  1355. if (Defender != null)
  1356. {
  1357. if (Defender.TopCard != null)
  1358. {
  1359. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1360. {
  1361. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1362. {
  1363. if (Defender.IsSuspended)
  1364. {
  1365. return true;
  1366. }
  1367. #region 「対象の防御パーマネントを攻撃できる」効果
  1368. #region 場のパーマネントの効果
  1369. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1370. {
  1371. foreach (Permanent permanent in player.GetFieldPermanents())
  1372. {
  1373. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1374. {
  1375. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1376. {
  1377. if (cardEffect1.CanUse(null))
  1378. {
  1379. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1380. {
  1381. return true;
  1382. }
  1383. }
  1384. }
  1385. }
  1386. }
  1387. }
  1388. #endregion
  1389. #region プレイヤーの効果
  1390. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1391. {
  1392. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1393. {
  1394. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1395. {
  1396. if (cardEffect1.CanUse(null))
  1397. {
  1398. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1399. {
  1400. return true;
  1401. }
  1402. }
  1403. }
  1404. }
  1405. }
  1406. #endregion
  1407. #endregion
  1408. }
  1409. }
  1410. }
  1411. }
  1412. else
  1413. {
  1414. return true;
  1415. }
  1416. }
  1417. return false;
  1418. }
  1419. #endregion
  1420. #region Is Unblockable
  1421. public bool IsUnblockable
  1422. {
  1423. get
  1424. {
  1425. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1426. {
  1427. if (cardEffect is CannotBlockClass)
  1428. {
  1429. if (cardEffect.EffectName == "Can't Block")
  1430. {
  1431. return true;
  1432. }
  1433. }
  1434. }
  1435. return false;
  1436. }
  1437. }
  1438. #endregion
  1439. #region Has Blocker
  1440. public bool HasBlocker
  1441. {
  1442. get
  1443. {
  1444. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1445. {
  1446. foreach (Permanent permanent in player.GetFieldPermanents())
  1447. {
  1448. #region 場のパーマネントの効果
  1449. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1450. {
  1451. if (cardEffect is IBlockerEffect)
  1452. {
  1453. if (cardEffect.CanTrigger(null))
  1454. {
  1455. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1456. {
  1457. return true;
  1458. }
  1459. }
  1460. }
  1461. }
  1462. #endregion
  1463. }
  1464. #region プレイヤーの効果
  1465. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1466. {
  1467. if (cardEffect is IBlockerEffect)
  1468. {
  1469. if (cardEffect.CanTrigger(null))
  1470. {
  1471. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1472. {
  1473. return true;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. #endregion
  1479. }
  1480. return false;
  1481. }
  1482. }
  1483. #endregion
  1484. #region Has Jamming
  1485. public bool HasJamming
  1486. {
  1487. get
  1488. {
  1489. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1490. {
  1491. foreach (Permanent permanent in player.GetFieldPermanents())
  1492. {
  1493. #region 場のパーマネントの効果
  1494. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1495. {
  1496. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1497. {
  1498. if (cardEffect.CanTrigger(null))
  1499. {
  1500. if (cardEffect.EffectName == "Jamming")
  1501. {
  1502. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1503. {
  1504. return true;
  1505. }
  1506. }
  1507. }
  1508. }
  1509. }
  1510. #endregion
  1511. }
  1512. #region プレイヤーの効果
  1513. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1514. {
  1515. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1516. {
  1517. if (cardEffect.CanTrigger(null))
  1518. {
  1519. if (cardEffect.EffectName == "Jamming")
  1520. {
  1521. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1522. {
  1523. return true;
  1524. }
  1525. }
  1526. }
  1527. }
  1528. }
  1529. #endregion
  1530. }
  1531. return false;
  1532. }
  1533. }
  1534. #endregion
  1535. #region Whether this permanent has Pierce
  1536. public bool HasPierce
  1537. {
  1538. get
  1539. {
  1540. if (IsDigimon)
  1541. {
  1542. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  1543. {
  1544. if (cardEffect is ActivateICardEffect)
  1545. {
  1546. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  1547. {
  1548. if (cardEffect.EffectName == "Pierce")
  1549. {
  1550. return true;
  1551. }
  1552. if (cardEffect.EffectName == "Piercing")
  1553. {
  1554. return true;
  1555. }
  1556. }
  1557. }
  1558. }
  1559. }
  1560. return false;
  1561. }
  1562. }
  1563. #endregion
  1564. #region 再起動を持つか
  1565. public bool HasReboot
  1566. {
  1567. get
  1568. {
  1569. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1570. {
  1571. foreach (Permanent permanent in player.GetFieldPermanents())
  1572. {
  1573. #region 場のパーマネントの効果
  1574. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1575. {
  1576. if (cardEffect is IRebootEffect)
  1577. {
  1578. if (cardEffect.CanTrigger(null))
  1579. {
  1580. if (((IRebootEffect)cardEffect).HasReboot(this))
  1581. {
  1582. return true;
  1583. }
  1584. }
  1585. }
  1586. }
  1587. #endregion
  1588. }
  1589. #region プレイヤーの効果
  1590. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1591. {
  1592. if (cardEffect is IRebootEffect)
  1593. {
  1594. if (cardEffect.CanTrigger(null))
  1595. {
  1596. if (((IRebootEffect)cardEffect).HasReboot(this))
  1597. {
  1598. return true;
  1599. }
  1600. }
  1601. }
  1602. }
  1603. #endregion
  1604. }
  1605. return false;
  1606. }
  1607. }
  1608. #endregion
  1609. #region 突進を持つか
  1610. public bool HasRaid
  1611. {
  1612. get
  1613. {
  1614. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1615. {
  1616. if (cardEffect is ActivateICardEffect)
  1617. {
  1618. if (cardEffect.EffectName == "Raid")
  1619. {
  1620. return true;
  1621. }
  1622. }
  1623. }
  1624. return false;
  1625. }
  1626. }
  1627. #endregion
  1628. #region 速攻を持つか
  1629. public bool HasRush
  1630. {
  1631. get
  1632. {
  1633. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1634. {
  1635. foreach (Permanent permanent in player.GetFieldPermanents())
  1636. {
  1637. #region 場のパーマネントの効果
  1638. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1639. {
  1640. if (cardEffect is IRushEffect)
  1641. {
  1642. if (cardEffect.CanTrigger(null))
  1643. {
  1644. if (((IRushEffect)cardEffect).HasRush(this))
  1645. {
  1646. return true;
  1647. }
  1648. }
  1649. }
  1650. }
  1651. #endregion
  1652. }
  1653. #region プレイヤーの効果
  1654. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1655. {
  1656. if (cardEffect is IRushEffect)
  1657. {
  1658. if (cardEffect.CanTrigger(null))
  1659. {
  1660. if (((IRushEffect)cardEffect).HasRush(this))
  1661. {
  1662. return true;
  1663. }
  1664. }
  1665. }
  1666. }
  1667. #endregion
  1668. }
  1669. return false;
  1670. }
  1671. }
  1672. #endregion
  1673. #region 道連れを持つか
  1674. public bool HasRetaliation
  1675. {
  1676. get
  1677. {
  1678. if (RetaliationCount >= 1)
  1679. {
  1680. return true;
  1681. }
  1682. return false;
  1683. }
  1684. }
  1685. #endregion
  1686. #region 道連れを持つ個数
  1687. public int RetaliationCount
  1688. {
  1689. get
  1690. {
  1691. int count = 0;
  1692. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1693. {
  1694. if (cardEffect is ActivateICardEffect)
  1695. {
  1696. if (cardEffect.EffectName == "Retaliation")
  1697. {
  1698. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1699. {
  1700. count++;
  1701. }
  1702. }
  1703. }
  1704. }
  1705. return count;
  1706. }
  1707. }
  1708. #endregion
  1709. #region 不屈を持つか
  1710. public bool HasFortitude
  1711. {
  1712. get
  1713. {
  1714. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1715. {
  1716. if (cardEffect is ActivateICardEffect)
  1717. {
  1718. if (cardEffect.EffectName == "Fortitude")
  1719. {
  1720. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1721. {
  1722. return true;
  1723. }
  1724. }
  1725. }
  1726. }
  1727. return false;
  1728. }
  1729. }
  1730. #endregion
  1731. #region Has Blitz
  1732. public bool HasBlitz
  1733. {
  1734. get
  1735. {
  1736. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  1737. {
  1738. if (cardEffect is ActivateICardEffect)
  1739. {
  1740. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  1741. {
  1742. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1743. {
  1744. if (cardEffect.EffectDiscription.Contains("Blitz"))
  1745. {
  1746. return true;
  1747. }
  1748. }
  1749. }
  1750. }
  1751. }
  1752. return false;
  1753. }
  1754. }
  1755. #endregion
  1756. #region 回避を持つか
  1757. public bool HasEvade
  1758. {
  1759. get
  1760. {
  1761. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1762. {
  1763. if (cardEffect is ActivateICardEffect)
  1764. {
  1765. Hashtable hashtable = new Hashtable()
  1766. {
  1767. {"Permanents", new List<Permanent>() { this }}
  1768. };
  1769. if (cardEffect.CanTrigger(hashtable))
  1770. {
  1771. if (cardEffect.EffectName == "Evade")
  1772. {
  1773. return true;
  1774. }
  1775. }
  1776. }
  1777. }
  1778. return false;
  1779. }
  1780. }
  1781. #endregion
  1782. #region マインドリンクを持つか
  1783. public bool HasMindLink
  1784. {
  1785. get
  1786. {
  1787. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  1788. {
  1789. if (cardEffect is ActivateICardEffect)
  1790. {
  1791. if (cardEffect.CanTrigger(null))
  1792. {
  1793. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  1794. {
  1795. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  1796. {
  1797. return true;
  1798. }
  1799. }
  1800. }
  1801. }
  1802. }
  1803. return false;
  1804. }
  1805. }
  1806. #endregion
  1807. #region 防壁を持つか
  1808. public bool HasBarrier
  1809. {
  1810. get
  1811. {
  1812. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1813. {
  1814. if (cardEffect is ActivateICardEffect)
  1815. {
  1816. Hashtable hashtable = new Hashtable();
  1817. hashtable.Add("Permanents", new List<Permanent>() { this });
  1818. hashtable.Add("battle", new IBattle(null, null, null));
  1819. if (cardEffect.CanTrigger(hashtable))
  1820. {
  1821. if (cardEffect.EffectName == "Barrier")
  1822. {
  1823. return true;
  1824. }
  1825. }
  1826. }
  1827. }
  1828. return false;
  1829. }
  1830. }
  1831. #endregion
  1832. #region 連携を持つか
  1833. public bool HasAlliance
  1834. {
  1835. get
  1836. {
  1837. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1838. {
  1839. if (cardEffect is ActivateICardEffect)
  1840. {
  1841. if (cardEffect.EffectName == "Alliance")
  1842. {
  1843. return true;
  1844. }
  1845. }
  1846. }
  1847. return false;
  1848. }
  1849. }
  1850. #endregion
  1851. #region 消滅時効化を持つか
  1852. public bool HasOnDeletionEffect
  1853. {
  1854. get
  1855. {
  1856. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1857. {
  1858. if (cardEffect is ActivateICardEffect)
  1859. {
  1860. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1861. {
  1862. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1863. {
  1864. if (cardEffect.IsOnDeletion)
  1865. {
  1866. return true;
  1867. }
  1868. }
  1869. }
  1870. }
  1871. }
  1872. return false;
  1873. }
  1874. }
  1875. #endregion
  1876. #region バトルしているか
  1877. public IBattle battle { get; set; } = null;
  1878. #endregion
  1879. #region このデジモンが消滅するか
  1880. public bool CanBeDestroyed()
  1881. {
  1882. #region 消滅しない効果
  1883. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1884. {
  1885. foreach (Permanent permanent in player.GetFieldPermanents())
  1886. {
  1887. #region 場のパーマネントの効果
  1888. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1889. {
  1890. if (cardEffect is ICanNotBeDestroyedEffect)
  1891. {
  1892. if (cardEffect.CanUse(null))
  1893. {
  1894. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  1895. {
  1896. return false;
  1897. }
  1898. }
  1899. }
  1900. }
  1901. #endregion
  1902. }
  1903. #region プレイヤーの効果
  1904. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1905. {
  1906. if (cardEffect is ICanNotBeDestroyedEffect)
  1907. {
  1908. if (cardEffect.CanUse(null))
  1909. {
  1910. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  1911. {
  1912. return false;
  1913. }
  1914. }
  1915. }
  1916. }
  1917. #endregion
  1918. }
  1919. #endregion
  1920. return true;
  1921. }
  1922. #endregion
  1923. #region このデジモンが戦闘によって消滅するか
  1924. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  1925. {
  1926. if (!CanBeDestroyed())
  1927. {
  1928. return false;
  1929. }
  1930. #region 戦闘で消滅しない効果
  1931. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1932. {
  1933. foreach (Permanent permanent in player.GetFieldPermanents())
  1934. {
  1935. #region 場のパーマネントの効果
  1936. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1937. {
  1938. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1939. {
  1940. if (cardEffect.CanUse(null))
  1941. {
  1942. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  1943. {
  1944. return false;
  1945. }
  1946. }
  1947. }
  1948. }
  1949. #endregion
  1950. }
  1951. #region プレイヤーの効果
  1952. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1953. {
  1954. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1955. {
  1956. if (cardEffect.CanUse(null))
  1957. {
  1958. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  1959. {
  1960. return false;
  1961. }
  1962. }
  1963. }
  1964. }
  1965. #endregion
  1966. }
  1967. #endregion
  1968. return true;
  1969. }
  1970. #endregion
  1971. #region このパーマネントが効果で消滅するか
  1972. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  1973. {
  1974. if (this.TopCard != null)
  1975. {
  1976. if (this.TopCard.CanNotBeAffected(cardEffect))
  1977. {
  1978. return false;
  1979. }
  1980. if (!CanBeDestroyed())
  1981. {
  1982. return false;
  1983. }
  1984. #region 効果で消滅しない効果
  1985. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1986. {
  1987. foreach (Permanent permanent in player.GetFieldPermanents())
  1988. {
  1989. #region 場のパーマネントの効果
  1990. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1991. {
  1992. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  1993. {
  1994. if (cardEffect1.CanUse(null))
  1995. {
  1996. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  1997. {
  1998. return false;
  1999. }
  2000. }
  2001. }
  2002. }
  2003. #endregion
  2004. }
  2005. #region プレイヤーの効果
  2006. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2007. {
  2008. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2009. {
  2010. if (cardEffect1.CanUse(null))
  2011. {
  2012. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2013. {
  2014. return false;
  2015. }
  2016. }
  2017. }
  2018. }
  2019. #endregion
  2020. }
  2021. #endregion
  2022. }
  2023. return true;
  2024. }
  2025. #endregion
  2026. #region トークンかどうか
  2027. public bool IsToken
  2028. {
  2029. get
  2030. {
  2031. if (TopCard != null)
  2032. {
  2033. if (TopCard.IsToken)
  2034. {
  2035. return true;
  2036. }
  2037. }
  2038. return false;
  2039. }
  2040. }
  2041. #endregion
  2042. #region そのパーマネントが消滅・バウンス待機状態か
  2043. public bool willBeRemoveField { get; set; } = false;
  2044. #endregion
  2045. #region このパーマネントがデジモンか
  2046. public bool IsDigimon
  2047. {
  2048. get
  2049. {
  2050. if (TopCard != null)
  2051. {
  2052. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2053. {
  2054. return true;
  2055. }
  2056. #region Effect of treating it as a Digimon
  2057. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2058. {
  2059. foreach (Permanent permanent in player.GetFieldPermanents())
  2060. {
  2061. #region Effects of permanents in play
  2062. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2063. {
  2064. if (cardEffect is ITreatAsDigimonEffect)
  2065. {
  2066. if (cardEffect.CanTrigger(null))
  2067. {
  2068. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2069. {
  2070. return true;
  2071. }
  2072. }
  2073. }
  2074. }
  2075. #endregion
  2076. }
  2077. #region player effect
  2078. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2079. {
  2080. if (cardEffect is ITreatAsDigimonEffect)
  2081. {
  2082. if (cardEffect.CanTrigger(null))
  2083. {
  2084. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2085. {
  2086. return true;
  2087. }
  2088. }
  2089. }
  2090. }
  2091. #endregion
  2092. }
  2093. #endregion
  2094. }
  2095. return false;
  2096. }
  2097. }
  2098. #endregion
  2099. #region このパーマネントがテイマーか
  2100. public bool IsTamer
  2101. {
  2102. get
  2103. {
  2104. if (TopCard != null)
  2105. {
  2106. if (TopCard.IsTamer)
  2107. {
  2108. return true;
  2109. }
  2110. }
  2111. return false;
  2112. }
  2113. }
  2114. #endregion
  2115. #region ジョグレスで扱うレベル
  2116. public List<int> Levels_ForJogress(CardSource cardSource)
  2117. {
  2118. List<int> levels = new List<int>();
  2119. if (cardSource != null)
  2120. {
  2121. if (cardSource.HasLevel)
  2122. {
  2123. levels.Add(this.Level);
  2124. }
  2125. #region "ジョグレス進化で扱うレベルを追加する"効果
  2126. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2127. {
  2128. foreach (Permanent permanent in player.GetFieldPermanents())
  2129. {
  2130. #region 場のパーマネントの効果
  2131. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2132. {
  2133. if (cardEffect is IAddJogressLevelsEffect)
  2134. {
  2135. if (cardEffect.CanUse(null))
  2136. {
  2137. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2138. {
  2139. levels.Add(level);
  2140. }
  2141. }
  2142. }
  2143. }
  2144. #endregion
  2145. }
  2146. #region プレイヤーの効果
  2147. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2148. {
  2149. if (cardEffect is IAddJogressLevelsEffect)
  2150. {
  2151. if (cardEffect.CanUse(null))
  2152. {
  2153. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2154. {
  2155. levels.Add(level);
  2156. }
  2157. }
  2158. }
  2159. }
  2160. #endregion
  2161. }
  2162. #endregion
  2163. }
  2164. return levels;
  2165. }
  2166. #endregion
  2167. #region バトルで消滅したか
  2168. public bool IsDestroyedByBattle { get; set; } = false;
  2169. #endregion
  2170. #region 消滅に使用された効果
  2171. public ICardEffect DestroyingEffect { get; set; } = null;
  2172. #endregion
  2173. #region 他のパーマネントの下に置くのに使用された効果
  2174. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2175. #endregion
  2176. #region 手札バウンス に使用された効果
  2177. public ICardEffect HandBounceEffect { get; set; } = null;
  2178. #endregion
  2179. #region 山札バウンス に使用された効果
  2180. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2181. #endregion
  2182. #region 登場に使用された効果
  2183. public ICardEffect PlayingEffect { get; set; } = null;
  2184. #endregion
  2185. #region 進化に使用された効果
  2186. public ICardEffect DigivolvingEffect { get; set; } = null;
  2187. #endregion
  2188. #region Whether this digimon is placed in the trash by not having a DP
  2189. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2190. #endregion
  2191. #region Whether this permanent can suspend
  2192. public bool CanSuspend
  2193. {
  2194. get
  2195. {
  2196. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2197. {
  2198. #region Effects of field permanents
  2199. foreach (Permanent permanent in player.GetFieldPermanents())
  2200. {
  2201. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2202. {
  2203. if (cardEffect is ICanNotSuspendEffect)
  2204. {
  2205. if (cardEffect.CanUse(null))
  2206. {
  2207. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2208. {
  2209. return false;
  2210. }
  2211. }
  2212. }
  2213. }
  2214. }
  2215. #endregion
  2216. #region Effects of players
  2217. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2218. {
  2219. if (cardEffect is ICanNotSuspendEffect)
  2220. {
  2221. if (cardEffect.CanUse(null))
  2222. {
  2223. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2224. {
  2225. return false;
  2226. }
  2227. }
  2228. }
  2229. }
  2230. #endregion
  2231. }
  2232. return true;
  2233. }
  2234. }
  2235. #endregion
  2236. #region このデジモンのアタックの対象が変更できるか
  2237. public bool CanSwitchAttackTarget
  2238. {
  2239. get
  2240. {
  2241. #region アタックの対象が変更できない効果
  2242. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2243. {
  2244. foreach (Permanent permanent in player.GetFieldPermanents())
  2245. {
  2246. #region 場のパーマネントの効果
  2247. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2248. {
  2249. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2250. {
  2251. if (cardEffect.CanUse(null))
  2252. {
  2253. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2254. {
  2255. return false;
  2256. }
  2257. }
  2258. }
  2259. }
  2260. #endregion
  2261. }
  2262. #region プレイヤーの効果
  2263. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2264. {
  2265. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2266. {
  2267. if (cardEffect.CanUse(null))
  2268. {
  2269. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2270. {
  2271. return false;
  2272. }
  2273. }
  2274. }
  2275. }
  2276. #endregion
  2277. }
  2278. #endregion
  2279. return true;
  2280. }
  2281. }
  2282. #endregion
  2283. #region このデジモンを場からデジクロス条件の代わりにできるか
  2284. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  2285. {
  2286. #region デジクロス条件の代わりにできる効果
  2287. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2288. {
  2289. foreach (Permanent permanent in player.GetFieldPermanents())
  2290. {
  2291. #region 場のパーマネントの効果
  2292. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2293. {
  2294. if (cardEffect is ICanSelectDigiXrosEffect)
  2295. {
  2296. if (cardEffect.CanUse(null))
  2297. {
  2298. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2299. {
  2300. return true;
  2301. }
  2302. }
  2303. }
  2304. }
  2305. #endregion
  2306. }
  2307. #region プレイヤーの効果
  2308. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2309. {
  2310. if (cardEffect is ICanSelectDigiXrosEffect)
  2311. {
  2312. if (cardEffect.CanUse(null))
  2313. {
  2314. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2315. {
  2316. return true;
  2317. }
  2318. }
  2319. }
  2320. }
  2321. #endregion
  2322. }
  2323. #endregion
  2324. return false;
  2325. }
  2326. #endregion
  2327. #region 登場した直後のLevel
  2328. public int LevelJustAfterPlayed { get; set; } = -1;
  2329. #endregion
  2330. #region 登場した直後のPlay Cost
  2331. public int PlayCostJustAfterPlayed { get; set; } = -1;
  2332. #endregion
  2333. #region 登場した直後のCardNames
  2334. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  2335. #endregion
  2336. #region 進化した直後のCardNames
  2337. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  2338. #endregion
  2339. #region 登場した直後のTraits
  2340. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  2341. #endregion
  2342. #region 場を離れる直前のDP
  2343. public int DPJustBeforeRemoveField { get; set; } = -1;
  2344. #endregion
  2345. #region 場を離れる直前のLevel
  2346. public int LevelJustBeforeRemoveField { get; set; } = -1;
  2347. #endregion
  2348. #region 場を離れる直前のCost
  2349. public int CostJustBeforeRemoveField { get; set; } = -1;
  2350. #endregion
  2351. #region 場を離れる直前のカード名
  2352. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  2353. #endregion
  2354. #region バースト進化で手札に戻ったか
  2355. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  2356. #endregion
  2357. #region バースト進化したか
  2358. public bool IsBurstDigivolved { get; set; } = false;
  2359. #endregion
  2360. #region 効果で場に出たオプションか
  2361. public bool IsPlayedOptionPermanent { get; set; } = false;
  2362. #endregion
  2363. #region 進化元を持たないか
  2364. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  2365. #endregion
  2366. #region Digivolution cards' colors
  2367. public List<CardColor> DigivolutionCardsColors
  2368. {
  2369. get
  2370. {
  2371. List<CardColor> cardColors = new List<CardColor>();
  2372. foreach (CardSource cardSource in DigivolutionCards)
  2373. {
  2374. foreach (CardColor cardColor in cardSource.CardColors)
  2375. {
  2376. if (!cardColors.Contains(cardColor))
  2377. {
  2378. cardColors.Add(cardColor);
  2379. }
  2380. }
  2381. }
  2382. return cardColors.Distinct().ToList();
  2383. }
  2384. }
  2385. #endregion
  2386. #region Show "Unsuspend" effect object
  2387. public void ShowUnsuspendEffect()
  2388. {
  2389. if (TopCard != null)
  2390. {
  2391. if (ShowingPermanentCard != null)
  2392. {
  2393. if (ShowingPermanentCard.WillUntapObject != null)
  2394. {
  2395. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  2396. ShowingPermanentCard.WillUntapObject.SetActive(true);
  2397. }
  2398. }
  2399. }
  2400. }
  2401. #endregion
  2402. #region Show "Return to deck" effect object
  2403. public void ShowDeckBounceEffect()
  2404. {
  2405. if (TopCard != null)
  2406. {
  2407. if (willBeRemoveField)
  2408. {
  2409. if (ShowingPermanentCard != null)
  2410. {
  2411. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2412. {
  2413. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  2414. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  2415. }
  2416. }
  2417. }
  2418. }
  2419. }
  2420. #endregion
  2421. #region Hide "Return to deck" effect object
  2422. public void HideDeckBounceEffect()
  2423. {
  2424. if (TopCard != null)
  2425. {
  2426. if (ShowingPermanentCard != null)
  2427. {
  2428. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2429. {
  2430. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  2431. }
  2432. }
  2433. }
  2434. }
  2435. #endregion
  2436. #region Show "Return to hand" effect object
  2437. public void ShowHandBounceEffect()
  2438. {
  2439. if (TopCard != null)
  2440. {
  2441. if (willBeRemoveField)
  2442. {
  2443. if (ShowingPermanentCard != null)
  2444. {
  2445. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2446. {
  2447. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  2448. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  2449. }
  2450. }
  2451. }
  2452. }
  2453. }
  2454. #endregion
  2455. #region Hide "Return to hand" effect object
  2456. public void HideHandBounceEffect()
  2457. {
  2458. if (TopCard != null)
  2459. {
  2460. if (ShowingPermanentCard != null)
  2461. {
  2462. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2463. {
  2464. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  2465. }
  2466. }
  2467. }
  2468. }
  2469. #endregion
  2470. #region Show "Delete" effect object
  2471. public void ShowDeleteEffect()
  2472. {
  2473. if (TopCard != null)
  2474. {
  2475. if (willBeRemoveField)
  2476. {
  2477. if (ShowingPermanentCard != null)
  2478. {
  2479. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2480. {
  2481. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  2482. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  2483. }
  2484. }
  2485. }
  2486. }
  2487. }
  2488. #endregion
  2489. #region Hide "Delete" effect object
  2490. public void HideDeleteEffect()
  2491. {
  2492. if (TopCard != null)
  2493. {
  2494. if (ShowingPermanentCard != null)
  2495. {
  2496. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2497. {
  2498. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  2499. }
  2500. }
  2501. }
  2502. }
  2503. #endregion
  2504. #region Show "Remove Field" effect object
  2505. public void ShowWillRemoveFieldEffect()
  2506. {
  2507. if (TopCard != null)
  2508. {
  2509. if (willBeRemoveField)
  2510. {
  2511. if (ShowingPermanentCard != null)
  2512. {
  2513. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2514. {
  2515. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  2516. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  2517. }
  2518. }
  2519. }
  2520. }
  2521. }
  2522. #endregion
  2523. #region Hide "Remove Field" effect object
  2524. public void HideWillRemoveFieldEffect()
  2525. {
  2526. if (TopCard != null)
  2527. {
  2528. if (ShowingPermanentCard != null)
  2529. {
  2530. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2531. {
  2532. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  2533. }
  2534. }
  2535. }
  2536. }
  2537. #endregion
  2538. #region Show "Digivolution" effect object
  2539. public void ShowWillEvolutionEffect()
  2540. {
  2541. if (TopCard != null)
  2542. {
  2543. if (ShowingPermanentCard != null)
  2544. {
  2545. if (ShowingPermanentCard.WillEvolutionObject != null)
  2546. {
  2547. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  2548. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  2549. }
  2550. }
  2551. }
  2552. }
  2553. #endregion
  2554. #region Hide "Digivolution" effect object
  2555. public void HideWillEvolutionEffect()
  2556. {
  2557. if (TopCard != null)
  2558. {
  2559. if (ShowingPermanentCard != null)
  2560. {
  2561. if (ShowingPermanentCard.WillEvolutionObject != null)
  2562. {
  2563. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  2564. }
  2565. }
  2566. }
  2567. }
  2568. #endregion
  2569. }