Permanent.cs 112 KB

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