Permanent.cs 127 KB

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