CardSource.cs 120 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System;
  4. using Photon.Pun;
  5. using System.Linq;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8. using DCGO.CardEntities;
  9. public class CardSource : MonoBehaviour
  10. {
  11. #region card base entity
  12. CEntity_Base _cEntity_Base = null;
  13. #endregion
  14. #region PhotonView
  15. public PhotonView PhotonView { get; set; }
  16. #endregion
  17. #region owner
  18. public Player Owner { get; private set; } = null;
  19. #endregion
  20. #region card index
  21. public int CardIndex { get; private set; } = 0;
  22. #endregion
  23. #region set card base entity
  24. public void SetBaseData(CEntity_Base cEntity_Base, Player owner)
  25. {
  26. _cEntity_Base = cEntity_Base;
  27. Owner = owner;
  28. gameObject.name = _cEntity_Base.CardName_ENG;
  29. SetFace();
  30. }
  31. #endregion
  32. #region card effect controller
  33. public CEntity_EffectController cEntity_EffectController;
  34. #endregion
  35. #region whether this card is reversed
  36. public bool IsFlipped { get; private set; }
  37. #region set face
  38. public void SetFace(string str = "")
  39. {
  40. IsFlipped = false;
  41. if (str != "")
  42. UnityEngine.Debug.Log($"CARD FLIPPED: {this.BaseENGCardNameFromEntity}, from - {str}");
  43. GManager.OnCardFlippedChanged?.Invoke();
  44. GManager.OnSecurityStackChanged?.Invoke(Owner);
  45. }
  46. #endregion
  47. #region set reverse
  48. public void SetReverse()
  49. {
  50. IsFlipped = true;
  51. GManager.OnCardFlippedChanged?.Invoke();
  52. GManager.OnSecurityStackChanged?.Invoke(Owner);
  53. }
  54. #endregion
  55. #endregion
  56. #region Card ID setup
  57. public void SetUpCardIndex(int _cardIndex)
  58. {
  59. PhotonView _PhotonView = GetComponent<PhotonView>();
  60. _PhotonView ??= gameObject.AddComponent<PhotonView>();
  61. CardIndex = _cardIndex;
  62. _PhotonView.ViewID = CardIndex + 60;
  63. PhotonView = _PhotonView;
  64. }
  65. #endregion
  66. #region whether this card can be played
  67. public bool CanPlayFromHandDuringMainPhase
  68. {
  69. get
  70. {
  71. if (IsDigimon && Owner.GetBattleAreaDigimons().Some(permanent => CanPlayCardTargetFrame(permanent.PermanentFrame, true, null)))
  72. {
  73. return true;
  74. }
  75. if (_cEntity_Base.IsPermanent && !IsOption)
  76. {
  77. if (!CanPlayJogress(true))
  78. {
  79. if (!CanPutFieldThisPermanentCard(true, null))
  80. {
  81. return false;
  82. }
  83. }
  84. }
  85. else if (IsOption)
  86. {
  87. if (CanNotPlayThisOption)
  88. {
  89. return false;
  90. }
  91. #region whether cost can be paid
  92. List<int> costs = new List<int>() { this.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: true) };
  93. bool canPayCost = costs.Some(cost => Owner.MaxMemoryCost >= cost);
  94. if (!canPayCost) return false;
  95. #endregion
  96. }
  97. return true;
  98. }
  99. }
  100. #endregion
  101. #region Whether this option card's effect prevents it from being played
  102. public bool CanNotPlayThisOption
  103. {
  104. get
  105. {
  106. if (!IsOption)
  107. {
  108. return false;
  109. }
  110. #region the effects of players
  111. if (GManager.instance.turnStateMachine.gameContext.Players
  112. .Map(player => player.EffectList(EffectTiming.None))
  113. .Flat()
  114. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  115. && cardEffect.CanUse(null)
  116. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  117. {
  118. return true;
  119. }
  120. #endregion
  121. #region the effects of permanents
  122. if (GManager.instance.turnStateMachine.gameContext.Players
  123. .Map(player => player.GetFieldPermanents())
  124. .Flat()
  125. .Map(permanent => permanent.EffectList(EffectTiming.None))
  126. .Flat()
  127. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  128. && cardEffect.CanUse(null)
  129. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  130. {
  131. return true;
  132. }
  133. #endregion
  134. #region the effects of itself
  135. if (PermanentOfThisCard() == null)
  136. {
  137. if (EffectList(EffectTiming.None)
  138. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  139. && cardEffect.CanUse(null)
  140. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  141. {
  142. return true;
  143. }
  144. }
  145. #endregion
  146. #region Whether the color requirement is met
  147. if (!MatchColorRequirement)
  148. {
  149. return true;
  150. }
  151. #endregion
  152. return false;
  153. }
  154. }
  155. #endregion
  156. #region Whether the color requirement is met
  157. public bool MatchColorRequirement
  158. {
  159. get
  160. {
  161. if (IsOption)
  162. {
  163. #region "ignore color requirement" effects
  164. #region the effects of permanents
  165. if (GManager.instance.turnStateMachine.gameContext.Players
  166. .Map(player => player.GetFieldPermanents())
  167. .Flat()
  168. .Map(permanent => permanent.EffectList(EffectTiming.None))
  169. .Flat()
  170. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  171. && cardEffect.CanUse(null)
  172. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  173. {
  174. return true;
  175. }
  176. #endregion
  177. #region the effects of players
  178. if (GManager.instance.turnStateMachine.gameContext.Players
  179. .Map(player => player.EffectList(EffectTiming.None))
  180. .Flat()
  181. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  182. && cardEffect.CanUse(null)
  183. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  184. {
  185. return true;
  186. }
  187. #endregion
  188. #region the effects of itself
  189. if (EffectList(EffectTiming.None)
  190. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  191. && cardEffect.CanUse(null)
  192. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  193. {
  194. return true;
  195. }
  196. #endregion
  197. #endregion
  198. List<CardColor> colorsToCheck = IsDigimon ? DualCardColors : CardColors;
  199. bool matchColorRequirement = colorsToCheck.Every(cardColor =>
  200. Owner.GetFieldPermanents().Some(permanent =>
  201. permanent.TopCard.IsPermanent && permanent.TopCard.CardColors.Contains(cardColor)));
  202. if (!matchColorRequirement)
  203. {
  204. return false;
  205. }
  206. }
  207. return true;
  208. }
  209. }
  210. #endregion
  211. #region Card object in hand displaying this card
  212. public HandCard ShowingHandCard { get; private set; }
  213. public void SetShowingHandCard(HandCard showingHandCard) => ShowingHandCard = showingHandCard;
  214. #endregion
  215. #region Permanent in the field containing this card
  216. public Permanent PermanentOfThisCard()
  217. {
  218. return Owner.GetFieldPermanents().Find(permanent =>
  219. (permanent.cardSources.Contains(this)));
  220. }
  221. #endregion
  222. #region initialize
  223. public void Init()
  224. {
  225. cEntity_EffectController.InitUseCountThisTurn();
  226. SetFace();
  227. }
  228. #endregion
  229. #region base card colors from entity
  230. public List<CardColor> BaseCardColorsFromEntity => _cEntity_Base.cardColors.Distinct().ToList();
  231. public List<CardColor> BaseDualCardColorsFromEntity => _cEntity_Base.OptionCardColorRequirements.Distinct().ToList();
  232. #endregion
  233. #region base card colors
  234. public List<CardColor> BaseCardColors
  235. {
  236. get
  237. {
  238. List<CardColor> baseCardColors = BaseCardColorsFromEntity;
  239. #region the effects that changes base card colors
  240. #region the effects of itself
  241. if (PermanentOfThisCard() == null)
  242. {
  243. EffectList(EffectTiming.None)
  244. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  245. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  246. }
  247. #endregion
  248. #region the effects of permanents
  249. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  250. .Map(player => player.GetFieldPermanents())
  251. .Flat()
  252. .Map(permanent => permanent.EffectList(EffectTiming.None))
  253. .Flat()
  254. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  255. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  256. #endregion
  257. #endregion
  258. baseCardColors = baseCardColors.Distinct().ToList();
  259. return baseCardColors;
  260. }
  261. }
  262. public List<CardColor> BaseDualCardColors
  263. {
  264. get
  265. {
  266. List<CardColor> baseCardColors = BaseDualCardColorsFromEntity;
  267. #region the effects that changes base card colors
  268. #region the effects of itself
  269. if (PermanentOfThisCard() == null)
  270. {
  271. EffectList(EffectTiming.None)
  272. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  273. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  274. }
  275. #endregion
  276. #region the effects of permanents
  277. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  278. .Map(player => player.GetFieldPermanents())
  279. .Flat()
  280. .Map(permanent => permanent.EffectList(EffectTiming.None))
  281. .Flat()
  282. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  283. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  284. #endregion
  285. #endregion
  286. baseCardColors = baseCardColors.Distinct().ToList();
  287. return baseCardColors;
  288. }
  289. }
  290. #endregion
  291. #region card colors
  292. public List<CardColor> CardColors
  293. {
  294. get
  295. {
  296. List<CardColor> cardColors = BaseCardColors;
  297. #region the effects that changes card colors
  298. #region the effects of itself
  299. if (PermanentOfThisCard() == null)
  300. {
  301. EffectList(EffectTiming.None)
  302. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  303. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  304. }
  305. #endregion
  306. #region the effects of permanents
  307. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  308. .Map(player => player.GetFieldPermanents())
  309. .Flat()
  310. .Map(permanent => permanent.EffectList(EffectTiming.None))
  311. .Flat()
  312. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  313. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  314. #endregion
  315. #endregion
  316. cardColors = cardColors.Distinct().ToList();
  317. return cardColors;
  318. }
  319. }
  320. public List<CardColor> DualCardColors
  321. {
  322. get
  323. {
  324. List<CardColor> cardColors = BaseDualCardColors;
  325. #region the effects that changes card colors
  326. #region the effects of itself
  327. if (PermanentOfThisCard() == null)
  328. {
  329. EffectList(EffectTiming.None)
  330. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  331. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  332. }
  333. #endregion
  334. #region the effects of permanents
  335. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  336. .Map(player => player.GetFieldPermanents())
  337. .Flat()
  338. .Map(permanent => permanent.EffectList(EffectTiming.None))
  339. .Flat()
  340. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  341. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  342. #endregion
  343. #endregion
  344. cardColors = cardColors.Distinct().ToList();
  345. return cardColors;
  346. }
  347. }
  348. #endregion
  349. #region evoCosts from entity
  350. public List<EvoCost> BaseEvoCostsFromEntity => _cEntity_Base.EvoCosts;
  351. #endregion
  352. #region evoCosts
  353. public List<Func<Permanent, int>> EvoCosts(CardEffectCommons.IgnoreRequirement ignore, bool checkAvailability)
  354. {
  355. List<Func<Permanent, int>> EvoCosts = new List<Func<Permanent, int>>();
  356. #region the effects that add evoCosts
  357. #region the effects of players
  358. EvoCosts = EvoCosts
  359. .Concat(
  360. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  361. .Map(player => player.EffectList(EffectTiming.None))
  362. .Flat()
  363. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  364. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  365. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, ignore, checkAvailability)))
  366. .ToList();
  367. #endregion
  368. #region the effects of permanents
  369. EvoCosts = EvoCosts
  370. .Concat(
  371. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  372. .Map(player => player.GetFieldPermanents())
  373. .Flat()
  374. .Map(permanent => permanent.EffectList(EffectTiming.None))
  375. .Flat()
  376. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  377. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  378. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, ignore, checkAvailability)))
  379. .ToList();
  380. #endregion
  381. #region the effects of itself
  382. if (PermanentOfThisCard() == null || PermanentOfThisCard().DigivolutionCards.Contains(this))
  383. {
  384. EvoCosts = EvoCosts
  385. .Concat(
  386. EffectList(EffectTiming.None)
  387. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  388. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  389. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, ignore, checkAvailability)))
  390. .ToList();
  391. }
  392. #endregion
  393. #endregion
  394. EvoCosts = EvoCosts
  395. .Concat(
  396. BaseEvoCostsFromEntity
  397. .Map<EvoCost, Func<Permanent, int>>(evoCost =>
  398. (targetPermanent) =>
  399. {
  400. if (ignore.Equals(CardEffectCommons.IgnoreRequirement.All) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  401. return evoCost.MemoryCost;
  402. if ((ignore.Equals(CardEffectCommons.IgnoreRequirement.Color) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  403. || targetPermanent.TopCard.CardColors.Contains(evoCost.CardColor))
  404. {
  405. if ((ignore.Equals(CardEffectCommons.IgnoreRequirement.Level) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  406. || targetPermanent.Level == evoCost.Level)
  407. {
  408. return evoCost.MemoryCost;
  409. }
  410. }
  411. return -1;
  412. }))
  413. .ToList();
  414. return EvoCosts;
  415. }
  416. #endregion
  417. #region evo cost list
  418. public List<int> CostList(Permanent targetPermanent, bool ignoreLevel, bool checkAvailability)
  419. {
  420. CardEffectCommons.IgnoreRequirement ignore = CardEffectCommons.IgnoreRequirement.None;
  421. if (ignoreLevel)
  422. ignore = CardEffectCommons.IgnoreRequirement.Level;
  423. return EvoCosts(ignore, checkAvailability)
  424. .Filter(evoCost => evoCost(targetPermanent) >= 0)
  425. .Map(evoCost => evoCost(targetPermanent));
  426. }
  427. #endregion
  428. #region cost list
  429. #region cost to pay
  430. public int PayingCost(SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false, bool ignoreLevel = false, int FixedCost = -1)
  431. {
  432. int baseCost = _cEntity_Base.PlayCost;
  433. if (targetPermanents != null)
  434. {
  435. if (targetPermanents.Count == 1)
  436. {
  437. Permanent targetPermanent = targetPermanents[0];
  438. if (targetPermanent != null)
  439. {
  440. List<int> costList = CostList(targetPermanent, ignoreLevel: ignoreLevel, checkAvailability: checkAvailability);
  441. if (costList.Count >= 1)
  442. {
  443. baseCost = costList.Min();
  444. }
  445. }
  446. }
  447. }
  448. return GetPayingCostWithBaseCost(baseCost, root, targetPermanents, checkAvailability: checkAvailability, FixedCost: FixedCost);
  449. }
  450. #endregion
  451. #region cost that will be paid taking into account baseCost
  452. public int GetPayingCostWithBaseCost(int baseCost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false, int FixedCost = -1)
  453. {
  454. int Cost = FixedCost >= 0 ? FixedCost : baseCost;
  455. bool isEvolution = targetPermanents != null && targetPermanents.Some((permanent) => permanent != null);
  456. #region DigiXros
  457. if (!isEvolution)
  458. {
  459. if (HasDigiXros)
  460. {
  461. if (Owner.CanReduceCost(null, this))
  462. {
  463. //AI
  464. if (!(!Owner.isYou && GManager.instance.IsAI))
  465. {
  466. if (checkAvailability)
  467. {
  468. return 0;
  469. }
  470. }
  471. if (!checkAvailability)
  472. {
  473. SelectDigiXrosClass selectDigiXrosClass = GManager.instance.GetComponent<SelectDigiXrosClass>();
  474. if (selectDigiXrosClass != null)
  475. {
  476. if (selectDigiXrosClass.playCard == this)
  477. {
  478. Cost -= selectDigiXrosClass.selectedDigicrossCards.Count * digiXrosCondition.reduceCostPerCard;
  479. }
  480. }
  481. }
  482. }
  483. }
  484. }
  485. #endregion
  486. #region Assembly
  487. if (!isEvolution)
  488. {
  489. if (HasAssembly)
  490. {
  491. if (Owner.CanReduceCost(null, this))
  492. {
  493. //AI
  494. if (!(!Owner.isYou && GManager.instance.IsAI))
  495. {
  496. if (checkAvailability)
  497. {
  498. return 0;
  499. }
  500. }
  501. if (!checkAvailability)
  502. {
  503. SelectAssemblyClass selectAssemblyClass = GManager.instance.GetComponent<SelectAssemblyClass>();
  504. if (selectAssemblyClass != null)
  505. {
  506. if (selectAssemblyClass.playCard == this)
  507. {
  508. if (selectAssemblyClass.selectedAssemblyCards.Count == assemblyCondition.elementCount)
  509. Cost -= assemblyCondition.reduceCost;
  510. }
  511. }
  512. }
  513. }
  514. }
  515. }
  516. #endregion
  517. Cost = GetChangedCostItselef(Cost, root, targetPermanents, checkAvailability);
  518. Cost = GetChangedPayingCost(Cost, root, targetPermanents, checkAvailability);
  519. if (Cost < 0)
  520. {
  521. Cost = 0;
  522. }
  523. return Cost;
  524. }
  525. #endregion
  526. #region base play cost from entity
  527. public int BasePlayCostFromEntity
  528. {
  529. get
  530. {
  531. return _cEntity_Base.PlayCost;
  532. }
  533. }
  534. #endregion
  535. #region get card cost of itself (refered by card effects)
  536. public int GetCostItself => Math.Max(0, GetChangedCostItselef(BasePlayCostFromEntity, SelectCardEffect.Root.None, new List<Permanent>() { PermanentOfThisCard() }));
  537. #endregion
  538. #region get card cost of itself taking into account card effects
  539. public int GetChangedCostItselef(int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false)
  540. {
  541. if (checkAvailability)
  542. {
  543. if (GManager.instance.IsAI)
  544. {
  545. if (targetPermanents != null)
  546. {
  547. if (targetPermanents.Some(permanent => permanent != null && permanent.TopCard != null && !permanent.TopCard.Owner.isYou))
  548. {
  549. return Math.Max(0, Cost);
  550. }
  551. }
  552. }
  553. }
  554. #region card effects that changes card cost
  555. List<ICardEffect> changeCostCardEffects = new List<ICardEffect>();
  556. #region the effects of permanents
  557. changeCostCardEffects = changeCostCardEffects
  558. .Concat(
  559. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  560. .Map(player => player.GetFieldPermanents())
  561. .Flat()
  562. .Map(permanent => permanent.EffectList(EffectTiming.None))
  563. .Flat()
  564. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  565. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  566. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  567. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  568. .ToList();
  569. #endregion
  570. #region the effects of players
  571. changeCostCardEffects = changeCostCardEffects
  572. .Concat(
  573. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  574. .Map(player => player.EffectList(EffectTiming.None))
  575. .Flat()
  576. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  577. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  578. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  579. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  580. .ToList();
  581. #endregion
  582. #region the effects of itself
  583. if (PermanentOfThisCard() == null)
  584. {
  585. changeCostCardEffects = changeCostCardEffects
  586. .Concat(
  587. EffectList(EffectTiming.None)
  588. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  589. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  590. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  591. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  592. .ToList();
  593. }
  594. #endregion
  595. List<ICardEffect> changeCostCardEffects_NotIsUpDown = changeCostCardEffects
  596. .Filter(cardEffect => !((IChangeCostEffect)cardEffect).IsUpDown());
  597. List<ICardEffect> changeCostCardEffects_IsUpDown = changeCostCardEffects
  598. .Filter(cardEffect => ((IChangeCostEffect)cardEffect).IsUpDown());
  599. changeCostCardEffects_NotIsUpDown
  600. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  601. changeCostCardEffects_IsUpDown
  602. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  603. #endregion
  604. return Math.Max(0, Cost);
  605. }
  606. #endregion
  607. #region get card cost to pay of itself taking into account card effects
  608. public int GetChangedPayingCost(int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false)
  609. {
  610. #region card effects that changes card cost to pay
  611. List<ICardEffect> changePayingCostCardEffects = new List<ICardEffect>();
  612. #region the effects of permanents
  613. changePayingCostCardEffects = changePayingCostCardEffects
  614. .Concat(
  615. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  616. .Map(player => player.GetFieldPermanents())
  617. .Flat()
  618. .Map(permanent => permanent.EffectList(EffectTiming.None))
  619. .Flat()
  620. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  621. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  622. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  623. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  624. .ToList();
  625. #endregion
  626. #region the effects of players
  627. changePayingCostCardEffects = changePayingCostCardEffects
  628. .Concat(
  629. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  630. .Map(player => player.EffectList(EffectTiming.None))
  631. .Flat()
  632. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  633. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  634. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  635. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  636. .ToList();
  637. #endregion
  638. #region the effects of itself
  639. if (PermanentOfThisCard() == null)
  640. {
  641. changePayingCostCardEffects = changePayingCostCardEffects
  642. .Concat(
  643. EffectList(EffectTiming.None)
  644. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  645. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  646. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  647. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  648. .ToList();
  649. }
  650. #endregion
  651. List<ICardEffect> changePayingCostCardEffects_NotIsUpDown = changePayingCostCardEffects
  652. .Filter(cardEffect => !((IChangeCostEffect)cardEffect).IsUpDown());
  653. List<ICardEffect> changePayingCostCardEffects_IsUpDown = changePayingCostCardEffects
  654. .Filter(cardEffect => ((IChangeCostEffect)cardEffect).IsUpDown());
  655. changePayingCostCardEffects_NotIsUpDown
  656. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  657. changePayingCostCardEffects_IsUpDown
  658. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  659. #endregion
  660. return Math.Max(0, Cost);
  661. }
  662. #endregion
  663. #endregion
  664. #region level
  665. public int Level => TreatedLevel;
  666. #endregion
  667. #region Level
  668. public int TreatedLevel
  669. {
  670. get
  671. {
  672. int treatedLevel = 0;
  673. treatedLevel = _cEntity_Base.Level;
  674. if (!HasLevel)
  675. treatedLevel = 1145140;
  676. #region Check Card Change Level Effects
  677. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  678. {
  679. if (cardEffect is IChangeCardLevelEffect)
  680. {
  681. if (cardEffect.CanUse(null))
  682. {
  683. treatedLevel = ((IChangeCardLevelEffect)cardEffect).GetCardLevel(treatedLevel, this);
  684. }
  685. }
  686. }
  687. #endregion
  688. return treatedLevel;
  689. }
  690. }
  691. #endregion
  692. #region effect list
  693. public List<ICardEffect> EffectList(EffectTiming timing)
  694. {
  695. return EffectList_ForCard(timing, this);
  696. }
  697. #endregion
  698. #region effect list for 1 card
  699. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource cardSource)
  700. {
  701. List<ICardEffect> _EffectList = cEntity_EffectController
  702. .GetCardEffects(timing, cardSource)
  703. .Filter(cardEffect => cardEffect != null);
  704. foreach (ICardEffect cardEffect in _EffectList)
  705. {
  706. if (cardEffect.EffectSourceCard == null)
  707. {
  708. cardEffect.SetEffectSourceCard(this);
  709. }
  710. }
  711. return _EffectList;
  712. }
  713. #endregion
  714. #region effect list except added effects
  715. public List<ICardEffect> EffectList_ExceptAddedEffects(EffectTiming timing)
  716. {
  717. return EffectList_ForCard_ExceptAddedEffects(timing, this);
  718. }
  719. #endregion
  720. #region effect list for 1 card
  721. public List<ICardEffect> EffectList_ForCard_ExceptAddedEffects(EffectTiming timing, CardSource cardSource)
  722. {
  723. List<ICardEffect> _EffectList = cEntity_EffectController
  724. .GetCardEffects_ExceptAddedEffects(timing, cardSource)
  725. .Filter(cardEffect => cardEffect != null);
  726. foreach (ICardEffect cardEffect in _EffectList)
  727. {
  728. if (cardEffect.EffectSourceCard == null)
  729. {
  730. cardEffect.SetEffectSourceCard(this);
  731. }
  732. }
  733. return _EffectList;
  734. }
  735. #endregion
  736. #region whether this card can declare skill
  737. public bool CanDeclareSkill => CanDeclareSkillList.Count > 0;
  738. #endregion
  739. #region effect list that this card can declare
  740. public List<ICardEffect> CanDeclareSkillList
  741. {
  742. get
  743. {
  744. return EffectList(EffectTiming.OnDeclaration)
  745. .Filter(cardEffect => cardEffect is ActivateICardEffect && cardEffect.CanUse(null));
  746. }
  747. }
  748. #endregion
  749. #region whether this card can not be affected by the effect
  750. public bool CanNotBeAffected(ICardEffect _cardEffect)
  751. {
  752. if (_cardEffect == null) return false;
  753. #region the effects of permanents
  754. if (GManager.instance.turnStateMachine.gameContext.Players
  755. .Map(player => player.GetFieldPermanents())
  756. .Flat()
  757. .Map(permanent => permanent.EffectList(EffectTiming.None))
  758. .Flat()
  759. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  760. && cardEffect.CanUse(null)
  761. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  762. {
  763. return true;
  764. }
  765. #endregion
  766. #region the effects of players
  767. if (GManager.instance.turnStateMachine.gameContext.Players
  768. .Map(player => player.EffectList(EffectTiming.None))
  769. .Flat()
  770. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  771. && cardEffect.CanUse(null)
  772. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  773. {
  774. return true;
  775. }
  776. #endregion
  777. #region the effects of itself
  778. if (PermanentOfThisCard() == null)
  779. {
  780. if (EffectList(EffectTiming.None)
  781. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  782. && cardEffect.CanUse(null)
  783. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  784. {
  785. return true;
  786. }
  787. }
  788. #endregion
  789. return false;
  790. }
  791. #endregion
  792. #region whether this card can be played at the frame
  793. public bool CanPlayCardTargetFrame(FieldCardFrame frame, bool PayCost, ICardEffect cardEffect, SelectCardEffect.Root root = SelectCardEffect.Root.Hand, int fixedCost = -1, bool isBreedingArea = false, CardEffectCommons.IgnoreRequirement ignore = CardEffectCommons.IgnoreRequirement.None)
  794. {
  795. bool isBattleAreaFrame = FieldCardFrame.isBattleAreaFrameID(frame.FrameID);
  796. if (isBreedingArea)
  797. {
  798. if (isBattleAreaFrame)
  799. {
  800. return false;
  801. }
  802. }
  803. if (PermanentOfThisCard() != null)
  804. {
  805. if (this == PermanentOfThisCard().TopCard)
  806. {
  807. if (PermanentOfThisCard().HasNoDigivolutionCards)
  808. {
  809. return false;
  810. }
  811. }
  812. }
  813. if (frame.player != Owner)
  814. {
  815. return false;
  816. }
  817. if (PayCost && frame.GetFramePermanent() == null)
  818. {
  819. if (IsOption)
  820. {
  821. return false;
  822. }
  823. int cost = PayingCost(root, new List<Permanent>() { frame.GetFramePermanent() }, checkAvailability: true, FixedCost: fixedCost);
  824. if (Owner.MaxMemoryCost < cost)
  825. {
  826. return false;
  827. }
  828. }
  829. if (frame.GetFramePermanent() != null)
  830. {
  831. if (!CanEvolve(frame.GetFramePermanent(), true, ignore))
  832. {
  833. return false;
  834. }
  835. }
  836. else
  837. {
  838. if (!CanEnterField(cardEffect))
  839. {
  840. return false;
  841. }
  842. }
  843. if (!isBattleAreaFrame && frame.GetFramePermanent() == null && !isBreedingArea)
  844. {
  845. return false;
  846. }
  847. /*if (IsDigiEgg)
  848. {
  849. if (isBattleAreaFrame)
  850. {
  851. return false;
  852. }
  853. }
  854. else
  855. {
  856. if (!isBattleAreaFrame && frame.GetFramePermanent() == null && !isBreedingArea)
  857. {
  858. return false;
  859. }
  860. }*/
  861. return true;
  862. }
  863. #endregion
  864. #region whether there is at least 1 frame where this card can be placed
  865. public bool CanPutFieldThisPermanentCard(bool PayCost, ICardEffect cardEffect, bool isBreedingArea = false)
  866. {
  867. return Owner.fieldCardFrames.Some((frame) => CanPlayCardTargetFrame(frame, PayCost, cardEffect, isBreedingArea: isBreedingArea));
  868. }
  869. #endregion
  870. #region whether this card can be placed on the field by the effect
  871. public bool CanEnterField(ICardEffect _cardEffect)
  872. {
  873. #region the effects of permanents
  874. if (GManager.instance.turnStateMachine.gameContext.Players
  875. .Map(player => player.GetFieldPermanents())
  876. .Flat()
  877. .Map(permanent => permanent.EffectList(EffectTiming.None))
  878. .Flat()
  879. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  880. && cardEffect.CanUse(null)
  881. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  882. {
  883. return false;
  884. }
  885. #endregion
  886. #region the effects of players
  887. if (GManager.instance.turnStateMachine.gameContext.Players
  888. .Map(player => player.EffectList(EffectTiming.None))
  889. .Flat()
  890. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  891. && cardEffect.CanUse(null)
  892. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  893. {
  894. return false;
  895. }
  896. #endregion
  897. #region the effects of itself
  898. if (PermanentOfThisCard() == null)
  899. {
  900. if (EffectList(EffectTiming.None)
  901. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  902. && cardEffect.CanUse(null)
  903. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  904. {
  905. return false;
  906. }
  907. }
  908. #endregion
  909. return true;
  910. }
  911. #endregion
  912. #region whether the permanent can digivolve into this card
  913. public bool CanEvolve(Permanent targetPermanent, bool checkAvailability, CardEffectCommons.IgnoreRequirement ignore = CardEffectCommons.IgnoreRequirement.None)
  914. {
  915. if (targetPermanent != null)
  916. {
  917. if (CanNotEvolve(targetPermanent))
  918. {
  919. return false;
  920. }
  921. if (targetPermanent.TopCard != null)
  922. {
  923. foreach (Func<Permanent, int> EvoCost in EvoCosts(ignore, checkAvailability))
  924. {
  925. if (EvoCost(targetPermanent) >= 0)
  926. {
  927. return true;
  928. }
  929. }
  930. }
  931. }
  932. return false;
  933. }
  934. #endregion
  935. #region whether the permanent's digivolution into this card is prohibited
  936. public bool CanNotEvolve(Permanent targetPermanent)
  937. {
  938. if (targetPermanent.IsToken)
  939. {
  940. return true;
  941. }
  942. if (IsToken)
  943. {
  944. return true;
  945. }
  946. #region card effects that can't digivolve
  947. #region the effects of permanents
  948. if (GManager.instance.turnStateMachine.gameContext.Players
  949. .Map(player => player.GetFieldPermanents())
  950. .Flat()
  951. .Map(permanent => permanent.EffectList(EffectTiming.None))
  952. .Flat()
  953. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  954. && cardEffect.CanUse(null)
  955. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  956. {
  957. return true;
  958. }
  959. #endregion
  960. #region the effects of players
  961. if (GManager.instance.turnStateMachine.gameContext.Players
  962. .Map(player => player.EffectList(EffectTiming.None))
  963. .Flat()
  964. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  965. && cardEffect.CanUse(null)
  966. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  967. {
  968. return true;
  969. }
  970. #endregion
  971. #region the effects of itself
  972. if (PermanentOfThisCard() == null)
  973. {
  974. if (EffectList(EffectTiming.None)
  975. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  976. && cardEffect.CanUse(null)
  977. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  978. {
  979. return true;
  980. }
  981. }
  982. #endregion
  983. #endregion
  984. return false;
  985. }
  986. #endregion
  987. #region ENG card name from entity
  988. public string BaseENGCardNameFromEntity => _cEntity_Base.CardName_ENG;
  989. #endregion
  990. #region JPN card name from entity
  991. public string BaseJPNCardNameFromEntity => _cEntity_Base.CardName_ENG;
  992. #endregion
  993. #region base card names
  994. public List<string> BaseCardNames
  995. {
  996. get
  997. {
  998. List<string> baseCardNames = new List<string>() { BaseENGCardNameFromEntity };
  999. Permanent thisPermanent = PermanentOfThisCard();
  1000. bool isPermanent = PermanentOfThisCard() != null;
  1001. bool isDigivolutionCard = isPermanent && thisPermanent.DigivolutionCards.Contains(this);
  1002. #region if dual card and not in play
  1003. if (!isPermanent && _cEntity_Base.IsDualCard)
  1004. {
  1005. baseCardNames.Add(_cEntity_Base.dualEffect);
  1006. }
  1007. #endregion
  1008. #region card effects that change base card names
  1009. if (isDigivolutionCard)
  1010. {
  1011. EffectList_ExceptAddedEffects(EffectTiming.None)
  1012. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1013. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1014. }
  1015. else
  1016. {
  1017. #region the effects of itself
  1018. if (PermanentOfThisCard() == null)
  1019. {
  1020. EffectList(EffectTiming.None)
  1021. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1022. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1023. }
  1024. #endregion
  1025. #region the effects of permanents
  1026. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1027. .Map(player => player.GetFieldPermanents())
  1028. .Flat()
  1029. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1030. .Flat()
  1031. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1032. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1033. #endregion
  1034. #region the effects of players
  1035. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1036. .Map(player => player.EffectList(EffectTiming.None))
  1037. .Flat()
  1038. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1039. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1040. #endregion
  1041. }
  1042. #endregion
  1043. return baseCardNames;
  1044. }
  1045. }
  1046. #endregion
  1047. #region card names
  1048. public List<string> CardNames
  1049. {
  1050. get
  1051. {
  1052. List<string> cardNames = BaseCardNames.Clone();
  1053. #region the effects of itself
  1054. EffectList_ExceptAddedEffects(EffectTiming.None)
  1055. .Filter(cardEffect => cardEffect != null)
  1056. .Filter(cardEffect => cardEffect is IChangeCardNamesEffect && cardEffect.CanUse(null))
  1057. .ForEach(cardEffect => cardNames = ((IChangeCardNamesEffect)cardEffect).ChangeCardNames(cardNames, this));
  1058. #endregion
  1059. return cardNames.Distinct().ToList();
  1060. }
  1061. }
  1062. #endregion
  1063. #region Whether target other card's name has same name as this
  1064. public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => EqualsCardName(cardName)) >= 1;
  1065. //public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => CardNames.Contains(cardName)) >= 1;
  1066. #endregion
  1067. #region whether this card has at least 1 card name that equals the string
  1068. /// <summary>
  1069. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1070. /// </summary>
  1071. /// <param name="string">value to check for</param>
  1072. /// <author>Mike Bunch</author>
  1073. public bool EqualsCardName(string name)
  1074. {
  1075. if (string.IsNullOrEmpty(name))
  1076. {
  1077. return false;
  1078. }
  1079. string replaced = name.Replace(" ", "");
  1080. string lower = name.ToLower();
  1081. return CardNames.Some((cardName) =>
  1082. cardName.Equals(name)
  1083. || cardName.Equals(replaced)
  1084. || cardName.Replace(" ", "").Equals(replaced)
  1085. || cardName.Equals(lower)
  1086. || cardName.ToLower().Equals(lower));
  1087. }
  1088. #endregion
  1089. #region whether this card has at least 1 card name that contains the string
  1090. /// <summary>
  1091. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1092. /// </summary>
  1093. /// <param trait="string">value to check for</param>
  1094. /// <author>Mike Bunch</author>
  1095. public bool ContainsCardName(string name)
  1096. {
  1097. if (string.IsNullOrEmpty(name))
  1098. {
  1099. return false;
  1100. }
  1101. string replaced = name.Replace(" ", "");
  1102. string lower = name.ToLower();
  1103. return CardNames.Some((cardName) =>
  1104. cardName.Contains(name)
  1105. || cardName.Contains(replaced)
  1106. || cardName.Contains(lower)
  1107. || cardName.ToLower().Contains(lower));
  1108. }
  1109. #endregion
  1110. #region All colors of a Digimon Card
  1111. public List<CardColor> DigimonCardColors
  1112. {
  1113. get
  1114. {
  1115. if (!IsDigimon)
  1116. {
  1117. return new List<CardColor>();
  1118. }
  1119. return CardColors;
  1120. }
  1121. }
  1122. #endregion
  1123. #region All Colors of an Option Card
  1124. public List<CardColor> OptionCardColors
  1125. {
  1126. get
  1127. {
  1128. if (!IsOption)
  1129. return new List<CardColor>();
  1130. if (IsDigimon) //Dual Card
  1131. {
  1132. return DualCardColors;
  1133. }
  1134. return CardColors;
  1135. }
  1136. }
  1137. #endregion
  1138. #region All colors of a card
  1139. public List<CardColor> AllCardColors
  1140. {
  1141. get
  1142. {
  1143. return CardColors.Concat(DualCardColors).ToList();
  1144. }
  1145. }
  1146. #endregion
  1147. #region whether this card has the mentioned color
  1148. public bool HasCardColor(CardColor cardColor, bool isOptionOnly = false, bool isDigimonOnly = false)
  1149. {
  1150. if (isOptionOnly && isDigimonOnly)
  1151. return false; //Shouldn't be done, just here to cover all bases with consistency
  1152. if (isOptionOnly)
  1153. {
  1154. return OptionCardColors.Contains(cardColor);
  1155. }
  1156. else if (isDigimonOnly)
  1157. {
  1158. return DigimonCardColors.Contains(cardColor);
  1159. }
  1160. return AllCardColors.Contains(cardColor); //check entire card
  1161. }
  1162. public bool HasDigimonColor(CardColor cardColor)
  1163. {
  1164. if (!IsDigimon)
  1165. return false;
  1166. return HasCardColor(cardColor, isDigimonOnly: true);
  1167. }
  1168. public bool HasOptionColor(CardColor cardColor)
  1169. {
  1170. if (!IsOption)
  1171. return false;
  1172. return HasCardColor(cardColor, isOptionOnly: true);
  1173. }
  1174. #endregion
  1175. #region whether this card has at least 1 card name that contains "Greymon"
  1176. public bool HasGreymonName
  1177. {
  1178. get
  1179. {
  1180. if (CardNames.Some((cardName) => (cardName.Contains("Greymon") || cardName.Contains("greymon"))
  1181. && cardName != "DoruGreymon"
  1182. && cardName != "BurningGreymon"
  1183. && cardName != "DexDoruGreymon"))
  1184. {
  1185. return true;
  1186. }
  1187. return false;
  1188. }
  1189. }
  1190. #endregion
  1191. #region whether this card has at least 1 card name that contains "Garurumon"
  1192. public bool HasGarurumonName
  1193. {
  1194. get
  1195. {
  1196. if (CardNames.Some((cardName) => (cardName.Contains("Garurumon") || cardName.Contains("garurumon"))
  1197. && cardName != "KendoGarurumon"))
  1198. {
  1199. return true;
  1200. }
  1201. return false;
  1202. }
  1203. }
  1204. #endregion
  1205. #region whether this card has at least 1 card name that contains "Impmon"
  1206. public bool HasImpmonName
  1207. {
  1208. get
  1209. {
  1210. if (CardNames.Some((cardName) => (cardName.Contains("Impmon") || cardName.Contains("impmon"))
  1211. && cardName != "Blimpmon"))
  1212. {
  1213. return true;
  1214. }
  1215. return false;
  1216. }
  1217. }
  1218. #endregion
  1219. #region whether this card has at least 1 card name that contains "Dramon"
  1220. public bool HasDramonName
  1221. {
  1222. get
  1223. {
  1224. if (CardNames.Some((cardName) => (cardName.Contains("Dramon") || cardName.Contains("dramon"))
  1225. && cardName != "Indramon"))
  1226. {
  1227. return true;
  1228. }
  1229. return false;
  1230. }
  1231. }
  1232. #endregion
  1233. #region whether this card has at least 1 card name that contains "AAntibody"
  1234. public bool HasXAntiBodyName => CardNames.Some(DataBase.IsContainingXAntibodyString);
  1235. #endregion
  1236. #region whether this card has at least 1 trait that equals the string
  1237. /// <summary>
  1238. /// Used to check if specified trait is exactly in cards trait values ("Sky Dragon" is not "Dragon")
  1239. /// </summary>
  1240. /// <param trait="string">value to check for</param>
  1241. /// <author>Mike Bunch</author>
  1242. public bool EqualsTraits(string trait)
  1243. {
  1244. if (string.IsNullOrEmpty(trait))
  1245. return false;
  1246. string replaced = trait.Replace(" ", "").ToLower();
  1247. return CardTraits.Some(cardTrait => cardTrait.Equals(trait) || cardTrait.ToLower().Equals(replaced));
  1248. }
  1249. #endregion
  1250. #region whether this card has at least 1 trait that contains the string
  1251. /// <summary>
  1252. /// Used to check if specified trait is within cards trait values ("Sky Dragon" contains "Dragon")
  1253. /// </summary>
  1254. /// <param trait="string">value to check for</param>
  1255. /// <author>Mike Bunch</author>
  1256. public bool ContainsTraits(string trait)
  1257. {
  1258. if (string.IsNullOrEmpty(trait))
  1259. return false;
  1260. string replaced = trait.Replace(" ", "").ToLower();
  1261. return CardTraits.Some(cardTrait => cardTrait.Contains(trait) || cardTrait.ToLower().Contains(replaced));
  1262. }
  1263. #endregion
  1264. #region whether this card has at least 1 trait that contains "Bird"
  1265. public bool HasBirdTraits
  1266. {
  1267. get
  1268. {
  1269. if (ContainsTraits("Avian"))
  1270. {
  1271. return true;
  1272. }
  1273. if (ContainsTraits("Bird"))
  1274. {
  1275. return true;
  1276. }
  1277. return false;
  1278. }
  1279. }
  1280. #endregion
  1281. #region whether this card has at least 1 trait that contains "Beast"
  1282. public bool HasBeastTraits
  1283. {
  1284. get
  1285. {
  1286. if (ContainsTraits("Beast"))
  1287. {
  1288. return true;
  1289. }
  1290. if (ContainsTraits("Animal") && !ContainsTraits("Sea"))
  1291. {
  1292. return true;
  1293. }
  1294. if (ContainsTraits("Sovereign"))
  1295. {
  1296. return true;
  1297. }
  1298. return false;
  1299. }
  1300. }
  1301. #endregion
  1302. #region whether this card has at least 1 trait that contains "Plant"
  1303. public bool HasPlantTraits
  1304. {
  1305. get
  1306. {
  1307. if (ContainsTraits("Vegetation"))
  1308. {
  1309. return true;
  1310. }
  1311. if (ContainsTraits("Plant"))
  1312. {
  1313. return true;
  1314. }
  1315. return false;
  1316. }
  1317. }
  1318. #endregion
  1319. #region whether this card has at least 1 trait that contains "Fairy"
  1320. public bool HasFairyTraits
  1321. {
  1322. get
  1323. {
  1324. if (ContainsTraits("Fairy"))
  1325. {
  1326. return true;
  1327. }
  1328. return false;
  1329. }
  1330. }
  1331. #endregion
  1332. #region whether this card has at least 1 trait that contains "Dragon"
  1333. public bool HasDragonTraits
  1334. {
  1335. get
  1336. {
  1337. if (ContainsTraits("Dragon"))
  1338. {
  1339. return true;
  1340. }
  1341. if (ContainsTraits("saur"))
  1342. {
  1343. return true;
  1344. }
  1345. if (ContainsTraits("Ceratopsian"))
  1346. {
  1347. return true;
  1348. }
  1349. return false;
  1350. }
  1351. }
  1352. #endregion
  1353. #region whether this card has at least 1 trait that contains "Aqua"
  1354. public bool HasAquaTraits
  1355. {
  1356. get
  1357. {
  1358. if (ContainsTraits("Aqua"))
  1359. {
  1360. return true;
  1361. }
  1362. if (ContainsTraits("Sea Animal"))
  1363. {
  1364. return true;
  1365. }
  1366. if (ContainsTraits("SeaAnimal"))
  1367. {
  1368. return true;
  1369. }
  1370. return false;
  1371. }
  1372. }
  1373. #endregion
  1374. #region whether this card has at least 1 trait that contains "Angel"
  1375. public bool HasAngelTraits
  1376. {
  1377. get
  1378. {
  1379. if (CardTraits.Count((trait) => (trait.Contains("Angel") || trait.Contains("angel")) && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1380. {
  1381. return true;
  1382. }
  1383. if (ContainsTraits("Cherub"))
  1384. {
  1385. return true;
  1386. }
  1387. if (ContainsTraits("Throne"))
  1388. {
  1389. return true;
  1390. }
  1391. if (ContainsTraits("Authority"))
  1392. {
  1393. return true;
  1394. }
  1395. if (ContainsTraits("Seraph"))
  1396. {
  1397. return true;
  1398. }
  1399. if (ContainsTraits("Virtue"))
  1400. {
  1401. return true;
  1402. }
  1403. return false;
  1404. }
  1405. }
  1406. #endregion
  1407. #region whether this card has 1 of the "Angel", "Archangel" or "Three Great Angels" trait
  1408. public bool HasAngelTraitRestrictive
  1409. {
  1410. get
  1411. {
  1412. if (ContainsTraits("Three Great Angels") || ContainsTraits("ThreeGreatAngels"))
  1413. {
  1414. return true;
  1415. }
  1416. if (ContainsTraits("Archangel"))
  1417. {
  1418. return true;
  1419. }
  1420. if (CardTraits.Count(trait =>
  1421. (trait.Contains("Angel") || trait.Contains("angel"))
  1422. && trait != "Archangel"
  1423. && trait != "Fallen Angel" && trait != "FallenAngel"
  1424. && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1425. {
  1426. return true;
  1427. }
  1428. return false;
  1429. }
  1430. }
  1431. #endregion
  1432. #region whether this card has at least 1 trait that contains "Avian", "Bird", "Beast", "Animal", "Sovereign", other than "Sea Animal"
  1433. public bool HasAvianBeastAnimalTraits
  1434. {
  1435. get
  1436. {
  1437. if (ContainsTraits("Avian"))
  1438. return true;
  1439. if (ContainsTraits("Bird"))
  1440. return true;
  1441. if (ContainsTraits("Beast"))
  1442. return true;
  1443. if (ContainsTraits("Animal") && !ContainsTraits("Sea Animal"))
  1444. return true;
  1445. if (ContainsTraits("Sovereign"))
  1446. return true;
  1447. return false;
  1448. }
  1449. }
  1450. #endregion
  1451. #region whether this card has at least 1 trait that contains "Hybrid", "Ten Warriors"
  1452. public bool HasHybridTenWarriorsTraits
  1453. {
  1454. get
  1455. {
  1456. if (ContainsTraits("Hybrid"))
  1457. return true;
  1458. if (ContainsTraits("Ten Warriors"))
  1459. return true;
  1460. return false;
  1461. }
  1462. }
  1463. #endregion
  1464. #region whether this card has "XAntibody" trait
  1465. public bool HasXAntibodyTraits => CardTraits.Some(DataBase.IsXAntibodyString);
  1466. #endregion
  1467. #region whether this card has "Royal Knight" trait
  1468. public bool HasRoyalKnightTraits
  1469. {
  1470. get
  1471. {
  1472. return EqualsTraits("Royal Knight");
  1473. }
  1474. }
  1475. #endregion
  1476. #region whether this card has "SoC" trait
  1477. public bool HasSocTraits
  1478. {
  1479. get
  1480. {
  1481. if (CardTraits.Contains("SoC"))
  1482. {
  1483. return true;
  1484. }
  1485. return false;
  1486. }
  1487. }
  1488. #endregion
  1489. #region whether this card has "D-Brigade"/"DigiPolice trait
  1490. public bool HasDBrigadeorDigiPoliceTraits
  1491. {
  1492. get
  1493. {
  1494. if (CardTraits.Contains("D-Brigade"))
  1495. {
  1496. return true;
  1497. }
  1498. if (CardTraits.Contains("DigiPolice"))
  1499. {
  1500. return true;
  1501. }
  1502. return false;
  1503. }
  1504. }
  1505. #endregion
  1506. #region whether this card has at least 1 trait that contains "Beast Dragon"
  1507. public bool HasBeastDragonTraits
  1508. {
  1509. get
  1510. {
  1511. if (ContainsTraits("BeastDragon"))
  1512. {
  1513. return true;
  1514. }
  1515. if (ContainsTraits("Beast Dragon"))
  1516. {
  1517. return true;
  1518. }
  1519. return false;
  1520. }
  1521. }
  1522. #endregion
  1523. #region whether this card has at least 1 trait that contains "DigiPolice"
  1524. public bool HasDigiPoliceTraits
  1525. {
  1526. get
  1527. {
  1528. if (ContainsTraits("DigiPolice"))
  1529. {
  1530. return true;
  1531. }
  1532. return false;
  1533. }
  1534. }
  1535. #endregion
  1536. #region whether this card has at least 1 trait that contains "Light Fang" or "Night Claw"
  1537. public bool HasLightFangNightClawTraits => ContainsTraits("Light Fang") || ContainsTraits("Night Claw");
  1538. #endregion
  1539. #region whether this card has at least 1 trait that contains "Light Fang/Night Claw"
  1540. public bool HasLightFangOrNightClawTraits
  1541. {
  1542. get
  1543. {
  1544. if (ContainsTraits("Light Fang"))
  1545. {
  1546. return true;
  1547. }
  1548. if (ContainsTraits("Night Claw"))
  1549. {
  1550. return true;
  1551. }
  1552. return false;
  1553. }
  1554. }
  1555. #endregion
  1556. #region [Onmyōjutsu] or [Plug-In] trait
  1557. public bool HasOnmyoOrPluginTraits
  1558. {
  1559. get
  1560. {
  1561. if (EqualsTraits("Plug-In"))
  1562. {
  1563. return true;
  1564. }
  1565. if (EqualsTraits("Onmyōjutsu"))
  1566. {
  1567. return true;
  1568. }
  1569. return false;
  1570. }
  1571. }
  1572. #endregion
  1573. #region whether this card has the string in text
  1574. public bool HasText(string text)
  1575. {
  1576. if (String.IsNullOrEmpty(text)) return false;
  1577. text = DataBase.ReplaceToASCII(text);
  1578. string replaced = text.Replace(" ", "");
  1579. string lower = text.ToLower();
  1580. List<string> checkStrings = new List<string>()
  1581. {
  1582. DataBase.ReplaceToASCII(_cEntity_Base.CardName_ENG),
  1583. DataBase.ReplaceToASCII(_cEntity_Base.dualEffect),
  1584. DataBase.ReplaceToASCII(_cEntity_Base.EffectDiscription_ENG),
  1585. DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG),
  1586. DataBase.ReplaceToASCII(_cEntity_Base.SecurityEffectDiscription_ENG),
  1587. DataBase.ReplaceToASCII(_cEntity_Base.OptionEffect),
  1588. };
  1589. foreach (string attribute in _cEntity_Base.Attribute_ENG)
  1590. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1591. foreach (string attribute in _cEntity_Base.Type_ENG)
  1592. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1593. if (jogressCondition.Count > 0)
  1594. {
  1595. foreach (JogressCondition jogress in jogressCondition)
  1596. {
  1597. foreach (JogressConditionElement element in jogress.elements)
  1598. checkStrings.Add(element.SelectMessage);
  1599. }
  1600. }
  1601. foreach (string checkString in checkStrings)
  1602. {
  1603. if (!string.IsNullOrEmpty(checkString))
  1604. {
  1605. if (checkString.Contains(text))
  1606. {
  1607. return true;
  1608. }
  1609. if (checkString.Contains(replaced))
  1610. {
  1611. return true;
  1612. }
  1613. if (checkString.Contains(lower))
  1614. {
  1615. return true;
  1616. }
  1617. }
  1618. }
  1619. return false;
  1620. }
  1621. #endregion
  1622. #region whether this card has <Save> in text
  1623. public bool HasSaveText => HasText("<Save>");
  1624. #endregion
  1625. #region whether this card has "Pulsemon" in text
  1626. public bool HasPulsemonText => HasText("Pulsemon");
  1627. #endregion
  1628. #region card names checked when digixros
  1629. public List<string> CardNames_DigiXros
  1630. {
  1631. get
  1632. {
  1633. List<string> cardNames_DigiXros = CardNames.Clone();
  1634. #region the effects of itself
  1635. EffectList(EffectTiming.None)
  1636. .Filter(cardEffect => cardEffect is IChangeCardNamesForDigiXrosEffect && cardEffect.CanUse(null))
  1637. .ForEach(cardEffect => cardNames_DigiXros = ((IChangeCardNamesForDigiXrosEffect)cardEffect).ChangeCardNamesForDigiXros(cardNames_DigiXros, this));
  1638. #endregion
  1639. return cardNames_DigiXros;
  1640. }
  1641. }
  1642. #endregion
  1643. #region card level checked when Assembly
  1644. public List<int> Level_Assembly
  1645. {
  1646. get
  1647. {
  1648. List<int> cardLevel_Assembly = new List<int>();
  1649. cardLevel_Assembly.Add(TreatedLevel);
  1650. #region the effects of itself
  1651. EffectList(EffectTiming.None)
  1652. .Filter(cardEffect => cardEffect is IChangeCardLevelForAssemblyEffect && cardEffect.CanUse(null))
  1653. .ForEach(cardEffect => cardLevel_Assembly = ((IChangeCardLevelForAssemblyEffect)cardEffect).ChangeCardLevelForAssembly(cardLevel_Assembly, this));
  1654. #endregion
  1655. return cardLevel_Assembly;
  1656. }
  1657. }
  1658. #endregion
  1659. #region whether this card has at least 1 card name checked when digixros that equals the string
  1660. /// <summary>
  1661. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1662. /// </summary>
  1663. /// <param name="string">value to check for</param>
  1664. /// <author>Mike Bunch</author>
  1665. public bool EqualsCardNameDigiXros(string name)
  1666. {
  1667. if (string.IsNullOrEmpty(name))
  1668. {
  1669. return false;
  1670. }
  1671. string replaced = name.Replace(" ", "");
  1672. string lower = name.ToLower();
  1673. return CardNames_DigiXros.Some((cardName) =>
  1674. cardName.Equals(name)
  1675. || cardName.Equals(replaced)
  1676. || cardName.Equals(lower)
  1677. || cardName.ToLower().Equals(lower));
  1678. }
  1679. #endregion
  1680. #region whether this card has at least 1 card name that contains the string
  1681. /// <summary>
  1682. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1683. /// </summary>
  1684. /// <param trait="string">value to check for</param>
  1685. /// <author>Mike Bunch</author>
  1686. public bool ContainsCardNameDigiXros(string name)
  1687. {
  1688. if (string.IsNullOrEmpty(name))
  1689. {
  1690. return false;
  1691. }
  1692. string replaced = name.Replace(" ", "");
  1693. string lower = name.ToLower();
  1694. return CardNames_DigiXros.Some((cardName) =>
  1695. cardName.Contains(name)
  1696. || cardName.Contains(replaced)
  1697. || cardName.Contains(lower)
  1698. || cardName.ToLower().Contains(lower));
  1699. }
  1700. #endregion
  1701. #region preferered frame to play
  1702. public FieldCardFrame PreferredFrame()
  1703. {
  1704. FieldCardFrame PreferredFrame = Owner.fieldCardFrames[0];
  1705. List<FieldCardFrame> fieldCardFrames =
  1706. Owner.fieldCardFrames
  1707. .Filter(fieldCardFrame => fieldCardFrame.IsBattleAreaFrame()
  1708. && fieldCardFrame.IsEmptyFrame());
  1709. if (_cEntity_Base != null)
  1710. {
  1711. if (IsDigimon || IsDigiEgg)
  1712. {
  1713. if (Owner.isYou)
  1714. {
  1715. fieldCardFrames = fieldCardFrames
  1716. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1717. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1718. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1719. .ToList();
  1720. }
  1721. else
  1722. {
  1723. fieldCardFrames = fieldCardFrames
  1724. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1725. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1726. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1727. .ToList();
  1728. int[] correctOrder = new int[] { 4, 3, 5, 2, 6, 1, 7, 0, 8, 11, 10, 12, 9, 13, 14, 15, };
  1729. List<FieldCardFrame> correctOrderFrames = new List<FieldCardFrame>();
  1730. for (int i = 0; i < correctOrder.Length; i++)
  1731. {
  1732. foreach (FieldCardFrame frame in fieldCardFrames)
  1733. {
  1734. if (frame.FrameID == correctOrder[i])
  1735. {
  1736. correctOrderFrames.Add(frame);
  1737. }
  1738. }
  1739. }
  1740. fieldCardFrames = correctOrderFrames;
  1741. }
  1742. }
  1743. else if (IsTamer || IsOption)
  1744. {
  1745. if (Owner.isYou)
  1746. {
  1747. fieldCardFrames = fieldCardFrames
  1748. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1749. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1750. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1751. .ToList();
  1752. }
  1753. else
  1754. {
  1755. fieldCardFrames = fieldCardFrames
  1756. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1757. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1758. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1759. .ToList();
  1760. }
  1761. }
  1762. if (fieldCardFrames.Count >= 1)
  1763. {
  1764. PreferredFrame = fieldCardFrames[0];
  1765. }
  1766. }
  1767. return PreferredFrame;
  1768. }
  1769. #endregion
  1770. #region Whether this card has DP
  1771. public bool HasDP => IsDigimon || _cEntity_Base.DP > 0 || BaseDP > 0;
  1772. #endregion
  1773. #region base card DP
  1774. public int BaseCardDP => _cEntity_Base.DP;
  1775. public int BaseDP = 0;
  1776. #endregion
  1777. #region DP
  1778. public int CardDP
  1779. {
  1780. get
  1781. {
  1782. int cardDP = -1;
  1783. if (HasDP)
  1784. {
  1785. cardDP = BaseCardDP;
  1786. cardDP += BaseDP;
  1787. #region card effects that change card DP
  1788. List<ICardEffect> changeCardDPCardEffects = new List<ICardEffect>();
  1789. #region the effects of permanents
  1790. changeCardDPCardEffects = changeCardDPCardEffects
  1791. .Concat(
  1792. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1793. .Map(player => player.GetFieldPermanents())
  1794. .Flat()
  1795. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1796. .Flat()
  1797. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1798. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1799. .ToList();
  1800. #endregion
  1801. #region the effects of players
  1802. changeCardDPCardEffects = changeCardDPCardEffects
  1803. .Concat(
  1804. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1805. .Map(player => player.EffectList(EffectTiming.None))
  1806. .Flat()
  1807. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1808. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1809. .ToList();
  1810. #endregion
  1811. List<ICardEffect> cardEffects_ChangeDP_IsUpDown = changeCardDPCardEffects
  1812. .Filter(cardEffect => ((IChangeCardDPEffect)cardEffect).IsUpDown());
  1813. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = changeCardDPCardEffects
  1814. .Filter(cardEffect => !((IChangeCardDPEffect)cardEffect).IsUpDown());
  1815. cardEffects_ChangeDP_IsUpDown
  1816. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1817. cardEffects_ChangeDP_NotIsUpDown
  1818. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1819. #endregion
  1820. }
  1821. return Math.Max(0, cardDP);
  1822. }
  1823. }
  1824. #endregion
  1825. #region Link DP
  1826. public int LinkDP => _cEntity_Base.LinkDP;
  1827. #endregion
  1828. #region Set DP - Must be used in conjunction with when removed field
  1829. public void SetDP(int value)
  1830. {
  1831. BaseDP = value;
  1832. }
  1833. #endregion
  1834. #region whether this card is token
  1835. public bool IsToken { get; private set; } = false;
  1836. public void SetIsToken(bool isToken) => IsToken = isToken;
  1837. #endregion
  1838. #region Will this card be trashed from sources
  1839. public bool willBeRemoveSources { get; set; } = false;
  1840. #endregion
  1841. #region whether this card can not be trashed from digivolution cards
  1842. public bool CanNotTrashFromDigivolutionCards(ICardEffect _cardEffect)
  1843. {
  1844. if (willBeRemoveSources)
  1845. return true;
  1846. #region the effects of permanents
  1847. if (GManager.instance.turnStateMachine.gameContext.Players
  1848. .Map(player => player.GetFieldPermanents())
  1849. .Flat()
  1850. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1851. .Flat()
  1852. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1853. && cardEffect.CanUse(null)
  1854. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1855. {
  1856. return true;
  1857. }
  1858. #endregion
  1859. #region the effects of players
  1860. if (GManager.instance.turnStateMachine.gameContext.Players
  1861. .Map(player => player.EffectList(EffectTiming.None))
  1862. .Flat()
  1863. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1864. && cardEffect.CanUse(null)
  1865. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1866. {
  1867. return true;
  1868. }
  1869. #endregion
  1870. #region the effects of itself
  1871. if (PermanentOfThisCard() == null)
  1872. {
  1873. if (EffectList(EffectTiming.None)
  1874. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1875. && cardEffect.CanUse(null)
  1876. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1877. {
  1878. return true;
  1879. }
  1880. }
  1881. #endregion
  1882. return false;
  1883. }
  1884. #endregion
  1885. #region whether this card has [Blocker]
  1886. public bool HasBlocker =>
  1887. EffectList(EffectTiming.None)
  1888. .Some(cardEffect => cardEffect is BlockerClass
  1889. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect);
  1890. #endregion
  1891. #region whether this card has [DigiBurst]
  1892. public bool HasDigiBurst
  1893. {
  1894. get
  1895. {
  1896. if (_cEntity_Base != null)
  1897. {
  1898. if (!string.IsNullOrEmpty(_cEntity_Base.EffectDiscription_JPN))
  1899. {
  1900. bool result = Regex.IsMatch(_cEntity_Base.EffectDiscription_JPN, DataBase.DigiburstRegex);
  1901. if (result)
  1902. {
  1903. return true;
  1904. }
  1905. }
  1906. }
  1907. return false;
  1908. }
  1909. }
  1910. #endregion
  1911. #region whether this card has [DigiXros]
  1912. public bool HasDigiXros => digiXrosCondition != null;
  1913. #endregion
  1914. #region whether this card has [Assembly]
  1915. public bool HasAssembly => assemblyCondition != null;
  1916. #endregion
  1917. #region traits
  1918. public List<string> CardTraits
  1919. {
  1920. get
  1921. {
  1922. List<string> traits =
  1923. _cEntity_Base.Form_ENG
  1924. .Filter(s => !string.IsNullOrEmpty(s))
  1925. .Concat(_cEntity_Base.Attribute_ENG
  1926. .Filter(s => !string.IsNullOrEmpty(s)))
  1927. .Concat(_cEntity_Base.Type_ENG
  1928. .Filter(s => !string.IsNullOrEmpty(s)))
  1929. .ToList();
  1930. #region the effects of itself
  1931. EffectList(EffectTiming.None)
  1932. .Filter(cardEffect => cardEffect is IChangeTraitsEffect && cardEffect.CanUse(null))
  1933. .ForEach(cardEffect => traits = ((IChangeTraitsEffect)cardEffect).ChangTraits(traits, this));
  1934. #endregion
  1935. return traits;
  1936. }
  1937. }
  1938. #endregion
  1939. #region whether this card has [On Deletion] effect
  1940. public bool HasOnDeletionEffect =>
  1941. EffectList(EffectTiming.OnDestroyedAnyone)
  1942. .Some(cardEffect => cardEffect is ActivateICardEffect
  1943. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1944. && cardEffect.IsOnDeletion);
  1945. #endregion
  1946. #region whether this card has [On Play] effect
  1947. public bool HasOnPlayEffect =>
  1948. EffectList(EffectTiming.OnEnterFieldAnyone)
  1949. .Some(cardEffect => cardEffect is ActivateICardEffect
  1950. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1951. && cardEffect.IsOnPlay);
  1952. #endregion
  1953. #region whether this card has [When Digivolving] effect
  1954. public bool HasWhenDigivolvingEffect =>
  1955. EffectList(EffectTiming.OnEnterFieldAnyone)
  1956. .Some(cardEffect => cardEffect is ActivateICardEffect
  1957. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1958. && cardEffect.IsWhenDigivolving);
  1959. #endregion
  1960. #region whether this card has [Digisorption]
  1961. public bool HasDigisorption =>
  1962. EffectList(EffectTiming.BeforePayCost)
  1963. .Some(cardEffect => cardEffect is ActivateICardEffect
  1964. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1965. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1966. && cardEffect.EffectDiscription.Contains("Digisorption -"));
  1967. #endregion
  1968. #region whether this card has [Blitz]
  1969. public bool HasBlitz =>
  1970. EffectList(EffectTiming.OnEnterFieldAnyone)
  1971. .Some(cardEffect => cardEffect is ActivateICardEffect
  1972. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1973. && (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfCard(this)))
  1974. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1975. && cardEffect.EffectDiscription.Contains("Blitz"));
  1976. #endregion
  1977. #region whether this card has [Retaliation]
  1978. public bool HasRetaliation =>
  1979. EffectList(EffectTiming.OnDestroyedAnyone)
  1980. .Some(cardEffect => cardEffect is ActivateICardEffect
  1981. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1982. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1983. && cardEffect.EffectName == "Retaliation");
  1984. #endregion
  1985. #region whether this card has [Fortitude]
  1986. public bool HasFortitude =>
  1987. EffectList(EffectTiming.OnDestroyedAnyone)
  1988. .Some(cardEffect => cardEffect is ActivateICardEffect
  1989. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1990. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1991. && cardEffect.EffectName == "Fortitude");
  1992. #endregion
  1993. #region whether this card has inherited effect
  1994. public bool HasInheritedEffect
  1995. {
  1996. get
  1997. {
  1998. foreach (EffectTiming timing in Enum.GetValues(typeof(EffectTiming)))
  1999. {
  2000. if (EffectList(timing)
  2001. .Some(cardEffect => cardEffect.IsInheritedEffect
  2002. && !cardEffect.IsDisabled))
  2003. {
  2004. return true;
  2005. }
  2006. }
  2007. return false;
  2008. }
  2009. }
  2010. #endregion
  2011. #region DNA digivolution requirement
  2012. public List<JogressCondition> jogressCondition
  2013. {
  2014. get
  2015. {
  2016. List<JogressCondition> addJogressConditionEffect =
  2017. EffectList(EffectTiming.None)
  2018. .Filter(cardEffect => cardEffect is IAddJogressConditionEffect
  2019. && cardEffect.CanUse(null)
  2020. && ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this) != null)
  2021. .Select(cardEffect => ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this))
  2022. .ToList();
  2023. return addJogressConditionEffect;
  2024. }
  2025. }
  2026. #endregion
  2027. #region Link requirement
  2028. public LinkCondition linkCondition
  2029. {
  2030. get
  2031. {
  2032. ICardEffect addLinkConditonEffect =
  2033. EffectList(EffectTiming.None)
  2034. .Find(cardEffect => cardEffect is IAddLinkConditionEffect
  2035. && cardEffect.CanUse(null)
  2036. && ((IAddLinkConditionEffect)cardEffect).GetLinkCondition(this) != null);
  2037. if (addLinkConditonEffect != null) return ((IAddLinkConditionEffect)addLinkConditonEffect).GetLinkCondition(this);
  2038. return null;
  2039. }
  2040. }
  2041. #endregion
  2042. #region whether this card can DNA digivolve
  2043. public bool CanPlayJogress(bool PayCost)
  2044. {
  2045. if (jogressCondition != null)
  2046. {
  2047. foreach (JogressCondition condition in jogressCondition)
  2048. {
  2049. if (Owner.GetBattleAreaDigimons().Count >= condition.elements.Length)
  2050. {
  2051. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(Owner.GetBattleAreaDigimons(), condition.elements.Length).ToList();
  2052. foreach (Permanent[] permanents in permanentsList)
  2053. {
  2054. if (permanents != null)
  2055. {
  2056. if (permanents.Length == condition.elements.Length)
  2057. {
  2058. if (permanents.Length == 2)
  2059. {
  2060. if (condition.elements[0].EvoRootCondition(permanents[0]) && !this.CanNotEvolve(permanents[0]))
  2061. {
  2062. if (condition.elements[1].EvoRootCondition(permanents[1]) && !this.CanNotEvolve(permanents[1]))
  2063. {
  2064. if (PayCost)
  2065. {
  2066. int cost = condition.cost;
  2067. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, permanents.ToList(), checkAvailability: true);
  2068. if (Owner.MaxMemoryCost < cost)
  2069. {
  2070. return false;
  2071. }
  2072. }
  2073. return true;
  2074. }
  2075. }
  2076. }
  2077. }
  2078. }
  2079. }
  2080. }
  2081. }
  2082. }
  2083. return false;
  2084. }
  2085. #endregion
  2086. #region whether target permanent can DNA digivolve into this card
  2087. public bool CanJogressFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2088. {
  2089. if (targetPermanent != null)
  2090. {
  2091. if (targetPermanent.TopCard != null)
  2092. {
  2093. foreach (JogressCondition condition in jogressCondition)
  2094. {
  2095. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  2096. {
  2097. if (this.CanPlayJogress(PayCost))
  2098. {
  2099. if (condition != null)
  2100. {
  2101. if (condition.elements.ToList().Count((element) => element.EvoRootCondition(targetPermanent)) >= 1)
  2102. {
  2103. if (!this.CanNotEvolve(targetPermanent))
  2104. {
  2105. if (PayCost)
  2106. {
  2107. int cost = condition.cost;
  2108. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent, new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2109. if (Owner.MaxMemoryCost < cost)
  2110. {
  2111. return false;
  2112. }
  2113. }
  2114. return true;
  2115. }
  2116. }
  2117. }
  2118. }
  2119. }
  2120. }
  2121. }
  2122. }
  2123. return false;
  2124. }
  2125. #endregion
  2126. #region whether target permanents can DNA digivolve into this card
  2127. public bool CanJogressFromTargetPermanents(List<Permanent> targetPermanents, bool PayCost)
  2128. {
  2129. if (targetPermanents != null)
  2130. {
  2131. if (targetPermanents.Count == 2)
  2132. {
  2133. if (this.CanPlayJogress(PayCost))
  2134. {
  2135. foreach (JogressCondition condition in jogressCondition)
  2136. {
  2137. if (condition != null)
  2138. {
  2139. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(targetPermanents, 2).ToList();
  2140. foreach (Permanent[] permanents in permanentsList)
  2141. {
  2142. if (condition.elements.Length == permanents.Length)
  2143. {
  2144. bool canJogress = true;
  2145. for (int i = 0; i < permanents.Length; i++)
  2146. {
  2147. if (permanents[i] != null)
  2148. {
  2149. if (permanents[i].TopCard != null)
  2150. {
  2151. if ((!condition.elements[i].EvoRootCondition(permanents[i])) || this.CanNotEvolve(permanents[i]))
  2152. {
  2153. canJogress = false;
  2154. break;
  2155. }
  2156. }
  2157. }
  2158. }
  2159. if (canJogress)
  2160. {
  2161. return true;
  2162. }
  2163. }
  2164. }
  2165. }
  2166. }
  2167. }
  2168. }
  2169. }
  2170. return false;
  2171. }
  2172. #endregion
  2173. #region whether this card has level
  2174. public bool HasLevel
  2175. {
  2176. get
  2177. {
  2178. if (_cEntity_Base == null || _cEntity_Base.HasLevel)
  2179. {
  2180. return true;
  2181. }
  2182. return false;
  2183. }
  2184. }
  2185. #endregion
  2186. #region whether this card is level 2
  2187. public bool IsLevel2 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 2;
  2188. #endregion
  2189. #region whether this card is level 3
  2190. public bool IsLevel3 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 3;
  2191. #endregion
  2192. #region whether this card is level 4
  2193. public bool IsLevel4 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 4;
  2194. #endregion
  2195. #region whether this card is level 5
  2196. public bool IsLevel5 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 5;
  2197. #endregion
  2198. #region whether this card is level 6
  2199. public bool IsLevel6 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 6;
  2200. #endregion
  2201. #region whether this card is linked
  2202. public bool IsLinked
  2203. {
  2204. get
  2205. {
  2206. return PermanentOfThisCard().LinkedCards.Contains(this);
  2207. }
  2208. }
  2209. #endregion
  2210. #region DigiXros requirement
  2211. public DigiXrosCondition digiXrosCondition
  2212. {
  2213. get
  2214. {
  2215. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2216. {
  2217. if (cardEffect is IAddDigiXrosConditionEffect)
  2218. {
  2219. if (cardEffect.CanUse(null))
  2220. {
  2221. DigiXrosCondition digiXrosCondition = ((IAddDigiXrosConditionEffect)cardEffect).GetDigiXrosCondition(this);
  2222. if (digiXrosCondition != null)
  2223. {
  2224. return digiXrosCondition;
  2225. }
  2226. }
  2227. }
  2228. }
  2229. return null;
  2230. }
  2231. }
  2232. #endregion
  2233. #region Blast Digivolution requirement
  2234. public BurstDigivolutionCondition burstDigivolutionCondition
  2235. {
  2236. get
  2237. {
  2238. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2239. {
  2240. if (cardEffect is IAddBurstDigivolutionConditionEffect)
  2241. {
  2242. if (cardEffect.CanUse(null))
  2243. {
  2244. BurstDigivolutionCondition burstDigivolutionCondition = ((IAddBurstDigivolutionConditionEffect)cardEffect).GetBurstDigivolutionCondition(this);
  2245. if (burstDigivolutionCondition != null)
  2246. {
  2247. return burstDigivolutionCondition;
  2248. }
  2249. }
  2250. }
  2251. }
  2252. return null;
  2253. }
  2254. }
  2255. #endregion
  2256. #region App Fusion requirement
  2257. public AppFusionCondition appFusionCondition
  2258. {
  2259. get
  2260. {
  2261. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2262. {
  2263. if (cardEffect is IAddAppFusionConditionEffect)
  2264. {
  2265. if (cardEffect.CanUse(null))
  2266. {
  2267. AppFusionCondition appFusionCondition = ((IAddAppFusionConditionEffect)cardEffect).GetAppFusionCondition(this);
  2268. if (appFusionCondition != null)
  2269. {
  2270. return appFusionCondition;
  2271. }
  2272. }
  2273. }
  2274. }
  2275. return null;
  2276. }
  2277. }
  2278. #endregion
  2279. #region Assembly requirement
  2280. public AssemblyCondition assemblyCondition
  2281. {
  2282. get
  2283. {
  2284. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2285. {
  2286. if (cardEffect is IAddAssemblyConditionEffect)
  2287. {
  2288. if (cardEffect.CanUse(null))
  2289. {
  2290. AssemblyCondition assemblyCondition = ((IAddAssemblyConditionEffect)cardEffect).GetAssemblyCondition(this);
  2291. if (assemblyCondition != null)
  2292. {
  2293. return assemblyCondition;
  2294. }
  2295. }
  2296. }
  2297. }
  2298. return null;
  2299. }
  2300. }
  2301. #endregion
  2302. #region whether this card can Burst digivolve
  2303. public bool CanPlayBurst(bool PayCost)
  2304. {
  2305. if (burstDigivolutionCondition != null)
  2306. {
  2307. if (PayCost)
  2308. {
  2309. int cost = burstDigivolutionCondition.cost;
  2310. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2311. if (Owner.MaxMemoryCost < cost)
  2312. {
  2313. return false;
  2314. }
  2315. }
  2316. List<Permanent> availableDigimon = new List<Permanent>();
  2317. availableDigimon.AddRange(Owner.GetBattleAreaDigimons());
  2318. availableDigimon.AddRange(Owner.GetBreedingAreaPermanents());
  2319. if (availableDigimon.Count >= 1)
  2320. {
  2321. foreach (Permanent digimon in availableDigimon)
  2322. {
  2323. if (digimon != null)
  2324. {
  2325. if (!this.CanNotEvolve(digimon))
  2326. {
  2327. if (burstDigivolutionCondition.digimonCondition(digimon))
  2328. {
  2329. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2330. {
  2331. if (tamer != digimon)
  2332. {
  2333. if (burstDigivolutionCondition.tamerCondition(tamer))
  2334. {
  2335. if (!tamer.CannotReturnToHand(null))
  2336. {
  2337. if (PayCost)
  2338. {
  2339. int cost = burstDigivolutionCondition.cost;
  2340. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
  2341. if (Owner.MaxMemoryCost < cost)
  2342. {
  2343. return false;
  2344. }
  2345. }
  2346. return true;
  2347. }
  2348. }
  2349. }
  2350. }
  2351. }
  2352. }
  2353. }
  2354. }
  2355. }
  2356. }
  2357. return false;
  2358. }
  2359. #endregion
  2360. #region whether this card can Link
  2361. public bool CanLink(bool PayCost, bool allowBreeding = false)
  2362. {
  2363. if (linkCondition != null)
  2364. {
  2365. SelectCardEffect.Root root = CardEffectCommons.IsExistOnHand(this) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.None;
  2366. if (allowBreeding)
  2367. {
  2368. if (Owner.GetFieldPermanents().Count >= 1)
  2369. {
  2370. foreach (Permanent digimon in Owner.GetFieldPermanents())
  2371. {
  2372. if (digimon != null)
  2373. {
  2374. if (linkCondition.digimonCondition(digimon))
  2375. {
  2376. if (PayCost)
  2377. {
  2378. int cost = GetChangedLinkCost(digimon, root);
  2379. if (Owner.MaxMemoryCost >= cost)
  2380. {
  2381. return true;
  2382. }
  2383. }
  2384. else
  2385. {
  2386. return true;
  2387. }
  2388. }
  2389. }
  2390. }
  2391. }
  2392. }
  2393. else
  2394. {
  2395. if (Owner.GetBattleAreaDigimons().Count >= 1)
  2396. {
  2397. foreach (Permanent digimon in Owner.GetBattleAreaDigimons())
  2398. {
  2399. if (digimon != null)
  2400. {
  2401. if (linkCondition.digimonCondition(digimon))
  2402. {
  2403. if (PayCost)
  2404. {
  2405. int cost = GetChangedLinkCost(digimon, root);
  2406. if (Owner.MaxMemoryCost >= cost)
  2407. {
  2408. return true;
  2409. }
  2410. }
  2411. else
  2412. {
  2413. return true;
  2414. }
  2415. }
  2416. }
  2417. }
  2418. }
  2419. }
  2420. }
  2421. return false;
  2422. }
  2423. #endregion
  2424. #region whether target permanent can Burst digivolve into this card
  2425. public bool CanBurstDigivolutionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2426. {
  2427. if (targetPermanent != null)
  2428. {
  2429. if (targetPermanent.TopCard != null)
  2430. {
  2431. if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent) || targetPermanent.TopCard.Owner.GetBreedingAreaPermanents().Contains(targetPermanent))
  2432. {
  2433. if (this.CanPlayBurst(PayCost))
  2434. {
  2435. if (burstDigivolutionCondition != null)
  2436. {
  2437. if (!this.CanNotEvolve(targetPermanent))
  2438. {
  2439. if (burstDigivolutionCondition.digimonCondition(targetPermanent))
  2440. {
  2441. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2442. {
  2443. if (tamer != targetPermanent)
  2444. {
  2445. if (burstDigivolutionCondition.tamerCondition(tamer))
  2446. {
  2447. if (!tamer.CannotReturnToHand(null))
  2448. {
  2449. if (PayCost)
  2450. {
  2451. int cost = burstDigivolutionCondition.cost;
  2452. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2453. if (Owner.MaxMemoryCost < cost)
  2454. {
  2455. return false;
  2456. }
  2457. }
  2458. return true;
  2459. }
  2460. }
  2461. }
  2462. }
  2463. }
  2464. }
  2465. }
  2466. }
  2467. }
  2468. }
  2469. }
  2470. return false;
  2471. }
  2472. #endregion
  2473. #region Get Link Cost Accounting for Cost Reduction
  2474. public int GetChangedLinkCost(Permanent targetPermanent, SelectCardEffect.Root root)
  2475. {
  2476. if (linkCondition == null) return 0;
  2477. int Cost = linkCondition.cost;
  2478. List<ICardEffect> changeLinkCostCardEffects = new List<ICardEffect>();
  2479. #region the effects of permanents
  2480. changeLinkCostCardEffects = changeLinkCostCardEffects
  2481. .Concat(
  2482. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  2483. .Map(player => player.GetFieldPermanents())
  2484. .Flat()
  2485. .Filter(permanent => permanent != PermanentOfThisCard())
  2486. .Map(permanent => permanent.EffectList(EffectTiming.None))
  2487. .Flat()
  2488. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2489. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2490. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2491. .ToList();
  2492. #endregion
  2493. #region the effects of players
  2494. changeLinkCostCardEffects = changeLinkCostCardEffects
  2495. .Concat(
  2496. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  2497. .Map(player => player.EffectList(EffectTiming.None))
  2498. .Flat()
  2499. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2500. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2501. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2502. .ToList();
  2503. #endregion
  2504. #region the effects of itself
  2505. changeLinkCostCardEffects = changeLinkCostCardEffects
  2506. .Concat(
  2507. EffectList(EffectTiming.None)
  2508. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2509. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2510. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2511. .ToList();
  2512. #endregion
  2513. List<ICardEffect> changeLinkCostCardEffects_NotIsUpDown = changeLinkCostCardEffects
  2514. .Filter(cardEffect => !((IChangeLinkCostEffect)cardEffect).IsUpDown());
  2515. List<ICardEffect> changeLinkCostCardEffects_IsUpDown = changeLinkCostCardEffects
  2516. .Filter(cardEffect => ((IChangeLinkCostEffect)cardEffect).IsUpDown());
  2517. changeLinkCostCardEffects_NotIsUpDown
  2518. .ForEach(cardEffect => Cost = ((IChangeLinkCostEffect)cardEffect).GetCost(Cost, this, targetPermanent, root));
  2519. changeLinkCostCardEffects_IsUpDown
  2520. .ForEach(cardEffect => Cost = ((IChangeLinkCostEffect)cardEffect).GetCost(Cost, this, targetPermanent, root));
  2521. return Math.Max(0, Cost);
  2522. }
  2523. #endregion
  2524. #region whether target permanent can Link into this card
  2525. public bool CanLinkToTargetPermanent(Permanent targetPermanent, bool PayCost, bool allowBreeding = false)
  2526. {
  2527. if (targetPermanent != null)
  2528. {
  2529. if (targetPermanent.TopCard != null && !targetPermanent.TopCard.IsToken)
  2530. {
  2531. if(allowBreeding || !targetPermanent.TopCard.Owner.GetBreedingAreaPermanents().Contains(targetPermanent))
  2532. {
  2533. if (this.CanLink(false, allowBreeding)) // Don't check PayCost in CanLink since this method will check again anyway
  2534. {
  2535. if (linkCondition != null)
  2536. {
  2537. if (linkCondition.digimonCondition(targetPermanent))
  2538. {
  2539. if (PayCost)
  2540. {
  2541. SelectCardEffect.Root root = CardEffectCommons.IsExistOnHand(this) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.None;
  2542. int cost = GetChangedLinkCost(targetPermanent, root);
  2543. if (Owner.MaxMemoryCost < cost)
  2544. {
  2545. return false;
  2546. }
  2547. }
  2548. return true;
  2549. }
  2550. }
  2551. }
  2552. }
  2553. }
  2554. }
  2555. return false;
  2556. }
  2557. #endregion
  2558. #region whether target permanent can App Fusion into this card
  2559. public bool CanAppFusionFromTargetPermanent(Permanent targetPermanent, bool PayCost, SelectCardEffect.Root root = SelectCardEffect.Root.Hand)
  2560. {
  2561. if (targetPermanent != null)
  2562. {
  2563. if (targetPermanent.TopCard != null)
  2564. {
  2565. if (appFusionCondition != null)
  2566. {
  2567. if (!this.CanNotEvolve(targetPermanent))
  2568. {
  2569. if (appFusionCondition.digimonCondition(targetPermanent))
  2570. {
  2571. foreach (CardSource linkedCard in targetPermanent.LinkedCards)
  2572. {
  2573. if (appFusionCondition.linkedCondition(targetPermanent, linkedCard))
  2574. {
  2575. if (PayCost)
  2576. {
  2577. int cost = appFusionCondition.cost;
  2578. cost = GetChangedCostItselef(cost, root, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2579. if (Owner.MaxMemoryCost < cost)
  2580. {
  2581. return false;
  2582. }
  2583. }
  2584. return true;
  2585. }
  2586. }
  2587. }
  2588. }
  2589. }
  2590. }
  2591. }
  2592. return false;
  2593. }
  2594. #endregion
  2595. #region Whether this card's digiXrosCondition contains target card
  2596. public bool IsContainDigiXrosCondition(CardSource cardSource)
  2597. {
  2598. if (cardSource != null)
  2599. {
  2600. if (cardSource.Owner == Owner)
  2601. {
  2602. if (PermanentOfThisCard() != null)
  2603. {
  2604. if (PermanentOfThisCard().TopCard.HasDigiXros)
  2605. {
  2606. if (this == PermanentOfThisCard().TopCard)
  2607. {
  2608. if (digiXrosCondition != null)
  2609. {
  2610. if (digiXrosCondition.elements.Count((element) => element.CardCondition(cardSource)) >= 1)
  2611. {
  2612. return true;
  2613. }
  2614. }
  2615. }
  2616. }
  2617. }
  2618. }
  2619. }
  2620. return false;
  2621. }
  2622. #endregion
  2623. #region CardID
  2624. public string CardID => _cEntity_Base.CardID;
  2625. #endregion
  2626. #region whether this card is Digimon
  2627. public bool IsDigimon => CardKinds.Contains(CardKind.Digimon);
  2628. #endregion
  2629. #region whether this card is DigiEgg
  2630. public bool IsDigiEgg => CardKinds.Contains(CardKind.DigiEgg);
  2631. #endregion
  2632. #region whether this card is Tamer
  2633. public bool IsTamer => CardKinds.Contains(CardKind.Tamer);
  2634. #endregion
  2635. #region whether this card is Option
  2636. public bool IsOption => CardKinds.Contains(CardKind.Option);
  2637. #endregion
  2638. #region Wheter this card is permanent
  2639. public bool IsPermanent => _cEntity_Base.IsPermanent;
  2640. #endregion
  2641. #region Whether to have Play Cost
  2642. public bool HasPlayCost => _cEntity_Base.HasPlayCost;
  2643. #endregion
  2644. #region Whether to have Use Cost
  2645. public bool HasUseCost => _cEntity_Base.HasUseCost;
  2646. #endregion
  2647. #region Inherited Effects ENG discription
  2648. public string InheritedEffectDiscription_ENG => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG);
  2649. #endregion
  2650. #region Inherited Effects JPN discription
  2651. public string InheritedEffectDiscription_JPN => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_JPN);
  2652. #endregion
  2653. #region Link Effects
  2654. public string LinkEffectDiscription => DataBase.ReplaceToASCII(_cEntity_Base.LinkEffect);
  2655. #endregion
  2656. #region Card Sprite
  2657. public Sprite CardSprite => _cEntity_Base.CardSprite;
  2658. public async Task<Sprite> GetCardSprite()
  2659. {
  2660. return await _cEntity_Base.GetCardSprite();
  2661. }
  2662. #endregion
  2663. #region SetID
  2664. public string SetID => _cEntity_Base.SetID;
  2665. #endregion
  2666. #region CardEntityIndex
  2667. public int CardEntityIndex => _cEntity_Base.CardIndex;
  2668. #endregion
  2669. #region Card Kind
  2670. public List<CardKind> CardKinds => _cEntity_Base.cardKind;
  2671. #endregion
  2672. #region ACE
  2673. public bool IsACE => _cEntity_Base.IsACE;
  2674. #endregion
  2675. #region OverflowMemory
  2676. public int OverflowMemory => _cEntity_Base.OverflowMemory;
  2677. #endregion
  2678. #region Whether this card is being revealed
  2679. public bool IsBeingRevealed { get; set; } = false;
  2680. #endregion
  2681. #region The permanent that belonged to this card just before it left the field
  2682. public Permanent PermanentJustBeforeRemoveField { get; set; } = null;
  2683. #endregion
  2684. #region whether this card has "SEEKERS" trait
  2685. public bool HasSeekersTraits
  2686. {
  2687. get
  2688. {
  2689. if (CardTraits.Contains("SEEKERS"))
  2690. {
  2691. return true;
  2692. }
  2693. return false;
  2694. }
  2695. }
  2696. #endregion
  2697. #region whether this card has "ADVENTURE" trait
  2698. public bool HasAdventureTraits
  2699. {
  2700. get
  2701. {
  2702. if (CardTraits.Contains("ADVENTURE"))
  2703. {
  2704. return true;
  2705. }
  2706. return false;
  2707. }
  2708. }
  2709. #endregion
  2710. #region whether this card has "Hero" trait
  2711. public bool HasHeroTraits
  2712. {
  2713. get
  2714. {
  2715. return EqualsTraits("Hero");
  2716. }
  2717. }
  2718. #endregion
  2719. #region whether this card has "Chronicle" trait
  2720. public bool HasChronicleTraits
  2721. {
  2722. get
  2723. {
  2724. if (CardTraits.Contains("Chronicle"))
  2725. {
  2726. return true;
  2727. }
  2728. return false;
  2729. }
  2730. }
  2731. #endregion
  2732. #region whether this card has "Device" trait
  2733. public bool HasDeviceTraits
  2734. {
  2735. get
  2736. {
  2737. if (CardTraits.Contains("Device"))
  2738. {
  2739. return true;
  2740. }
  2741. return false;
  2742. }
  2743. }
  2744. #endregion
  2745. #region whether this card has "Three Musketeers" trait
  2746. public bool HasThreeMusketeersTraits
  2747. {
  2748. get
  2749. {
  2750. if (CardTraits.Contains("Three Musketeers"))
  2751. {
  2752. return true;
  2753. }
  2754. return false;
  2755. }
  2756. }
  2757. #endregion
  2758. #region whether this card has "Royal Base" trait
  2759. public bool HasRoyalBaseTraits
  2760. {
  2761. get
  2762. {
  2763. if (CardTraits.Contains("Royal Base"))
  2764. {
  2765. return true;
  2766. }
  2767. return false;
  2768. }
  2769. }
  2770. #endregion
  2771. #region whether this card has "Appmon" trait
  2772. public bool HasAppmonTraits
  2773. {
  2774. get
  2775. {
  2776. return EqualsTraits("Appmon");
  2777. }
  2778. }
  2779. #endregion
  2780. #region whether this card has "WG" trait
  2781. public bool HasWGTraits
  2782. {
  2783. get
  2784. {
  2785. return EqualsTraits("WG");
  2786. }
  2787. }
  2788. #endregion
  2789. #region whether this card has "DM" trait
  2790. public bool HasDMTraits
  2791. {
  2792. get
  2793. {
  2794. return EqualsTraits("DM");
  2795. }
  2796. }
  2797. #endregion
  2798. #region whether this card has "CS" trait
  2799. public bool HasCSTraits
  2800. {
  2801. get
  2802. {
  2803. return EqualsTraits("CS");
  2804. }
  2805. }
  2806. #endregion
  2807. #region whether this card has "TS" trait
  2808. public bool HasTSTraits
  2809. {
  2810. get
  2811. {
  2812. return EqualsTraits("TS");
  2813. }
  2814. }
  2815. #endregion
  2816. #region whether this card has "Iliad" trait
  2817. public bool HasIliadTraits
  2818. {
  2819. get
  2820. {
  2821. return EqualsTraits("Iliad");
  2822. }
  2823. }
  2824. #endregion
  2825. #region whether this card has "Unidentified" trait
  2826. public bool HasUnidentifiedTraits
  2827. {
  2828. get
  2829. {
  2830. return EqualsTraits("Unidentified");
  2831. }
  2832. }
  2833. #endregion
  2834. #region whether this card has "Flame" trait
  2835. public bool HasFlameTraits
  2836. {
  2837. get
  2838. {
  2839. return EqualsTraits("Flame");
  2840. }
  2841. }
  2842. #endregion
  2843. #region whether this card has "Eater" trait
  2844. public bool HasEaterTraits
  2845. {
  2846. get
  2847. {
  2848. return EqualsTraits("Eater");
  2849. }
  2850. }
  2851. #endregion
  2852. #region whether this card has "Hudie" trait
  2853. public bool HasHudieTraits
  2854. {
  2855. get
  2856. {
  2857. return EqualsTraits("Hudie");
  2858. }
  2859. }
  2860. #endregion
  2861. #region whether this card has "Sea Animal" trait
  2862. public bool HasSeaAnimalTraits
  2863. {
  2864. get
  2865. {
  2866. return EqualsTraits("Sea Animal");
  2867. }
  2868. }
  2869. #endregion
  2870. #region whether this card has "Puppet" trait
  2871. public bool HasPuppetTraits
  2872. {
  2873. get
  2874. {
  2875. return EqualsTraits("Puppet");
  2876. }
  2877. }
  2878. #endregion
  2879. #region whether this card has "Ver.1" trait
  2880. public bool HasVer1Traits
  2881. {
  2882. get
  2883. {
  2884. return EqualsTraits("Ver.1");
  2885. }
  2886. }
  2887. #endregion
  2888. #region whether this card has "Ver.2" trait
  2889. public bool HasVer2Traits
  2890. {
  2891. get
  2892. {
  2893. return EqualsTraits("Ver.2");
  2894. }
  2895. }
  2896. #endregion
  2897. #region whether this card has "Ver.3" trait
  2898. public bool HasVer3Traits
  2899. {
  2900. get
  2901. {
  2902. return EqualsTraits("Ver.3");
  2903. }
  2904. }
  2905. #endregion
  2906. #region whether this card has "Ver.4" trait
  2907. public bool HasVer4Traits
  2908. {
  2909. get
  2910. {
  2911. return EqualsTraits("Ver.4");
  2912. }
  2913. }
  2914. #endregion
  2915. #region whether this card has "Ver.5" trait
  2916. public bool HasVer5Traits
  2917. {
  2918. get
  2919. {
  2920. return EqualsTraits("Ver.5");
  2921. }
  2922. }
  2923. #endregion
  2924. #region whether this card has "Aquatic" trait
  2925. public bool HasAquaticTraits
  2926. {
  2927. get
  2928. {
  2929. return EqualsTraits("Aquatic");
  2930. }
  2931. }
  2932. #endregion
  2933. #region whether this card has "LIBERATOR" trait
  2934. public bool HasLiberatorTraits
  2935. {
  2936. get
  2937. {
  2938. return EqualsTraits("LIBERATOR");
  2939. }
  2940. }
  2941. #endregion
  2942. #region whether this card has "Standard" Appmon Grade trait
  2943. public bool HasStandardAppTraits
  2944. {
  2945. get
  2946. {
  2947. return EqualsTraits("Stnd.");
  2948. }
  2949. }
  2950. #endregion
  2951. #region whether this card has "Super" Appmon Grade trait
  2952. public bool HasSuperAppTraits
  2953. {
  2954. get
  2955. {
  2956. return EqualsTraits("Sup.");
  2957. }
  2958. }
  2959. #endregion
  2960. #region whether this card has "Ultimate" Appmon Grade trait
  2961. public bool HasUltimateAppTraits
  2962. {
  2963. get
  2964. {
  2965. return EqualsTraits("Ult.");
  2966. }
  2967. }
  2968. #endregion
  2969. #region whether this card has "Holy Beast" trait
  2970. public bool HasHolyBeastTraits
  2971. {
  2972. get
  2973. {
  2974. return EqualsTraits("Holy Beast");
  2975. }
  2976. }
  2977. #endregion
  2978. #region whether this card has "Archangel" trait
  2979. public bool HasArchAngelTraits
  2980. {
  2981. get
  2982. {
  2983. return EqualsTraits("Archangel");
  2984. }
  2985. }
  2986. #endregion
  2987. #region whether this card has "Fallen Angel" trait
  2988. public bool HasFallenAngelTraits
  2989. {
  2990. get
  2991. {
  2992. return EqualsTraits("Fallen Angel");
  2993. }
  2994. }
  2995. #endregion
  2996. #region whether this card has "Bagra Army" trait
  2997. public bool HasBagraArmyTraits
  2998. {
  2999. get
  3000. {
  3001. return EqualsTraits("Bagra Army");
  3002. }
  3003. }
  3004. #endregion
  3005. #region whether this card has "Evil" trait
  3006. public bool HasEvilTraits
  3007. {
  3008. get
  3009. {
  3010. return EqualsTraits("Evil");
  3011. }
  3012. }
  3013. #endregion
  3014. #region whether this card has "Wizard" trait
  3015. public bool HasWizardTraits
  3016. {
  3017. get
  3018. {
  3019. return EqualsTraits("Wizard");
  3020. }
  3021. }
  3022. #endregion
  3023. #region whether this card has "Leviathan" trait
  3024. public bool HasLeviathanTraits
  3025. {
  3026. get
  3027. {
  3028. return EqualsTraits("Leviathan");
  3029. }
  3030. }
  3031. #endregion
  3032. #region whether this card has "Undead" trait
  3033. public bool HasUndeadTraits
  3034. {
  3035. get
  3036. {
  3037. return EqualsTraits("Undead");
  3038. }
  3039. }
  3040. #endregion
  3041. #region whether this card has "Galaxy" trait
  3042. public bool HasGalaxyTraits
  3043. {
  3044. get
  3045. {
  3046. return EqualsTraits("Galaxy");
  3047. }
  3048. }
  3049. #endregion
  3050. #region whether this card has "Rock"/"Mineral trait
  3051. public bool HasRockMineralTraits
  3052. {
  3053. get
  3054. {
  3055. return EqualsTraits("Rock") || EqualsTraits("Mineral");
  3056. }
  3057. }
  3058. #endregion
  3059. #region whether this card has Sea Beast trait
  3060. public bool HasSeaBeastTraits
  3061. {
  3062. get
  3063. {
  3064. return EqualsTraits("Sea Beast");
  3065. }
  3066. }
  3067. #endregion
  3068. #region whether this card has Twilight trait
  3069. public bool HasTwilightTrait
  3070. {
  3071. get
  3072. {
  3073. return EqualsTraits("Twilight");
  3074. }
  3075. }
  3076. #endregion
  3077. #region whether this card has Angel trait
  3078. public bool HasAngelStrictTraits
  3079. {
  3080. get
  3081. {
  3082. return EqualsTraits("Angel");
  3083. }
  3084. }
  3085. #endregion
  3086. #region whether this card has Dark Masters trait
  3087. public bool HasDarkMastersTrait
  3088. {
  3089. get
  3090. {
  3091. return EqualsTraits("Dark Masters");
  3092. }
  3093. }
  3094. #endregion
  3095. #region whether this card has Ghost trait
  3096. public bool HasGhostTraits
  3097. {
  3098. get
  3099. {
  3100. return EqualsTraits("Ghost");
  3101. }
  3102. }
  3103. #endregion
  3104. #region whether this card has Dark Animal trait
  3105. public bool HasDarkAnimalTraits
  3106. {
  3107. get
  3108. {
  3109. return EqualsTraits("Dark Animal");
  3110. }
  3111. }
  3112. #endregion
  3113. }
  3114. public class JogressCondition
  3115. {
  3116. public JogressCondition(JogressConditionElement[] elements, int cost)
  3117. {
  3118. this.elements = new JogressConditionElement[2];
  3119. if (this.elements.Length == elements.Length)
  3120. {
  3121. for (int i = 0; i < elements.Length; i++)
  3122. {
  3123. this.elements[i] = elements[i];
  3124. }
  3125. }
  3126. this.cost = cost;
  3127. }
  3128. public JogressConditionElement[] elements { get; private set; } = new JogressConditionElement[2];
  3129. public int cost { get; private set; } = 0;
  3130. }
  3131. public class JogressConditionElement
  3132. {
  3133. public JogressConditionElement(Func<Permanent, bool> evoRootCondition, string selectMessage)
  3134. {
  3135. EvoRootCondition = evoRootCondition;
  3136. SelectMessage = selectMessage;
  3137. }
  3138. Func<Permanent, bool> _evoRootCondition = null;
  3139. public Func<Permanent, bool> EvoRootCondition
  3140. {
  3141. get
  3142. {
  3143. return permanent => _evoRootCondition == null || _evoRootCondition(permanent);
  3144. }
  3145. private set
  3146. {
  3147. _evoRootCondition = value;
  3148. }
  3149. }
  3150. public string SelectMessage { get; private set; } = "";
  3151. }
  3152. public class DigiXrosCondition
  3153. {
  3154. public DigiXrosCondition(List<DigiXrosConditionElement> elements, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, int reduceCostPerCard)
  3155. {
  3156. this.elements = new List<DigiXrosConditionElement>();
  3157. foreach (DigiXrosConditionElement element in elements)
  3158. {
  3159. this.elements.Add(element);
  3160. }
  3161. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3162. this.reduceCostPerCard = reduceCostPerCard;
  3163. }
  3164. public List<DigiXrosConditionElement> elements { get; private set; } = new List<DigiXrosConditionElement>();
  3165. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; private set; } = null;
  3166. public int reduceCostPerCard { get; private set; } = 0;
  3167. }
  3168. public class DigiXrosConditionElement
  3169. {
  3170. public DigiXrosConditionElement(Func<CardSource, bool> cardCondition, string selectMessage, bool skipAllIfNoSelect = false)
  3171. {
  3172. this.CardCondition = cardCondition;
  3173. this.selectMessage = selectMessage;
  3174. this.skipAllIfNoSelect = skipAllIfNoSelect;
  3175. }
  3176. public Func<CardSource, bool> CardCondition { get; private set; } = null;
  3177. public string selectMessage { get; private set; } = "";
  3178. public bool skipAllIfNoSelect { get; private set; } = false;
  3179. }
  3180. public class BurstDigivolutionCondition
  3181. {
  3182. public BurstDigivolutionCondition(Func<Permanent, bool> tamerCondition, string selectTamerMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
  3183. {
  3184. this.tamerCondition = tamerCondition;
  3185. this.selectTamerMessage = selectTamerMessage;
  3186. this.digimonCondition = digimonCondition;
  3187. this.selectDigimonMessage = selectDigimonMessage;
  3188. this.cost = cost;
  3189. }
  3190. public Func<Permanent, bool> tamerCondition { get; private set; } = null;
  3191. public string selectTamerMessage { get; private set; } = null;
  3192. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3193. public string selectDigimonMessage { get; private set; } = null;
  3194. public int cost { get; private set; } = 0;
  3195. }
  3196. public class LinkCondition
  3197. {
  3198. public LinkCondition(Func<Permanent, bool> digimonCondition, int cost)
  3199. {
  3200. this.digimonCondition = digimonCondition;
  3201. this.cost = cost;
  3202. }
  3203. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3204. public int cost { get; private set; } = 0;
  3205. }
  3206. public class AppFusionCondition
  3207. {
  3208. public AppFusionCondition(Func<Permanent, CardSource, bool> linkedCondition, Func<Permanent, bool> digimonCondition, int cost)
  3209. {
  3210. this.linkedCondition = linkedCondition;
  3211. this.digimonCondition = digimonCondition;
  3212. this.cost = cost;
  3213. }
  3214. public Func<Permanent, CardSource, bool> linkedCondition { get; private set; } = null;
  3215. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3216. public int cost { get; private set; } = 0;
  3217. }
  3218. public class AssemblyCondition
  3219. {
  3220. //Method to work with older form of Assembly, 1 single condition X times
  3221. public AssemblyCondition(AssemblyConditionElement element, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, string selectMessage, int elementCount, int reduceCost)
  3222. {
  3223. element.ElementCount = elementCount;
  3224. element.selectMessage = selectMessage;
  3225. element.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3226. this.elements = new List<AssemblyConditionElement>(){ element };
  3227. this.elementCount = elementCount;
  3228. this.reduceCost = reduceCost;
  3229. }
  3230. //Method to work with A x B x C... DigiXros like conditions
  3231. public AssemblyCondition(List<AssemblyConditionElement> elements, int reduceCost)
  3232. {
  3233. this.elements = elements;
  3234. this.elementCount = elements.Select(element => element.ElementCount).Sum();
  3235. this.reduceCost = reduceCost;
  3236. }
  3237. public List<AssemblyConditionElement> elements { get; private set; } = new List<AssemblyConditionElement>();
  3238. public int elementCount { get; private set; } = 0;
  3239. public int reduceCost { get; private set; } = 0;
  3240. }
  3241. public class AssemblyConditionElement
  3242. {
  3243. public AssemblyConditionElement(Func<CardSource, bool> cardCondition, bool skipAllIfNoSelect = true, string selectMessage = null, int elementCount = 0, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList = null)
  3244. {
  3245. this.CardCondition = cardCondition;
  3246. this.skipAllIfNoSelect = skipAllIfNoSelect;
  3247. this.selectMessage = selectMessage;
  3248. this.ElementCount = elementCount;
  3249. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3250. }
  3251. public Func<CardSource, bool> CardCondition { get; set; } = null;
  3252. public bool skipAllIfNoSelect { get; set; } = true;
  3253. public int ElementCount { get; set; } = 0;
  3254. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; set; } = null;
  3255. public string selectMessage { get; set; } = "";
  3256. }