Permanent.cs 110 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using System.Linq;
  6. public class Permanent
  7. {
  8. public Permanent(List<CardSource> cardSources)
  9. {
  10. SetCardSources(cardSources);
  11. }
  12. public void SetCardSources(List<CardSource> cardSources)
  13. {
  14. List<CardSource> newCardSources = cardSources.Clone();
  15. newCardSources.Reverse();
  16. foreach (CardSource cardSource in newCardSources)
  17. {
  18. AddCardSource(cardSource);
  19. }
  20. }
  21. public FieldCardFrame PermanentFrame
  22. {
  23. get
  24. {
  25. if (TopCard != null)
  26. {
  27. int index = Array.IndexOf(TopCard.Owner.FieldPermanents, this);
  28. if (0 <= index && index <= TopCard.Owner.fieldCardFrames.Count - 1)
  29. {
  30. return TopCard.Owner.fieldCardFrames[index];
  31. }
  32. }
  33. return null;
  34. }
  35. }
  36. public bool oldIsTapped_playCard { get; set; }
  37. #region Level
  38. public int Level
  39. {
  40. get
  41. {
  42. int Level = 0;
  43. if (TopCard != null)
  44. {
  45. Level = TopCard.Level;
  46. if (!TopCard.HasLevel)
  47. {
  48. Level = 1145140;
  49. }
  50. #region レベルを変更する効果
  51. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  52. {
  53. foreach (Permanent permanent in player.GetFieldPermanents())
  54. {
  55. #region 場のパーマネントの効果
  56. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  57. {
  58. if (cardEffect is IChangePermanentLevelEffect)
  59. {
  60. if (cardEffect.CanUse(null))
  61. {
  62. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  63. }
  64. }
  65. }
  66. #endregion
  67. }
  68. #region プレイヤーの効果
  69. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  70. {
  71. if (cardEffect is IChangePermanentLevelEffect)
  72. {
  73. if (cardEffect.CanUse(null))
  74. {
  75. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  76. }
  77. }
  78. }
  79. #endregion
  80. }
  81. #endregion
  82. }
  83. return Level;
  84. }
  85. }
  86. #endregion
  87. #region Place all evolution sources in the trash
  88. public IEnumerator DiscardEvoRoots(bool ignoreOverflow = false, bool putToTrash = true)
  89. {
  90. List<CardSource> evoRoots = DigivolutionCards.Clone();
  91. if (!ignoreOverflow)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(evoRoots).Overflow());
  94. }
  95. foreach (CardSource cardSource1 in evoRoots)
  96. {
  97. if (putToTrash)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource1));
  100. }
  101. else
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource1));
  104. }
  105. }
  106. }
  107. #endregion
  108. #region Whether this permanent has DP
  109. public bool HasDP
  110. {
  111. get
  112. {
  113. if (TopCard == null)
  114. {
  115. return false;
  116. }
  117. if (!IsDigimon)
  118. {
  119. return false;
  120. }
  121. if (!TopCard.HasDP && TopCard.IsDigiEgg)
  122. {
  123. return false;
  124. }
  125. #region Effect of not having DP
  126. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  127. {
  128. foreach (Permanent permanent in player.GetFieldPermanents())
  129. {
  130. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  131. {
  132. if (cardEffect1 is IDontHaveDPEffect)
  133. {
  134. if (cardEffect1.CanUse(null))
  135. {
  136. if (((IDontHaveDPEffect)cardEffect1).DontHaveDP(this))
  137. {
  138. return false;
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. #endregion
  146. return true;
  147. }
  148. }
  149. #endregion
  150. #region Base DP
  151. public int BaseDP
  152. {
  153. get
  154. {
  155. int BaseDP = 0;
  156. if (HasDP)
  157. {
  158. BaseDP = TopCard.BaseCardDP;
  159. #region 基礎DPを変更する効果
  160. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  161. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  162. {
  163. foreach (Permanent permanent in player.GetFieldPermanents())
  164. {
  165. #region 場のパーマネントの効果
  166. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  167. {
  168. if (cardEffect is IChangeBaseDPEffect)
  169. {
  170. if (cardEffect.CanUse(null))
  171. {
  172. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  173. {
  174. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  175. {
  176. if (this.ImmuneFromDPMinus(cardEffect))
  177. {
  178. continue;
  179. }
  180. }
  181. if (!TopCard.CanNotBeAffected(cardEffect))
  182. {
  183. cardEffects_ChangeDP.Add(cardEffect);
  184. }
  185. }
  186. }
  187. }
  188. }
  189. #endregion
  190. }
  191. #region プレイヤーの効果
  192. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  193. {
  194. if (cardEffect is IChangeBaseDPEffect)
  195. {
  196. if (cardEffect.CanUse(null))
  197. {
  198. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  199. {
  200. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  201. {
  202. if (this.ImmuneFromDPMinus(cardEffect))
  203. {
  204. continue;
  205. }
  206. }
  207. if (!TopCard.CanNotBeAffected(cardEffect))
  208. {
  209. cardEffects_ChangeDP.Add(cardEffect);
  210. }
  211. }
  212. }
  213. }
  214. }
  215. #endregion
  216. }
  217. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  218. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  219. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  220. {
  221. if (cardEffect is IChangeBaseDPEffect)
  222. {
  223. if (cardEffect.CanUse(null))
  224. {
  225. if (((IChangeBaseDPEffect)cardEffect).IsUpDown())
  226. {
  227. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  228. }
  229. else
  230. {
  231. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  232. }
  233. }
  234. }
  235. }
  236. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  237. {
  238. if (cardEffect is IChangeBaseDPEffect)
  239. {
  240. if (cardEffect.CanUse(null))
  241. {
  242. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  243. }
  244. }
  245. }
  246. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  247. {
  248. if (cardEffect is IChangeBaseDPEffect)
  249. {
  250. if (cardEffect.CanUse(null))
  251. {
  252. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  253. }
  254. }
  255. }
  256. #endregion
  257. if (BaseDP < 0)
  258. {
  259. BaseDP = 0;
  260. }
  261. }
  262. return BaseDP;
  263. }
  264. }
  265. #endregion
  266. #region DP
  267. public int DP
  268. {
  269. get
  270. {
  271. int DP = -1;
  272. if (HasDP)
  273. {
  274. DP = BaseDP;
  275. #region DPを変更する効果
  276. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  277. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  278. {
  279. #region Effects of permanents in play
  280. foreach (Permanent permanent in player.GetFieldPermanents())
  281. {
  282. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  283. {
  284. if (cardEffect is IChangeDPEffect)
  285. {
  286. if (cardEffect.CanUse(null))
  287. {
  288. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  289. {
  290. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  291. {
  292. if (this.ImmuneFromDPMinus(cardEffect))
  293. {
  294. continue;
  295. }
  296. }
  297. if (!TopCard.CanNotBeAffected(cardEffect))
  298. {
  299. cardEffects_ChangeDP.Add(cardEffect);
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. #endregion
  307. #region Effects of face up security
  308. foreach (CardSource cardSource in player.SecurityCards)
  309. {
  310. if (cardSource.IsFlipped)
  311. continue;
  312. foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
  313. {
  314. if (cardEffect is IChangeDPEffect)
  315. {
  316. if (cardEffect.CanUse(null))
  317. {
  318. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  319. {
  320. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  321. {
  322. if (this.ImmuneFromDPMinus(cardEffect))
  323. {
  324. continue;
  325. }
  326. }
  327. if (!TopCard.CanNotBeAffected(cardEffect))
  328. {
  329. cardEffects_ChangeDP.Add(cardEffect);
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. #endregion
  337. #region Player effect
  338. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  339. {
  340. if (cardEffect is IChangeDPEffect)
  341. {
  342. if (cardEffect.CanUse(null))
  343. {
  344. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  345. {
  346. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  347. {
  348. if (this.ImmuneFromDPMinus(cardEffect))
  349. {
  350. continue;
  351. }
  352. }
  353. if (!TopCard.CanNotBeAffected(cardEffect))
  354. {
  355. cardEffects_ChangeDP.Add(cardEffect);
  356. }
  357. }
  358. }
  359. }
  360. }
  361. #endregion
  362. }
  363. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  364. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  365. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  366. {
  367. if (cardEffect is IChangeDPEffect)
  368. {
  369. if (cardEffect.CanUse(null))
  370. {
  371. if (((IChangeDPEffect)cardEffect).IsUpDown())
  372. {
  373. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  374. }
  375. else
  376. {
  377. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  378. }
  379. }
  380. }
  381. }
  382. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  383. {
  384. if (cardEffect is IChangeDPEffect)
  385. {
  386. if (cardEffect.CanUse(null))
  387. {
  388. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  389. }
  390. }
  391. }
  392. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  393. {
  394. if (cardEffect is IChangeDPEffect)
  395. {
  396. if (cardEffect.CanUse(null))
  397. {
  398. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  399. }
  400. }
  401. }
  402. #endregion
  403. if (DP < 0)
  404. {
  405. DP = 0;
  406. }
  407. }
  408. return DP;
  409. }
  410. }
  411. #endregion
  412. #region Will it not receive negative DP effect?
  413. public bool ImmuneFromDPMinus(ICardEffect cardEffect)
  414. {
  415. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  416. {
  417. foreach (Permanent permanent in player.GetFieldPermanents())
  418. {
  419. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  420. {
  421. if (cardEffect1 is IImmuneFromDPMinusEffect)
  422. {
  423. if (cardEffect1.CanUse(null))
  424. {
  425. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  426. {
  427. return true;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  434. {
  435. if (cardEffect1 is IImmuneFromDPMinusEffect)
  436. {
  437. if (cardEffect1.CanUse(null))
  438. {
  439. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  440. {
  441. return true;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. return false;
  448. }
  449. #endregion
  450. #region Can be returned to your hand?
  451. public bool CannotReturnToHand(ICardEffect cardEffect)
  452. {
  453. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  454. {
  455. foreach (Permanent permanent in player.GetFieldPermanents())
  456. {
  457. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  458. {
  459. if (cardEffect1 is ICannotReturnToHandEffect)
  460. {
  461. if (cardEffect1.CanUse(null))
  462. {
  463. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  464. {
  465. return true;
  466. }
  467. }
  468. }
  469. }
  470. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  471. {
  472. if (cardEffect1 is ICannotReturnToHandEffect)
  473. {
  474. if (cardEffect1.CanUse(null))
  475. {
  476. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  477. {
  478. return true;
  479. }
  480. }
  481. }
  482. }
  483. }
  484. }
  485. return false;
  486. }
  487. #endregion
  488. #region Can be returned to deck?
  489. public bool CannotReturnToLibrary(ICardEffect cardEffect)
  490. {
  491. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  492. {
  493. foreach (Permanent permanent in player.GetFieldPermanents())
  494. {
  495. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  496. {
  497. if (cardEffect1 is ICannotReturnToLibraryEffect)
  498. {
  499. if (cardEffect1.CanUse(null))
  500. {
  501. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  502. {
  503. return true;
  504. }
  505. }
  506. }
  507. }
  508. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  509. {
  510. if (cardEffect1 is ICannotReturnToLibraryEffect)
  511. {
  512. if (cardEffect1.CanUse(null))
  513. {
  514. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  515. {
  516. return true;
  517. }
  518. }
  519. }
  520. }
  521. }
  522. }
  523. return false;
  524. }
  525. #endregion
  526. #region 退化を受けないか
  527. public bool ImmuneFromDeDigivolve()
  528. {
  529. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  530. {
  531. foreach (Permanent permanent in player.GetFieldPermanents())
  532. {
  533. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  534. {
  535. if (cardEffect1 is IImmuneFromDeDigivolveEffect)
  536. {
  537. if (cardEffect1.CanUse(null))
  538. {
  539. if (((IImmuneFromDeDigivolveEffect)cardEffect1).ImmuneDeDigivolve(this))
  540. {
  541. return true;
  542. }
  543. }
  544. }
  545. }
  546. }
  547. }
  548. return false;
  549. }
  550. #endregion
  551. #region このパーマネントの持つカードリスト
  552. public List<CardSource> cardSources = new List<CardSource>();
  553. #endregion
  554. #region 一番上以外のカード
  555. public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard);
  556. #endregion
  557. #region パーマネントのカードリストにカードを追加
  558. public void AddCardSource(CardSource cardSource)
  559. {
  560. cardSources.Insert(0, cardSource);
  561. cardSource.SetFace();
  562. }
  563. #endregion
  564. #region Add digivolution cards to top of sources
  565. /// <summary>
  566. /// IEnumerator to add a list of CardSource to a permanents top sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToDigivolutionCards
  567. /// </summary>
  568. /// <param name="addedDigivolutionCards"></param>
  569. /// <param name="cardEffect"></param>
  570. /// <param name="skipEffectAndActivateSkill"></param>
  571. /// <returns></returns>
  572. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  573. {
  574. List<CardSource> addedCards = new List<CardSource>();
  575. bool isFromSameDigimon = false;
  576. bool isFromDigimon = false;
  577. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  578. {
  579. if (cardSources.Contains(addedDigivolutionCard))
  580. {
  581. isFromSameDigimon = true;
  582. }
  583. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  584. {
  585. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  586. {
  587. isFromDigimon = true;
  588. }
  589. }
  590. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  591. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  592. {
  593. this.cardSources.Insert(1, addedDigivolutionCard);
  594. addedDigivolutionCard.SetFace();
  595. addedCards.Add(addedDigivolutionCard);
  596. }
  597. }
  598. if (addedCards.Count >= 1)
  599. {
  600. if (ShowingPermanentCard != null)
  601. {
  602. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  603. }
  604. #region "進化元が増えた時"の効果
  605. #region Hashtable Setting
  606. Hashtable hashtable = new Hashtable()
  607. {
  608. {"Permanent", this},
  609. {"CardEffect", cardEffect},
  610. {"CardSources", addedCards},
  611. {"isFromSameDigimon", isFromSameDigimon},
  612. {"isFromDigimon", isFromDigimon},
  613. };
  614. #endregion
  615. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  616. #endregion
  617. }
  618. }
  619. #endregion
  620. #region Add digivolution cards to bottom of sources
  621. /// <summary>
  622. /// IEnumerator to add a list of CardSource to a permanents bottom sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToDigivolutionCards
  623. /// </summary>
  624. /// <param name="addedDigivolutionCards"></param>
  625. /// <param name="cardEffect"></param>
  626. /// <param name="skipEffectAndActivateSkill"></param>
  627. /// <returns></returns>
  628. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false)
  629. {
  630. List<CardSource> addedCards = new List<CardSource>();
  631. bool isFromSameDigimon = false;
  632. bool isFromDigimon = false;
  633. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  634. {
  635. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  636. {
  637. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  638. {
  639. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  640. {
  641. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
  642. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  643. if (!placePermanent.Placed)
  644. {
  645. continue;
  646. }
  647. }
  648. }
  649. }
  650. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  651. {
  652. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  653. {
  654. isFromDigimon = true;
  655. }
  656. }
  657. if (cardSources.Contains(addedDigivolutionCard))
  658. {
  659. isFromSameDigimon = true;
  660. if (addedDigivolutionCard == TopCard)
  661. {
  662. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  663. ShowingPermanentCard.ShowPermanentData(true);
  664. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  665. addedDigivolutionCard,
  666. this));
  667. }
  668. }
  669. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  670. if (!IsToken && !addedDigivolutionCard.IsToken)
  671. {
  672. cardSources.Add(addedDigivolutionCard);
  673. addedDigivolutionCard.SetFace();
  674. addedCards.Add(addedDigivolutionCard);
  675. }
  676. }
  677. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  678. {
  679. if (ShowingPermanentCard != null)
  680. {
  681. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  682. }
  683. #region Effect of "when the number of evolution sources increases"
  684. #region Hashtable Setting
  685. Hashtable hashtable = new Hashtable()
  686. {
  687. {"Permanent", this},
  688. {"CardEffect", cardEffect},
  689. {"CardSources", addedCards},
  690. {"isFromSameDigimon", isFromSameDigimon},
  691. {"isFromDigimon", isFromDigimon},
  692. };
  693. #endregion
  694. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  695. #endregion
  696. }
  697. }
  698. #endregion
  699. #region パーマネントのカードリストからカードを除く
  700. public IEnumerator RemoveCardSource(CardSource cardSource)
  701. {
  702. yield return null;
  703. cardSources.Remove(cardSource);
  704. }
  705. #endregion
  706. #region このパーマネントの一番上のカード
  707. public CardSource TopCard
  708. {
  709. get
  710. {
  711. if (cardSources.Count >= 1)
  712. {
  713. return cardSources[0];
  714. }
  715. return null;
  716. }
  717. }
  718. #endregion
  719. #region Permanent effect list
  720. #region このパーマネントの効果リスト
  721. public List<ICardEffect> EffectList(EffectTiming timing)
  722. {
  723. return EffectList_ForCard(timing, TopCard);
  724. }
  725. #endregion
  726. #region このポケモンの追加効果リスト
  727. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  728. {
  729. List<ICardEffect> _EffectList = new List<ICardEffect>();
  730. if (TopCard != null)
  731. {
  732. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  733. {
  734. ICardEffect cardEffect = GetCardEffect(timing);
  735. if (cardEffect != null)
  736. {
  737. _EffectList.Add(cardEffect);
  738. }
  739. }
  740. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  741. {
  742. ICardEffect cardEffect = GetCardEffect(timing);
  743. if (cardEffect != null)
  744. {
  745. _EffectList.Add(cardEffect);
  746. }
  747. }
  748. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  749. {
  750. ICardEffect cardEffect = GetCardEffect(timing);
  751. if (cardEffect != null)
  752. {
  753. _EffectList.Add(cardEffect);
  754. }
  755. }
  756. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  757. {
  758. ICardEffect cardEffect = GetCardEffect(timing);
  759. if (cardEffect != null)
  760. {
  761. _EffectList.Add(cardEffect);
  762. }
  763. }
  764. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  765. {
  766. ICardEffect cardEffect = GetCardEffect(timing);
  767. if (cardEffect != null)
  768. {
  769. _EffectList.Add(cardEffect);
  770. }
  771. }
  772. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  773. {
  774. ICardEffect cardEffect = GetCardEffect(timing);
  775. if (cardEffect != null)
  776. {
  777. _EffectList.Add(cardEffect);
  778. }
  779. }
  780. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  781. {
  782. ICardEffect cardEffect = GetCardEffect(timing);
  783. if (cardEffect != null)
  784. {
  785. _EffectList.Add(cardEffect);
  786. }
  787. }
  788. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  789. {
  790. ICardEffect cardEffect = GetCardEffect(timing);
  791. if (cardEffect != null)
  792. {
  793. _EffectList.Add(cardEffect);
  794. }
  795. }
  796. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  797. {
  798. ICardEffect cardEffect = GetCardEffect(timing);
  799. if (cardEffect != null)
  800. {
  801. _EffectList.Add(cardEffect);
  802. }
  803. }
  804. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  805. foreach (ICardEffect cardEffect in _EffectList)
  806. {
  807. if (cardEffect != null)
  808. {
  809. if (cardEffect.EffectSourceCard == null)
  810. {
  811. cardEffect.SetEffectSourceCard(TopCard);
  812. }
  813. cardEffect.SetIsInheritedEffect(false);
  814. }
  815. }
  816. }
  817. return _EffectList;
  818. }
  819. #endregion
  820. #region このパーマネントの効果リスト(引数:CardSource)
  821. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  822. {
  823. List<ICardEffect> _EffectList = new List<ICardEffect>();
  824. if (TopCard != null && _cardSource != null)
  825. {
  826. foreach (CardSource cardSource in cardSources)
  827. {
  828. if (cardSource != null)
  829. {
  830. if (!cardSource.IsFlipped)
  831. {
  832. bool isTopCard = cardSource == TopCard;
  833. if (!isTopCard)
  834. {
  835. if (!IsDigimon)
  836. {
  837. continue;
  838. }
  839. }
  840. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  841. {
  842. if (cardEffect != null)
  843. {
  844. if (isTopCard == cardEffect.IsInheritedEffect)
  845. {
  846. continue;
  847. }
  848. _EffectList.Add(cardEffect);
  849. }
  850. }
  851. }
  852. }
  853. }
  854. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  855. {
  856. if (cardEffect != null)
  857. {
  858. _EffectList.Add(cardEffect);
  859. }
  860. }
  861. foreach (ICardEffect cardEffect in _EffectList)
  862. {
  863. if (cardEffect != null)
  864. {
  865. if (cardEffect.EffectSourceCard == null)
  866. {
  867. cardEffect.SetEffectSourceCard(_cardSource);
  868. }
  869. }
  870. }
  871. }
  872. return _EffectList;
  873. }
  874. #endregion
  875. #region 自分のターン終了時に消える効果
  876. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  877. #endregion
  878. #region 自分のドローフェイズ終了時に消える効果
  879. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  880. #endregion
  881. #region お互いのターン終了時に消える効果
  882. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  883. #endregion
  884. #region 相手のターン終了時に消える効果
  885. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  886. #endregion
  887. #region バトル終了時に消える効果
  888. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  889. #endregion
  890. #region 攻撃終了時に消える効果
  891. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  892. #endregion
  893. #region 自分のターン開始時に消える効果
  894. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  895. #endregion
  896. #region 次にアンタップする時に消える効果
  897. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  898. #endregion
  899. #region 場を離れるまで残る効果
  900. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  901. #endregion
  902. #endregion
  903. #region 起動型効果を宣言できるか
  904. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  905. #endregion
  906. #region 宣言可能な起動型効果リスト
  907. public List<ICardEffect> CanDeclareSkillList()
  908. {
  909. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  910. if (TopCard != null)
  911. {
  912. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  913. {
  914. if (_cardEffect is ActivateICardEffect)
  915. {
  916. if (_cardEffect.CanUse(null))
  917. {
  918. CanDeclareSkillList.Add(_cardEffect);
  919. }
  920. }
  921. }
  922. }
  923. return CanDeclareSkillList;
  924. }
  925. #endregion
  926. #region このパーマネントが場に出たターン
  927. public int EnterFieldTurnCount { get; set; } = -1;
  928. #endregion
  929. #region このパーマネントを表す場のオブジェクト
  930. public FieldPermanentCard ShowingPermanentCard { get; set; }
  931. #endregion
  932. #region Whether this permanent can be selected by the effect
  933. public bool CanSelectBySkill(ICardEffect skill)
  934. {
  935. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  936. {
  937. #region Effects of field permanents
  938. foreach (Permanent permanent in player.GetFieldPermanents())
  939. {
  940. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  941. {
  942. if (cardEffect is ICanNotSelectBySkillEffect)
  943. {
  944. if (cardEffect.CanUse(null))
  945. {
  946. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  947. {
  948. return false;
  949. }
  950. }
  951. }
  952. }
  953. }
  954. #endregion
  955. }
  956. return true;
  957. }
  958. #endregion
  959. #region Number of sheets to undergo security check
  960. public int InvertSecutiryValue
  961. {
  962. get
  963. {
  964. int Invert = 0;
  965. List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
  966. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  967. {
  968. foreach (Permanent permanent in player.GetFieldPermanents())
  969. {
  970. #region Effects of permanents in play
  971. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  972. {
  973. if (cardEffect is IInvertSAttackEffect)
  974. {
  975. if (cardEffect.CanUse(null))
  976. {
  977. if (!TopCard.CanNotBeAffected(cardEffect))
  978. {
  979. cardEffects_InvertStrike.Add(cardEffect);
  980. }
  981. }
  982. }
  983. }
  984. #endregion
  985. }
  986. #region player effect
  987. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  988. {
  989. if (cardEffect is IInvertSAttackEffect)
  990. {
  991. if (cardEffect.CanUse(null))
  992. {
  993. if (!TopCard.CanNotBeAffected(cardEffect))
  994. {
  995. cardEffects_InvertStrike.Add(cardEffect);
  996. }
  997. }
  998. }
  999. }
  1000. #endregion
  1001. }
  1002. foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
  1003. {
  1004. Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
  1005. }
  1006. return Mathf.Clamp(Invert,-1,1);
  1007. }
  1008. }
  1009. public List<int> SecurityAttackChanges
  1010. {
  1011. get
  1012. {
  1013. List<int> SecurityAttackChanges = new List<int>();
  1014. int Strike = 1;
  1015. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1016. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1017. {
  1018. foreach (Permanent permanent in player.GetFieldPermanents())
  1019. {
  1020. #region 場のパーマネントの効果
  1021. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1022. {
  1023. if (cardEffect is IChangeSAttackEffect)
  1024. {
  1025. if (cardEffect.CanUse(null))
  1026. {
  1027. if (!TopCard.CanNotBeAffected(cardEffect))
  1028. {
  1029. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1030. {
  1031. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1032. }
  1033. }
  1034. }
  1035. }
  1036. }
  1037. #endregion
  1038. }
  1039. #region プレイヤーの効果
  1040. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1041. {
  1042. if (cardEffect is IChangeSAttackEffect)
  1043. {
  1044. if (cardEffect.CanUse(null))
  1045. {
  1046. if (!TopCard.CanNotBeAffected(cardEffect))
  1047. {
  1048. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1049. {
  1050. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1051. }
  1052. }
  1053. }
  1054. }
  1055. }
  1056. #endregion
  1057. }
  1058. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1059. {
  1060. if (cardEffect is IChangeSAttackEffect)
  1061. {
  1062. if (cardEffect.CanUse(null))
  1063. {
  1064. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
  1065. if (Strike1 != Strike)
  1066. {
  1067. SecurityAttackChanges.Add(Strike1 - Strike);
  1068. }
  1069. }
  1070. }
  1071. }
  1072. return SecurityAttackChanges;
  1073. }
  1074. }
  1075. public bool HasSecurityAttackChanges
  1076. {
  1077. get
  1078. {
  1079. if (!IsDigimon)
  1080. {
  1081. return false;
  1082. }
  1083. return SecurityAttackChanges.Count >= 1;
  1084. }
  1085. }
  1086. public int Strike_AllowMinus
  1087. {
  1088. get
  1089. {
  1090. int Strike = 1;
  1091. #region Effect of changing the number of sheets to undergo security check
  1092. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1093. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1094. {
  1095. foreach (Permanent permanent in player.GetFieldPermanents())
  1096. {
  1097. #region Effects of permanents in play
  1098. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1099. {
  1100. if (cardEffect is IChangeSAttackEffect)
  1101. {
  1102. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1103. {
  1104. if (cardEffect.CanUse(null))
  1105. {
  1106. if (!TopCard.CanNotBeAffected(cardEffect))
  1107. {
  1108. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. #endregion
  1115. }
  1116. #region player effect
  1117. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1118. {
  1119. if (cardEffect is IChangeSAttackEffect)
  1120. {
  1121. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1122. {
  1123. if (cardEffect.CanUse(null))
  1124. {
  1125. if (!TopCard.CanNotBeAffected(cardEffect))
  1126. {
  1127. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1128. }
  1129. }
  1130. }
  1131. }
  1132. }
  1133. #endregion
  1134. }
  1135. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1136. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1137. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1138. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1139. {
  1140. if (cardEffect is IChangeSAttackEffect)
  1141. {
  1142. if (cardEffect.CanUse(null))
  1143. {
  1144. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1145. {
  1146. case CalculateOrder.UpToConstant:
  1147. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1148. break;
  1149. case CalculateOrder.UpDownValue:
  1150. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1151. break;
  1152. case CalculateOrder.DownToConstant:
  1153. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1154. break;
  1155. }
  1156. }
  1157. }
  1158. }
  1159. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1160. {
  1161. if (cardEffect is IChangeSAttackEffect)
  1162. {
  1163. if (cardEffect.CanUse(null))
  1164. {
  1165. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1166. }
  1167. }
  1168. }
  1169. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1170. {
  1171. if (cardEffect is IChangeSAttackEffect)
  1172. {
  1173. if (cardEffect.CanUse(null))
  1174. {
  1175. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1176. }
  1177. }
  1178. }
  1179. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1180. {
  1181. if (cardEffect is IChangeSAttackEffect)
  1182. {
  1183. if (cardEffect.CanUse(null))
  1184. {
  1185. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1186. }
  1187. }
  1188. }
  1189. #endregion
  1190. return Strike;
  1191. }
  1192. }
  1193. public int Strike
  1194. {
  1195. get
  1196. {
  1197. int Strike = Strike_AllowMinus;
  1198. if (Strike < 0)
  1199. {
  1200. Strike = 0;
  1201. }
  1202. return Strike;
  1203. }
  1204. }
  1205. #endregion
  1206. #region このパーマネントがタップされているかどうか
  1207. public bool OldIsSuspended = false;
  1208. public bool IsSuspended = false;
  1209. public int DPWhenSuspended = 114514;
  1210. #endregion
  1211. #region Whether this permanent can unsuspend
  1212. public bool CanUnsuspend
  1213. {
  1214. get
  1215. {
  1216. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1217. {
  1218. #region Effects of field permanents
  1219. foreach (Permanent permanent in player.GetFieldPermanents())
  1220. {
  1221. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1222. {
  1223. if (cardEffect is ICanNotUnsuspendEffect)
  1224. {
  1225. if (cardEffect.CanUse(null))
  1226. {
  1227. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1228. {
  1229. return false;
  1230. }
  1231. }
  1232. }
  1233. }
  1234. }
  1235. #endregion
  1236. #region Effects of players
  1237. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1238. {
  1239. if (cardEffect is ICanNotUnsuspendEffect)
  1240. {
  1241. if (cardEffect.CanUse(null))
  1242. {
  1243. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1244. {
  1245. return false;
  1246. }
  1247. }
  1248. }
  1249. }
  1250. #endregion
  1251. }
  1252. return true;
  1253. }
  1254. }
  1255. #endregion
  1256. #region このパーマネントが移動できるかどうか
  1257. public bool CanMove
  1258. {
  1259. get
  1260. {
  1261. if (TopCard != null)
  1262. {
  1263. #region the effects of permanents
  1264. if (GManager.instance.turnStateMachine.gameContext.Players
  1265. .Map(player => player.GetFieldPermanents())
  1266. .Flat()
  1267. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1268. .Flat()
  1269. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1270. && cardEffect.CanUse(null)
  1271. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1272. {
  1273. return false;
  1274. }
  1275. #endregion
  1276. #region the effects of players
  1277. if (GManager.instance.turnStateMachine.gameContext.Players
  1278. .Map(player => player.EffectList(EffectTiming.None))
  1279. .Flat()
  1280. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1281. && cardEffect.CanUse(null)
  1282. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1283. {
  1284. return false;
  1285. }
  1286. #endregion
  1287. #region the effects of itself
  1288. if (this == null)
  1289. {
  1290. if (EffectList(EffectTiming.None)
  1291. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1292. && cardEffect.CanUse(null)
  1293. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1294. {
  1295. return false;
  1296. }
  1297. }
  1298. #endregion
  1299. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1300. {
  1301. return false;
  1302. }
  1303. if (!IsDigimon)
  1304. {
  1305. return false;
  1306. }
  1307. if (DP <= 0)
  1308. {
  1309. return false;
  1310. }
  1311. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1312. {
  1313. return false;
  1314. }
  1315. }
  1316. else
  1317. {
  1318. return false;
  1319. }
  1320. return true;
  1321. }
  1322. }
  1323. #endregion
  1324. #region このパーマネントが攻撃できるかどうか
  1325. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1326. {
  1327. // can not attack with empty cards
  1328. if (TopCard == null)
  1329. {
  1330. return false;
  1331. }
  1332. // can not attack during opponent's turn
  1333. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1334. {
  1335. return false;
  1336. }
  1337. // can not attack to player
  1338. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex))
  1339. {
  1340. // can not attack to opponent's Digimon
  1341. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex)) == 0)
  1342. {
  1343. return false;
  1344. }
  1345. }
  1346. return true;
  1347. }
  1348. #endregion
  1349. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1350. public bool CanBlock(Permanent AttackingPermanent)
  1351. {
  1352. if (TopCard == null)
  1353. {
  1354. return false;
  1355. }
  1356. if (!IsDigimon)
  1357. {
  1358. return false;
  1359. }
  1360. if (IsSuspended)
  1361. {
  1362. return false;
  1363. }
  1364. if (!CanSuspend)
  1365. {
  1366. return false;
  1367. }
  1368. if (PermanentFrame != null)
  1369. {
  1370. if (!PermanentFrame.IsBattleAreaFrame())
  1371. {
  1372. return false;
  1373. }
  1374. }
  1375. if (!AttackingPermanent.CanSwitchAttackTarget)
  1376. return false;
  1377. #region "Unblockable" effect
  1378. #region Effects of permanents in play
  1379. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1380. {
  1381. foreach (Permanent permanent in player.GetFieldPermanents())
  1382. {
  1383. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1384. {
  1385. if (cardEffect is ICannotBlockEffect)
  1386. {
  1387. if (cardEffect.CanUse(null))
  1388. {
  1389. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1390. {
  1391. return false;
  1392. }
  1393. }
  1394. }
  1395. }
  1396. }
  1397. }
  1398. #endregion
  1399. #region player effect
  1400. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1401. {
  1402. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1403. {
  1404. if (cardEffect is ICannotBlockEffect)
  1405. {
  1406. if (cardEffect.CanUse(null))
  1407. {
  1408. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1409. {
  1410. if (!TopCard.CanNotBeAffected(cardEffect))
  1411. {
  1412. return false;
  1413. }
  1414. }
  1415. }
  1416. }
  1417. }
  1418. }
  1419. #endregion
  1420. #endregion
  1421. return true;
  1422. }
  1423. #endregion
  1424. #region 対象のパーマネントを攻撃できるか
  1425. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1426. {
  1427. if (TopCard != null)
  1428. {
  1429. if (!IsDigimon)
  1430. {
  1431. return false;
  1432. }
  1433. if (!withoutTap)
  1434. {
  1435. if (IsSuspended)
  1436. {
  1437. return false;
  1438. }
  1439. if (!CanSuspend)
  1440. {
  1441. return false;
  1442. }
  1443. }
  1444. if (PermanentFrame != null)
  1445. {
  1446. if (!PermanentFrame.IsBattleAreaFrame())
  1447. {
  1448. return false;
  1449. }
  1450. }
  1451. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1452. {
  1453. if (!HasRush && !isVortex)
  1454. {
  1455. return false;
  1456. }
  1457. }
  1458. #region 「対象の防御パーマネントを攻撃できない」効果
  1459. #region 場のパーマネントの効果
  1460. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1461. {
  1462. foreach (Permanent permanent in player.GetFieldPermanents())
  1463. {
  1464. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1465. {
  1466. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1467. {
  1468. if (cardEffect1.CanUse(null))
  1469. {
  1470. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1471. {
  1472. if (!TopCard.CanNotBeAffected(cardEffect1))
  1473. {
  1474. return false;
  1475. }
  1476. }
  1477. }
  1478. }
  1479. }
  1480. }
  1481. }
  1482. #endregion
  1483. #region プレイヤーの効果
  1484. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1485. {
  1486. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1487. {
  1488. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1489. {
  1490. if (cardEffect1.CanUse(null))
  1491. {
  1492. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1493. {
  1494. if (!TopCard.CanNotBeAffected(cardEffect1))
  1495. {
  1496. return false;
  1497. }
  1498. }
  1499. }
  1500. }
  1501. }
  1502. }
  1503. #endregion
  1504. #endregion
  1505. if (Defender != null)
  1506. {
  1507. if (Defender.TopCard != null)
  1508. {
  1509. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1510. {
  1511. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1512. {
  1513. if (Defender.IsSuspended)
  1514. {
  1515. return true;
  1516. }
  1517. #region 「対象の防御パーマネントを攻撃できる」効果
  1518. #region 場のパーマネントの効果
  1519. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1520. {
  1521. foreach (Permanent permanent in player.GetFieldPermanents())
  1522. {
  1523. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1524. {
  1525. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1526. {
  1527. if (cardEffect1.CanUse(null))
  1528. {
  1529. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1530. {
  1531. return true;
  1532. }
  1533. }
  1534. }
  1535. }
  1536. }
  1537. }
  1538. #endregion
  1539. #region プレイヤーの効果
  1540. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1541. {
  1542. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1543. {
  1544. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1545. {
  1546. if (cardEffect1.CanUse(null))
  1547. {
  1548. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1549. {
  1550. return true;
  1551. }
  1552. }
  1553. }
  1554. }
  1555. }
  1556. #endregion
  1557. #endregion
  1558. }
  1559. }
  1560. }
  1561. }
  1562. else
  1563. {
  1564. return true;
  1565. }
  1566. }
  1567. return false;
  1568. }
  1569. #endregion
  1570. #region Is Unblockable
  1571. public bool IsUnblockable
  1572. {
  1573. get
  1574. {
  1575. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1576. {
  1577. if (cardEffect is CannotBlockClass)
  1578. {
  1579. if (cardEffect.EffectName == "Can't Block")
  1580. {
  1581. return true;
  1582. }
  1583. }
  1584. }
  1585. return false;
  1586. }
  1587. }
  1588. #endregion
  1589. #region Has Blocker
  1590. public bool HasBlocker
  1591. {
  1592. get
  1593. {
  1594. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1595. {
  1596. #region Effects of permanents in play
  1597. foreach (Permanent permanent in player.GetFieldPermanents())
  1598. {
  1599. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1600. {
  1601. if (cardEffect is IBlockerEffect)
  1602. {
  1603. if (cardEffect.CanTrigger(null))
  1604. {
  1605. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1606. {
  1607. return true;
  1608. }
  1609. }
  1610. }
  1611. }
  1612. }
  1613. #endregion
  1614. #region Effects of faceup security
  1615. foreach (CardSource source in player.SecurityCards)
  1616. {
  1617. if (source.IsFlipped)
  1618. continue;
  1619. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  1620. {
  1621. if (cardEffect is IBlockerEffect)
  1622. {
  1623. if (cardEffect.CanTrigger(null))
  1624. {
  1625. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1626. {
  1627. return true;
  1628. }
  1629. }
  1630. }
  1631. }
  1632. }
  1633. #endregion
  1634. #region プレイヤーの効果
  1635. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1636. {
  1637. if (cardEffect is IBlockerEffect)
  1638. {
  1639. if (cardEffect.CanTrigger(null))
  1640. {
  1641. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1642. {
  1643. return true;
  1644. }
  1645. }
  1646. }
  1647. }
  1648. #endregion
  1649. }
  1650. return false;
  1651. }
  1652. }
  1653. #endregion
  1654. #region Has Jamming
  1655. public bool HasJamming
  1656. {
  1657. get
  1658. {
  1659. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1660. {
  1661. foreach (Permanent permanent in player.GetFieldPermanents())
  1662. {
  1663. #region 場のパーマネントの効果
  1664. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1665. {
  1666. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1667. {
  1668. if (cardEffect.CanTrigger(null))
  1669. {
  1670. if (cardEffect.EffectName == "Jamming")
  1671. {
  1672. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1673. {
  1674. return true;
  1675. }
  1676. }
  1677. }
  1678. }
  1679. }
  1680. #endregion
  1681. }
  1682. #region プレイヤーの効果
  1683. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1684. {
  1685. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1686. {
  1687. if (cardEffect.CanTrigger(null))
  1688. {
  1689. if (cardEffect.EffectName == "Jamming")
  1690. {
  1691. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1692. {
  1693. return true;
  1694. }
  1695. }
  1696. }
  1697. }
  1698. }
  1699. #endregion
  1700. }
  1701. return false;
  1702. }
  1703. }
  1704. #endregion
  1705. #region Has Ice Clad
  1706. public bool HasIceclad
  1707. {
  1708. get
  1709. {
  1710. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1711. {
  1712. #region Ice clad permanent effects
  1713. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  1714. {
  1715. if (cardEffect is IIcecladEffect)
  1716. {
  1717. if (cardEffect.CanTrigger(null))
  1718. {
  1719. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1720. {
  1721. return true;
  1722. }
  1723. }
  1724. }
  1725. }
  1726. #endregion
  1727. #region Ice clad Player Effects
  1728. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1729. {
  1730. if (cardEffect is IIcecladEffect)
  1731. {
  1732. if (cardEffect.CanTrigger(null))
  1733. {
  1734. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1735. {
  1736. return true;
  1737. }
  1738. }
  1739. }
  1740. }
  1741. #endregion
  1742. }
  1743. return false;
  1744. }
  1745. }
  1746. #endregion
  1747. #region Whether this permanent has Pierce
  1748. public bool HasPierce
  1749. {
  1750. get
  1751. {
  1752. if (IsDigimon)
  1753. {
  1754. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  1755. {
  1756. if (cardEffect is ActivateICardEffect)
  1757. {
  1758. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  1759. {
  1760. if (cardEffect.EffectName == "Pierce")
  1761. {
  1762. return true;
  1763. }
  1764. if (cardEffect.EffectName == "Piercing")
  1765. {
  1766. return true;
  1767. }
  1768. }
  1769. }
  1770. }
  1771. }
  1772. return false;
  1773. }
  1774. }
  1775. #endregion
  1776. #region Has Reboot
  1777. public bool HasReboot
  1778. {
  1779. get
  1780. {
  1781. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1782. {
  1783. foreach (Permanent permanent in player.GetFieldPermanents())
  1784. {
  1785. #region 場のパーマネントの効果
  1786. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1787. {
  1788. if (cardEffect is IRebootEffect)
  1789. {
  1790. if (cardEffect.CanTrigger(null))
  1791. {
  1792. if (((IRebootEffect)cardEffect).HasReboot(this))
  1793. {
  1794. return true;
  1795. }
  1796. }
  1797. }
  1798. }
  1799. #endregion
  1800. }
  1801. #region プレイヤーの効果
  1802. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1803. {
  1804. if (cardEffect is IRebootEffect)
  1805. {
  1806. if (cardEffect.CanTrigger(null))
  1807. {
  1808. if (((IRebootEffect)cardEffect).HasReboot(this))
  1809. {
  1810. return true;
  1811. }
  1812. }
  1813. }
  1814. }
  1815. #endregion
  1816. }
  1817. return false;
  1818. }
  1819. }
  1820. #endregion
  1821. #region Has Raid
  1822. public bool HasRaid
  1823. {
  1824. get
  1825. {
  1826. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1827. {
  1828. if (cardEffect is ActivateICardEffect)
  1829. {
  1830. if (cardEffect.EffectName == "Raid")
  1831. {
  1832. return true;
  1833. }
  1834. }
  1835. }
  1836. return false;
  1837. }
  1838. }
  1839. #endregion
  1840. #region Has Rush
  1841. public bool HasRush
  1842. {
  1843. get
  1844. {
  1845. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1846. {
  1847. foreach (Permanent permanent in player.GetFieldPermanents())
  1848. {
  1849. #region 場のパーマネントの効果
  1850. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1851. {
  1852. if (cardEffect is IRushEffect)
  1853. {
  1854. if (cardEffect.CanTrigger(null))
  1855. {
  1856. if (((IRushEffect)cardEffect).HasRush(this))
  1857. {
  1858. return true;
  1859. }
  1860. }
  1861. }
  1862. }
  1863. #endregion
  1864. }
  1865. #region プレイヤーの効果
  1866. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1867. {
  1868. if (cardEffect is IRushEffect)
  1869. {
  1870. if (cardEffect.CanTrigger(null))
  1871. {
  1872. if (((IRushEffect)cardEffect).HasRush(this))
  1873. {
  1874. return true;
  1875. }
  1876. }
  1877. }
  1878. }
  1879. #endregion
  1880. }
  1881. return false;
  1882. }
  1883. }
  1884. #endregion
  1885. #region Has Retaliation
  1886. public bool HasRetaliation
  1887. {
  1888. get
  1889. {
  1890. if (RetaliationCount >= 1)
  1891. {
  1892. return true;
  1893. }
  1894. return false;
  1895. }
  1896. }
  1897. #endregion
  1898. #region 道連れを持つ個数
  1899. public int RetaliationCount
  1900. {
  1901. get
  1902. {
  1903. int count = 0;
  1904. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1905. {
  1906. if (cardEffect is ActivateICardEffect)
  1907. {
  1908. if (cardEffect.EffectName == "Retaliation")
  1909. {
  1910. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1911. {
  1912. count++;
  1913. }
  1914. }
  1915. }
  1916. }
  1917. return count;
  1918. }
  1919. }
  1920. #endregion
  1921. #region Has Fortitude
  1922. public bool HasFortitude
  1923. {
  1924. get
  1925. {
  1926. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1927. {
  1928. if (cardEffect is ActivateICardEffect)
  1929. {
  1930. if (cardEffect.EffectName == "Fortitude")
  1931. {
  1932. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1933. {
  1934. return true;
  1935. }
  1936. }
  1937. }
  1938. }
  1939. return false;
  1940. }
  1941. }
  1942. #endregion
  1943. #region Has Blitz
  1944. public bool HasBlitz
  1945. {
  1946. get
  1947. {
  1948. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  1949. {
  1950. if (cardEffect is ActivateICardEffect)
  1951. {
  1952. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  1953. {
  1954. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1955. {
  1956. if (cardEffect.EffectDiscription.Contains("Blitz"))
  1957. {
  1958. return true;
  1959. }
  1960. }
  1961. }
  1962. }
  1963. }
  1964. return false;
  1965. }
  1966. }
  1967. #endregion
  1968. #region Has Evade
  1969. public bool HasEvade
  1970. {
  1971. get
  1972. {
  1973. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1974. {
  1975. if (cardEffect is ActivateICardEffect)
  1976. {
  1977. Hashtable hashtable = new Hashtable()
  1978. {
  1979. {"Permanents", new List<Permanent>() { this }}
  1980. };
  1981. if (cardEffect.CanTrigger(hashtable))
  1982. {
  1983. if (cardEffect.EffectName == "Evade")
  1984. {
  1985. return true;
  1986. }
  1987. }
  1988. }
  1989. }
  1990. return false;
  1991. }
  1992. }
  1993. #endregion
  1994. #region Has Mind Link
  1995. public bool HasMindLink
  1996. {
  1997. get
  1998. {
  1999. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  2000. {
  2001. if (cardEffect is ActivateICardEffect)
  2002. {
  2003. if (cardEffect.CanTrigger(null))
  2004. {
  2005. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2006. {
  2007. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2008. {
  2009. return true;
  2010. }
  2011. }
  2012. }
  2013. }
  2014. }
  2015. return false;
  2016. }
  2017. }
  2018. #endregion
  2019. #region Has Barrier
  2020. public bool HasBarrier
  2021. {
  2022. get
  2023. {
  2024. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2025. {
  2026. if (cardEffect is ActivateICardEffect)
  2027. {
  2028. Hashtable hashtable = new Hashtable();
  2029. hashtable.Add("Permanents", new List<Permanent>() { this });
  2030. hashtable.Add("battle", new IBattle(null, null, null));
  2031. if (cardEffect.CanTrigger(hashtable))
  2032. {
  2033. if (cardEffect.EffectName == "Barrier")
  2034. {
  2035. return true;
  2036. }
  2037. }
  2038. }
  2039. }
  2040. return false;
  2041. }
  2042. }
  2043. #endregion
  2044. #region Has Alliance
  2045. public bool HasAlliance
  2046. {
  2047. get
  2048. {
  2049. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2050. {
  2051. foreach (Permanent permanent in player.GetFieldPermanents())
  2052. {
  2053. #region Permanent Effects
  2054. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2055. {
  2056. if (cardEffect is IAllianceEffect)
  2057. {
  2058. if (cardEffect.CanTrigger(null))
  2059. {
  2060. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2061. {
  2062. return true;
  2063. }
  2064. }
  2065. }
  2066. }
  2067. #endregion
  2068. }
  2069. #region Player Effects
  2070. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2071. {
  2072. if (cardEffect is IAllianceEffect)
  2073. {
  2074. if (cardEffect.CanTrigger(null))
  2075. {
  2076. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2077. {
  2078. return true;
  2079. }
  2080. }
  2081. }
  2082. }
  2083. #endregion
  2084. }
  2085. return false;
  2086. }
  2087. }
  2088. #endregion
  2089. #region Has Collision
  2090. public bool HasCollision
  2091. {
  2092. get
  2093. {
  2094. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2095. {
  2096. if (cardEffect is ActivateICardEffect)
  2097. {
  2098. if (cardEffect.EffectName == "Collision")
  2099. {
  2100. return true;
  2101. }
  2102. }
  2103. }
  2104. return false;
  2105. }
  2106. }
  2107. #endregion
  2108. #region Has Partition
  2109. public bool HasPartition
  2110. {
  2111. get
  2112. {
  2113. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2114. {
  2115. if (cardEffect is ActivateICardEffect)
  2116. {
  2117. if (cardEffect.EffectName == "Partition")
  2118. {
  2119. return true;
  2120. }
  2121. }
  2122. }
  2123. return false;
  2124. }
  2125. }
  2126. #endregion
  2127. #region 消滅時効化を持つか
  2128. public bool HasOnDeletionEffect
  2129. {
  2130. get
  2131. {
  2132. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2133. {
  2134. if (cardEffect is ActivateICardEffect)
  2135. {
  2136. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2137. {
  2138. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2139. {
  2140. if (cardEffect.IsOnDeletion)
  2141. {
  2142. return true;
  2143. }
  2144. }
  2145. }
  2146. }
  2147. }
  2148. return false;
  2149. }
  2150. }
  2151. #endregion
  2152. #region バトルしているか
  2153. public IBattle battle { get; set; } = null;
  2154. #endregion
  2155. #region Can Be Destroyed
  2156. public bool CanBeDestroyed()
  2157. {
  2158. #region 消滅しない効果
  2159. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2160. {
  2161. foreach (Permanent permanent in player.GetFieldPermanents())
  2162. {
  2163. #region 場のパーマネントの効果
  2164. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2165. {
  2166. if (cardEffect is ICanNotBeDestroyedEffect)
  2167. {
  2168. if (cardEffect.CanUse(null))
  2169. {
  2170. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2171. {
  2172. return false;
  2173. }
  2174. }
  2175. }
  2176. }
  2177. #endregion
  2178. }
  2179. #region プレイヤーの効果
  2180. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2181. {
  2182. if (cardEffect is ICanNotBeDestroyedEffect)
  2183. {
  2184. if (cardEffect.CanUse(null))
  2185. {
  2186. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2187. {
  2188. return false;
  2189. }
  2190. }
  2191. }
  2192. }
  2193. #endregion
  2194. }
  2195. #endregion
  2196. return true;
  2197. }
  2198. #endregion
  2199. #region このデジモンが戦闘によって消滅するか
  2200. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2201. {
  2202. if (!CanBeDestroyed())
  2203. {
  2204. return false;
  2205. }
  2206. #region 戦闘で消滅しない効果
  2207. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2208. {
  2209. foreach (Permanent permanent in player.GetFieldPermanents())
  2210. {
  2211. #region 場のパーマネントの効果
  2212. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2213. {
  2214. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2215. {
  2216. if (cardEffect.CanUse(null))
  2217. {
  2218. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2219. {
  2220. return false;
  2221. }
  2222. }
  2223. }
  2224. }
  2225. #endregion
  2226. }
  2227. #region プレイヤーの効果
  2228. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2229. {
  2230. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2231. {
  2232. if (cardEffect.CanUse(null))
  2233. {
  2234. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2235. {
  2236. return false;
  2237. }
  2238. }
  2239. }
  2240. }
  2241. #endregion
  2242. }
  2243. #endregion
  2244. return true;
  2245. }
  2246. #endregion
  2247. #region このパーマネントが効果で消滅するか
  2248. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2249. {
  2250. if (this.TopCard != null)
  2251. {
  2252. if (this.TopCard.CanNotBeAffected(cardEffect))
  2253. {
  2254. return false;
  2255. }
  2256. if (!CanBeDestroyed())
  2257. {
  2258. return false;
  2259. }
  2260. #region 効果で消滅しない効果
  2261. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2262. {
  2263. foreach (Permanent permanent in player.GetFieldPermanents())
  2264. {
  2265. #region 場のパーマネントの効果
  2266. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2267. {
  2268. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2269. {
  2270. if (cardEffect1.CanUse(null))
  2271. {
  2272. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2273. {
  2274. return false;
  2275. }
  2276. }
  2277. }
  2278. }
  2279. #endregion
  2280. }
  2281. #region プレイヤーの効果
  2282. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2283. {
  2284. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2285. {
  2286. if (cardEffect1.CanUse(null))
  2287. {
  2288. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2289. {
  2290. return false;
  2291. }
  2292. }
  2293. }
  2294. }
  2295. #endregion
  2296. }
  2297. #endregion
  2298. }
  2299. return true;
  2300. }
  2301. #endregion
  2302. #region Can Leave Field
  2303. public bool CanBeRemoved()
  2304. {
  2305. #region Effect that never disappears
  2306. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2307. {
  2308. foreach (Permanent permanent in player.GetFieldPermanents())
  2309. {
  2310. #region Effects of permanents in play
  2311. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2312. {
  2313. if (cardEffect is ICanNotBeRemovedEffect)
  2314. {
  2315. if (cardEffect.CanUse(null))
  2316. {
  2317. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2318. {
  2319. return false;
  2320. }
  2321. }
  2322. }
  2323. }
  2324. #endregion
  2325. }
  2326. #region player effect
  2327. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2328. {
  2329. if (cardEffect is ICanNotBeRemovedEffect)
  2330. {
  2331. if (cardEffect.CanUse(null))
  2332. {
  2333. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2334. {
  2335. return false;
  2336. }
  2337. }
  2338. }
  2339. }
  2340. #endregion
  2341. }
  2342. #endregion
  2343. return true;
  2344. }
  2345. #endregion
  2346. #region トークンかどうか
  2347. public bool IsToken
  2348. {
  2349. get
  2350. {
  2351. if (TopCard != null)
  2352. {
  2353. if (TopCard.IsToken)
  2354. {
  2355. return true;
  2356. }
  2357. }
  2358. return false;
  2359. }
  2360. }
  2361. #endregion
  2362. #region そのパーマネントが消滅・バウンス待機状態か
  2363. public bool willBeRemoveField { get; set; } = false;
  2364. #endregion
  2365. #region Is a Digimon card
  2366. public bool IsDigimon
  2367. {
  2368. get
  2369. {
  2370. if (TopCard != null)
  2371. {
  2372. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2373. {
  2374. return true;
  2375. }
  2376. #region Effect of treating it as a Digimon
  2377. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2378. {
  2379. foreach (Permanent permanent in player.GetFieldPermanents())
  2380. {
  2381. #region Effects of permanents in play
  2382. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2383. {
  2384. if (cardEffect is ITreatAsDigimonEffect)
  2385. {
  2386. if (cardEffect.CanTrigger(null))
  2387. {
  2388. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2389. {
  2390. return true;
  2391. }
  2392. }
  2393. }
  2394. }
  2395. #endregion
  2396. }
  2397. #region player effect
  2398. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2399. {
  2400. if (cardEffect is ITreatAsDigimonEffect)
  2401. {
  2402. if (cardEffect.CanTrigger(null))
  2403. {
  2404. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2405. {
  2406. return true;
  2407. }
  2408. }
  2409. }
  2410. }
  2411. #endregion
  2412. }
  2413. #endregion
  2414. }
  2415. return false;
  2416. }
  2417. }
  2418. #endregion
  2419. #region Is a Tamer card
  2420. public bool IsTamer
  2421. {
  2422. get
  2423. {
  2424. if (TopCard != null)
  2425. {
  2426. if (TopCard.IsTamer)
  2427. {
  2428. return true;
  2429. }
  2430. }
  2431. return false;
  2432. }
  2433. }
  2434. #endregion
  2435. #region Is an Option card
  2436. public bool IsOption
  2437. {
  2438. get
  2439. {
  2440. if (TopCard != null)
  2441. {
  2442. if (TopCard.IsOption)
  2443. {
  2444. return true;
  2445. }
  2446. }
  2447. return false;
  2448. }
  2449. }
  2450. #endregion
  2451. #region Levels handled by Jogress
  2452. public List<int> Levels_ForJogress(CardSource cardSource)
  2453. {
  2454. List<int> levels = new List<int>();
  2455. if (cardSource != null)
  2456. {
  2457. if (cardSource.HasLevel)
  2458. {
  2459. levels.Add(this.Level);
  2460. }
  2461. #region Effect of "adding levels handled by jogless evolution"
  2462. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2463. {
  2464. foreach (Permanent permanent in player.GetFieldPermanents())
  2465. {
  2466. #region Effects of permanents in play
  2467. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2468. {
  2469. if (cardEffect is IAddJogressLevelsEffect)
  2470. {
  2471. if (cardEffect.CanUse(null))
  2472. {
  2473. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2474. {
  2475. levels.Add(level);
  2476. }
  2477. }
  2478. }
  2479. }
  2480. #endregion
  2481. }
  2482. #region player effect
  2483. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2484. {
  2485. if (cardEffect is IAddJogressLevelsEffect)
  2486. {
  2487. if (cardEffect.CanUse(null))
  2488. {
  2489. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2490. {
  2491. levels.Add(level);
  2492. }
  2493. }
  2494. }
  2495. }
  2496. #endregion
  2497. }
  2498. #endregion
  2499. }
  2500. return levels;
  2501. }
  2502. #endregion
  2503. #region Names handled by Jogress
  2504. public List<string> Names_ForDNA(CardSource cardSource)
  2505. {
  2506. List<string> names = new List<string>();
  2507. if (cardSource != null)
  2508. {
  2509. foreach(string name in cardSource.CardNames)
  2510. names.Add(name);
  2511. #region Effect of "adding names handled by DNA evolution"
  2512. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2513. {
  2514. foreach (Permanent permanent in player.GetFieldPermanents())
  2515. {
  2516. #region Effects of permanents in play
  2517. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2518. {
  2519. if (cardEffect is IAddDNANamesEffect)
  2520. {
  2521. if (cardEffect.CanUse(null))
  2522. {
  2523. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2524. {
  2525. names.Add(name);
  2526. }
  2527. }
  2528. }
  2529. }
  2530. #endregion
  2531. }
  2532. #region player effect
  2533. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2534. {
  2535. if (cardEffect is IAddDNANamesEffect)
  2536. {
  2537. if (cardEffect.CanUse(null))
  2538. {
  2539. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2540. {
  2541. names.Add(name);
  2542. }
  2543. }
  2544. }
  2545. }
  2546. #endregion
  2547. }
  2548. #endregion
  2549. }
  2550. return names;
  2551. }
  2552. #endregion
  2553. #region バトルで消滅したか
  2554. public bool IsDestroyedByBattle { get; set; } = false;
  2555. #endregion
  2556. #region 消滅に使用された効果
  2557. public ICardEffect DestroyingEffect { get; set; } = null;
  2558. #endregion
  2559. #region 他のパーマネントの下に置くのに使用された効果
  2560. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2561. #endregion
  2562. #region 手札バウンス に使用された効果
  2563. public ICardEffect HandBounceEffect { get; set; } = null;
  2564. #endregion
  2565. #region 山札バウンス に使用された効果
  2566. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2567. #endregion
  2568. #region 登場に使用された効果
  2569. public ICardEffect PlayingEffect { get; set; } = null;
  2570. #endregion
  2571. #region 進化に使用された効果
  2572. public ICardEffect DigivolvingEffect { get; set; } = null;
  2573. #endregion
  2574. #region Whether this digimon is placed in the trash by not having a DP
  2575. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2576. #endregion
  2577. #region Whether this permanent can suspend
  2578. public bool CanSuspend
  2579. {
  2580. get
  2581. {
  2582. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2583. {
  2584. #region Effects of field permanents
  2585. foreach (Permanent permanent in player.GetFieldPermanents())
  2586. {
  2587. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2588. {
  2589. if (cardEffect is ICanNotSuspendEffect)
  2590. {
  2591. if (cardEffect.CanUse(null))
  2592. {
  2593. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2594. {
  2595. return false;
  2596. }
  2597. }
  2598. }
  2599. }
  2600. }
  2601. #endregion
  2602. #region Effects of players
  2603. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2604. {
  2605. if (cardEffect is ICanNotSuspendEffect)
  2606. {
  2607. if (cardEffect.CanUse(null))
  2608. {
  2609. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2610. {
  2611. return false;
  2612. }
  2613. }
  2614. }
  2615. }
  2616. #endregion
  2617. }
  2618. return true;
  2619. }
  2620. }
  2621. #endregion
  2622. #region このデジモンのアタックの対象が変更できるか
  2623. public bool CanSwitchAttackTarget
  2624. {
  2625. get
  2626. {
  2627. #region アタックの対象が変更できない効果
  2628. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2629. {
  2630. foreach (Permanent permanent in player.GetFieldPermanents())
  2631. {
  2632. #region 場のパーマネントの効果
  2633. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2634. {
  2635. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2636. {
  2637. if (cardEffect.CanUse(null))
  2638. {
  2639. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2640. {
  2641. return false;
  2642. }
  2643. }
  2644. }
  2645. }
  2646. #endregion
  2647. }
  2648. #region プレイヤーの効果
  2649. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2650. {
  2651. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2652. {
  2653. if (cardEffect.CanUse(null))
  2654. {
  2655. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2656. {
  2657. return false;
  2658. }
  2659. }
  2660. }
  2661. }
  2662. #endregion
  2663. }
  2664. #endregion
  2665. return true;
  2666. }
  2667. }
  2668. #endregion
  2669. #region このデジモンを場からデジクロス条件の代わりにできるか
  2670. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  2671. {
  2672. #region デジクロス条件の代わりにできる効果
  2673. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2674. {
  2675. foreach (Permanent permanent in player.GetFieldPermanents())
  2676. {
  2677. #region 場のパーマネントの効果
  2678. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2679. {
  2680. if (cardEffect is ICanSelectDigiXrosEffect)
  2681. {
  2682. if (cardEffect.CanUse(null))
  2683. {
  2684. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2685. {
  2686. return true;
  2687. }
  2688. }
  2689. }
  2690. }
  2691. #endregion
  2692. }
  2693. #region プレイヤーの効果
  2694. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2695. {
  2696. if (cardEffect is ICanSelectDigiXrosEffect)
  2697. {
  2698. if (cardEffect.CanUse(null))
  2699. {
  2700. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2701. {
  2702. return true;
  2703. }
  2704. }
  2705. }
  2706. }
  2707. #endregion
  2708. }
  2709. #endregion
  2710. return false;
  2711. }
  2712. #endregion
  2713. #region 登場した直後のLevel
  2714. public int LevelJustAfterPlayed { get; set; } = -1;
  2715. #endregion
  2716. #region 登場した直後のPlay Cost
  2717. public int PlayCostJustAfterPlayed { get; set; } = -1;
  2718. #endregion
  2719. #region 登場した直後のCardNames
  2720. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  2721. #endregion
  2722. #region 進化した直後のCardNames
  2723. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  2724. #endregion
  2725. #region 登場した直後のTraits
  2726. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  2727. #endregion
  2728. #region 場を離れる直前のDP
  2729. public int DPJustBeforeRemoveField { get; set; } = -1;
  2730. #endregion
  2731. #region 場を離れる直前のLevel
  2732. public int LevelJustBeforeRemoveField { get; set; } = -1;
  2733. #endregion
  2734. #region 場を離れる直前のCost
  2735. public int CostJustBeforeRemoveField { get; set; } = -1;
  2736. #endregion
  2737. #region 場を離れる直前のカード名
  2738. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  2739. #endregion
  2740. #region Card Traits Just Before Removed Field
  2741. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  2742. #endregion
  2743. #region バースト進化で手札に戻ったか
  2744. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  2745. #endregion
  2746. #region バースト進化したか
  2747. public bool IsBurstDigivolved { get; set; } = false;
  2748. #endregion
  2749. #region 効果で場に出たオプションか
  2750. public bool IsPlayedOptionPermanent { get; set; } = false;
  2751. #endregion
  2752. #region 進化元を持たないか
  2753. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  2754. #endregion
  2755. #region Digivolution cards' colors
  2756. public List<CardColor> DigivolutionCardsColors
  2757. {
  2758. get
  2759. {
  2760. List<CardColor> cardColors = new List<CardColor>();
  2761. foreach (CardSource cardSource in DigivolutionCards)
  2762. {
  2763. foreach (CardColor cardColor in cardSource.CardColors)
  2764. {
  2765. if (!cardColors.Contains(cardColor))
  2766. {
  2767. cardColors.Add(cardColor);
  2768. }
  2769. }
  2770. }
  2771. return cardColors.Distinct().ToList();
  2772. }
  2773. }
  2774. #endregion
  2775. #region Show "Unsuspend" effect object
  2776. public void ShowUnsuspendEffect()
  2777. {
  2778. if (TopCard != null)
  2779. {
  2780. if (ShowingPermanentCard != null)
  2781. {
  2782. if (ShowingPermanentCard.WillUntapObject != null)
  2783. {
  2784. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  2785. ShowingPermanentCard.WillUntapObject.SetActive(true);
  2786. }
  2787. }
  2788. }
  2789. }
  2790. #endregion
  2791. #region Show "Return to deck" effect object
  2792. public void ShowDeckBounceEffect()
  2793. {
  2794. if (TopCard != null)
  2795. {
  2796. if (willBeRemoveField)
  2797. {
  2798. if (ShowingPermanentCard != null)
  2799. {
  2800. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2801. {
  2802. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  2803. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  2804. }
  2805. }
  2806. }
  2807. }
  2808. }
  2809. #endregion
  2810. #region Hide "Return to deck" effect object
  2811. public void HideDeckBounceEffect()
  2812. {
  2813. if (TopCard != null)
  2814. {
  2815. if (ShowingPermanentCard != null)
  2816. {
  2817. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2818. {
  2819. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  2820. }
  2821. }
  2822. }
  2823. }
  2824. #endregion
  2825. #region Show "Return to hand" effect object
  2826. public void ShowHandBounceEffect()
  2827. {
  2828. if (TopCard != null)
  2829. {
  2830. if (willBeRemoveField)
  2831. {
  2832. if (ShowingPermanentCard != null)
  2833. {
  2834. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2835. {
  2836. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  2837. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  2838. }
  2839. }
  2840. }
  2841. }
  2842. }
  2843. #endregion
  2844. #region Hide "Return to hand" effect object
  2845. public void HideHandBounceEffect()
  2846. {
  2847. if (TopCard != null)
  2848. {
  2849. if (ShowingPermanentCard != null)
  2850. {
  2851. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2852. {
  2853. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  2854. }
  2855. }
  2856. }
  2857. }
  2858. #endregion
  2859. #region Show "Delete" effect object
  2860. public void ShowDeleteEffect()
  2861. {
  2862. if (TopCard != null)
  2863. {
  2864. if (willBeRemoveField)
  2865. {
  2866. if (ShowingPermanentCard != null)
  2867. {
  2868. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2869. {
  2870. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  2871. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  2872. }
  2873. }
  2874. }
  2875. }
  2876. }
  2877. #endregion
  2878. #region Hide "Delete" effect object
  2879. public void HideDeleteEffect()
  2880. {
  2881. if (TopCard != null)
  2882. {
  2883. if (ShowingPermanentCard != null)
  2884. {
  2885. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2886. {
  2887. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  2888. }
  2889. }
  2890. }
  2891. }
  2892. #endregion
  2893. #region Show "Remove Field" effect object
  2894. public void ShowWillRemoveFieldEffect()
  2895. {
  2896. if (TopCard != null)
  2897. {
  2898. if (willBeRemoveField)
  2899. {
  2900. if (ShowingPermanentCard != null)
  2901. {
  2902. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2903. {
  2904. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  2905. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  2906. }
  2907. }
  2908. }
  2909. }
  2910. }
  2911. #endregion
  2912. #region Hide "Remove Field" effect object
  2913. public void HideWillRemoveFieldEffect()
  2914. {
  2915. if (TopCard != null)
  2916. {
  2917. if (ShowingPermanentCard != null)
  2918. {
  2919. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2920. {
  2921. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  2922. }
  2923. }
  2924. }
  2925. }
  2926. #endregion
  2927. #region Show "Digivolution" effect object
  2928. public void ShowWillEvolutionEffect()
  2929. {
  2930. if (TopCard != null)
  2931. {
  2932. if (ShowingPermanentCard != null)
  2933. {
  2934. if (ShowingPermanentCard.WillEvolutionObject != null)
  2935. {
  2936. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  2937. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  2938. }
  2939. }
  2940. }
  2941. }
  2942. #endregion
  2943. #region Hide "Digivolution" effect object
  2944. public void HideWillEvolutionEffect()
  2945. {
  2946. if (TopCard != null)
  2947. {
  2948. if (ShowingPermanentCard != null)
  2949. {
  2950. if (ShowingPermanentCard.WillEvolutionObject != null)
  2951. {
  2952. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  2953. }
  2954. }
  2955. }
  2956. }
  2957. #endregion
  2958. }