Permanent.cs 112 KB

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