Permanent.cs 139 KB

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