Permanent.cs 134 KB

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