Permanent.cs 141 KB

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