Permanent.cs 138 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113
  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 player effect
  821. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  822. {
  823. if (cardEffect is IChangeLinkMaxEffect)
  824. {
  825. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  826. {
  827. if (cardEffect.CanUse(null))
  828. {
  829. if (!TopCard.CanNotBeAffected(cardEffect))
  830. {
  831. cardEffects_ChangeLinkedMax.Add(cardEffect);
  832. }
  833. }
  834. }
  835. }
  836. }
  837. #endregion
  838. }
  839. List<ICardEffect> cardEffects_ChangeLinkedMax_UpToConstant = new List<ICardEffect>();
  840. List<ICardEffect> cardEffects_ChangeLinkedMax_UpDownValue = new List<ICardEffect>();
  841. List<ICardEffect> cardEffects_ChangeLinkedMax_DownToConstant = new List<ICardEffect>();
  842. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax)
  843. {
  844. if (cardEffect is IChangeLinkMaxEffect)
  845. {
  846. if (cardEffect.CanUse(null))
  847. {
  848. switch (((IChangeLinkMaxEffect)cardEffect).isUpDown())
  849. {
  850. case CalculateOrder.UpToConstant:
  851. cardEffects_ChangeLinkedMax_UpToConstant.Add(cardEffect);
  852. break;
  853. case CalculateOrder.UpDownValue:
  854. cardEffects_ChangeLinkedMax_UpDownValue.Add(cardEffect);
  855. break;
  856. case CalculateOrder.DownToConstant:
  857. cardEffects_ChangeLinkedMax_DownToConstant.Add(cardEffect);
  858. break;
  859. }
  860. }
  861. }
  862. }
  863. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpToConstant)
  864. {
  865. if (cardEffect is IChangeLinkMaxEffect)
  866. {
  867. if (cardEffect.CanUse(null))
  868. {
  869. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  870. }
  871. }
  872. }
  873. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpDownValue)
  874. {
  875. if (cardEffect is IChangeLinkMaxEffect)
  876. {
  877. if (cardEffect.CanUse(null))
  878. {
  879. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  880. }
  881. }
  882. }
  883. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_DownToConstant)
  884. {
  885. if (cardEffect is IChangeLinkMaxEffect)
  886. {
  887. if (cardEffect.CanUse(null))
  888. {
  889. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  890. }
  891. }
  892. }
  893. #endregion
  894. return Max;
  895. }
  896. }
  897. public List<CardSource> LinkedCards = new List<CardSource>();
  898. #endregion
  899. #region Add Card Source
  900. public void AddCardSource(CardSource cardSource)
  901. {
  902. cardSources.Insert(0, cardSource);
  903. if (!cardSource.IsFlipped)
  904. cardSource.SetFace();
  905. else
  906. cardSource.SetReverse();
  907. }
  908. #endregion
  909. #region Add digivolution cards to top of sources
  910. /// <summary>
  911. /// 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
  912. /// </summary>
  913. /// <param name="addedDigivolutionCards"></param>
  914. /// <param name="cardEffect"></param>
  915. /// <param name="skipEffectAndActivateSkill"></param>
  916. /// <returns></returns>
  917. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  918. {
  919. List<CardSource> addedCards = new List<CardSource>();
  920. bool isFromSameDigimon = false;
  921. bool isFromDigimon = false;
  922. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  923. {
  924. if (cardSources.Contains(addedDigivolutionCard))
  925. {
  926. isFromSameDigimon = true;
  927. }
  928. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  929. {
  930. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  931. {
  932. isFromDigimon = true;
  933. }
  934. }
  935. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  936. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  937. {
  938. this.cardSources.Insert(1, addedDigivolutionCard);
  939. if (!addedDigivolutionCard.IsFlipped || addedDigivolutionCard.IsBeingRevealed || GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  940. addedDigivolutionCard.SetFace();
  941. addedCards.Add(addedDigivolutionCard);
  942. }
  943. }
  944. if (addedCards.Count >= 1)
  945. {
  946. if (ShowingPermanentCard != null)
  947. {
  948. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  949. }
  950. #region "進化元が増えた時"の効果
  951. #region Hashtable Setting
  952. Hashtable hashtable = new Hashtable()
  953. {
  954. {"Permanent", this},
  955. {"CardEffect", cardEffect},
  956. {"CardSources", addedCards},
  957. {"isFromSameDigimon", isFromSameDigimon},
  958. {"isFromDigimon", isFromDigimon},
  959. };
  960. #endregion
  961. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  962. #endregion
  963. }
  964. }
  965. #endregion
  966. #region Add digivolution cards to bottom of sources
  967. /// <summary>
  968. /// 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
  969. /// </summary>
  970. /// <param name="addedDigivolutionCards"></param>
  971. /// <param name="cardEffect"></param>
  972. /// <param name="skipEffectAndActivateSkill"></param>
  973. /// <returns></returns>
  974. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false, bool isFacedown = false)
  975. {
  976. List<CardSource> addedCards = new List<CardSource>();
  977. bool isFromSameDigimon = false;
  978. bool isFromDigimon = false;
  979. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  980. {
  981. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  982. {
  983. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  984. {
  985. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  986. {
  987. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
  988. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  989. if (!placePermanent.Placed)
  990. {
  991. continue;
  992. }
  993. }
  994. }
  995. }
  996. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  997. {
  998. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  999. {
  1000. isFromDigimon = true;
  1001. }
  1002. }
  1003. if (cardSources.Contains(addedDigivolutionCard))
  1004. {
  1005. isFromSameDigimon = true;
  1006. if (LinkedCards.Contains(addedDigivolutionCard))
  1007. {
  1008. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(addedDigivolutionCard, trashCard: false));
  1009. }
  1010. else if (addedDigivolutionCard == TopCard)
  1011. {
  1012. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  1013. ShowingPermanentCard.ShowPermanentData(true);
  1014. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  1015. addedDigivolutionCard,
  1016. this));
  1017. }
  1018. }
  1019. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  1020. if (!IsToken && !addedDigivolutionCard.IsToken)
  1021. {
  1022. cardSources.Add(addedDigivolutionCard);
  1023. if (isFacedown)
  1024. addedDigivolutionCard.SetReverse();
  1025. else
  1026. addedDigivolutionCard.SetFace();
  1027. addedCards.Add(addedDigivolutionCard);
  1028. }
  1029. }
  1030. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  1031. {
  1032. if (ShowingPermanentCard != null)
  1033. {
  1034. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  1035. }
  1036. #region Effect of "when the number of evolution sources increases"
  1037. #region Hashtable Setting
  1038. Hashtable hashtable = new Hashtable()
  1039. {
  1040. {"Permanent", this},
  1041. {"CardEffect", cardEffect},
  1042. {"CardSources", addedCards},
  1043. {"isFromSameDigimon", isFromSameDigimon},
  1044. {"isFromDigimon", isFromDigimon},
  1045. };
  1046. #endregion
  1047. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  1048. #endregion
  1049. }
  1050. }
  1051. #endregion
  1052. #region Add Link cards
  1053. /// <summary>
  1054. /// 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
  1055. /// </summary>
  1056. /// <param name="addedLinkCards"></param>
  1057. /// <param name="cardEffect"></param>
  1058. /// <param name="skipEffectAndActivateSkill"></param>
  1059. /// <returns></returns>
  1060. public IEnumerator AddLinkCard(CardSource addedLinkCard, ICardEffect cardEffect)
  1061. {
  1062. bool addedCard = false;
  1063. bool isFromDigimon = false;
  1064. if (CardEffectCommons.IsExistOnBattleArea(addedLinkCard))
  1065. {
  1066. if (addedLinkCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  1067. {
  1068. isFromDigimon = true;
  1069. }
  1070. }
  1071. if (LinkedCards.Count >= LinkedMax)
  1072. {
  1073. if(LinkedMax > 1)
  1074. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(null,((LinkedCards.Count + 1) - LinkedMax)));
  1075. else
  1076. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(LinkedCards[0]));
  1077. }
  1078. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
  1079. if (!this.IsToken && !addedLinkCard.IsToken)
  1080. {
  1081. LinkedCards.Insert(0, addedLinkCard);
  1082. LinkedDP += addedLinkCard.LinkDP;
  1083. this.cardSources.Insert(1, addedLinkCard);
  1084. addedLinkCard.SetFace();
  1085. addedCard = true;
  1086. }
  1087. if (addedCard)
  1088. {
  1089. if (ShowingPermanentCard != null)
  1090. {
  1091. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  1092. }
  1093. #region Add Linked Card
  1094. #region Hashtable Setting
  1095. Hashtable hashtable = new Hashtable()
  1096. {
  1097. {"Permanent", this},
  1098. {"CardEffect", cardEffect},
  1099. {"Card", addedLinkCard},
  1100. {"isFromDigimon", isFromDigimon},
  1101. };
  1102. #endregion
  1103. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.WhenLinked));
  1104. #endregion
  1105. }
  1106. }
  1107. #endregion
  1108. #region RemoveCardSource
  1109. public IEnumerator RemoveCardSource(CardSource cardSource)
  1110. {
  1111. yield return null;
  1112. cardSources.Remove(cardSource);
  1113. }
  1114. #endregion
  1115. #region Remove Linked Card
  1116. public IEnumerator RemoveLinkedCard(CardSource cardSource, int removeCount = 0, bool trashCard = true)
  1117. {
  1118. if (LinkedCards.Contains(cardSource))
  1119. {
  1120. LinkedDP -= cardSource.LinkDP;
  1121. LinkedCards.Remove(cardSource);
  1122. yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(cardSource));
  1123. if (trashCard)
  1124. {
  1125. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource));
  1126. }
  1127. }
  1128. if(removeCount > 0)
  1129. {
  1130. int maxCount = Mathf.Min(removeCount, LinkedCards.Count);
  1131. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  1132. selectCardEffect.SetUp(
  1133. canTargetCondition: (CardSource) => true,
  1134. canTargetCondition_ByPreSelecetedList: null,
  1135. canEndSelectCondition: null,
  1136. canNoSelect: () => false,
  1137. selectCardCoroutine: null,
  1138. afterSelectCardCoroutine: null,
  1139. message: $"Select {maxCount} card to trash.",
  1140. maxCount: removeCount,
  1141. canEndNotMax: false,
  1142. isShowOpponent: true,
  1143. mode: SelectCardEffect.Mode.Discard,
  1144. root: SelectCardEffect.Root.Custom,
  1145. customRootCardList: LinkedCards,
  1146. canLookReverseCard: true,
  1147. selectPlayer: TopCard.Owner,
  1148. cardEffect: null);
  1149. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  1150. }
  1151. //TODO: Add event call if something was removed
  1152. }
  1153. #endregion
  1154. #region Top Card
  1155. public CardSource TopCard
  1156. {
  1157. get
  1158. {
  1159. if (cardSources.Count >= 1)
  1160. {
  1161. if (LinkedCards.Count > 0)
  1162. return cardSources.First(source => !LinkedCards.Contains(source));
  1163. else
  1164. return cardSources[0];
  1165. }
  1166. return null;
  1167. }
  1168. }
  1169. #endregion
  1170. #region Permanent effect list
  1171. #region このパーマネントの効果リスト
  1172. public List<ICardEffect> EffectList(EffectTiming timing)
  1173. {
  1174. return EffectList_ForCard(timing, TopCard);
  1175. }
  1176. #endregion
  1177. #region このポケモンの追加効果リスト
  1178. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  1179. {
  1180. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1181. if (TopCard != null)
  1182. {
  1183. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  1184. {
  1185. ICardEffect cardEffect = GetCardEffect(timing);
  1186. if (cardEffect != null)
  1187. {
  1188. _EffectList.Add(cardEffect);
  1189. }
  1190. }
  1191. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  1192. {
  1193. ICardEffect cardEffect = GetCardEffect(timing);
  1194. if (cardEffect != null)
  1195. {
  1196. _EffectList.Add(cardEffect);
  1197. }
  1198. }
  1199. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  1200. {
  1201. ICardEffect cardEffect = GetCardEffect(timing);
  1202. if (cardEffect != null)
  1203. {
  1204. _EffectList.Add(cardEffect);
  1205. }
  1206. }
  1207. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  1208. {
  1209. ICardEffect cardEffect = GetCardEffect(timing);
  1210. if (cardEffect != null)
  1211. {
  1212. _EffectList.Add(cardEffect);
  1213. }
  1214. }
  1215. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  1216. {
  1217. ICardEffect cardEffect = GetCardEffect(timing);
  1218. if (cardEffect != null)
  1219. {
  1220. _EffectList.Add(cardEffect);
  1221. }
  1222. }
  1223. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  1224. {
  1225. ICardEffect cardEffect = GetCardEffect(timing);
  1226. if (cardEffect != null)
  1227. {
  1228. _EffectList.Add(cardEffect);
  1229. }
  1230. }
  1231. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  1232. {
  1233. ICardEffect cardEffect = GetCardEffect(timing);
  1234. if (cardEffect != null)
  1235. {
  1236. _EffectList.Add(cardEffect);
  1237. }
  1238. }
  1239. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  1240. {
  1241. ICardEffect cardEffect = GetCardEffect(timing);
  1242. if (cardEffect != null)
  1243. {
  1244. _EffectList.Add(cardEffect);
  1245. }
  1246. }
  1247. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  1248. {
  1249. ICardEffect cardEffect = GetCardEffect(timing);
  1250. if (cardEffect != null)
  1251. {
  1252. _EffectList.Add(cardEffect);
  1253. }
  1254. }
  1255. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  1256. foreach (ICardEffect cardEffect in _EffectList)
  1257. {
  1258. if (cardEffect != null)
  1259. {
  1260. if (cardEffect.EffectSourceCard == null)
  1261. {
  1262. cardEffect.SetEffectSourceCard(TopCard);
  1263. }
  1264. cardEffect.SetIsInheritedEffect(false);
  1265. }
  1266. }
  1267. }
  1268. return _EffectList;
  1269. }
  1270. #endregion
  1271. #region このパーマネントの効果リスト(引数:CardSource)
  1272. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  1273. {
  1274. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1275. if (TopCard != null && _cardSource != null)
  1276. {
  1277. foreach (CardSource cardSource in cardSources)
  1278. {
  1279. if (cardSource != null)
  1280. {
  1281. if (!cardSource.IsFlipped)
  1282. {
  1283. bool isTopCard = cardSource == TopCard;
  1284. if (!isTopCard)
  1285. {
  1286. if (!IsDigimon)
  1287. {
  1288. continue;
  1289. }
  1290. }
  1291. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  1292. {
  1293. if (cardEffect != null)
  1294. {
  1295. #region Entity, Inherited and Link effects
  1296. if (cardEffect.IsInheritedEffect && !isTopCard)
  1297. {
  1298. _EffectList.Add(cardEffect);
  1299. continue;
  1300. }
  1301. if (cardEffect.IsLinkedEffect && cardSource.IsLinked)
  1302. {
  1303. _EffectList.Add(cardEffect);
  1304. continue;
  1305. }
  1306. if(isTopCard && !cardEffect.IsInheritedEffect && !cardEffect.IsLinkedEffect)
  1307. {
  1308. _EffectList.Add(cardEffect);
  1309. }
  1310. #endregion
  1311. }
  1312. }
  1313. }
  1314. }
  1315. }
  1316. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  1317. {
  1318. if (cardEffect != null)
  1319. {
  1320. _EffectList.Add(cardEffect);
  1321. }
  1322. }
  1323. foreach (ICardEffect cardEffect in _EffectList)
  1324. {
  1325. if (cardEffect != null)
  1326. {
  1327. if (cardEffect.EffectSourceCard == null)
  1328. {
  1329. cardEffect.SetEffectSourceCard(_cardSource);
  1330. }
  1331. }
  1332. }
  1333. }
  1334. return _EffectList;
  1335. }
  1336. #endregion
  1337. #region 自分のターン終了時に消える効果
  1338. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1339. #endregion
  1340. #region 自分のドローフェイズ終了時に消える効果
  1341. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  1342. #endregion
  1343. #region お互いのターン終了時に消える効果
  1344. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1345. #endregion
  1346. #region 相手のターン終了時に消える効果
  1347. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1348. #endregion
  1349. #region バトル終了時に消える効果
  1350. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  1351. #endregion
  1352. #region 攻撃終了時に消える効果
  1353. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  1354. #endregion
  1355. #region 自分のターン開始時に消える効果
  1356. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  1357. #endregion
  1358. #region 次にアンタップする時に消える効果
  1359. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  1360. #endregion
  1361. #region 場を離れるまで残る効果
  1362. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  1363. #endregion
  1364. #endregion
  1365. #region 起動型効果を宣言できるか
  1366. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  1367. #endregion
  1368. #region 宣言可能な起動型効果リスト
  1369. public List<ICardEffect> CanDeclareSkillList()
  1370. {
  1371. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  1372. if (TopCard != null)
  1373. {
  1374. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  1375. {
  1376. if (_cardEffect is ActivateICardEffect)
  1377. {
  1378. if (_cardEffect.CanUse(null))
  1379. {
  1380. CanDeclareSkillList.Add(_cardEffect);
  1381. }
  1382. }
  1383. }
  1384. }
  1385. return CanDeclareSkillList;
  1386. }
  1387. #endregion
  1388. #region このパーマネントが場に出たターン
  1389. public int EnterFieldTurnCount { get; set; } = -1;
  1390. #endregion
  1391. #region このパーマネントを表す場のオブジェクト
  1392. public FieldPermanentCard ShowingPermanentCard { get; set; }
  1393. #endregion
  1394. #region Whether this permanent can be selected by the effect
  1395. public bool CanSelectBySkill(ICardEffect skill)
  1396. {
  1397. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1398. {
  1399. #region Effects of field permanents
  1400. foreach (Permanent permanent in player.GetFieldPermanents())
  1401. {
  1402. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1403. {
  1404. if (cardEffect is ICanNotSelectBySkillEffect)
  1405. {
  1406. if (cardEffect.CanUse(null))
  1407. {
  1408. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  1409. {
  1410. return false;
  1411. }
  1412. }
  1413. }
  1414. }
  1415. }
  1416. #endregion
  1417. }
  1418. return true;
  1419. }
  1420. #endregion
  1421. #region Number of sheets to undergo security check
  1422. public int InvertSecutiryValue
  1423. {
  1424. get
  1425. {
  1426. int Invert = 0;
  1427. List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
  1428. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1429. {
  1430. foreach (Permanent permanent in player.GetFieldPermanents())
  1431. {
  1432. #region Effects of permanents in play
  1433. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1434. {
  1435. if (cardEffect is IInvertSAttackEffect)
  1436. {
  1437. if (cardEffect.CanUse(null))
  1438. {
  1439. if (!TopCard.CanNotBeAffected(cardEffect))
  1440. {
  1441. cardEffects_InvertStrike.Add(cardEffect);
  1442. }
  1443. }
  1444. }
  1445. }
  1446. #endregion
  1447. }
  1448. #region player effect
  1449. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1450. {
  1451. if (cardEffect is IInvertSAttackEffect)
  1452. {
  1453. if (cardEffect.CanUse(null))
  1454. {
  1455. if (!TopCard.CanNotBeAffected(cardEffect))
  1456. {
  1457. cardEffects_InvertStrike.Add(cardEffect);
  1458. }
  1459. }
  1460. }
  1461. }
  1462. #endregion
  1463. }
  1464. foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
  1465. {
  1466. Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
  1467. }
  1468. return Mathf.Clamp(Invert,-1,1);
  1469. }
  1470. }
  1471. public List<int> SecurityAttackChanges
  1472. {
  1473. get
  1474. {
  1475. List<int> SecurityAttackChanges = new List<int>();
  1476. int Strike = 1;
  1477. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1478. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1479. {
  1480. foreach (Permanent permanent in player.GetFieldPermanents())
  1481. {
  1482. #region 場のパーマネントの効果
  1483. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1484. {
  1485. if (cardEffect is IChangeSAttackEffect)
  1486. {
  1487. if (cardEffect.CanUse(null))
  1488. {
  1489. if (!TopCard.CanNotBeAffected(cardEffect))
  1490. {
  1491. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1492. {
  1493. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1494. }
  1495. }
  1496. }
  1497. }
  1498. }
  1499. #endregion
  1500. }
  1501. #region プレイヤーの効果
  1502. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1503. {
  1504. if (cardEffect is IChangeSAttackEffect)
  1505. {
  1506. if (cardEffect.CanUse(null))
  1507. {
  1508. if (!TopCard.CanNotBeAffected(cardEffect))
  1509. {
  1510. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1511. {
  1512. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1513. }
  1514. }
  1515. }
  1516. }
  1517. }
  1518. #endregion
  1519. }
  1520. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1521. {
  1522. if (cardEffect is IChangeSAttackEffect)
  1523. {
  1524. if (cardEffect.CanUse(null))
  1525. {
  1526. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
  1527. if (Strike1 != Strike)
  1528. {
  1529. SecurityAttackChanges.Add(Strike1 - Strike);
  1530. }
  1531. }
  1532. }
  1533. }
  1534. return SecurityAttackChanges;
  1535. }
  1536. }
  1537. public bool HasSecurityAttackChanges
  1538. {
  1539. get
  1540. {
  1541. if (!IsDigimon)
  1542. {
  1543. return false;
  1544. }
  1545. return SecurityAttackChanges.Count >= 1;
  1546. }
  1547. }
  1548. public int Strike_AllowMinus
  1549. {
  1550. get
  1551. {
  1552. int Strike = 1;
  1553. #region Effect of changing the number of sheets to undergo security check
  1554. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1555. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1556. {
  1557. foreach (Permanent permanent in player.GetFieldPermanents())
  1558. {
  1559. #region Effects of permanents in play
  1560. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1561. {
  1562. if (cardEffect is IChangeSAttackEffect)
  1563. {
  1564. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1565. {
  1566. if (cardEffect.CanUse(null))
  1567. {
  1568. if (!TopCard.CanNotBeAffected(cardEffect))
  1569. {
  1570. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1571. }
  1572. }
  1573. }
  1574. }
  1575. }
  1576. #endregion
  1577. }
  1578. #region player effect
  1579. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1580. {
  1581. if (cardEffect is IChangeSAttackEffect)
  1582. {
  1583. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1584. {
  1585. if (cardEffect.CanUse(null))
  1586. {
  1587. if (!TopCard.CanNotBeAffected(cardEffect))
  1588. {
  1589. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1590. }
  1591. }
  1592. }
  1593. }
  1594. }
  1595. #endregion
  1596. }
  1597. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1598. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1599. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1600. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1601. {
  1602. if (cardEffect is IChangeSAttackEffect)
  1603. {
  1604. if (cardEffect.CanUse(null))
  1605. {
  1606. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1607. {
  1608. case CalculateOrder.UpToConstant:
  1609. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1610. break;
  1611. case CalculateOrder.UpDownValue:
  1612. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1613. break;
  1614. case CalculateOrder.DownToConstant:
  1615. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1616. break;
  1617. }
  1618. }
  1619. }
  1620. }
  1621. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1622. {
  1623. if (cardEffect is IChangeSAttackEffect)
  1624. {
  1625. if (cardEffect.CanUse(null))
  1626. {
  1627. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1628. }
  1629. }
  1630. }
  1631. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1632. {
  1633. if (cardEffect is IChangeSAttackEffect)
  1634. {
  1635. if (cardEffect.CanUse(null))
  1636. {
  1637. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1638. }
  1639. }
  1640. }
  1641. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1642. {
  1643. if (cardEffect is IChangeSAttackEffect)
  1644. {
  1645. if (cardEffect.CanUse(null))
  1646. {
  1647. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1648. }
  1649. }
  1650. }
  1651. #endregion
  1652. return Strike;
  1653. }
  1654. }
  1655. public int Strike
  1656. {
  1657. get
  1658. {
  1659. int Strike = Strike_AllowMinus;
  1660. if (Strike < 0)
  1661. {
  1662. Strike = 0;
  1663. }
  1664. return Strike;
  1665. }
  1666. }
  1667. #endregion
  1668. #region このパーマネントがタップされているかどうか
  1669. public bool OldIsSuspended = false;
  1670. public bool IsSuspended = false;
  1671. public int DPWhenSuspended = 114514;
  1672. #endregion
  1673. #region Whether this permanent can unsuspend
  1674. public bool CanUnsuspend
  1675. {
  1676. get
  1677. {
  1678. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1679. {
  1680. #region Effects of field permanents
  1681. foreach (Permanent permanent in player.GetFieldPermanents())
  1682. {
  1683. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1684. {
  1685. if (cardEffect is ICanNotUnsuspendEffect)
  1686. {
  1687. if (cardEffect.CanUse(null))
  1688. {
  1689. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1690. {
  1691. return false;
  1692. }
  1693. }
  1694. }
  1695. }
  1696. }
  1697. #endregion
  1698. #region Effects of players
  1699. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1700. {
  1701. if (cardEffect is ICanNotUnsuspendEffect)
  1702. {
  1703. if (cardEffect.CanUse(null))
  1704. {
  1705. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1706. {
  1707. return false;
  1708. }
  1709. }
  1710. }
  1711. }
  1712. #endregion
  1713. }
  1714. return true;
  1715. }
  1716. }
  1717. #endregion
  1718. #region このパーマネントが移動できるかどうか
  1719. public bool CanMove
  1720. {
  1721. get
  1722. {
  1723. if (TopCard != null)
  1724. {
  1725. #region the effects of permanents
  1726. if (GManager.instance.turnStateMachine.gameContext.Players
  1727. .Map(player => player.GetFieldPermanents())
  1728. .Flat()
  1729. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1730. .Flat()
  1731. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1732. && cardEffect.CanUse(null)
  1733. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1734. {
  1735. return false;
  1736. }
  1737. #endregion
  1738. #region the effects of players
  1739. if (GManager.instance.turnStateMachine.gameContext.Players
  1740. .Map(player => player.EffectList(EffectTiming.None))
  1741. .Flat()
  1742. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1743. && cardEffect.CanUse(null)
  1744. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1745. {
  1746. return false;
  1747. }
  1748. #endregion
  1749. #region the effects of itself
  1750. if (this == null)
  1751. {
  1752. if (EffectList(EffectTiming.None)
  1753. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1754. && cardEffect.CanUse(null)
  1755. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1756. {
  1757. return false;
  1758. }
  1759. }
  1760. #endregion
  1761. if (TopCard.PermanentOfThisCard().PermanentFrame.isBreedingAreaFrame())
  1762. {
  1763. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1764. {
  1765. return false;
  1766. }
  1767. }
  1768. else
  1769. {
  1770. if (TopCard.Owner.GetBreedingAreaPermanents().Count > 0)
  1771. return false;
  1772. }
  1773. if (!IsDigimon)
  1774. return false;
  1775. if (TopCard.IsDigiEgg && DP <= 0)
  1776. return false;
  1777. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1778. {
  1779. return false;
  1780. }
  1781. }
  1782. else
  1783. {
  1784. return false;
  1785. }
  1786. return true;
  1787. }
  1788. }
  1789. #endregion
  1790. #region このパーマネントが攻撃できるかどうか
  1791. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false, bool isExecute = false)
  1792. {
  1793. // can not attack with empty cards
  1794. if (TopCard == null)
  1795. {
  1796. return false;
  1797. }
  1798. // can not attack during opponent's turn
  1799. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1800. {
  1801. return false;
  1802. }
  1803. //Can not attack during another attack
  1804. if (GManager.instance.attackProcess.IsAttacking)
  1805. return false;
  1806. // can not attack to player
  1807. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex, isExecute))
  1808. {
  1809. // can not attack to opponent's Digimon
  1810. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex, isExecute)) == 0)
  1811. {
  1812. return false;
  1813. }
  1814. }
  1815. return true;
  1816. }
  1817. #endregion
  1818. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1819. public bool CanBlock(Permanent AttackingPermanent)
  1820. {
  1821. if (TopCard == null)
  1822. {
  1823. return false;
  1824. }
  1825. if (!IsDigimon)
  1826. {
  1827. return false;
  1828. }
  1829. if (IsSuspended)
  1830. {
  1831. return false;
  1832. }
  1833. if (!CanSuspend)
  1834. {
  1835. return false;
  1836. }
  1837. if (PermanentFrame != null)
  1838. {
  1839. if (!PermanentFrame.IsBattleAreaFrame())
  1840. {
  1841. return false;
  1842. }
  1843. }
  1844. if (!AttackingPermanent.IsDigimon)
  1845. return false;
  1846. if (!AttackingPermanent.CanSwitchAttackTarget)
  1847. return false;
  1848. #region "Unblockable" effect
  1849. #region Effects of permanents in play
  1850. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1851. {
  1852. foreach (Permanent permanent in player.GetFieldPermanents())
  1853. {
  1854. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1855. {
  1856. if (cardEffect is ICannotBlockEffect)
  1857. {
  1858. if (cardEffect.CanUse(null))
  1859. {
  1860. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1861. {
  1862. return false;
  1863. }
  1864. }
  1865. }
  1866. }
  1867. }
  1868. }
  1869. #endregion
  1870. #region player effect
  1871. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1872. {
  1873. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1874. {
  1875. if (cardEffect is ICannotBlockEffect)
  1876. {
  1877. if (cardEffect.CanUse(null))
  1878. {
  1879. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1880. {
  1881. if (!TopCard.CanNotBeAffected(cardEffect))
  1882. {
  1883. return false;
  1884. }
  1885. }
  1886. }
  1887. }
  1888. }
  1889. }
  1890. #endregion
  1891. #endregion
  1892. return true;
  1893. }
  1894. #endregion
  1895. #region 対象のパーマネントを攻撃できるか
  1896. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false, bool isExecute = false)
  1897. {
  1898. if (TopCard != null)
  1899. {
  1900. if (!IsDigimon)
  1901. {
  1902. return false;
  1903. }
  1904. if (!withoutTap)
  1905. {
  1906. if (IsSuspended)
  1907. {
  1908. return false;
  1909. }
  1910. if (!CanSuspend)
  1911. {
  1912. return false;
  1913. }
  1914. }
  1915. if (PermanentFrame != null)
  1916. {
  1917. if (!PermanentFrame.IsBattleAreaFrame())
  1918. {
  1919. return false;
  1920. }
  1921. }
  1922. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1923. {
  1924. if (!HasRush && !isVortex)
  1925. {
  1926. return false;
  1927. }
  1928. }
  1929. #region 「対象の防御パーマネントを攻撃できない」効果
  1930. #region 場のパーマネントの効果
  1931. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1932. {
  1933. foreach (Permanent permanent in player.GetFieldPermanents())
  1934. {
  1935. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1936. {
  1937. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1938. {
  1939. if (cardEffect1.CanUse(null))
  1940. {
  1941. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1942. {
  1943. if (!TopCard.CanNotBeAffected(cardEffect1))
  1944. {
  1945. return false;
  1946. }
  1947. }
  1948. }
  1949. }
  1950. }
  1951. }
  1952. }
  1953. #endregion
  1954. #region プレイヤーの効果
  1955. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1956. {
  1957. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1958. {
  1959. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1960. {
  1961. if (cardEffect1.CanUse(null))
  1962. {
  1963. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1964. {
  1965. if (!TopCard.CanNotBeAffected(cardEffect1))
  1966. {
  1967. return false;
  1968. }
  1969. }
  1970. }
  1971. }
  1972. }
  1973. }
  1974. #endregion
  1975. #endregion
  1976. if (Defender != null)
  1977. {
  1978. if (Defender.TopCard != null)
  1979. {
  1980. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1981. {
  1982. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1983. {
  1984. if (Defender.IsSuspended || isExecute)
  1985. {
  1986. return true;
  1987. }
  1988. #region 「対象の防御パーマネントを攻撃できる」効果
  1989. #region 場のパーマネントの効果
  1990. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1991. {
  1992. foreach (Permanent permanent in player.GetFieldPermanents())
  1993. {
  1994. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1995. {
  1996. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1997. {
  1998. if (cardEffect1.CanUse(null))
  1999. {
  2000. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  2001. {
  2002. return true;
  2003. }
  2004. }
  2005. }
  2006. }
  2007. }
  2008. }
  2009. #endregion
  2010. #region プレイヤーの効果
  2011. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2012. {
  2013. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2014. {
  2015. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  2016. {
  2017. if (cardEffect1.CanUse(null))
  2018. {
  2019. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  2020. {
  2021. return true;
  2022. }
  2023. }
  2024. }
  2025. }
  2026. }
  2027. #endregion
  2028. #endregion
  2029. }
  2030. }
  2031. }
  2032. }
  2033. else
  2034. {
  2035. return true;
  2036. }
  2037. }
  2038. return false;
  2039. }
  2040. #endregion
  2041. #region Is Unblockable
  2042. public bool IsUnblockable
  2043. {
  2044. get
  2045. {
  2046. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2047. {
  2048. if (cardEffect is CannotBlockClass)
  2049. {
  2050. if (cardEffect.EffectName == "Unblockable")
  2051. {
  2052. return true;
  2053. }
  2054. }
  2055. }
  2056. return false;
  2057. }
  2058. }
  2059. #endregion
  2060. #region Has Blocker
  2061. public bool HasBlocker
  2062. {
  2063. get
  2064. {
  2065. #region if attacking digimon has collision
  2066. if (GManager.instance.attackProcess.ActiveAttack())
  2067. {
  2068. Permanent attackingPermanent = GManager.instance.attackProcess.AttackingPermanent;
  2069. if (attackingPermanent != null
  2070. && attackingPermanent.TopCard !=null
  2071. && TopCard != null
  2072. && attackingPermanent.TopCard.Owner != TopCard.Owner
  2073. && attackingPermanent.HasCollision)
  2074. {
  2075. return true;
  2076. }
  2077. }
  2078. #endregion
  2079. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2080. {
  2081. #region Effects of permanents in play
  2082. foreach (Permanent permanent in player.GetFieldPermanents())
  2083. {
  2084. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2085. {
  2086. if (cardEffect is IBlockerEffect)
  2087. {
  2088. if (cardEffect.CanTrigger(null))
  2089. {
  2090. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2091. {
  2092. return true;
  2093. }
  2094. }
  2095. }
  2096. }
  2097. }
  2098. #endregion
  2099. #region Effects of faceup security
  2100. foreach (CardSource source in player.SecurityCards)
  2101. {
  2102. if (source.IsFlipped)
  2103. continue;
  2104. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2105. {
  2106. if (cardEffect is IBlockerEffect)
  2107. {
  2108. if (cardEffect.CanTrigger(null))
  2109. {
  2110. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2111. {
  2112. return true;
  2113. }
  2114. }
  2115. }
  2116. }
  2117. }
  2118. #endregion
  2119. #region プレイヤーの効果
  2120. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2121. {
  2122. if (cardEffect is IBlockerEffect)
  2123. {
  2124. if (cardEffect.CanTrigger(null))
  2125. {
  2126. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  2127. {
  2128. return true;
  2129. }
  2130. }
  2131. }
  2132. }
  2133. #endregion
  2134. }
  2135. return false;
  2136. }
  2137. }
  2138. #endregion
  2139. #region Has Jamming
  2140. public bool HasJamming
  2141. {
  2142. get
  2143. {
  2144. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2145. {
  2146. foreach (Permanent permanent in player.GetFieldPermanents())
  2147. {
  2148. #region 場のパーマネントの効果
  2149. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2150. {
  2151. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2152. {
  2153. if (cardEffect.CanTrigger(null))
  2154. {
  2155. if (cardEffect.EffectName == "Jamming")
  2156. {
  2157. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  2158. {
  2159. return true;
  2160. }
  2161. }
  2162. }
  2163. }
  2164. }
  2165. #endregion
  2166. }
  2167. #region プレイヤーの効果
  2168. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2169. {
  2170. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2171. {
  2172. if (cardEffect.CanTrigger(null))
  2173. {
  2174. if (cardEffect.EffectName == "Jamming")
  2175. {
  2176. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  2177. {
  2178. return true;
  2179. }
  2180. }
  2181. }
  2182. }
  2183. }
  2184. #endregion
  2185. }
  2186. return false;
  2187. }
  2188. }
  2189. #endregion
  2190. #region Has Ice Clad
  2191. public bool HasIceclad
  2192. {
  2193. get
  2194. {
  2195. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2196. {
  2197. #region Ice clad permanent effects
  2198. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  2199. {
  2200. if (cardEffect is IIcecladEffect)
  2201. {
  2202. if (cardEffect.CanTrigger(null))
  2203. {
  2204. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2205. {
  2206. return true;
  2207. }
  2208. }
  2209. }
  2210. }
  2211. #endregion
  2212. #region Ice clad Player Effects
  2213. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2214. {
  2215. if (cardEffect is IIcecladEffect)
  2216. {
  2217. if (cardEffect.CanTrigger(null))
  2218. {
  2219. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2220. {
  2221. return true;
  2222. }
  2223. }
  2224. }
  2225. }
  2226. #endregion
  2227. }
  2228. return false;
  2229. }
  2230. }
  2231. #endregion
  2232. #region Whether this permanent has Pierce
  2233. public bool HasPierce
  2234. {
  2235. get
  2236. {
  2237. if (IsDigimon)
  2238. {
  2239. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  2240. {
  2241. if (cardEffect is ActivateICardEffect)
  2242. {
  2243. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  2244. {
  2245. if (cardEffect.EffectName == "Pierce")
  2246. {
  2247. return true;
  2248. }
  2249. if (cardEffect.EffectName == "Piercing")
  2250. {
  2251. return true;
  2252. }
  2253. }
  2254. }
  2255. }
  2256. }
  2257. return false;
  2258. }
  2259. }
  2260. #endregion
  2261. #region Has Reboot
  2262. public bool HasReboot
  2263. {
  2264. get
  2265. {
  2266. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2267. {
  2268. foreach (Permanent permanent in player.GetFieldPermanents())
  2269. {
  2270. #region 場のパーマネントの効果
  2271. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2272. {
  2273. if (cardEffect is IRebootEffect)
  2274. {
  2275. if (cardEffect.CanTrigger(null))
  2276. {
  2277. if (((IRebootEffect)cardEffect).HasReboot(this))
  2278. {
  2279. return true;
  2280. }
  2281. }
  2282. }
  2283. }
  2284. #endregion
  2285. }
  2286. #region Effects of faceup security
  2287. foreach (CardSource source in player.SecurityCards)
  2288. {
  2289. if (source.IsFlipped)
  2290. continue;
  2291. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2292. {
  2293. if (cardEffect is IRebootEffect)
  2294. {
  2295. if (cardEffect.CanTrigger(null))
  2296. {
  2297. if (((IRebootEffect)cardEffect).HasReboot(this))
  2298. {
  2299. return true;
  2300. }
  2301. }
  2302. }
  2303. }
  2304. }
  2305. #endregion
  2306. #region プレイヤーの効果
  2307. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2308. {
  2309. if (cardEffect is IRebootEffect)
  2310. {
  2311. if (cardEffect.CanTrigger(null))
  2312. {
  2313. if (((IRebootEffect)cardEffect).HasReboot(this))
  2314. {
  2315. return true;
  2316. }
  2317. }
  2318. }
  2319. }
  2320. #endregion
  2321. }
  2322. return false;
  2323. }
  2324. }
  2325. #endregion
  2326. #region Has Raid
  2327. public bool HasRaid
  2328. {
  2329. get
  2330. {
  2331. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2332. {
  2333. if (cardEffect is ActivateICardEffect)
  2334. {
  2335. if (cardEffect.EffectName == "Raid")
  2336. {
  2337. return true;
  2338. }
  2339. }
  2340. }
  2341. return false;
  2342. }
  2343. }
  2344. #endregion
  2345. #region Has Rush
  2346. public bool HasRush
  2347. {
  2348. get
  2349. {
  2350. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2351. {
  2352. foreach (Permanent permanent in player.GetFieldPermanents())
  2353. {
  2354. #region 場のパーマネントの効果
  2355. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2356. {
  2357. if (cardEffect is IRushEffect)
  2358. {
  2359. if (cardEffect.CanTrigger(null))
  2360. {
  2361. if (((IRushEffect)cardEffect).HasRush(this))
  2362. {
  2363. return true;
  2364. }
  2365. }
  2366. }
  2367. }
  2368. #endregion
  2369. }
  2370. #region プレイヤーの効果
  2371. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2372. {
  2373. if (cardEffect is IRushEffect)
  2374. {
  2375. if (cardEffect.CanTrigger(null))
  2376. {
  2377. if (((IRushEffect)cardEffect).HasRush(this))
  2378. {
  2379. return true;
  2380. }
  2381. }
  2382. }
  2383. }
  2384. #endregion
  2385. }
  2386. return false;
  2387. }
  2388. }
  2389. #endregion
  2390. #region Has Retaliation
  2391. public bool HasRetaliation
  2392. {
  2393. get
  2394. {
  2395. if (RetaliationCount >= 1)
  2396. {
  2397. return true;
  2398. }
  2399. return false;
  2400. }
  2401. }
  2402. #endregion
  2403. #region Retaliation Count
  2404. public int RetaliationCount
  2405. {
  2406. get
  2407. {
  2408. int count = 0;
  2409. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2410. {
  2411. if (cardEffect is ActivateICardEffect)
  2412. {
  2413. if (cardEffect.EffectName == "Retaliation")
  2414. {
  2415. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2416. {
  2417. count++;
  2418. }
  2419. }
  2420. }
  2421. }
  2422. return count;
  2423. }
  2424. }
  2425. #endregion
  2426. #region Has Fortitude
  2427. public bool HasFortitude
  2428. {
  2429. get
  2430. {
  2431. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2432. {
  2433. if (cardEffect is ActivateICardEffect)
  2434. {
  2435. if (cardEffect.EffectName == "Fortitude")
  2436. {
  2437. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2438. {
  2439. return true;
  2440. }
  2441. }
  2442. }
  2443. }
  2444. return false;
  2445. }
  2446. }
  2447. #endregion
  2448. #region Has Blitz
  2449. public bool HasBlitz
  2450. {
  2451. get
  2452. {
  2453. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  2454. {
  2455. if (cardEffect is ActivateICardEffect)
  2456. {
  2457. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  2458. {
  2459. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2460. {
  2461. if (cardEffect.EffectDiscription.Contains("Blitz"))
  2462. {
  2463. return true;
  2464. }
  2465. }
  2466. }
  2467. }
  2468. }
  2469. return false;
  2470. }
  2471. }
  2472. #endregion
  2473. #region Has Evade
  2474. public bool HasEvade
  2475. {
  2476. get
  2477. {
  2478. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2479. {
  2480. if (cardEffect is ActivateICardEffect)
  2481. {
  2482. Hashtable hashtable = new Hashtable()
  2483. {
  2484. {"Permanents", new List<Permanent>() { this }}
  2485. };
  2486. if (cardEffect.CanTrigger(hashtable))
  2487. {
  2488. if (cardEffect.EffectName == "Evade")
  2489. {
  2490. return true;
  2491. }
  2492. }
  2493. }
  2494. }
  2495. return false;
  2496. }
  2497. }
  2498. #endregion
  2499. #region Has Mind Link
  2500. public bool HasMindLink
  2501. {
  2502. get
  2503. {
  2504. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  2505. {
  2506. if (cardEffect is ActivateICardEffect)
  2507. {
  2508. if (cardEffect.CanTrigger(null))
  2509. {
  2510. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2511. {
  2512. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2513. {
  2514. return true;
  2515. }
  2516. }
  2517. }
  2518. }
  2519. }
  2520. return false;
  2521. }
  2522. }
  2523. #endregion
  2524. #region Has Barrier
  2525. public bool HasBarrier
  2526. {
  2527. get
  2528. {
  2529. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2530. {
  2531. if (cardEffect is ActivateICardEffect)
  2532. {
  2533. Hashtable hashtable = new Hashtable();
  2534. hashtable.Add("Permanents", new List<Permanent>() { this });
  2535. hashtable.Add("battle", new IBattle(null, null, null));
  2536. if (cardEffect.CanTrigger(hashtable))
  2537. {
  2538. if (cardEffect.EffectName == "Barrier")
  2539. {
  2540. return true;
  2541. }
  2542. }
  2543. }
  2544. }
  2545. return false;
  2546. }
  2547. }
  2548. #endregion
  2549. #region Has Alliance
  2550. public bool HasAlliance
  2551. {
  2552. get
  2553. {
  2554. Hashtable hashtable = new Hashtable(){
  2555. {"AttackingPermanent", this}
  2556. };
  2557. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2558. {
  2559. foreach (Permanent permanent in player.GetFieldPermanents())
  2560. {
  2561. #region Permanent Effects
  2562. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2563. {
  2564. if (cardEffect.EffectName == "Alliance")
  2565. {
  2566. if (cardEffect.CanTrigger(hashtable))
  2567. {
  2568. return true;
  2569. }
  2570. }
  2571. }
  2572. #endregion
  2573. }
  2574. #region Effects of faceup security
  2575. foreach (CardSource source in player.SecurityCards)
  2576. {
  2577. if (source.IsFlipped)
  2578. continue;
  2579. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnAllyAttack))
  2580. {
  2581. if (cardEffect.EffectName == "Alliance")
  2582. {
  2583. if (cardEffect.CanTrigger(hashtable))
  2584. {
  2585. return true;
  2586. }
  2587. }
  2588. }
  2589. }
  2590. #endregion
  2591. #region Player Effects
  2592. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2593. {
  2594. if (cardEffect.EffectName == "Alliance")
  2595. {
  2596. if (cardEffect.CanTrigger(hashtable))
  2597. {
  2598. return true;
  2599. }
  2600. }
  2601. }
  2602. #endregion
  2603. }
  2604. return false;
  2605. }
  2606. }
  2607. #endregion
  2608. #region Has Collision
  2609. public bool HasCollision
  2610. {
  2611. get
  2612. {
  2613. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2614. {
  2615. foreach (Permanent permanent in player.GetFieldPermanents())
  2616. {
  2617. #region Permanent Effects
  2618. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnCounterTiming))
  2619. {
  2620. if (cardEffect is ICollisionEffect)
  2621. {
  2622. if (cardEffect.CanTrigger(null))
  2623. {
  2624. if (((ICollisionEffect)cardEffect).HasCollision(this))
  2625. {
  2626. return true;
  2627. }
  2628. }
  2629. }
  2630. }
  2631. #endregion
  2632. }
  2633. #region Effects of faceup security
  2634. foreach (CardSource source in player.SecurityCards)
  2635. {
  2636. if (source.IsFlipped)
  2637. continue;
  2638. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnCounterTiming))
  2639. {
  2640. if (cardEffect is ICollisionEffect)
  2641. {
  2642. if (cardEffect.CanTrigger(null))
  2643. {
  2644. if (((ICollisionEffect)cardEffect).HasCollision(this))
  2645. {
  2646. return true;
  2647. }
  2648. }
  2649. }
  2650. }
  2651. }
  2652. #endregion
  2653. #region Player Effects
  2654. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnCounterTiming))
  2655. {
  2656. if (cardEffect is ICollisionEffect)
  2657. {
  2658. if (cardEffect.CanTrigger(null))
  2659. {
  2660. if (((ICollisionEffect)cardEffect).HasCollision(this))
  2661. {
  2662. return true;
  2663. }
  2664. }
  2665. }
  2666. }
  2667. #endregion
  2668. }
  2669. return false;
  2670. }
  2671. }
  2672. #endregion
  2673. #region Has Partition
  2674. public bool HasPartition
  2675. {
  2676. get
  2677. {
  2678. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2679. {
  2680. if (cardEffect is ActivateICardEffect)
  2681. {
  2682. if (cardEffect.EffectName == "Partition")
  2683. {
  2684. return true;
  2685. }
  2686. }
  2687. }
  2688. return false;
  2689. }
  2690. }
  2691. #endregion
  2692. #region Has Scapegoat
  2693. public bool HasScapegoat
  2694. {
  2695. get
  2696. {
  2697. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2698. {
  2699. if (cardEffect is ActivateICardEffect)
  2700. {
  2701. if (cardEffect.EffectName == "<Scapegoat>")
  2702. {
  2703. return true;
  2704. }
  2705. }
  2706. }
  2707. return false;
  2708. }
  2709. }
  2710. #endregion
  2711. #region 消滅時効化を持つか
  2712. public bool HasOnDeletionEffect
  2713. {
  2714. get
  2715. {
  2716. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2717. {
  2718. if (cardEffect is ActivateICardEffect)
  2719. {
  2720. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2721. {
  2722. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2723. {
  2724. if (cardEffect.IsOnDeletion)
  2725. {
  2726. return true;
  2727. }
  2728. }
  2729. }
  2730. }
  2731. }
  2732. return false;
  2733. }
  2734. }
  2735. #endregion
  2736. #region バトルしているか
  2737. public IBattle battle { get; set; } = null;
  2738. #endregion
  2739. #region Can Be Destroyed
  2740. public bool CanBeDestroyed()
  2741. {
  2742. #region 消滅しない効果
  2743. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2744. {
  2745. foreach (Permanent permanent in player.GetFieldPermanents())
  2746. {
  2747. #region 場のパーマネントの効果
  2748. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2749. {
  2750. if (cardEffect is ICanNotBeDestroyedEffect)
  2751. {
  2752. if (cardEffect.CanUse(null))
  2753. {
  2754. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2755. {
  2756. return false;
  2757. }
  2758. }
  2759. }
  2760. }
  2761. #endregion
  2762. }
  2763. #region プレイヤーの効果
  2764. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2765. {
  2766. if (cardEffect is ICanNotBeDestroyedEffect)
  2767. {
  2768. if (cardEffect.CanUse(null))
  2769. {
  2770. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2771. {
  2772. return false;
  2773. }
  2774. }
  2775. }
  2776. }
  2777. #endregion
  2778. }
  2779. #endregion
  2780. return true;
  2781. }
  2782. #endregion
  2783. #region Can Be Destroyed By Battle
  2784. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2785. {
  2786. if (!CanBeDestroyed())
  2787. {
  2788. return false;
  2789. }
  2790. #region Given Effects
  2791. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2792. {
  2793. foreach (Permanent permanent in player.GetFieldPermanents())
  2794. {
  2795. #region Permanents
  2796. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2797. {
  2798. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2799. {
  2800. if (cardEffect.CanUse(null))
  2801. {
  2802. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2803. {
  2804. return false;
  2805. }
  2806. }
  2807. }
  2808. }
  2809. #endregion
  2810. }
  2811. #region Effects of faceup security
  2812. foreach (CardSource source in player.SecurityCards)
  2813. {
  2814. if (source.IsFlipped)
  2815. continue;
  2816. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2817. {
  2818. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2819. {
  2820. if (cardEffect.CanUse(null))
  2821. {
  2822. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2823. {
  2824. return false;
  2825. }
  2826. }
  2827. }
  2828. }
  2829. }
  2830. #endregion
  2831. #region Player Effects
  2832. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2833. {
  2834. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2835. {
  2836. if (cardEffect.CanUse(null))
  2837. {
  2838. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2839. {
  2840. return false;
  2841. }
  2842. }
  2843. }
  2844. }
  2845. #endregion
  2846. }
  2847. #endregion
  2848. return true;
  2849. }
  2850. #endregion
  2851. #region このパーマネントが効果で消滅するか
  2852. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2853. {
  2854. if (this.TopCard != null)
  2855. {
  2856. if (this.TopCard.CanNotBeAffected(cardEffect))
  2857. {
  2858. return false;
  2859. }
  2860. if (!CanBeDestroyed())
  2861. {
  2862. return false;
  2863. }
  2864. #region 効果で消滅しない効果
  2865. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2866. {
  2867. foreach (Permanent permanent in player.GetFieldPermanents())
  2868. {
  2869. #region 場のパーマネントの効果
  2870. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2871. {
  2872. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2873. {
  2874. if (cardEffect1.CanUse(null))
  2875. {
  2876. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2877. {
  2878. return false;
  2879. }
  2880. }
  2881. }
  2882. }
  2883. #endregion
  2884. }
  2885. #region プレイヤーの効果
  2886. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2887. {
  2888. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2889. {
  2890. if (cardEffect1.CanUse(null))
  2891. {
  2892. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2893. {
  2894. return false;
  2895. }
  2896. }
  2897. }
  2898. }
  2899. #endregion
  2900. }
  2901. #endregion
  2902. }
  2903. return true;
  2904. }
  2905. #endregion
  2906. #region Can Leave Field
  2907. public bool CanBeRemoved()
  2908. {
  2909. #region Effect that never disappears
  2910. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2911. {
  2912. foreach (Permanent permanent in player.GetFieldPermanents())
  2913. {
  2914. #region Effects of permanents in play
  2915. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2916. {
  2917. if (cardEffect is ICanNotBeRemovedEffect)
  2918. {
  2919. if (cardEffect.CanUse(null))
  2920. {
  2921. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2922. {
  2923. return false;
  2924. }
  2925. }
  2926. }
  2927. }
  2928. #endregion
  2929. }
  2930. #region player effect
  2931. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2932. {
  2933. if (cardEffect is ICanNotBeRemovedEffect)
  2934. {
  2935. if (cardEffect.CanUse(null))
  2936. {
  2937. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2938. {
  2939. return false;
  2940. }
  2941. }
  2942. }
  2943. }
  2944. #endregion
  2945. }
  2946. #endregion
  2947. return true;
  2948. }
  2949. #endregion
  2950. #region トークンかどうか
  2951. public bool IsToken
  2952. {
  2953. get
  2954. {
  2955. if (TopCard != null)
  2956. {
  2957. if (TopCard.IsToken)
  2958. {
  2959. return true;
  2960. }
  2961. }
  2962. return false;
  2963. }
  2964. }
  2965. #endregion
  2966. #region そのパーマネントが消滅・バウンス待機状態か
  2967. public bool willBeRemoveField { get; set; } = false;
  2968. #endregion
  2969. #region Is a Digimon card
  2970. public bool IsDigimon
  2971. {
  2972. get
  2973. {
  2974. if (TopCard != null)
  2975. {
  2976. if (TopCard.IsFlipped)
  2977. return false;
  2978. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2979. {
  2980. return true;
  2981. }
  2982. #region Effect on TopCard
  2983. foreach (ICardEffect cardEffect in TopCard.EffectList(EffectTiming.None))
  2984. {
  2985. if (cardEffect is ITreatAsDigimonEffect)
  2986. {
  2987. if (cardEffect.CanTrigger(null))
  2988. {
  2989. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2990. {
  2991. return true;
  2992. }
  2993. }
  2994. }
  2995. }
  2996. #endregion
  2997. #region Effect of treating it as a Digimon
  2998. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2999. {
  3000. foreach (Permanent permanent in player.GetFieldPermanents())
  3001. {
  3002. #region Effects of permanents in play
  3003. 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
  3004. {
  3005. if (cardEffect is ITreatAsDigimonEffect)
  3006. {
  3007. if (cardEffect.CanTrigger(null))
  3008. {
  3009. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  3010. {
  3011. return true;
  3012. }
  3013. }
  3014. }
  3015. }
  3016. #endregion
  3017. }
  3018. #region player effect
  3019. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3020. {
  3021. if (cardEffect is ITreatAsDigimonEffect)
  3022. {
  3023. if (cardEffect.CanTrigger(null))
  3024. {
  3025. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  3026. {
  3027. return true;
  3028. }
  3029. }
  3030. }
  3031. }
  3032. #endregion
  3033. }
  3034. #endregion
  3035. }
  3036. return false;
  3037. }
  3038. }
  3039. #endregion
  3040. #region Is a Tamer card
  3041. public bool IsTamer
  3042. {
  3043. get
  3044. {
  3045. if (TopCard != null)
  3046. {
  3047. if (TopCard.IsFlipped)
  3048. return false;
  3049. if (TopCard.IsTamer)
  3050. {
  3051. return true;
  3052. }
  3053. }
  3054. return false;
  3055. }
  3056. }
  3057. #endregion
  3058. #region Is an Option card
  3059. public bool IsOption
  3060. {
  3061. get
  3062. {
  3063. if (TopCard != null)
  3064. {
  3065. if (TopCard.IsOption && !TopCard.IsDigimon) //DualCard is never an option while it is a permanent
  3066. {
  3067. return true;
  3068. }
  3069. }
  3070. return false;
  3071. }
  3072. }
  3073. #endregion
  3074. #region Levels handled by Jogress
  3075. public List<int> Levels_ForJogress(CardSource cardSource)
  3076. {
  3077. List<int> levels = new List<int>();
  3078. if (cardSource != null)
  3079. {
  3080. if (cardSource.HasLevel)
  3081. {
  3082. levels.Add(this.Level);
  3083. }
  3084. #region Effect of "adding levels handled by jogless evolution"
  3085. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3086. {
  3087. foreach (Permanent permanent in player.GetFieldPermanents())
  3088. {
  3089. #region Effects of permanents in play
  3090. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3091. {
  3092. if (cardEffect is IAddJogressLevelsEffect)
  3093. {
  3094. if (cardEffect.CanUse(null))
  3095. {
  3096. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  3097. {
  3098. levels.Add(level);
  3099. }
  3100. }
  3101. }
  3102. }
  3103. #endregion
  3104. }
  3105. #region player effect
  3106. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3107. {
  3108. if (cardEffect is IAddJogressLevelsEffect)
  3109. {
  3110. if (cardEffect.CanUse(null))
  3111. {
  3112. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  3113. {
  3114. levels.Add(level);
  3115. }
  3116. }
  3117. }
  3118. }
  3119. #endregion
  3120. }
  3121. #endregion
  3122. }
  3123. return levels;
  3124. }
  3125. #endregion
  3126. #region Names handled by Jogress
  3127. public List<string> Names_ForDNA(CardSource cardSource)
  3128. {
  3129. List<string> names = new List<string>();
  3130. if (cardSource != null)
  3131. {
  3132. foreach(string name in cardSource.CardNames)
  3133. names.Add(name);
  3134. #region Effect of "adding names handled by DNA evolution"
  3135. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3136. {
  3137. foreach (Permanent permanent in player.GetFieldPermanents())
  3138. {
  3139. #region Effects of permanents in play
  3140. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3141. {
  3142. if (cardEffect is IAddDNANamesEffect)
  3143. {
  3144. if (cardEffect.CanUse(null))
  3145. {
  3146. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  3147. {
  3148. names.Add(name);
  3149. }
  3150. }
  3151. }
  3152. }
  3153. #endregion
  3154. }
  3155. #region player effect
  3156. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3157. {
  3158. if (cardEffect is IAddDNANamesEffect)
  3159. {
  3160. if (cardEffect.CanUse(null))
  3161. {
  3162. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  3163. {
  3164. names.Add(name);
  3165. }
  3166. }
  3167. }
  3168. }
  3169. #endregion
  3170. }
  3171. #endregion
  3172. }
  3173. return names;
  3174. }
  3175. #endregion
  3176. #region バトルで消滅したか
  3177. public bool IsDestroyedByBattle { get; set; } = false;
  3178. #endregion
  3179. #region 消滅に使用された効果
  3180. public ICardEffect DestroyingEffect { get; set; } = null;
  3181. #endregion
  3182. #region 他のパーマネントの下に置くのに使用された効果
  3183. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  3184. #endregion
  3185. #region 手札バウンス に使用された効果
  3186. public ICardEffect HandBounceEffect { get; set; } = null;
  3187. #endregion
  3188. #region 山札バウンス に使用された効果
  3189. public ICardEffect LibraryBounceEffect { get; set; } = null;
  3190. #endregion
  3191. #region 登場に使用された効果
  3192. public ICardEffect PlayingEffect { get; set; } = null;
  3193. #endregion
  3194. #region 進化に使用された効果
  3195. public ICardEffect DigivolvingEffect { get; set; } = null;
  3196. #endregion
  3197. #region Whether this digimon is placed in the trash by not having a DP
  3198. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  3199. #endregion
  3200. #region Whether this permanent can suspend
  3201. public bool CanSuspend
  3202. {
  3203. get
  3204. {
  3205. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  3206. {
  3207. #region Effects of field permanents
  3208. foreach (Permanent permanent in player.GetFieldPermanents())
  3209. {
  3210. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3211. {
  3212. if (cardEffect is ICanNotSuspendEffect)
  3213. {
  3214. if (cardEffect.CanUse(null))
  3215. {
  3216. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  3217. {
  3218. return false;
  3219. }
  3220. }
  3221. }
  3222. }
  3223. }
  3224. #endregion
  3225. #region Effects of players
  3226. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3227. {
  3228. if (cardEffect is ICanNotSuspendEffect)
  3229. {
  3230. if (cardEffect.CanUse(null))
  3231. {
  3232. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  3233. {
  3234. return false;
  3235. }
  3236. }
  3237. }
  3238. }
  3239. #endregion
  3240. }
  3241. return true;
  3242. }
  3243. }
  3244. #endregion
  3245. #region このデジモンのアタックの対象が変更できるか
  3246. public bool CanSwitchAttackTarget
  3247. {
  3248. get
  3249. {
  3250. #region アタックの対象が変更できない効果
  3251. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3252. {
  3253. foreach (Permanent permanent in player.GetFieldPermanents())
  3254. {
  3255. #region 場のパーマネントの効果
  3256. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3257. {
  3258. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3259. {
  3260. if (cardEffect.CanUse(null))
  3261. {
  3262. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3263. {
  3264. return false;
  3265. }
  3266. }
  3267. }
  3268. }
  3269. #endregion
  3270. }
  3271. #region プレイヤーの効果
  3272. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3273. {
  3274. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3275. {
  3276. if (cardEffect.CanUse(null))
  3277. {
  3278. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3279. {
  3280. return false;
  3281. }
  3282. }
  3283. }
  3284. }
  3285. #endregion
  3286. }
  3287. #endregion
  3288. return true;
  3289. }
  3290. }
  3291. #endregion
  3292. #region このデジモンを場からデジクロス条件の代わりにできるか
  3293. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  3294. {
  3295. #region デジクロス条件の代わりにできる効果
  3296. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3297. {
  3298. foreach (Permanent permanent in player.GetFieldPermanents())
  3299. {
  3300. #region 場のパーマネントの効果
  3301. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3302. {
  3303. if (cardEffect is ICanSelectDigiXrosEffect)
  3304. {
  3305. if (cardEffect.CanUse(null))
  3306. {
  3307. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3308. {
  3309. return true;
  3310. }
  3311. }
  3312. }
  3313. }
  3314. #endregion
  3315. }
  3316. #region プレイヤーの効果
  3317. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3318. {
  3319. if (cardEffect is ICanSelectDigiXrosEffect)
  3320. {
  3321. if (cardEffect.CanUse(null))
  3322. {
  3323. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3324. {
  3325. return true;
  3326. }
  3327. }
  3328. }
  3329. }
  3330. #endregion
  3331. }
  3332. #endregion
  3333. return false;
  3334. }
  3335. #endregion
  3336. #region Can Substitue for Assembly
  3337. public bool CanSubstituteForAssemblyCondition(CardSource cardSource)
  3338. {
  3339. #region Effects that can be used in place of Assembly conditions
  3340. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3341. {
  3342. foreach (Permanent permanent in player.GetFieldPermanents())
  3343. {
  3344. #region Effects of permanents in play
  3345. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3346. {
  3347. if (cardEffect is ICanSelectAssemblyEffect)
  3348. {
  3349. if (cardEffect.CanUse(null))
  3350. {
  3351. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3352. {
  3353. return true;
  3354. }
  3355. }
  3356. }
  3357. }
  3358. #endregion
  3359. }
  3360. #region player effect
  3361. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3362. {
  3363. if (cardEffect is ICanSelectAssemblyEffect)
  3364. {
  3365. if (cardEffect.CanUse(null))
  3366. {
  3367. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3368. {
  3369. return true;
  3370. }
  3371. }
  3372. }
  3373. }
  3374. #endregion
  3375. }
  3376. #endregion
  3377. return false;
  3378. }
  3379. #endregion
  3380. #region 登場した直後のLevel
  3381. public int LevelJustAfterPlayed { get; set; } = -1;
  3382. #endregion
  3383. #region 登場した直後のPlay Cost
  3384. public int PlayCostJustAfterPlayed { get; set; } = -1;
  3385. #endregion
  3386. #region 登場した直後のCardNames
  3387. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  3388. #endregion
  3389. #region 進化した直後のCardNames
  3390. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  3391. #endregion
  3392. #region 登場した直後のTraits
  3393. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  3394. #endregion
  3395. #region 場を離れる直前のDP
  3396. public int DPJustBeforeRemoveField { get; set; } = -1;
  3397. #endregion
  3398. #region 場を離れる直前のLevel
  3399. public int LevelJustBeforeRemoveField { get; set; } = -1;
  3400. #endregion
  3401. #region 場を離れる直前のCost
  3402. public int CostJustBeforeRemoveField { get; set; } = -1;
  3403. #endregion
  3404. #region 場を離れる直前のカード名
  3405. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  3406. #endregion
  3407. #region Card Traits Just Before Removed Field
  3408. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  3409. #endregion
  3410. #region バースト進化で手札に戻ったか
  3411. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  3412. #endregion
  3413. #region Is Linked Card Added as Source By App Fusion
  3414. public bool IsAddedAsSourceByAppFusion { get; set; } = false;
  3415. #endregion
  3416. #region バースト進化したか
  3417. public bool IsBurstDigivolved { get; set; } = false;
  3418. #endregion
  3419. #region Did it App Fusion?
  3420. public bool IsAppFusion { get; set; } = false;
  3421. #endregion
  3422. #region 効果で場に出たオプションか
  3423. public bool IsPlayedOptionPermanent { get; set; } = false;
  3424. #endregion
  3425. #region 進化元を持たないか
  3426. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  3427. #endregion
  3428. #region Has face down Digivolution Cards
  3429. public bool HasFaceDownDigivolutionCards => DigivolutionCards.Any(x => x.IsFlipped);
  3430. #endregion
  3431. #region Has No Link Cards
  3432. public bool HasNoLinkCards => LinkedCards.Count == 0;
  3433. #endregion
  3434. #region Digivolution cards' colors
  3435. public List<CardColor> DigivolutionCardsColors
  3436. {
  3437. get
  3438. {
  3439. List<CardColor> cardColors = new List<CardColor>();
  3440. foreach (CardSource cardSource in DigivolutionCards)
  3441. {
  3442. if (cardSource.IsFlipped)
  3443. continue;
  3444. foreach (CardColor cardColor in cardSource.CardColors)
  3445. {
  3446. if (!cardColors.Contains(cardColor))
  3447. {
  3448. cardColors.Add(cardColor);
  3449. }
  3450. }
  3451. foreach (CardColor cardColor in cardSource.DualCardColors)
  3452. {
  3453. if (!cardColors.Contains(cardColor))
  3454. {
  3455. cardColors.Add(cardColor);
  3456. }
  3457. }
  3458. }
  3459. return cardColors.Distinct().ToList();
  3460. }
  3461. }
  3462. #endregion
  3463. #region Show "Unsuspend" effect object
  3464. public void ShowUnsuspendEffect()
  3465. {
  3466. if (TopCard != null)
  3467. {
  3468. if (ShowingPermanentCard != null)
  3469. {
  3470. if (ShowingPermanentCard.WillUntapObject != null)
  3471. {
  3472. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  3473. ShowingPermanentCard.WillUntapObject.SetActive(true);
  3474. }
  3475. }
  3476. }
  3477. }
  3478. #endregion
  3479. #region Show "Return to deck" effect object
  3480. public void ShowDeckBounceEffect()
  3481. {
  3482. if (TopCard != null)
  3483. {
  3484. if (willBeRemoveField)
  3485. {
  3486. if (ShowingPermanentCard != null)
  3487. {
  3488. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3489. {
  3490. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  3491. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  3492. }
  3493. }
  3494. }
  3495. }
  3496. }
  3497. #endregion
  3498. #region Hide "Return to deck" effect object
  3499. public void HideDeckBounceEffect()
  3500. {
  3501. if (TopCard != null)
  3502. {
  3503. if (ShowingPermanentCard != null)
  3504. {
  3505. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3506. {
  3507. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  3508. }
  3509. }
  3510. }
  3511. }
  3512. #endregion
  3513. #region Show "Return to hand" effect object
  3514. public void ShowHandBounceEffect()
  3515. {
  3516. if (TopCard != null)
  3517. {
  3518. if (willBeRemoveField)
  3519. {
  3520. if (ShowingPermanentCard != null)
  3521. {
  3522. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3523. {
  3524. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  3525. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  3526. }
  3527. }
  3528. }
  3529. }
  3530. }
  3531. #endregion
  3532. #region Hide "Return to hand" effect object
  3533. public void HideHandBounceEffect()
  3534. {
  3535. if (TopCard != null)
  3536. {
  3537. if (ShowingPermanentCard != null)
  3538. {
  3539. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3540. {
  3541. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  3542. }
  3543. }
  3544. }
  3545. }
  3546. #endregion
  3547. #region Show "Delete" effect object
  3548. public void ShowDeleteEffect()
  3549. {
  3550. if (TopCard != null)
  3551. {
  3552. if (willBeRemoveField)
  3553. {
  3554. if (ShowingPermanentCard != null)
  3555. {
  3556. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3557. {
  3558. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  3559. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  3560. }
  3561. }
  3562. }
  3563. }
  3564. }
  3565. #endregion
  3566. #region Hide "Delete" effect object
  3567. public void HideDeleteEffect()
  3568. {
  3569. if (TopCard != null)
  3570. {
  3571. if (ShowingPermanentCard != null)
  3572. {
  3573. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3574. {
  3575. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  3576. }
  3577. }
  3578. }
  3579. }
  3580. #endregion
  3581. #region Show "Remove Field" effect object
  3582. public void ShowWillRemoveFieldEffect()
  3583. {
  3584. if (TopCard != null)
  3585. {
  3586. if (willBeRemoveField)
  3587. {
  3588. if (ShowingPermanentCard != null)
  3589. {
  3590. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3591. {
  3592. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  3593. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  3594. }
  3595. }
  3596. }
  3597. }
  3598. }
  3599. #endregion
  3600. #region Hide "Remove Field" effect object
  3601. public void HideWillRemoveFieldEffect()
  3602. {
  3603. if (TopCard != null)
  3604. {
  3605. if (ShowingPermanentCard != null)
  3606. {
  3607. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3608. {
  3609. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  3610. }
  3611. }
  3612. }
  3613. }
  3614. #endregion
  3615. #region Show "Digivolution" effect object
  3616. public void ShowWillEvolutionEffect()
  3617. {
  3618. if (TopCard != null)
  3619. {
  3620. if (ShowingPermanentCard != null)
  3621. {
  3622. if (ShowingPermanentCard.WillEvolutionObject != null)
  3623. {
  3624. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  3625. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  3626. }
  3627. }
  3628. }
  3629. }
  3630. #endregion
  3631. #region Hide "Digivolution" effect object
  3632. public void HideWillEvolutionEffect()
  3633. {
  3634. if (TopCard != null)
  3635. {
  3636. if (ShowingPermanentCard != null)
  3637. {
  3638. if (ShowingPermanentCard.WillEvolutionObject != null)
  3639. {
  3640. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  3641. }
  3642. }
  3643. }
  3644. }
  3645. #endregion
  3646. }