Permanent.cs 111 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366
  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. return false;
  1305. if (TopCard.IsDigiEgg && DP <= 0)
  1306. return false;
  1307. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1308. {
  1309. return false;
  1310. }
  1311. }
  1312. else
  1313. {
  1314. return false;
  1315. }
  1316. return true;
  1317. }
  1318. }
  1319. #endregion
  1320. #region このパーマネントが攻撃できるかどうか
  1321. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1322. {
  1323. // can not attack with empty cards
  1324. if (TopCard == null)
  1325. {
  1326. return false;
  1327. }
  1328. // can not attack during opponent's turn
  1329. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1330. {
  1331. return false;
  1332. }
  1333. // can not attack to player
  1334. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex))
  1335. {
  1336. // can not attack to opponent's Digimon
  1337. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex)) == 0)
  1338. {
  1339. return false;
  1340. }
  1341. }
  1342. return true;
  1343. }
  1344. #endregion
  1345. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1346. public bool CanBlock(Permanent AttackingPermanent)
  1347. {
  1348. if (TopCard == null)
  1349. {
  1350. return false;
  1351. }
  1352. if (!IsDigimon)
  1353. {
  1354. return false;
  1355. }
  1356. if (IsSuspended)
  1357. {
  1358. return false;
  1359. }
  1360. if (!CanSuspend)
  1361. {
  1362. return false;
  1363. }
  1364. if (PermanentFrame != null)
  1365. {
  1366. if (!PermanentFrame.IsBattleAreaFrame())
  1367. {
  1368. return false;
  1369. }
  1370. }
  1371. if (!AttackingPermanent.CanSwitchAttackTarget)
  1372. return false;
  1373. #region "Unblockable" effect
  1374. #region Effects of permanents in play
  1375. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1376. {
  1377. foreach (Permanent permanent in player.GetFieldPermanents())
  1378. {
  1379. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1380. {
  1381. if (cardEffect is ICannotBlockEffect)
  1382. {
  1383. if (cardEffect.CanUse(null))
  1384. {
  1385. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1386. {
  1387. return false;
  1388. }
  1389. }
  1390. }
  1391. }
  1392. }
  1393. }
  1394. #endregion
  1395. #region player effect
  1396. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1397. {
  1398. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1399. {
  1400. if (cardEffect is ICannotBlockEffect)
  1401. {
  1402. if (cardEffect.CanUse(null))
  1403. {
  1404. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1405. {
  1406. if (!TopCard.CanNotBeAffected(cardEffect))
  1407. {
  1408. return false;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. }
  1414. }
  1415. #endregion
  1416. #endregion
  1417. return true;
  1418. }
  1419. #endregion
  1420. #region 対象のパーマネントを攻撃できるか
  1421. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1422. {
  1423. if (TopCard != null)
  1424. {
  1425. if (!IsDigimon)
  1426. {
  1427. return false;
  1428. }
  1429. if (!withoutTap)
  1430. {
  1431. if (IsSuspended)
  1432. {
  1433. return false;
  1434. }
  1435. if (!CanSuspend)
  1436. {
  1437. return false;
  1438. }
  1439. }
  1440. if (PermanentFrame != null)
  1441. {
  1442. if (!PermanentFrame.IsBattleAreaFrame())
  1443. {
  1444. return false;
  1445. }
  1446. }
  1447. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1448. {
  1449. if (!HasRush && !isVortex)
  1450. {
  1451. return false;
  1452. }
  1453. }
  1454. #region 「対象の防御パーマネントを攻撃できない」効果
  1455. #region 場のパーマネントの効果
  1456. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1457. {
  1458. foreach (Permanent permanent in player.GetFieldPermanents())
  1459. {
  1460. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1461. {
  1462. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1463. {
  1464. if (cardEffect1.CanUse(null))
  1465. {
  1466. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1467. {
  1468. if (!TopCard.CanNotBeAffected(cardEffect1))
  1469. {
  1470. return false;
  1471. }
  1472. }
  1473. }
  1474. }
  1475. }
  1476. }
  1477. }
  1478. #endregion
  1479. #region プレイヤーの効果
  1480. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1481. {
  1482. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1483. {
  1484. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1485. {
  1486. if (cardEffect1.CanUse(null))
  1487. {
  1488. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1489. {
  1490. if (!TopCard.CanNotBeAffected(cardEffect1))
  1491. {
  1492. return false;
  1493. }
  1494. }
  1495. }
  1496. }
  1497. }
  1498. }
  1499. #endregion
  1500. #endregion
  1501. if (Defender != null)
  1502. {
  1503. if (Defender.TopCard != null)
  1504. {
  1505. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1506. {
  1507. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1508. {
  1509. if (Defender.IsSuspended)
  1510. {
  1511. return true;
  1512. }
  1513. #region 「対象の防御パーマネントを攻撃できる」効果
  1514. #region 場のパーマネントの効果
  1515. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1516. {
  1517. foreach (Permanent permanent in player.GetFieldPermanents())
  1518. {
  1519. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1520. {
  1521. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1522. {
  1523. if (cardEffect1.CanUse(null))
  1524. {
  1525. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1526. {
  1527. return true;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. }
  1533. }
  1534. #endregion
  1535. #region プレイヤーの効果
  1536. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1537. {
  1538. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1539. {
  1540. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1541. {
  1542. if (cardEffect1.CanUse(null))
  1543. {
  1544. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1545. {
  1546. return true;
  1547. }
  1548. }
  1549. }
  1550. }
  1551. }
  1552. #endregion
  1553. #endregion
  1554. }
  1555. }
  1556. }
  1557. }
  1558. else
  1559. {
  1560. return true;
  1561. }
  1562. }
  1563. return false;
  1564. }
  1565. #endregion
  1566. #region Is Unblockable
  1567. public bool IsUnblockable
  1568. {
  1569. get
  1570. {
  1571. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1572. {
  1573. if (cardEffect is CannotBlockClass)
  1574. {
  1575. if (cardEffect.EffectName == "Can't Block")
  1576. {
  1577. return true;
  1578. }
  1579. }
  1580. }
  1581. return false;
  1582. }
  1583. }
  1584. #endregion
  1585. #region Has Blocker
  1586. public bool HasBlocker
  1587. {
  1588. get
  1589. {
  1590. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1591. {
  1592. #region Effects of permanents in play
  1593. foreach (Permanent permanent in player.GetFieldPermanents())
  1594. {
  1595. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1596. {
  1597. if (cardEffect is IBlockerEffect)
  1598. {
  1599. if (cardEffect.CanTrigger(null))
  1600. {
  1601. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1602. {
  1603. return true;
  1604. }
  1605. }
  1606. }
  1607. }
  1608. }
  1609. #endregion
  1610. #region Effects of faceup security
  1611. foreach (CardSource source in player.SecurityCards)
  1612. {
  1613. if (source.IsFlipped)
  1614. continue;
  1615. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  1616. {
  1617. if (cardEffect is IBlockerEffect)
  1618. {
  1619. if (cardEffect.CanTrigger(null))
  1620. {
  1621. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1622. {
  1623. return true;
  1624. }
  1625. }
  1626. }
  1627. }
  1628. }
  1629. #endregion
  1630. #region プレイヤーの効果
  1631. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1632. {
  1633. if (cardEffect is IBlockerEffect)
  1634. {
  1635. if (cardEffect.CanTrigger(null))
  1636. {
  1637. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1638. {
  1639. return true;
  1640. }
  1641. }
  1642. }
  1643. }
  1644. #endregion
  1645. }
  1646. return false;
  1647. }
  1648. }
  1649. #endregion
  1650. #region Has Jamming
  1651. public bool HasJamming
  1652. {
  1653. get
  1654. {
  1655. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1656. {
  1657. foreach (Permanent permanent in player.GetFieldPermanents())
  1658. {
  1659. #region 場のパーマネントの効果
  1660. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1661. {
  1662. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1663. {
  1664. if (cardEffect.CanTrigger(null))
  1665. {
  1666. if (cardEffect.EffectName == "Jamming")
  1667. {
  1668. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1669. {
  1670. return true;
  1671. }
  1672. }
  1673. }
  1674. }
  1675. }
  1676. #endregion
  1677. }
  1678. #region プレイヤーの効果
  1679. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1680. {
  1681. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1682. {
  1683. if (cardEffect.CanTrigger(null))
  1684. {
  1685. if (cardEffect.EffectName == "Jamming")
  1686. {
  1687. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1688. {
  1689. return true;
  1690. }
  1691. }
  1692. }
  1693. }
  1694. }
  1695. #endregion
  1696. }
  1697. return false;
  1698. }
  1699. }
  1700. #endregion
  1701. #region Has Ice Clad
  1702. public bool HasIceclad
  1703. {
  1704. get
  1705. {
  1706. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1707. {
  1708. #region Ice clad permanent effects
  1709. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  1710. {
  1711. if (cardEffect is IIcecladEffect)
  1712. {
  1713. if (cardEffect.CanTrigger(null))
  1714. {
  1715. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1716. {
  1717. return true;
  1718. }
  1719. }
  1720. }
  1721. }
  1722. #endregion
  1723. #region Ice clad Player Effects
  1724. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1725. {
  1726. if (cardEffect is IIcecladEffect)
  1727. {
  1728. if (cardEffect.CanTrigger(null))
  1729. {
  1730. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1731. {
  1732. return true;
  1733. }
  1734. }
  1735. }
  1736. }
  1737. #endregion
  1738. }
  1739. return false;
  1740. }
  1741. }
  1742. #endregion
  1743. #region Whether this permanent has Pierce
  1744. public bool HasPierce
  1745. {
  1746. get
  1747. {
  1748. if (IsDigimon)
  1749. {
  1750. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  1751. {
  1752. if (cardEffect is ActivateICardEffect)
  1753. {
  1754. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  1755. {
  1756. if (cardEffect.EffectName == "Pierce")
  1757. {
  1758. return true;
  1759. }
  1760. if (cardEffect.EffectName == "Piercing")
  1761. {
  1762. return true;
  1763. }
  1764. }
  1765. }
  1766. }
  1767. }
  1768. return false;
  1769. }
  1770. }
  1771. #endregion
  1772. #region Has Reboot
  1773. public bool HasReboot
  1774. {
  1775. get
  1776. {
  1777. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1778. {
  1779. foreach (Permanent permanent in player.GetFieldPermanents())
  1780. {
  1781. #region 場のパーマネントの効果
  1782. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1783. {
  1784. if (cardEffect is IRebootEffect)
  1785. {
  1786. if (cardEffect.CanTrigger(null))
  1787. {
  1788. if (((IRebootEffect)cardEffect).HasReboot(this))
  1789. {
  1790. return true;
  1791. }
  1792. }
  1793. }
  1794. }
  1795. #endregion
  1796. }
  1797. #region プレイヤーの効果
  1798. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1799. {
  1800. if (cardEffect is IRebootEffect)
  1801. {
  1802. if (cardEffect.CanTrigger(null))
  1803. {
  1804. if (((IRebootEffect)cardEffect).HasReboot(this))
  1805. {
  1806. return true;
  1807. }
  1808. }
  1809. }
  1810. }
  1811. #endregion
  1812. }
  1813. return false;
  1814. }
  1815. }
  1816. #endregion
  1817. #region Has Raid
  1818. public bool HasRaid
  1819. {
  1820. get
  1821. {
  1822. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  1823. {
  1824. if (cardEffect is ActivateICardEffect)
  1825. {
  1826. if (cardEffect.EffectName == "Raid")
  1827. {
  1828. return true;
  1829. }
  1830. }
  1831. }
  1832. return false;
  1833. }
  1834. }
  1835. #endregion
  1836. #region Has Rush
  1837. public bool HasRush
  1838. {
  1839. get
  1840. {
  1841. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1842. {
  1843. foreach (Permanent permanent in player.GetFieldPermanents())
  1844. {
  1845. #region 場のパーマネントの効果
  1846. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1847. {
  1848. if (cardEffect is IRushEffect)
  1849. {
  1850. if (cardEffect.CanTrigger(null))
  1851. {
  1852. if (((IRushEffect)cardEffect).HasRush(this))
  1853. {
  1854. return true;
  1855. }
  1856. }
  1857. }
  1858. }
  1859. #endregion
  1860. }
  1861. #region プレイヤーの効果
  1862. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1863. {
  1864. if (cardEffect is IRushEffect)
  1865. {
  1866. if (cardEffect.CanTrigger(null))
  1867. {
  1868. if (((IRushEffect)cardEffect).HasRush(this))
  1869. {
  1870. return true;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. #endregion
  1876. }
  1877. return false;
  1878. }
  1879. }
  1880. #endregion
  1881. #region Has Retaliation
  1882. public bool HasRetaliation
  1883. {
  1884. get
  1885. {
  1886. if (RetaliationCount >= 1)
  1887. {
  1888. return true;
  1889. }
  1890. return false;
  1891. }
  1892. }
  1893. #endregion
  1894. #region Retaliation Count
  1895. public int RetaliationCount
  1896. {
  1897. get
  1898. {
  1899. int count = 0;
  1900. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1901. {
  1902. if (cardEffect is ActivateICardEffect)
  1903. {
  1904. if (cardEffect.EffectName == "Retaliation")
  1905. {
  1906. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1907. {
  1908. count++;
  1909. }
  1910. }
  1911. }
  1912. }
  1913. return count;
  1914. }
  1915. }
  1916. #endregion
  1917. #region Has Fortitude
  1918. public bool HasFortitude
  1919. {
  1920. get
  1921. {
  1922. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  1923. {
  1924. if (cardEffect is ActivateICardEffect)
  1925. {
  1926. if (cardEffect.EffectName == "Fortitude")
  1927. {
  1928. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  1929. {
  1930. return true;
  1931. }
  1932. }
  1933. }
  1934. }
  1935. return false;
  1936. }
  1937. }
  1938. #endregion
  1939. #region Has Blitz
  1940. public bool HasBlitz
  1941. {
  1942. get
  1943. {
  1944. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  1945. {
  1946. if (cardEffect is ActivateICardEffect)
  1947. {
  1948. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  1949. {
  1950. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  1951. {
  1952. if (cardEffect.EffectDiscription.Contains("Blitz"))
  1953. {
  1954. return true;
  1955. }
  1956. }
  1957. }
  1958. }
  1959. }
  1960. return false;
  1961. }
  1962. }
  1963. #endregion
  1964. #region Has Evade
  1965. public bool HasEvade
  1966. {
  1967. get
  1968. {
  1969. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  1970. {
  1971. if (cardEffect is ActivateICardEffect)
  1972. {
  1973. Hashtable hashtable = new Hashtable()
  1974. {
  1975. {"Permanents", new List<Permanent>() { this }}
  1976. };
  1977. if (cardEffect.CanTrigger(hashtable))
  1978. {
  1979. if (cardEffect.EffectName == "Evade")
  1980. {
  1981. return true;
  1982. }
  1983. }
  1984. }
  1985. }
  1986. return false;
  1987. }
  1988. }
  1989. #endregion
  1990. #region Has Mind Link
  1991. public bool HasMindLink
  1992. {
  1993. get
  1994. {
  1995. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  1996. {
  1997. if (cardEffect is ActivateICardEffect)
  1998. {
  1999. if (cardEffect.CanTrigger(null))
  2000. {
  2001. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2002. {
  2003. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2004. {
  2005. return true;
  2006. }
  2007. }
  2008. }
  2009. }
  2010. }
  2011. return false;
  2012. }
  2013. }
  2014. #endregion
  2015. #region Has Barrier
  2016. public bool HasBarrier
  2017. {
  2018. get
  2019. {
  2020. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2021. {
  2022. if (cardEffect is ActivateICardEffect)
  2023. {
  2024. Hashtable hashtable = new Hashtable();
  2025. hashtable.Add("Permanents", new List<Permanent>() { this });
  2026. hashtable.Add("battle", new IBattle(null, null, null));
  2027. if (cardEffect.CanTrigger(hashtable))
  2028. {
  2029. if (cardEffect.EffectName == "Barrier")
  2030. {
  2031. return true;
  2032. }
  2033. }
  2034. }
  2035. }
  2036. return false;
  2037. }
  2038. }
  2039. #endregion
  2040. #region Has Alliance
  2041. public bool HasAlliance
  2042. {
  2043. get
  2044. {
  2045. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2046. {
  2047. foreach (Permanent permanent in player.GetFieldPermanents())
  2048. {
  2049. #region Permanent Effects
  2050. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2051. {
  2052. if (cardEffect is IAllianceEffect)
  2053. {
  2054. if (cardEffect.CanTrigger(null))
  2055. {
  2056. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2057. {
  2058. return true;
  2059. }
  2060. }
  2061. }
  2062. }
  2063. #endregion
  2064. }
  2065. #region Effects of faceup security
  2066. foreach (CardSource source in player.SecurityCards)
  2067. {
  2068. if (source.IsFlipped)
  2069. continue;
  2070. foreach (ICardEffect cardEffect in source.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. }
  2084. #endregion
  2085. #region Player Effects
  2086. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2087. {
  2088. if (cardEffect is IAllianceEffect)
  2089. {
  2090. if (cardEffect.CanTrigger(null))
  2091. {
  2092. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2093. {
  2094. return true;
  2095. }
  2096. }
  2097. }
  2098. }
  2099. #endregion
  2100. }
  2101. return false;
  2102. }
  2103. }
  2104. #endregion
  2105. #region Has Collision
  2106. public bool HasCollision
  2107. {
  2108. get
  2109. {
  2110. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2111. {
  2112. if (cardEffect is ActivateICardEffect)
  2113. {
  2114. if (cardEffect.EffectName == "Collision")
  2115. {
  2116. return true;
  2117. }
  2118. }
  2119. }
  2120. return false;
  2121. }
  2122. }
  2123. #endregion
  2124. #region Has Partition
  2125. public bool HasPartition
  2126. {
  2127. get
  2128. {
  2129. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2130. {
  2131. if (cardEffect is ActivateICardEffect)
  2132. {
  2133. if (cardEffect.EffectName == "Partition")
  2134. {
  2135. return true;
  2136. }
  2137. }
  2138. }
  2139. return false;
  2140. }
  2141. }
  2142. #endregion
  2143. #region 消滅時効化を持つか
  2144. public bool HasOnDeletionEffect
  2145. {
  2146. get
  2147. {
  2148. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2149. {
  2150. if (cardEffect is ActivateICardEffect)
  2151. {
  2152. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2153. {
  2154. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2155. {
  2156. if (cardEffect.IsOnDeletion)
  2157. {
  2158. return true;
  2159. }
  2160. }
  2161. }
  2162. }
  2163. }
  2164. return false;
  2165. }
  2166. }
  2167. #endregion
  2168. #region バトルしているか
  2169. public IBattle battle { get; set; } = null;
  2170. #endregion
  2171. #region Can Be Destroyed
  2172. public bool CanBeDestroyed()
  2173. {
  2174. #region 消滅しない効果
  2175. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2176. {
  2177. foreach (Permanent permanent in player.GetFieldPermanents())
  2178. {
  2179. #region 場のパーマネントの効果
  2180. foreach (ICardEffect cardEffect in permanent.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. #region プレイヤーの効果
  2196. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2197. {
  2198. if (cardEffect is ICanNotBeDestroyedEffect)
  2199. {
  2200. if (cardEffect.CanUse(null))
  2201. {
  2202. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2203. {
  2204. return false;
  2205. }
  2206. }
  2207. }
  2208. }
  2209. #endregion
  2210. }
  2211. #endregion
  2212. return true;
  2213. }
  2214. #endregion
  2215. #region Can Be Destroyed By Battle
  2216. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2217. {
  2218. if (!CanBeDestroyed())
  2219. {
  2220. return false;
  2221. }
  2222. #region Given Effects
  2223. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2224. {
  2225. foreach (Permanent permanent in player.GetFieldPermanents())
  2226. {
  2227. #region Permanents
  2228. foreach (ICardEffect cardEffect in permanent.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. #region Effects of faceup security
  2244. foreach (CardSource source in player.SecurityCards)
  2245. {
  2246. if (source.IsFlipped)
  2247. continue;
  2248. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2249. {
  2250. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2251. {
  2252. if (cardEffect.CanUse(null))
  2253. {
  2254. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2255. {
  2256. return false;
  2257. }
  2258. }
  2259. }
  2260. }
  2261. }
  2262. #endregion
  2263. #region Player Effects
  2264. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2265. {
  2266. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2267. {
  2268. if (cardEffect.CanUse(null))
  2269. {
  2270. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2271. {
  2272. return false;
  2273. }
  2274. }
  2275. }
  2276. }
  2277. #endregion
  2278. }
  2279. #endregion
  2280. return true;
  2281. }
  2282. #endregion
  2283. #region このパーマネントが効果で消滅するか
  2284. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2285. {
  2286. if (this.TopCard != null)
  2287. {
  2288. if (this.TopCard.CanNotBeAffected(cardEffect))
  2289. {
  2290. return false;
  2291. }
  2292. if (!CanBeDestroyed())
  2293. {
  2294. return false;
  2295. }
  2296. #region 効果で消滅しない効果
  2297. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2298. {
  2299. foreach (Permanent permanent in player.GetFieldPermanents())
  2300. {
  2301. #region 場のパーマネントの効果
  2302. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2303. {
  2304. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2305. {
  2306. if (cardEffect1.CanUse(null))
  2307. {
  2308. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2309. {
  2310. return false;
  2311. }
  2312. }
  2313. }
  2314. }
  2315. #endregion
  2316. }
  2317. #region プレイヤーの効果
  2318. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2319. {
  2320. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2321. {
  2322. if (cardEffect1.CanUse(null))
  2323. {
  2324. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2325. {
  2326. return false;
  2327. }
  2328. }
  2329. }
  2330. }
  2331. #endregion
  2332. }
  2333. #endregion
  2334. }
  2335. return true;
  2336. }
  2337. #endregion
  2338. #region Can Leave Field
  2339. public bool CanBeRemoved()
  2340. {
  2341. #region Effect that never disappears
  2342. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2343. {
  2344. foreach (Permanent permanent in player.GetFieldPermanents())
  2345. {
  2346. #region Effects of permanents in play
  2347. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2348. {
  2349. if (cardEffect is ICanNotBeRemovedEffect)
  2350. {
  2351. if (cardEffect.CanUse(null))
  2352. {
  2353. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2354. {
  2355. return false;
  2356. }
  2357. }
  2358. }
  2359. }
  2360. #endregion
  2361. }
  2362. #region player effect
  2363. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2364. {
  2365. if (cardEffect is ICanNotBeRemovedEffect)
  2366. {
  2367. if (cardEffect.CanUse(null))
  2368. {
  2369. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2370. {
  2371. return false;
  2372. }
  2373. }
  2374. }
  2375. }
  2376. #endregion
  2377. }
  2378. #endregion
  2379. return true;
  2380. }
  2381. #endregion
  2382. #region トークンかどうか
  2383. public bool IsToken
  2384. {
  2385. get
  2386. {
  2387. if (TopCard != null)
  2388. {
  2389. if (TopCard.IsToken)
  2390. {
  2391. return true;
  2392. }
  2393. }
  2394. return false;
  2395. }
  2396. }
  2397. #endregion
  2398. #region そのパーマネントが消滅・バウンス待機状態か
  2399. public bool willBeRemoveField { get; set; } = false;
  2400. #endregion
  2401. #region Is a Digimon card
  2402. public bool IsDigimon
  2403. {
  2404. get
  2405. {
  2406. if (TopCard != null)
  2407. {
  2408. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2409. {
  2410. return true;
  2411. }
  2412. #region Effect of treating it as a Digimon
  2413. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2414. {
  2415. foreach (Permanent permanent in player.GetFieldPermanents())
  2416. {
  2417. #region Effects of permanents in play
  2418. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2419. {
  2420. if (cardEffect is ITreatAsDigimonEffect)
  2421. {
  2422. if (cardEffect.CanTrigger(null))
  2423. {
  2424. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2425. {
  2426. return true;
  2427. }
  2428. }
  2429. }
  2430. }
  2431. #endregion
  2432. }
  2433. #region player effect
  2434. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2435. {
  2436. if (cardEffect is ITreatAsDigimonEffect)
  2437. {
  2438. if (cardEffect.CanTrigger(null))
  2439. {
  2440. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2441. {
  2442. return true;
  2443. }
  2444. }
  2445. }
  2446. }
  2447. #endregion
  2448. }
  2449. #endregion
  2450. }
  2451. return false;
  2452. }
  2453. }
  2454. #endregion
  2455. #region Is a Tamer card
  2456. public bool IsTamer
  2457. {
  2458. get
  2459. {
  2460. if (TopCard != null)
  2461. {
  2462. if (TopCard.IsTamer)
  2463. {
  2464. return true;
  2465. }
  2466. }
  2467. return false;
  2468. }
  2469. }
  2470. #endregion
  2471. #region Is an Option card
  2472. public bool IsOption
  2473. {
  2474. get
  2475. {
  2476. if (TopCard != null)
  2477. {
  2478. if (TopCard.IsOption)
  2479. {
  2480. return true;
  2481. }
  2482. }
  2483. return false;
  2484. }
  2485. }
  2486. #endregion
  2487. #region Levels handled by Jogress
  2488. public List<int> Levels_ForJogress(CardSource cardSource)
  2489. {
  2490. List<int> levels = new List<int>();
  2491. if (cardSource != null)
  2492. {
  2493. if (cardSource.HasLevel)
  2494. {
  2495. levels.Add(this.Level);
  2496. }
  2497. #region Effect of "adding levels handled by jogless evolution"
  2498. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2499. {
  2500. foreach (Permanent permanent in player.GetFieldPermanents())
  2501. {
  2502. #region Effects of permanents in play
  2503. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2504. {
  2505. if (cardEffect is IAddJogressLevelsEffect)
  2506. {
  2507. if (cardEffect.CanUse(null))
  2508. {
  2509. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2510. {
  2511. levels.Add(level);
  2512. }
  2513. }
  2514. }
  2515. }
  2516. #endregion
  2517. }
  2518. #region player effect
  2519. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2520. {
  2521. if (cardEffect is IAddJogressLevelsEffect)
  2522. {
  2523. if (cardEffect.CanUse(null))
  2524. {
  2525. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2526. {
  2527. levels.Add(level);
  2528. }
  2529. }
  2530. }
  2531. }
  2532. #endregion
  2533. }
  2534. #endregion
  2535. }
  2536. return levels;
  2537. }
  2538. #endregion
  2539. #region Names handled by Jogress
  2540. public List<string> Names_ForDNA(CardSource cardSource)
  2541. {
  2542. List<string> names = new List<string>();
  2543. if (cardSource != null)
  2544. {
  2545. foreach(string name in cardSource.CardNames)
  2546. names.Add(name);
  2547. #region Effect of "adding names handled by DNA evolution"
  2548. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2549. {
  2550. foreach (Permanent permanent in player.GetFieldPermanents())
  2551. {
  2552. #region Effects of permanents in play
  2553. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2554. {
  2555. if (cardEffect is IAddDNANamesEffect)
  2556. {
  2557. if (cardEffect.CanUse(null))
  2558. {
  2559. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2560. {
  2561. names.Add(name);
  2562. }
  2563. }
  2564. }
  2565. }
  2566. #endregion
  2567. }
  2568. #region player effect
  2569. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2570. {
  2571. if (cardEffect is IAddDNANamesEffect)
  2572. {
  2573. if (cardEffect.CanUse(null))
  2574. {
  2575. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2576. {
  2577. names.Add(name);
  2578. }
  2579. }
  2580. }
  2581. }
  2582. #endregion
  2583. }
  2584. #endregion
  2585. }
  2586. return names;
  2587. }
  2588. #endregion
  2589. #region バトルで消滅したか
  2590. public bool IsDestroyedByBattle { get; set; } = false;
  2591. #endregion
  2592. #region 消滅に使用された効果
  2593. public ICardEffect DestroyingEffect { get; set; } = null;
  2594. #endregion
  2595. #region 他のパーマネントの下に置くのに使用された効果
  2596. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2597. #endregion
  2598. #region 手札バウンス に使用された効果
  2599. public ICardEffect HandBounceEffect { get; set; } = null;
  2600. #endregion
  2601. #region 山札バウンス に使用された効果
  2602. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2603. #endregion
  2604. #region 登場に使用された効果
  2605. public ICardEffect PlayingEffect { get; set; } = null;
  2606. #endregion
  2607. #region 進化に使用された効果
  2608. public ICardEffect DigivolvingEffect { get; set; } = null;
  2609. #endregion
  2610. #region Whether this digimon is placed in the trash by not having a DP
  2611. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2612. #endregion
  2613. #region Whether this permanent can suspend
  2614. public bool CanSuspend
  2615. {
  2616. get
  2617. {
  2618. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2619. {
  2620. #region Effects of field permanents
  2621. foreach (Permanent permanent in player.GetFieldPermanents())
  2622. {
  2623. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2624. {
  2625. if (cardEffect is ICanNotSuspendEffect)
  2626. {
  2627. if (cardEffect.CanUse(null))
  2628. {
  2629. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2630. {
  2631. return false;
  2632. }
  2633. }
  2634. }
  2635. }
  2636. }
  2637. #endregion
  2638. #region Effects of players
  2639. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2640. {
  2641. if (cardEffect is ICanNotSuspendEffect)
  2642. {
  2643. if (cardEffect.CanUse(null))
  2644. {
  2645. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2646. {
  2647. return false;
  2648. }
  2649. }
  2650. }
  2651. }
  2652. #endregion
  2653. }
  2654. return true;
  2655. }
  2656. }
  2657. #endregion
  2658. #region このデジモンのアタックの対象が変更できるか
  2659. public bool CanSwitchAttackTarget
  2660. {
  2661. get
  2662. {
  2663. #region アタックの対象が変更できない効果
  2664. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2665. {
  2666. foreach (Permanent permanent in player.GetFieldPermanents())
  2667. {
  2668. #region 場のパーマネントの効果
  2669. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2670. {
  2671. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2672. {
  2673. if (cardEffect.CanUse(null))
  2674. {
  2675. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2676. {
  2677. return false;
  2678. }
  2679. }
  2680. }
  2681. }
  2682. #endregion
  2683. }
  2684. #region プレイヤーの効果
  2685. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2686. {
  2687. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2688. {
  2689. if (cardEffect.CanUse(null))
  2690. {
  2691. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2692. {
  2693. return false;
  2694. }
  2695. }
  2696. }
  2697. }
  2698. #endregion
  2699. }
  2700. #endregion
  2701. return true;
  2702. }
  2703. }
  2704. #endregion
  2705. #region このデジモンを場からデジクロス条件の代わりにできるか
  2706. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  2707. {
  2708. #region デジクロス条件の代わりにできる効果
  2709. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2710. {
  2711. foreach (Permanent permanent in player.GetFieldPermanents())
  2712. {
  2713. #region 場のパーマネントの効果
  2714. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2715. {
  2716. if (cardEffect is ICanSelectDigiXrosEffect)
  2717. {
  2718. if (cardEffect.CanUse(null))
  2719. {
  2720. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2721. {
  2722. return true;
  2723. }
  2724. }
  2725. }
  2726. }
  2727. #endregion
  2728. }
  2729. #region プレイヤーの効果
  2730. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2731. {
  2732. if (cardEffect is ICanSelectDigiXrosEffect)
  2733. {
  2734. if (cardEffect.CanUse(null))
  2735. {
  2736. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2737. {
  2738. return true;
  2739. }
  2740. }
  2741. }
  2742. }
  2743. #endregion
  2744. }
  2745. #endregion
  2746. return false;
  2747. }
  2748. #endregion
  2749. #region 登場した直後のLevel
  2750. public int LevelJustAfterPlayed { get; set; } = -1;
  2751. #endregion
  2752. #region 登場した直後のPlay Cost
  2753. public int PlayCostJustAfterPlayed { get; set; } = -1;
  2754. #endregion
  2755. #region 登場した直後のCardNames
  2756. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  2757. #endregion
  2758. #region 進化した直後のCardNames
  2759. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  2760. #endregion
  2761. #region 登場した直後のTraits
  2762. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  2763. #endregion
  2764. #region 場を離れる直前のDP
  2765. public int DPJustBeforeRemoveField { get; set; } = -1;
  2766. #endregion
  2767. #region 場を離れる直前のLevel
  2768. public int LevelJustBeforeRemoveField { get; set; } = -1;
  2769. #endregion
  2770. #region 場を離れる直前のCost
  2771. public int CostJustBeforeRemoveField { get; set; } = -1;
  2772. #endregion
  2773. #region 場を離れる直前のカード名
  2774. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  2775. #endregion
  2776. #region Card Traits Just Before Removed Field
  2777. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  2778. #endregion
  2779. #region バースト進化で手札に戻ったか
  2780. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  2781. #endregion
  2782. #region バースト進化したか
  2783. public bool IsBurstDigivolved { get; set; } = false;
  2784. #endregion
  2785. #region 効果で場に出たオプションか
  2786. public bool IsPlayedOptionPermanent { get; set; } = false;
  2787. #endregion
  2788. #region 進化元を持たないか
  2789. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  2790. #endregion
  2791. #region Digivolution cards' colors
  2792. public List<CardColor> DigivolutionCardsColors
  2793. {
  2794. get
  2795. {
  2796. List<CardColor> cardColors = new List<CardColor>();
  2797. foreach (CardSource cardSource in DigivolutionCards)
  2798. {
  2799. foreach (CardColor cardColor in cardSource.CardColors)
  2800. {
  2801. if (!cardColors.Contains(cardColor))
  2802. {
  2803. cardColors.Add(cardColor);
  2804. }
  2805. }
  2806. }
  2807. return cardColors.Distinct().ToList();
  2808. }
  2809. }
  2810. #endregion
  2811. #region Show "Unsuspend" effect object
  2812. public void ShowUnsuspendEffect()
  2813. {
  2814. if (TopCard != null)
  2815. {
  2816. if (ShowingPermanentCard != null)
  2817. {
  2818. if (ShowingPermanentCard.WillUntapObject != null)
  2819. {
  2820. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  2821. ShowingPermanentCard.WillUntapObject.SetActive(true);
  2822. }
  2823. }
  2824. }
  2825. }
  2826. #endregion
  2827. #region Show "Return to deck" effect object
  2828. public void ShowDeckBounceEffect()
  2829. {
  2830. if (TopCard != null)
  2831. {
  2832. if (willBeRemoveField)
  2833. {
  2834. if (ShowingPermanentCard != null)
  2835. {
  2836. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2837. {
  2838. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  2839. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  2840. }
  2841. }
  2842. }
  2843. }
  2844. }
  2845. #endregion
  2846. #region Hide "Return to deck" effect object
  2847. public void HideDeckBounceEffect()
  2848. {
  2849. if (TopCard != null)
  2850. {
  2851. if (ShowingPermanentCard != null)
  2852. {
  2853. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  2854. {
  2855. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  2856. }
  2857. }
  2858. }
  2859. }
  2860. #endregion
  2861. #region Show "Return to hand" effect object
  2862. public void ShowHandBounceEffect()
  2863. {
  2864. if (TopCard != null)
  2865. {
  2866. if (willBeRemoveField)
  2867. {
  2868. if (ShowingPermanentCard != null)
  2869. {
  2870. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2871. {
  2872. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  2873. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  2874. }
  2875. }
  2876. }
  2877. }
  2878. }
  2879. #endregion
  2880. #region Hide "Return to hand" effect object
  2881. public void HideHandBounceEffect()
  2882. {
  2883. if (TopCard != null)
  2884. {
  2885. if (ShowingPermanentCard != null)
  2886. {
  2887. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  2888. {
  2889. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  2890. }
  2891. }
  2892. }
  2893. }
  2894. #endregion
  2895. #region Show "Delete" effect object
  2896. public void ShowDeleteEffect()
  2897. {
  2898. if (TopCard != null)
  2899. {
  2900. if (willBeRemoveField)
  2901. {
  2902. if (ShowingPermanentCard != null)
  2903. {
  2904. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2905. {
  2906. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  2907. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  2908. }
  2909. }
  2910. }
  2911. }
  2912. }
  2913. #endregion
  2914. #region Hide "Delete" effect object
  2915. public void HideDeleteEffect()
  2916. {
  2917. if (TopCard != null)
  2918. {
  2919. if (ShowingPermanentCard != null)
  2920. {
  2921. if (ShowingPermanentCard.WillBeDeletedObject != null)
  2922. {
  2923. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  2924. }
  2925. }
  2926. }
  2927. }
  2928. #endregion
  2929. #region Show "Remove Field" effect object
  2930. public void ShowWillRemoveFieldEffect()
  2931. {
  2932. if (TopCard != null)
  2933. {
  2934. if (willBeRemoveField)
  2935. {
  2936. if (ShowingPermanentCard != null)
  2937. {
  2938. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2939. {
  2940. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  2941. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  2942. }
  2943. }
  2944. }
  2945. }
  2946. }
  2947. #endregion
  2948. #region Hide "Remove Field" effect object
  2949. public void HideWillRemoveFieldEffect()
  2950. {
  2951. if (TopCard != null)
  2952. {
  2953. if (ShowingPermanentCard != null)
  2954. {
  2955. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  2956. {
  2957. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  2958. }
  2959. }
  2960. }
  2961. }
  2962. #endregion
  2963. #region Show "Digivolution" effect object
  2964. public void ShowWillEvolutionEffect()
  2965. {
  2966. if (TopCard != null)
  2967. {
  2968. if (ShowingPermanentCard != null)
  2969. {
  2970. if (ShowingPermanentCard.WillEvolutionObject != null)
  2971. {
  2972. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  2973. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  2974. }
  2975. }
  2976. }
  2977. }
  2978. #endregion
  2979. #region Hide "Digivolution" effect object
  2980. public void HideWillEvolutionEffect()
  2981. {
  2982. if (TopCard != null)
  2983. {
  2984. if (ShowingPermanentCard != null)
  2985. {
  2986. if (ShowingPermanentCard.WillEvolutionObject != null)
  2987. {
  2988. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  2989. }
  2990. }
  2991. }
  2992. }
  2993. #endregion
  2994. }