Permanent.cs 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603
  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 || LinkedCards.Any(linked => linked.Source == cardSource));
  559. #endregion
  560. #region Linked Cards
  561. public int LinkedMax
  562. {
  563. get
  564. {
  565. int Max = 1;
  566. #region Effect of changing the number of sheets to undergo security check
  567. List<ICardEffect> cardEffects_ChangeLinkedMax = new List<ICardEffect>();
  568. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  569. {
  570. foreach (Permanent permanent in player.GetFieldPermanents())
  571. {
  572. #region Effects of permanents in play
  573. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  574. {
  575. if (cardEffect is IChangeLinkMaxEffect)
  576. {
  577. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  578. {
  579. if (cardEffect.CanUse(null))
  580. {
  581. if (!TopCard.CanNotBeAffected(cardEffect))
  582. {
  583. cardEffects_ChangeLinkedMax.Add(cardEffect);
  584. }
  585. }
  586. }
  587. }
  588. }
  589. #endregion
  590. }
  591. #region player effect
  592. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  593. {
  594. if (cardEffect is IChangeLinkMaxEffect)
  595. {
  596. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  597. {
  598. if (cardEffect.CanUse(null))
  599. {
  600. if (!TopCard.CanNotBeAffected(cardEffect))
  601. {
  602. cardEffects_ChangeLinkedMax.Add(cardEffect);
  603. }
  604. }
  605. }
  606. }
  607. }
  608. #endregion
  609. }
  610. List<ICardEffect> cardEffects_ChangeLinkedMax_UpToConstant = new List<ICardEffect>();
  611. List<ICardEffect> cardEffects_ChangeLinkedMax_UpDownValue = new List<ICardEffect>();
  612. List<ICardEffect> cardEffects_ChangeLinkedMax_DownToConstant = new List<ICardEffect>();
  613. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax)
  614. {
  615. if (cardEffect is IChangeLinkMaxEffect)
  616. {
  617. if (cardEffect.CanUse(null))
  618. {
  619. switch (((IChangeLinkMaxEffect)cardEffect).isUpDown())
  620. {
  621. case CalculateOrder.UpToConstant:
  622. cardEffects_ChangeLinkedMax_UpToConstant.Add(cardEffect);
  623. break;
  624. case CalculateOrder.UpDownValue:
  625. cardEffects_ChangeLinkedMax_UpDownValue.Add(cardEffect);
  626. break;
  627. case CalculateOrder.DownToConstant:
  628. cardEffects_ChangeLinkedMax_DownToConstant.Add(cardEffect);
  629. break;
  630. }
  631. }
  632. }
  633. }
  634. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpToConstant)
  635. {
  636. if (cardEffect is IChangeLinkMaxEffect)
  637. {
  638. if (cardEffect.CanUse(null))
  639. {
  640. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  641. }
  642. }
  643. }
  644. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpDownValue)
  645. {
  646. if (cardEffect is IChangeLinkMaxEffect)
  647. {
  648. if (cardEffect.CanUse(null))
  649. {
  650. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  651. }
  652. }
  653. }
  654. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_DownToConstant)
  655. {
  656. if (cardEffect is IChangeLinkMaxEffect)
  657. {
  658. if (cardEffect.CanUse(null))
  659. {
  660. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  661. }
  662. }
  663. }
  664. #endregion
  665. return Max;
  666. }
  667. }
  668. public struct LinkCard
  669. {
  670. public LinkCard(int dp, CardSource source)
  671. {
  672. DP = dp;
  673. Source = source;
  674. }
  675. public int DP { get; }
  676. public CardSource Source { get; }
  677. }
  678. public List<LinkCard> LinkedCards = new List<LinkCard>();
  679. #endregion
  680. #region Add Card Source
  681. public void AddCardSource(CardSource cardSource)
  682. {
  683. cardSources.Insert(0, cardSource);
  684. cardSource.SetFace();
  685. }
  686. #endregion
  687. #region Add digivolution cards to top of sources
  688. /// <summary>
  689. /// 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
  690. /// </summary>
  691. /// <param name="addedDigivolutionCards"></param>
  692. /// <param name="cardEffect"></param>
  693. /// <param name="skipEffectAndActivateSkill"></param>
  694. /// <returns></returns>
  695. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  696. {
  697. List<CardSource> addedCards = new List<CardSource>();
  698. bool isFromSameDigimon = false;
  699. bool isFromDigimon = false;
  700. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  701. {
  702. if (cardSources.Contains(addedDigivolutionCard))
  703. {
  704. isFromSameDigimon = true;
  705. }
  706. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  707. {
  708. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  709. {
  710. isFromDigimon = true;
  711. }
  712. }
  713. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  714. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  715. {
  716. this.cardSources.Insert(1, addedDigivolutionCard);
  717. addedDigivolutionCard.SetFace();
  718. addedCards.Add(addedDigivolutionCard);
  719. }
  720. }
  721. if (addedCards.Count >= 1)
  722. {
  723. if (ShowingPermanentCard != null)
  724. {
  725. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  726. }
  727. #region "進化元が増えた時"の効果
  728. #region Hashtable Setting
  729. Hashtable hashtable = new Hashtable()
  730. {
  731. {"Permanent", this},
  732. {"CardEffect", cardEffect},
  733. {"CardSources", addedCards},
  734. {"isFromSameDigimon", isFromSameDigimon},
  735. {"isFromDigimon", isFromDigimon},
  736. };
  737. #endregion
  738. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  739. #endregion
  740. }
  741. }
  742. #endregion
  743. #region Add digivolution cards to bottom of sources
  744. /// <summary>
  745. /// 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
  746. /// </summary>
  747. /// <param name="addedDigivolutionCards"></param>
  748. /// <param name="cardEffect"></param>
  749. /// <param name="skipEffectAndActivateSkill"></param>
  750. /// <returns></returns>
  751. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false)
  752. {
  753. List<CardSource> addedCards = new List<CardSource>();
  754. bool isFromSameDigimon = false;
  755. bool isFromDigimon = false;
  756. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  757. {
  758. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  759. {
  760. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  761. {
  762. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  763. {
  764. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
  765. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  766. if (!placePermanent.Placed)
  767. {
  768. continue;
  769. }
  770. }
  771. }
  772. }
  773. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  774. {
  775. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  776. {
  777. isFromDigimon = true;
  778. }
  779. }
  780. if (cardSources.Contains(addedDigivolutionCard))
  781. {
  782. isFromSameDigimon = true;
  783. if (addedDigivolutionCard == TopCard)
  784. {
  785. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  786. ShowingPermanentCard.ShowPermanentData(true);
  787. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  788. addedDigivolutionCard,
  789. this));
  790. }
  791. }
  792. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  793. if (!IsToken && !addedDigivolutionCard.IsToken)
  794. {
  795. cardSources.Add(addedDigivolutionCard);
  796. addedDigivolutionCard.SetFace();
  797. addedCards.Add(addedDigivolutionCard);
  798. }
  799. }
  800. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  801. {
  802. if (ShowingPermanentCard != null)
  803. {
  804. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  805. }
  806. #region Effect of "when the number of evolution sources increases"
  807. #region Hashtable Setting
  808. Hashtable hashtable = new Hashtable()
  809. {
  810. {"Permanent", this},
  811. {"CardEffect", cardEffect},
  812. {"CardSources", addedCards},
  813. {"isFromSameDigimon", isFromSameDigimon},
  814. {"isFromDigimon", isFromDigimon},
  815. };
  816. #endregion
  817. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  818. #endregion
  819. }
  820. }
  821. #endregion
  822. #region Add Link cards
  823. /// <summary>
  824. /// 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
  825. /// </summary>
  826. /// <param name="addedLinkCards"></param>
  827. /// <param name="cardEffect"></param>
  828. /// <param name="skipEffectAndActivateSkill"></param>
  829. /// <returns></returns>
  830. public IEnumerator AddLinkCard(CardSource addedLinkCard, int DP, ICardEffect cardEffect)
  831. {
  832. bool addedCard = false;
  833. bool isFromDigimon = false;
  834. if (CardEffectCommons.IsExistOnBattleArea(addedLinkCard))
  835. {
  836. if (addedLinkCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  837. {
  838. isFromDigimon = true;
  839. }
  840. }
  841. Debug.Log($"LINK CARDS: {LinkedCards.Count} >= {LinkedMax}");
  842. if (LinkedCards.Count >= LinkedMax)
  843. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(LinkedCards[0].Source));
  844. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
  845. if (!this.IsToken && !addedLinkCard.IsToken)
  846. {
  847. LinkedCards.Insert(0, new LinkCard(0, addedLinkCard));
  848. LinkedDP += DP;
  849. this.cardSources.Insert(1, addedLinkCard);
  850. addedLinkCard.SetFace();
  851. addedCard = true;
  852. }
  853. if (addedCard)
  854. {
  855. if (ShowingPermanentCard != null)
  856. {
  857. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  858. }
  859. #region Add Linked Card
  860. #region Hashtable Setting
  861. Hashtable hashtable = new Hashtable()
  862. {
  863. {"Permanent", this},
  864. {"CardEffect", cardEffect},
  865. {"Card", addedLinkCard},
  866. {"isFromDigimon", isFromDigimon},
  867. };
  868. #endregion
  869. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.WhenLinked));
  870. #endregion
  871. }
  872. }
  873. #endregion
  874. #region RemoveCardSource
  875. public IEnumerator RemoveCardSource(CardSource cardSource)
  876. {
  877. yield return null;
  878. cardSources.Remove(cardSource);
  879. }
  880. #endregion
  881. #region Remove Linked Card
  882. public IEnumerator RemoveLinkedCard(CardSource cardSource)
  883. {
  884. LinkCard linked = LinkedCards.Where(linked => linked.Source == cardSource).FirstOrDefault();
  885. Debug.Log($"REMOVE LINK CARD: {LinkedCards.Count} >= {linked.Source}");
  886. if (linked.Source != null)
  887. {
  888. LinkedDP -= linked.DP;
  889. yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(linked.Source));
  890. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(linked.Source));
  891. LinkedCards.Remove(linked);
  892. Debug.Log($"REMOVE LINK CARD: {linked.Source}");
  893. }
  894. //TODO: Add event call if something was removed
  895. }
  896. #endregion
  897. #region Top Card
  898. public CardSource TopCard
  899. {
  900. get
  901. {
  902. if (cardSources.Count >= 1)
  903. {
  904. return cardSources[0];
  905. }
  906. return null;
  907. }
  908. }
  909. #endregion
  910. #region Permanent effect list
  911. #region このパーマネントの効果リスト
  912. public List<ICardEffect> EffectList(EffectTiming timing)
  913. {
  914. return EffectList_ForCard(timing, TopCard);
  915. }
  916. #endregion
  917. #region このポケモンの追加効果リスト
  918. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  919. {
  920. List<ICardEffect> _EffectList = new List<ICardEffect>();
  921. if (TopCard != null)
  922. {
  923. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  924. {
  925. ICardEffect cardEffect = GetCardEffect(timing);
  926. if (cardEffect != null)
  927. {
  928. _EffectList.Add(cardEffect);
  929. }
  930. }
  931. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  932. {
  933. ICardEffect cardEffect = GetCardEffect(timing);
  934. if (cardEffect != null)
  935. {
  936. _EffectList.Add(cardEffect);
  937. }
  938. }
  939. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  940. {
  941. ICardEffect cardEffect = GetCardEffect(timing);
  942. if (cardEffect != null)
  943. {
  944. _EffectList.Add(cardEffect);
  945. }
  946. }
  947. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  948. {
  949. ICardEffect cardEffect = GetCardEffect(timing);
  950. if (cardEffect != null)
  951. {
  952. _EffectList.Add(cardEffect);
  953. }
  954. }
  955. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  956. {
  957. ICardEffect cardEffect = GetCardEffect(timing);
  958. if (cardEffect != null)
  959. {
  960. _EffectList.Add(cardEffect);
  961. }
  962. }
  963. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  964. {
  965. ICardEffect cardEffect = GetCardEffect(timing);
  966. if (cardEffect != null)
  967. {
  968. _EffectList.Add(cardEffect);
  969. }
  970. }
  971. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  972. {
  973. ICardEffect cardEffect = GetCardEffect(timing);
  974. if (cardEffect != null)
  975. {
  976. _EffectList.Add(cardEffect);
  977. }
  978. }
  979. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  980. {
  981. ICardEffect cardEffect = GetCardEffect(timing);
  982. if (cardEffect != null)
  983. {
  984. _EffectList.Add(cardEffect);
  985. }
  986. }
  987. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  988. {
  989. ICardEffect cardEffect = GetCardEffect(timing);
  990. if (cardEffect != null)
  991. {
  992. _EffectList.Add(cardEffect);
  993. }
  994. }
  995. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  996. foreach (ICardEffect cardEffect in _EffectList)
  997. {
  998. if (cardEffect != null)
  999. {
  1000. if (cardEffect.EffectSourceCard == null)
  1001. {
  1002. cardEffect.SetEffectSourceCard(TopCard);
  1003. }
  1004. cardEffect.SetIsInheritedEffect(false);
  1005. }
  1006. }
  1007. }
  1008. return _EffectList;
  1009. }
  1010. #endregion
  1011. #region このパーマネントの効果リスト(引数:CardSource)
  1012. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  1013. {
  1014. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1015. if (TopCard != null && _cardSource != null)
  1016. {
  1017. foreach (CardSource cardSource in cardSources)
  1018. {
  1019. if (cardSource != null)
  1020. {
  1021. if (!cardSource.IsFlipped)
  1022. {
  1023. bool isTopCard = cardSource == TopCard;
  1024. if (!isTopCard)
  1025. {
  1026. if (!IsDigimon)
  1027. {
  1028. continue;
  1029. }
  1030. }
  1031. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  1032. {
  1033. if (cardEffect != null)
  1034. {
  1035. if (isTopCard == cardEffect.IsInheritedEffect && isTopCard == cardEffect.IsLinkedEffect)
  1036. {
  1037. continue;
  1038. }
  1039. _EffectList.Add(cardEffect);
  1040. }
  1041. }
  1042. }
  1043. }
  1044. }
  1045. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  1046. {
  1047. if (cardEffect != null)
  1048. {
  1049. _EffectList.Add(cardEffect);
  1050. }
  1051. }
  1052. foreach (ICardEffect cardEffect in _EffectList)
  1053. {
  1054. if (cardEffect != null)
  1055. {
  1056. if (cardEffect.EffectSourceCard == null)
  1057. {
  1058. cardEffect.SetEffectSourceCard(_cardSource);
  1059. }
  1060. }
  1061. }
  1062. }
  1063. return _EffectList;
  1064. }
  1065. #endregion
  1066. #region 自分のターン終了時に消える効果
  1067. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1068. #endregion
  1069. #region 自分のドローフェイズ終了時に消える効果
  1070. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  1071. #endregion
  1072. #region お互いのターン終了時に消える効果
  1073. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1074. #endregion
  1075. #region 相手のターン終了時に消える効果
  1076. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1077. #endregion
  1078. #region バトル終了時に消える効果
  1079. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  1080. #endregion
  1081. #region 攻撃終了時に消える効果
  1082. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  1083. #endregion
  1084. #region 自分のターン開始時に消える効果
  1085. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  1086. #endregion
  1087. #region 次にアンタップする時に消える効果
  1088. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  1089. #endregion
  1090. #region 場を離れるまで残る効果
  1091. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  1092. #endregion
  1093. #endregion
  1094. #region 起動型効果を宣言できるか
  1095. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  1096. #endregion
  1097. #region 宣言可能な起動型効果リスト
  1098. public List<ICardEffect> CanDeclareSkillList()
  1099. {
  1100. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  1101. if (TopCard != null)
  1102. {
  1103. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  1104. {
  1105. if (_cardEffect is ActivateICardEffect)
  1106. {
  1107. if (_cardEffect.CanUse(null))
  1108. {
  1109. CanDeclareSkillList.Add(_cardEffect);
  1110. }
  1111. }
  1112. }
  1113. }
  1114. return CanDeclareSkillList;
  1115. }
  1116. #endregion
  1117. #region このパーマネントが場に出たターン
  1118. public int EnterFieldTurnCount { get; set; } = -1;
  1119. #endregion
  1120. #region このパーマネントを表す場のオブジェクト
  1121. public FieldPermanentCard ShowingPermanentCard { get; set; }
  1122. #endregion
  1123. #region Whether this permanent can be selected by the effect
  1124. public bool CanSelectBySkill(ICardEffect skill)
  1125. {
  1126. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1127. {
  1128. #region Effects of field permanents
  1129. foreach (Permanent permanent in player.GetFieldPermanents())
  1130. {
  1131. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1132. {
  1133. if (cardEffect is ICanNotSelectBySkillEffect)
  1134. {
  1135. if (cardEffect.CanUse(null))
  1136. {
  1137. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  1138. {
  1139. return false;
  1140. }
  1141. }
  1142. }
  1143. }
  1144. }
  1145. #endregion
  1146. }
  1147. return true;
  1148. }
  1149. #endregion
  1150. #region Number of sheets to undergo security check
  1151. public int InvertSecutiryValue
  1152. {
  1153. get
  1154. {
  1155. int Invert = 0;
  1156. List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
  1157. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1158. {
  1159. foreach (Permanent permanent in player.GetFieldPermanents())
  1160. {
  1161. #region Effects of permanents in play
  1162. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1163. {
  1164. if (cardEffect is IInvertSAttackEffect)
  1165. {
  1166. if (cardEffect.CanUse(null))
  1167. {
  1168. if (!TopCard.CanNotBeAffected(cardEffect))
  1169. {
  1170. cardEffects_InvertStrike.Add(cardEffect);
  1171. }
  1172. }
  1173. }
  1174. }
  1175. #endregion
  1176. }
  1177. #region player effect
  1178. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1179. {
  1180. if (cardEffect is IInvertSAttackEffect)
  1181. {
  1182. if (cardEffect.CanUse(null))
  1183. {
  1184. if (!TopCard.CanNotBeAffected(cardEffect))
  1185. {
  1186. cardEffects_InvertStrike.Add(cardEffect);
  1187. }
  1188. }
  1189. }
  1190. }
  1191. #endregion
  1192. }
  1193. foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
  1194. {
  1195. Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
  1196. }
  1197. return Mathf.Clamp(Invert,-1,1);
  1198. }
  1199. }
  1200. public List<int> SecurityAttackChanges
  1201. {
  1202. get
  1203. {
  1204. List<int> SecurityAttackChanges = new List<int>();
  1205. int Strike = 1;
  1206. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1207. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1208. {
  1209. foreach (Permanent permanent in player.GetFieldPermanents())
  1210. {
  1211. #region 場のパーマネントの効果
  1212. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1213. {
  1214. if (cardEffect is IChangeSAttackEffect)
  1215. {
  1216. if (cardEffect.CanUse(null))
  1217. {
  1218. if (!TopCard.CanNotBeAffected(cardEffect))
  1219. {
  1220. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1221. {
  1222. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1223. }
  1224. }
  1225. }
  1226. }
  1227. }
  1228. #endregion
  1229. }
  1230. #region プレイヤーの効果
  1231. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1232. {
  1233. if (cardEffect is IChangeSAttackEffect)
  1234. {
  1235. if (cardEffect.CanUse(null))
  1236. {
  1237. if (!TopCard.CanNotBeAffected(cardEffect))
  1238. {
  1239. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1240. {
  1241. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1242. }
  1243. }
  1244. }
  1245. }
  1246. }
  1247. #endregion
  1248. }
  1249. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1250. {
  1251. if (cardEffect is IChangeSAttackEffect)
  1252. {
  1253. if (cardEffect.CanUse(null))
  1254. {
  1255. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
  1256. if (Strike1 != Strike)
  1257. {
  1258. SecurityAttackChanges.Add(Strike1 - Strike);
  1259. }
  1260. }
  1261. }
  1262. }
  1263. return SecurityAttackChanges;
  1264. }
  1265. }
  1266. public bool HasSecurityAttackChanges
  1267. {
  1268. get
  1269. {
  1270. if (!IsDigimon)
  1271. {
  1272. return false;
  1273. }
  1274. return SecurityAttackChanges.Count >= 1;
  1275. }
  1276. }
  1277. public int Strike_AllowMinus
  1278. {
  1279. get
  1280. {
  1281. int Strike = 1;
  1282. #region Effect of changing the number of sheets to undergo security check
  1283. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1284. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1285. {
  1286. foreach (Permanent permanent in player.GetFieldPermanents())
  1287. {
  1288. #region Effects of permanents in play
  1289. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1290. {
  1291. if (cardEffect is IChangeSAttackEffect)
  1292. {
  1293. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1294. {
  1295. if (cardEffect.CanUse(null))
  1296. {
  1297. if (!TopCard.CanNotBeAffected(cardEffect))
  1298. {
  1299. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1300. }
  1301. }
  1302. }
  1303. }
  1304. }
  1305. #endregion
  1306. }
  1307. #region player effect
  1308. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1309. {
  1310. if (cardEffect is IChangeSAttackEffect)
  1311. {
  1312. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1313. {
  1314. if (cardEffect.CanUse(null))
  1315. {
  1316. if (!TopCard.CanNotBeAffected(cardEffect))
  1317. {
  1318. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1319. }
  1320. }
  1321. }
  1322. }
  1323. }
  1324. #endregion
  1325. }
  1326. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1327. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1328. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1329. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1330. {
  1331. if (cardEffect is IChangeSAttackEffect)
  1332. {
  1333. if (cardEffect.CanUse(null))
  1334. {
  1335. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1336. {
  1337. case CalculateOrder.UpToConstant:
  1338. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1339. break;
  1340. case CalculateOrder.UpDownValue:
  1341. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1342. break;
  1343. case CalculateOrder.DownToConstant:
  1344. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1345. break;
  1346. }
  1347. }
  1348. }
  1349. }
  1350. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1351. {
  1352. if (cardEffect is IChangeSAttackEffect)
  1353. {
  1354. if (cardEffect.CanUse(null))
  1355. {
  1356. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1357. }
  1358. }
  1359. }
  1360. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1361. {
  1362. if (cardEffect is IChangeSAttackEffect)
  1363. {
  1364. if (cardEffect.CanUse(null))
  1365. {
  1366. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1367. }
  1368. }
  1369. }
  1370. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1371. {
  1372. if (cardEffect is IChangeSAttackEffect)
  1373. {
  1374. if (cardEffect.CanUse(null))
  1375. {
  1376. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1377. }
  1378. }
  1379. }
  1380. #endregion
  1381. return Strike;
  1382. }
  1383. }
  1384. public int Strike
  1385. {
  1386. get
  1387. {
  1388. int Strike = Strike_AllowMinus;
  1389. if (Strike < 0)
  1390. {
  1391. Strike = 0;
  1392. }
  1393. return Strike;
  1394. }
  1395. }
  1396. #endregion
  1397. #region このパーマネントがタップされているかどうか
  1398. public bool OldIsSuspended = false;
  1399. public bool IsSuspended = false;
  1400. public int DPWhenSuspended = 114514;
  1401. #endregion
  1402. #region Whether this permanent can unsuspend
  1403. public bool CanUnsuspend
  1404. {
  1405. get
  1406. {
  1407. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1408. {
  1409. #region Effects of field permanents
  1410. foreach (Permanent permanent in player.GetFieldPermanents())
  1411. {
  1412. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1413. {
  1414. if (cardEffect is ICanNotUnsuspendEffect)
  1415. {
  1416. if (cardEffect.CanUse(null))
  1417. {
  1418. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1419. {
  1420. return false;
  1421. }
  1422. }
  1423. }
  1424. }
  1425. }
  1426. #endregion
  1427. #region Effects of players
  1428. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1429. {
  1430. if (cardEffect is ICanNotUnsuspendEffect)
  1431. {
  1432. if (cardEffect.CanUse(null))
  1433. {
  1434. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1435. {
  1436. return false;
  1437. }
  1438. }
  1439. }
  1440. }
  1441. #endregion
  1442. }
  1443. return true;
  1444. }
  1445. }
  1446. #endregion
  1447. #region このパーマネントが移動できるかどうか
  1448. public bool CanMove
  1449. {
  1450. get
  1451. {
  1452. if (TopCard != null)
  1453. {
  1454. #region the effects of permanents
  1455. if (GManager.instance.turnStateMachine.gameContext.Players
  1456. .Map(player => player.GetFieldPermanents())
  1457. .Flat()
  1458. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1459. .Flat()
  1460. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1461. && cardEffect.CanUse(null)
  1462. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1463. {
  1464. return false;
  1465. }
  1466. #endregion
  1467. #region the effects of players
  1468. if (GManager.instance.turnStateMachine.gameContext.Players
  1469. .Map(player => player.EffectList(EffectTiming.None))
  1470. .Flat()
  1471. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1472. && cardEffect.CanUse(null)
  1473. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1474. {
  1475. return false;
  1476. }
  1477. #endregion
  1478. #region the effects of itself
  1479. if (this == null)
  1480. {
  1481. if (EffectList(EffectTiming.None)
  1482. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  1483. && cardEffect.CanUse(null)
  1484. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(TopCard, null)))
  1485. {
  1486. return false;
  1487. }
  1488. }
  1489. #endregion
  1490. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1491. {
  1492. return false;
  1493. }
  1494. if (!IsDigimon)
  1495. return false;
  1496. if (TopCard.IsDigiEgg && DP <= 0)
  1497. return false;
  1498. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1499. {
  1500. return false;
  1501. }
  1502. }
  1503. else
  1504. {
  1505. return false;
  1506. }
  1507. return true;
  1508. }
  1509. }
  1510. #endregion
  1511. #region このパーマネントが攻撃できるかどうか
  1512. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1513. {
  1514. // can not attack with empty cards
  1515. if (TopCard == null)
  1516. {
  1517. return false;
  1518. }
  1519. // can not attack during opponent's turn
  1520. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1521. {
  1522. return false;
  1523. }
  1524. //Can not attack during another attack
  1525. if (GManager.instance.attackProcess.IsAttacking)
  1526. return false;
  1527. // can not attack to player
  1528. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex))
  1529. {
  1530. // can not attack to opponent's Digimon
  1531. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex)) == 0)
  1532. {
  1533. return false;
  1534. }
  1535. }
  1536. return true;
  1537. }
  1538. #endregion
  1539. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1540. public bool CanBlock(Permanent AttackingPermanent)
  1541. {
  1542. if (TopCard == null)
  1543. {
  1544. return false;
  1545. }
  1546. if (!IsDigimon)
  1547. {
  1548. return false;
  1549. }
  1550. if (IsSuspended)
  1551. {
  1552. return false;
  1553. }
  1554. if (!CanSuspend)
  1555. {
  1556. return false;
  1557. }
  1558. if (PermanentFrame != null)
  1559. {
  1560. if (!PermanentFrame.IsBattleAreaFrame())
  1561. {
  1562. return false;
  1563. }
  1564. }
  1565. if (!AttackingPermanent.CanSwitchAttackTarget)
  1566. return false;
  1567. #region "Unblockable" effect
  1568. #region Effects of permanents in play
  1569. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1570. {
  1571. foreach (Permanent permanent in player.GetFieldPermanents())
  1572. {
  1573. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1574. {
  1575. if (cardEffect is ICannotBlockEffect)
  1576. {
  1577. if (cardEffect.CanUse(null))
  1578. {
  1579. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1580. {
  1581. return false;
  1582. }
  1583. }
  1584. }
  1585. }
  1586. }
  1587. }
  1588. #endregion
  1589. #region player effect
  1590. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1591. {
  1592. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1593. {
  1594. if (cardEffect is ICannotBlockEffect)
  1595. {
  1596. if (cardEffect.CanUse(null))
  1597. {
  1598. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1599. {
  1600. if (!TopCard.CanNotBeAffected(cardEffect))
  1601. {
  1602. return false;
  1603. }
  1604. }
  1605. }
  1606. }
  1607. }
  1608. }
  1609. #endregion
  1610. #endregion
  1611. return true;
  1612. }
  1613. #endregion
  1614. #region 対象のパーマネントを攻撃できるか
  1615. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1616. {
  1617. if (TopCard != null)
  1618. {
  1619. if (!IsDigimon)
  1620. {
  1621. return false;
  1622. }
  1623. if (!withoutTap)
  1624. {
  1625. if (IsSuspended)
  1626. {
  1627. return false;
  1628. }
  1629. if (!CanSuspend)
  1630. {
  1631. return false;
  1632. }
  1633. }
  1634. if (PermanentFrame != null)
  1635. {
  1636. if (!PermanentFrame.IsBattleAreaFrame())
  1637. {
  1638. return false;
  1639. }
  1640. }
  1641. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1642. {
  1643. if (!HasRush && !isVortex)
  1644. {
  1645. return false;
  1646. }
  1647. }
  1648. #region 「対象の防御パーマネントを攻撃できない」効果
  1649. #region 場のパーマネントの効果
  1650. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1651. {
  1652. foreach (Permanent permanent in player.GetFieldPermanents())
  1653. {
  1654. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1655. {
  1656. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1657. {
  1658. if (cardEffect1.CanUse(null))
  1659. {
  1660. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1661. {
  1662. if (!TopCard.CanNotBeAffected(cardEffect1))
  1663. {
  1664. return false;
  1665. }
  1666. }
  1667. }
  1668. }
  1669. }
  1670. }
  1671. }
  1672. #endregion
  1673. #region プレイヤーの効果
  1674. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1675. {
  1676. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1677. {
  1678. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1679. {
  1680. if (cardEffect1.CanUse(null))
  1681. {
  1682. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1683. {
  1684. if (!TopCard.CanNotBeAffected(cardEffect1))
  1685. {
  1686. return false;
  1687. }
  1688. }
  1689. }
  1690. }
  1691. }
  1692. }
  1693. #endregion
  1694. #endregion
  1695. if (Defender != null)
  1696. {
  1697. if (Defender.TopCard != null)
  1698. {
  1699. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1700. {
  1701. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1702. {
  1703. if (Defender.IsSuspended)
  1704. {
  1705. return true;
  1706. }
  1707. #region 「対象の防御パーマネントを攻撃できる」効果
  1708. #region 場のパーマネントの効果
  1709. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1710. {
  1711. foreach (Permanent permanent in player.GetFieldPermanents())
  1712. {
  1713. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1714. {
  1715. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1716. {
  1717. if (cardEffect1.CanUse(null))
  1718. {
  1719. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1720. {
  1721. return true;
  1722. }
  1723. }
  1724. }
  1725. }
  1726. }
  1727. }
  1728. #endregion
  1729. #region プレイヤーの効果
  1730. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1731. {
  1732. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1733. {
  1734. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1735. {
  1736. if (cardEffect1.CanUse(null))
  1737. {
  1738. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1739. {
  1740. return true;
  1741. }
  1742. }
  1743. }
  1744. }
  1745. }
  1746. #endregion
  1747. #endregion
  1748. }
  1749. }
  1750. }
  1751. }
  1752. else
  1753. {
  1754. return true;
  1755. }
  1756. }
  1757. return false;
  1758. }
  1759. #endregion
  1760. #region Is Unblockable
  1761. public bool IsUnblockable
  1762. {
  1763. get
  1764. {
  1765. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1766. {
  1767. if (cardEffect is CannotBlockClass)
  1768. {
  1769. if (cardEffect.EffectName == "Can't Block")
  1770. {
  1771. return true;
  1772. }
  1773. }
  1774. }
  1775. return false;
  1776. }
  1777. }
  1778. #endregion
  1779. #region Has Blocker
  1780. public bool HasBlocker
  1781. {
  1782. get
  1783. {
  1784. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1785. {
  1786. #region Effects of permanents in play
  1787. foreach (Permanent permanent in player.GetFieldPermanents())
  1788. {
  1789. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1790. {
  1791. if (cardEffect is IBlockerEffect)
  1792. {
  1793. if (cardEffect.CanTrigger(null))
  1794. {
  1795. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1796. {
  1797. return true;
  1798. }
  1799. }
  1800. }
  1801. }
  1802. }
  1803. #endregion
  1804. #region Effects of faceup security
  1805. foreach (CardSource source in player.SecurityCards)
  1806. {
  1807. if (source.IsFlipped)
  1808. continue;
  1809. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  1810. {
  1811. if (cardEffect is IBlockerEffect)
  1812. {
  1813. if (cardEffect.CanTrigger(null))
  1814. {
  1815. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1816. {
  1817. return true;
  1818. }
  1819. }
  1820. }
  1821. }
  1822. }
  1823. #endregion
  1824. #region プレイヤーの効果
  1825. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1826. {
  1827. if (cardEffect is IBlockerEffect)
  1828. {
  1829. if (cardEffect.CanTrigger(null))
  1830. {
  1831. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1832. {
  1833. return true;
  1834. }
  1835. }
  1836. }
  1837. }
  1838. #endregion
  1839. }
  1840. return false;
  1841. }
  1842. }
  1843. #endregion
  1844. #region Has Jamming
  1845. public bool HasJamming
  1846. {
  1847. get
  1848. {
  1849. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1850. {
  1851. foreach (Permanent permanent in player.GetFieldPermanents())
  1852. {
  1853. #region 場のパーマネントの効果
  1854. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1855. {
  1856. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1857. {
  1858. if (cardEffect.CanTrigger(null))
  1859. {
  1860. if (cardEffect.EffectName == "Jamming")
  1861. {
  1862. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1863. {
  1864. return true;
  1865. }
  1866. }
  1867. }
  1868. }
  1869. }
  1870. #endregion
  1871. }
  1872. #region プレイヤーの効果
  1873. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1874. {
  1875. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1876. {
  1877. if (cardEffect.CanTrigger(null))
  1878. {
  1879. if (cardEffect.EffectName == "Jamming")
  1880. {
  1881. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1882. {
  1883. return true;
  1884. }
  1885. }
  1886. }
  1887. }
  1888. }
  1889. #endregion
  1890. }
  1891. return false;
  1892. }
  1893. }
  1894. #endregion
  1895. #region Has Ice Clad
  1896. public bool HasIceclad
  1897. {
  1898. get
  1899. {
  1900. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1901. {
  1902. #region Ice clad permanent effects
  1903. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  1904. {
  1905. if (cardEffect is IIcecladEffect)
  1906. {
  1907. if (cardEffect.CanTrigger(null))
  1908. {
  1909. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1910. {
  1911. return true;
  1912. }
  1913. }
  1914. }
  1915. }
  1916. #endregion
  1917. #region Ice clad Player Effects
  1918. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1919. {
  1920. if (cardEffect is IIcecladEffect)
  1921. {
  1922. if (cardEffect.CanTrigger(null))
  1923. {
  1924. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  1925. {
  1926. return true;
  1927. }
  1928. }
  1929. }
  1930. }
  1931. #endregion
  1932. }
  1933. return false;
  1934. }
  1935. }
  1936. #endregion
  1937. #region Whether this permanent has Pierce
  1938. public bool HasPierce
  1939. {
  1940. get
  1941. {
  1942. if (IsDigimon)
  1943. {
  1944. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  1945. {
  1946. if (cardEffect is ActivateICardEffect)
  1947. {
  1948. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  1949. {
  1950. if (cardEffect.EffectName == "Pierce")
  1951. {
  1952. return true;
  1953. }
  1954. if (cardEffect.EffectName == "Piercing")
  1955. {
  1956. return true;
  1957. }
  1958. }
  1959. }
  1960. }
  1961. }
  1962. return false;
  1963. }
  1964. }
  1965. #endregion
  1966. #region Has Reboot
  1967. public bool HasReboot
  1968. {
  1969. get
  1970. {
  1971. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1972. {
  1973. foreach (Permanent permanent in player.GetFieldPermanents())
  1974. {
  1975. #region 場のパーマネントの効果
  1976. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1977. {
  1978. if (cardEffect is IRebootEffect)
  1979. {
  1980. if (cardEffect.CanTrigger(null))
  1981. {
  1982. if (((IRebootEffect)cardEffect).HasReboot(this))
  1983. {
  1984. return true;
  1985. }
  1986. }
  1987. }
  1988. }
  1989. #endregion
  1990. }
  1991. #region プレイヤーの効果
  1992. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1993. {
  1994. if (cardEffect is IRebootEffect)
  1995. {
  1996. if (cardEffect.CanTrigger(null))
  1997. {
  1998. if (((IRebootEffect)cardEffect).HasReboot(this))
  1999. {
  2000. return true;
  2001. }
  2002. }
  2003. }
  2004. }
  2005. #endregion
  2006. }
  2007. return false;
  2008. }
  2009. }
  2010. #endregion
  2011. #region Has Raid
  2012. public bool HasRaid
  2013. {
  2014. get
  2015. {
  2016. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2017. {
  2018. if (cardEffect is ActivateICardEffect)
  2019. {
  2020. if (cardEffect.EffectName == "Raid")
  2021. {
  2022. return true;
  2023. }
  2024. }
  2025. }
  2026. return false;
  2027. }
  2028. }
  2029. #endregion
  2030. #region Has Rush
  2031. public bool HasRush
  2032. {
  2033. get
  2034. {
  2035. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2036. {
  2037. foreach (Permanent permanent in player.GetFieldPermanents())
  2038. {
  2039. #region 場のパーマネントの効果
  2040. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2041. {
  2042. if (cardEffect is IRushEffect)
  2043. {
  2044. if (cardEffect.CanTrigger(null))
  2045. {
  2046. if (((IRushEffect)cardEffect).HasRush(this))
  2047. {
  2048. return true;
  2049. }
  2050. }
  2051. }
  2052. }
  2053. #endregion
  2054. }
  2055. #region プレイヤーの効果
  2056. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2057. {
  2058. if (cardEffect is IRushEffect)
  2059. {
  2060. if (cardEffect.CanTrigger(null))
  2061. {
  2062. if (((IRushEffect)cardEffect).HasRush(this))
  2063. {
  2064. return true;
  2065. }
  2066. }
  2067. }
  2068. }
  2069. #endregion
  2070. }
  2071. return false;
  2072. }
  2073. }
  2074. #endregion
  2075. #region Has Retaliation
  2076. public bool HasRetaliation
  2077. {
  2078. get
  2079. {
  2080. if (RetaliationCount >= 1)
  2081. {
  2082. return true;
  2083. }
  2084. return false;
  2085. }
  2086. }
  2087. #endregion
  2088. #region Retaliation Count
  2089. public int RetaliationCount
  2090. {
  2091. get
  2092. {
  2093. int count = 0;
  2094. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2095. {
  2096. if (cardEffect is ActivateICardEffect)
  2097. {
  2098. if (cardEffect.EffectName == "Retaliation")
  2099. {
  2100. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2101. {
  2102. count++;
  2103. }
  2104. }
  2105. }
  2106. }
  2107. return count;
  2108. }
  2109. }
  2110. #endregion
  2111. #region Has Fortitude
  2112. public bool HasFortitude
  2113. {
  2114. get
  2115. {
  2116. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2117. {
  2118. if (cardEffect is ActivateICardEffect)
  2119. {
  2120. if (cardEffect.EffectName == "Fortitude")
  2121. {
  2122. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2123. {
  2124. return true;
  2125. }
  2126. }
  2127. }
  2128. }
  2129. return false;
  2130. }
  2131. }
  2132. #endregion
  2133. #region Has Blitz
  2134. public bool HasBlitz
  2135. {
  2136. get
  2137. {
  2138. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  2139. {
  2140. if (cardEffect is ActivateICardEffect)
  2141. {
  2142. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  2143. {
  2144. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2145. {
  2146. if (cardEffect.EffectDiscription.Contains("Blitz"))
  2147. {
  2148. return true;
  2149. }
  2150. }
  2151. }
  2152. }
  2153. }
  2154. return false;
  2155. }
  2156. }
  2157. #endregion
  2158. #region Has Evade
  2159. public bool HasEvade
  2160. {
  2161. get
  2162. {
  2163. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2164. {
  2165. if (cardEffect is ActivateICardEffect)
  2166. {
  2167. Hashtable hashtable = new Hashtable()
  2168. {
  2169. {"Permanents", new List<Permanent>() { this }}
  2170. };
  2171. if (cardEffect.CanTrigger(hashtable))
  2172. {
  2173. if (cardEffect.EffectName == "Evade")
  2174. {
  2175. return true;
  2176. }
  2177. }
  2178. }
  2179. }
  2180. return false;
  2181. }
  2182. }
  2183. #endregion
  2184. #region Has Mind Link
  2185. public bool HasMindLink
  2186. {
  2187. get
  2188. {
  2189. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  2190. {
  2191. if (cardEffect is ActivateICardEffect)
  2192. {
  2193. if (cardEffect.CanTrigger(null))
  2194. {
  2195. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2196. {
  2197. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2198. {
  2199. return true;
  2200. }
  2201. }
  2202. }
  2203. }
  2204. }
  2205. return false;
  2206. }
  2207. }
  2208. #endregion
  2209. #region Has Barrier
  2210. public bool HasBarrier
  2211. {
  2212. get
  2213. {
  2214. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2215. {
  2216. if (cardEffect is ActivateICardEffect)
  2217. {
  2218. Hashtable hashtable = new Hashtable();
  2219. hashtable.Add("Permanents", new List<Permanent>() { this });
  2220. hashtable.Add("battle", new IBattle(null, null, null));
  2221. if (cardEffect.CanTrigger(hashtable))
  2222. {
  2223. if (cardEffect.EffectName == "Barrier")
  2224. {
  2225. return true;
  2226. }
  2227. }
  2228. }
  2229. }
  2230. return false;
  2231. }
  2232. }
  2233. #endregion
  2234. #region Has Alliance
  2235. public bool HasAlliance
  2236. {
  2237. get
  2238. {
  2239. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2240. {
  2241. foreach (Permanent permanent in player.GetFieldPermanents())
  2242. {
  2243. #region Permanent Effects
  2244. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2245. {
  2246. if (cardEffect is IAllianceEffect)
  2247. {
  2248. if (cardEffect.CanTrigger(null))
  2249. {
  2250. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2251. {
  2252. return true;
  2253. }
  2254. }
  2255. }
  2256. }
  2257. #endregion
  2258. }
  2259. #region Effects of faceup security
  2260. foreach (CardSource source in player.SecurityCards)
  2261. {
  2262. if (source.IsFlipped)
  2263. continue;
  2264. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnAllyAttack))
  2265. {
  2266. if (cardEffect is IAllianceEffect)
  2267. {
  2268. if (cardEffect.CanTrigger(null))
  2269. {
  2270. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2271. {
  2272. return true;
  2273. }
  2274. }
  2275. }
  2276. }
  2277. }
  2278. #endregion
  2279. #region Player Effects
  2280. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2281. {
  2282. if (cardEffect is IAllianceEffect)
  2283. {
  2284. if (cardEffect.CanTrigger(null))
  2285. {
  2286. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2287. {
  2288. return true;
  2289. }
  2290. }
  2291. }
  2292. }
  2293. #endregion
  2294. }
  2295. return false;
  2296. }
  2297. }
  2298. #endregion
  2299. #region Has Collision
  2300. public bool HasCollision
  2301. {
  2302. get
  2303. {
  2304. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2305. {
  2306. if (cardEffect is ActivateICardEffect)
  2307. {
  2308. if (cardEffect.EffectName == "Collision")
  2309. {
  2310. return true;
  2311. }
  2312. }
  2313. }
  2314. return false;
  2315. }
  2316. }
  2317. #endregion
  2318. #region Has Partition
  2319. public bool HasPartition
  2320. {
  2321. get
  2322. {
  2323. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2324. {
  2325. if (cardEffect is ActivateICardEffect)
  2326. {
  2327. if (cardEffect.EffectName == "Partition")
  2328. {
  2329. return true;
  2330. }
  2331. }
  2332. }
  2333. return false;
  2334. }
  2335. }
  2336. #endregion
  2337. #region 消滅時効化を持つか
  2338. public bool HasOnDeletionEffect
  2339. {
  2340. get
  2341. {
  2342. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2343. {
  2344. if (cardEffect is ActivateICardEffect)
  2345. {
  2346. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2347. {
  2348. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2349. {
  2350. if (cardEffect.IsOnDeletion)
  2351. {
  2352. return true;
  2353. }
  2354. }
  2355. }
  2356. }
  2357. }
  2358. return false;
  2359. }
  2360. }
  2361. #endregion
  2362. #region バトルしているか
  2363. public IBattle battle { get; set; } = null;
  2364. #endregion
  2365. #region Can Be Destroyed
  2366. public bool CanBeDestroyed()
  2367. {
  2368. #region 消滅しない効果
  2369. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2370. {
  2371. foreach (Permanent permanent in player.GetFieldPermanents())
  2372. {
  2373. #region 場のパーマネントの効果
  2374. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2375. {
  2376. if (cardEffect is ICanNotBeDestroyedEffect)
  2377. {
  2378. if (cardEffect.CanUse(null))
  2379. {
  2380. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2381. {
  2382. return false;
  2383. }
  2384. }
  2385. }
  2386. }
  2387. #endregion
  2388. }
  2389. #region プレイヤーの効果
  2390. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2391. {
  2392. if (cardEffect is ICanNotBeDestroyedEffect)
  2393. {
  2394. if (cardEffect.CanUse(null))
  2395. {
  2396. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2397. {
  2398. return false;
  2399. }
  2400. }
  2401. }
  2402. }
  2403. #endregion
  2404. }
  2405. #endregion
  2406. return true;
  2407. }
  2408. #endregion
  2409. #region Can Be Destroyed By Battle
  2410. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2411. {
  2412. if (!CanBeDestroyed())
  2413. {
  2414. return false;
  2415. }
  2416. #region Given Effects
  2417. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2418. {
  2419. foreach (Permanent permanent in player.GetFieldPermanents())
  2420. {
  2421. #region Permanents
  2422. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2423. {
  2424. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2425. {
  2426. if (cardEffect.CanUse(null))
  2427. {
  2428. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2429. {
  2430. return false;
  2431. }
  2432. }
  2433. }
  2434. }
  2435. #endregion
  2436. }
  2437. #region Effects of faceup security
  2438. foreach (CardSource source in player.SecurityCards)
  2439. {
  2440. if (source.IsFlipped)
  2441. continue;
  2442. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2443. {
  2444. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2445. {
  2446. if (cardEffect.CanUse(null))
  2447. {
  2448. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2449. {
  2450. return false;
  2451. }
  2452. }
  2453. }
  2454. }
  2455. }
  2456. #endregion
  2457. #region Player Effects
  2458. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2459. {
  2460. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2461. {
  2462. if (cardEffect.CanUse(null))
  2463. {
  2464. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2465. {
  2466. return false;
  2467. }
  2468. }
  2469. }
  2470. }
  2471. #endregion
  2472. }
  2473. #endregion
  2474. return true;
  2475. }
  2476. #endregion
  2477. #region このパーマネントが効果で消滅するか
  2478. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2479. {
  2480. if (this.TopCard != null)
  2481. {
  2482. if (this.TopCard.CanNotBeAffected(cardEffect))
  2483. {
  2484. return false;
  2485. }
  2486. if (!CanBeDestroyed())
  2487. {
  2488. return false;
  2489. }
  2490. #region 効果で消滅しない効果
  2491. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2492. {
  2493. foreach (Permanent permanent in player.GetFieldPermanents())
  2494. {
  2495. #region 場のパーマネントの効果
  2496. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2497. {
  2498. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2499. {
  2500. if (cardEffect1.CanUse(null))
  2501. {
  2502. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2503. {
  2504. return false;
  2505. }
  2506. }
  2507. }
  2508. }
  2509. #endregion
  2510. }
  2511. #region プレイヤーの効果
  2512. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2513. {
  2514. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2515. {
  2516. if (cardEffect1.CanUse(null))
  2517. {
  2518. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2519. {
  2520. return false;
  2521. }
  2522. }
  2523. }
  2524. }
  2525. #endregion
  2526. }
  2527. #endregion
  2528. }
  2529. return true;
  2530. }
  2531. #endregion
  2532. #region Can Leave Field
  2533. public bool CanBeRemoved()
  2534. {
  2535. #region Effect that never disappears
  2536. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2537. {
  2538. foreach (Permanent permanent in player.GetFieldPermanents())
  2539. {
  2540. #region Effects of permanents in play
  2541. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2542. {
  2543. if (cardEffect is ICanNotBeRemovedEffect)
  2544. {
  2545. if (cardEffect.CanUse(null))
  2546. {
  2547. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2548. {
  2549. return false;
  2550. }
  2551. }
  2552. }
  2553. }
  2554. #endregion
  2555. }
  2556. #region player effect
  2557. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2558. {
  2559. if (cardEffect is ICanNotBeRemovedEffect)
  2560. {
  2561. if (cardEffect.CanUse(null))
  2562. {
  2563. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2564. {
  2565. return false;
  2566. }
  2567. }
  2568. }
  2569. }
  2570. #endregion
  2571. }
  2572. #endregion
  2573. return true;
  2574. }
  2575. #endregion
  2576. #region トークンかどうか
  2577. public bool IsToken
  2578. {
  2579. get
  2580. {
  2581. if (TopCard != null)
  2582. {
  2583. if (TopCard.IsToken)
  2584. {
  2585. return true;
  2586. }
  2587. }
  2588. return false;
  2589. }
  2590. }
  2591. #endregion
  2592. #region そのパーマネントが消滅・バウンス待機状態か
  2593. public bool willBeRemoveField { get; set; } = false;
  2594. #endregion
  2595. #region Is a Digimon card
  2596. public bool IsDigimon
  2597. {
  2598. get
  2599. {
  2600. if (TopCard != null)
  2601. {
  2602. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2603. {
  2604. return true;
  2605. }
  2606. #region Effect of treating it as a Digimon
  2607. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2608. {
  2609. foreach (Permanent permanent in player.GetFieldPermanents())
  2610. {
  2611. #region Effects of permanents in play
  2612. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2613. {
  2614. if (cardEffect is ITreatAsDigimonEffect)
  2615. {
  2616. if (cardEffect.CanTrigger(null))
  2617. {
  2618. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2619. {
  2620. return true;
  2621. }
  2622. }
  2623. }
  2624. }
  2625. #endregion
  2626. }
  2627. #region player effect
  2628. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2629. {
  2630. if (cardEffect is ITreatAsDigimonEffect)
  2631. {
  2632. if (cardEffect.CanTrigger(null))
  2633. {
  2634. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2635. {
  2636. return true;
  2637. }
  2638. }
  2639. }
  2640. }
  2641. #endregion
  2642. }
  2643. #endregion
  2644. }
  2645. return false;
  2646. }
  2647. }
  2648. #endregion
  2649. #region Is a Tamer card
  2650. public bool IsTamer
  2651. {
  2652. get
  2653. {
  2654. if (TopCard != null)
  2655. {
  2656. if (TopCard.IsTamer)
  2657. {
  2658. return true;
  2659. }
  2660. }
  2661. return false;
  2662. }
  2663. }
  2664. #endregion
  2665. #region Is an Option card
  2666. public bool IsOption
  2667. {
  2668. get
  2669. {
  2670. if (TopCard != null)
  2671. {
  2672. if (TopCard.IsOption)
  2673. {
  2674. return true;
  2675. }
  2676. }
  2677. return false;
  2678. }
  2679. }
  2680. #endregion
  2681. #region Levels handled by Jogress
  2682. public List<int> Levels_ForJogress(CardSource cardSource)
  2683. {
  2684. List<int> levels = new List<int>();
  2685. if (cardSource != null)
  2686. {
  2687. if (cardSource.HasLevel)
  2688. {
  2689. levels.Add(this.Level);
  2690. }
  2691. #region Effect of "adding levels handled by jogless evolution"
  2692. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2693. {
  2694. foreach (Permanent permanent in player.GetFieldPermanents())
  2695. {
  2696. #region Effects of permanents in play
  2697. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2698. {
  2699. if (cardEffect is IAddJogressLevelsEffect)
  2700. {
  2701. if (cardEffect.CanUse(null))
  2702. {
  2703. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2704. {
  2705. levels.Add(level);
  2706. }
  2707. }
  2708. }
  2709. }
  2710. #endregion
  2711. }
  2712. #region player effect
  2713. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2714. {
  2715. if (cardEffect is IAddJogressLevelsEffect)
  2716. {
  2717. if (cardEffect.CanUse(null))
  2718. {
  2719. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2720. {
  2721. levels.Add(level);
  2722. }
  2723. }
  2724. }
  2725. }
  2726. #endregion
  2727. }
  2728. #endregion
  2729. }
  2730. return levels;
  2731. }
  2732. #endregion
  2733. #region Names handled by Jogress
  2734. public List<string> Names_ForDNA(CardSource cardSource)
  2735. {
  2736. List<string> names = new List<string>();
  2737. if (cardSource != null)
  2738. {
  2739. foreach(string name in cardSource.CardNames)
  2740. names.Add(name);
  2741. #region Effect of "adding names handled by DNA evolution"
  2742. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2743. {
  2744. foreach (Permanent permanent in player.GetFieldPermanents())
  2745. {
  2746. #region Effects of permanents in play
  2747. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2748. {
  2749. if (cardEffect is IAddDNANamesEffect)
  2750. {
  2751. if (cardEffect.CanUse(null))
  2752. {
  2753. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2754. {
  2755. names.Add(name);
  2756. }
  2757. }
  2758. }
  2759. }
  2760. #endregion
  2761. }
  2762. #region player effect
  2763. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2764. {
  2765. if (cardEffect is IAddDNANamesEffect)
  2766. {
  2767. if (cardEffect.CanUse(null))
  2768. {
  2769. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2770. {
  2771. names.Add(name);
  2772. }
  2773. }
  2774. }
  2775. }
  2776. #endregion
  2777. }
  2778. #endregion
  2779. }
  2780. return names;
  2781. }
  2782. #endregion
  2783. #region バトルで消滅したか
  2784. public bool IsDestroyedByBattle { get; set; } = false;
  2785. #endregion
  2786. #region 消滅に使用された効果
  2787. public ICardEffect DestroyingEffect { get; set; } = null;
  2788. #endregion
  2789. #region 他のパーマネントの下に置くのに使用された効果
  2790. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2791. #endregion
  2792. #region 手札バウンス に使用された効果
  2793. public ICardEffect HandBounceEffect { get; set; } = null;
  2794. #endregion
  2795. #region 山札バウンス に使用された効果
  2796. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2797. #endregion
  2798. #region 登場に使用された効果
  2799. public ICardEffect PlayingEffect { get; set; } = null;
  2800. #endregion
  2801. #region 進化に使用された効果
  2802. public ICardEffect DigivolvingEffect { get; set; } = null;
  2803. #endregion
  2804. #region Whether this digimon is placed in the trash by not having a DP
  2805. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2806. #endregion
  2807. #region Whether this permanent can suspend
  2808. public bool CanSuspend
  2809. {
  2810. get
  2811. {
  2812. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2813. {
  2814. #region Effects of field permanents
  2815. foreach (Permanent permanent in player.GetFieldPermanents())
  2816. {
  2817. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2818. {
  2819. if (cardEffect is ICanNotSuspendEffect)
  2820. {
  2821. if (cardEffect.CanUse(null))
  2822. {
  2823. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2824. {
  2825. return false;
  2826. }
  2827. }
  2828. }
  2829. }
  2830. }
  2831. #endregion
  2832. #region Effects of players
  2833. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2834. {
  2835. if (cardEffect is ICanNotSuspendEffect)
  2836. {
  2837. if (cardEffect.CanUse(null))
  2838. {
  2839. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2840. {
  2841. return false;
  2842. }
  2843. }
  2844. }
  2845. }
  2846. #endregion
  2847. }
  2848. return true;
  2849. }
  2850. }
  2851. #endregion
  2852. #region このデジモンのアタックの対象が変更できるか
  2853. public bool CanSwitchAttackTarget
  2854. {
  2855. get
  2856. {
  2857. #region アタックの対象が変更できない効果
  2858. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2859. {
  2860. foreach (Permanent permanent in player.GetFieldPermanents())
  2861. {
  2862. #region 場のパーマネントの効果
  2863. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2864. {
  2865. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2866. {
  2867. if (cardEffect.CanUse(null))
  2868. {
  2869. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2870. {
  2871. return false;
  2872. }
  2873. }
  2874. }
  2875. }
  2876. #endregion
  2877. }
  2878. #region プレイヤーの効果
  2879. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2880. {
  2881. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  2882. {
  2883. if (cardEffect.CanUse(null))
  2884. {
  2885. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  2886. {
  2887. return false;
  2888. }
  2889. }
  2890. }
  2891. }
  2892. #endregion
  2893. }
  2894. #endregion
  2895. return true;
  2896. }
  2897. }
  2898. #endregion
  2899. #region このデジモンを場からデジクロス条件の代わりにできるか
  2900. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  2901. {
  2902. #region デジクロス条件の代わりにできる効果
  2903. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2904. {
  2905. foreach (Permanent permanent in player.GetFieldPermanents())
  2906. {
  2907. #region 場のパーマネントの効果
  2908. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2909. {
  2910. if (cardEffect is ICanSelectDigiXrosEffect)
  2911. {
  2912. if (cardEffect.CanUse(null))
  2913. {
  2914. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2915. {
  2916. return true;
  2917. }
  2918. }
  2919. }
  2920. }
  2921. #endregion
  2922. }
  2923. #region プレイヤーの効果
  2924. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2925. {
  2926. if (cardEffect is ICanSelectDigiXrosEffect)
  2927. {
  2928. if (cardEffect.CanUse(null))
  2929. {
  2930. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  2931. {
  2932. return true;
  2933. }
  2934. }
  2935. }
  2936. }
  2937. #endregion
  2938. }
  2939. #endregion
  2940. return false;
  2941. }
  2942. #endregion
  2943. #region 登場した直後のLevel
  2944. public int LevelJustAfterPlayed { get; set; } = -1;
  2945. #endregion
  2946. #region 登場した直後のPlay Cost
  2947. public int PlayCostJustAfterPlayed { get; set; } = -1;
  2948. #endregion
  2949. #region 登場した直後のCardNames
  2950. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  2951. #endregion
  2952. #region 進化した直後のCardNames
  2953. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  2954. #endregion
  2955. #region 登場した直後のTraits
  2956. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  2957. #endregion
  2958. #region 場を離れる直前のDP
  2959. public int DPJustBeforeRemoveField { get; set; } = -1;
  2960. #endregion
  2961. #region 場を離れる直前のLevel
  2962. public int LevelJustBeforeRemoveField { get; set; } = -1;
  2963. #endregion
  2964. #region 場を離れる直前のCost
  2965. public int CostJustBeforeRemoveField { get; set; } = -1;
  2966. #endregion
  2967. #region 場を離れる直前のカード名
  2968. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  2969. #endregion
  2970. #region Card Traits Just Before Removed Field
  2971. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  2972. #endregion
  2973. #region バースト進化で手札に戻ったか
  2974. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  2975. #endregion
  2976. #region Is Linked Card Added as Source By App Fusion
  2977. public bool IsAddedAsSourceByAppFusion { get; set; } = false;
  2978. #endregion
  2979. #region バースト進化したか
  2980. public bool IsBurstDigivolved { get; set; } = false;
  2981. #endregion
  2982. #region 効果で場に出たオプションか
  2983. public bool IsPlayedOptionPermanent { get; set; } = false;
  2984. #endregion
  2985. #region 進化元を持たないか
  2986. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  2987. #endregion
  2988. #region Has No Link Cards
  2989. public bool HasNoLinkCards => LinkedCards.Count == 0;
  2990. #endregion
  2991. #region Digivolution cards' colors
  2992. public List<CardColor> DigivolutionCardsColors
  2993. {
  2994. get
  2995. {
  2996. List<CardColor> cardColors = new List<CardColor>();
  2997. foreach (CardSource cardSource in DigivolutionCards)
  2998. {
  2999. foreach (CardColor cardColor in cardSource.CardColors)
  3000. {
  3001. if (!cardColors.Contains(cardColor))
  3002. {
  3003. cardColors.Add(cardColor);
  3004. }
  3005. }
  3006. }
  3007. return cardColors.Distinct().ToList();
  3008. }
  3009. }
  3010. #endregion
  3011. #region Show "Unsuspend" effect object
  3012. public void ShowUnsuspendEffect()
  3013. {
  3014. if (TopCard != null)
  3015. {
  3016. if (ShowingPermanentCard != null)
  3017. {
  3018. if (ShowingPermanentCard.WillUntapObject != null)
  3019. {
  3020. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  3021. ShowingPermanentCard.WillUntapObject.SetActive(true);
  3022. }
  3023. }
  3024. }
  3025. }
  3026. #endregion
  3027. #region Show "Return to deck" effect object
  3028. public void ShowDeckBounceEffect()
  3029. {
  3030. if (TopCard != null)
  3031. {
  3032. if (willBeRemoveField)
  3033. {
  3034. if (ShowingPermanentCard != null)
  3035. {
  3036. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3037. {
  3038. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  3039. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  3040. }
  3041. }
  3042. }
  3043. }
  3044. }
  3045. #endregion
  3046. #region Hide "Return to deck" effect object
  3047. public void HideDeckBounceEffect()
  3048. {
  3049. if (TopCard != null)
  3050. {
  3051. if (ShowingPermanentCard != null)
  3052. {
  3053. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3054. {
  3055. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  3056. }
  3057. }
  3058. }
  3059. }
  3060. #endregion
  3061. #region Show "Return to hand" effect object
  3062. public void ShowHandBounceEffect()
  3063. {
  3064. if (TopCard != null)
  3065. {
  3066. if (willBeRemoveField)
  3067. {
  3068. if (ShowingPermanentCard != null)
  3069. {
  3070. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3071. {
  3072. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  3073. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  3074. }
  3075. }
  3076. }
  3077. }
  3078. }
  3079. #endregion
  3080. #region Hide "Return to hand" effect object
  3081. public void HideHandBounceEffect()
  3082. {
  3083. if (TopCard != null)
  3084. {
  3085. if (ShowingPermanentCard != null)
  3086. {
  3087. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3088. {
  3089. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  3090. }
  3091. }
  3092. }
  3093. }
  3094. #endregion
  3095. #region Show "Delete" effect object
  3096. public void ShowDeleteEffect()
  3097. {
  3098. if (TopCard != null)
  3099. {
  3100. if (willBeRemoveField)
  3101. {
  3102. if (ShowingPermanentCard != null)
  3103. {
  3104. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3105. {
  3106. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  3107. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  3108. }
  3109. }
  3110. }
  3111. }
  3112. }
  3113. #endregion
  3114. #region Hide "Delete" effect object
  3115. public void HideDeleteEffect()
  3116. {
  3117. if (TopCard != null)
  3118. {
  3119. if (ShowingPermanentCard != null)
  3120. {
  3121. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3122. {
  3123. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  3124. }
  3125. }
  3126. }
  3127. }
  3128. #endregion
  3129. #region Show "Remove Field" effect object
  3130. public void ShowWillRemoveFieldEffect()
  3131. {
  3132. if (TopCard != null)
  3133. {
  3134. if (willBeRemoveField)
  3135. {
  3136. if (ShowingPermanentCard != null)
  3137. {
  3138. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3139. {
  3140. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  3141. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  3142. }
  3143. }
  3144. }
  3145. }
  3146. }
  3147. #endregion
  3148. #region Hide "Remove Field" effect object
  3149. public void HideWillRemoveFieldEffect()
  3150. {
  3151. if (TopCard != null)
  3152. {
  3153. if (ShowingPermanentCard != null)
  3154. {
  3155. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3156. {
  3157. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  3158. }
  3159. }
  3160. }
  3161. }
  3162. #endregion
  3163. #region Show "Digivolution" effect object
  3164. public void ShowWillEvolutionEffect()
  3165. {
  3166. if (TopCard != null)
  3167. {
  3168. if (ShowingPermanentCard != null)
  3169. {
  3170. if (ShowingPermanentCard.WillEvolutionObject != null)
  3171. {
  3172. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  3173. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  3174. }
  3175. }
  3176. }
  3177. }
  3178. #endregion
  3179. #region Hide "Digivolution" effect object
  3180. public void HideWillEvolutionEffect()
  3181. {
  3182. if (TopCard != null)
  3183. {
  3184. if (ShowingPermanentCard != null)
  3185. {
  3186. if (ShowingPermanentCard.WillEvolutionObject != null)
  3187. {
  3188. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  3189. }
  3190. }
  3191. }
  3192. }
  3193. #endregion
  3194. }