CardSource.cs 120 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276
  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 card effects that change base card names
  1003. if (isDigivolutionCard)
  1004. {
  1005. EffectList_ExceptAddedEffects(EffectTiming.None)
  1006. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1007. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1008. }
  1009. else
  1010. {
  1011. #region the effects of itself
  1012. if (PermanentOfThisCard() == null)
  1013. {
  1014. EffectList(EffectTiming.None)
  1015. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1016. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1017. }
  1018. #endregion
  1019. #region the effects of permanents
  1020. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1021. .Map(player => player.GetFieldPermanents())
  1022. .Flat()
  1023. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1024. .Flat()
  1025. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1026. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1027. #endregion
  1028. #region the effects of players
  1029. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1030. .Map(player => player.EffectList(EffectTiming.None))
  1031. .Flat()
  1032. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1033. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1034. #endregion
  1035. }
  1036. #endregion
  1037. return baseCardNames;
  1038. }
  1039. }
  1040. #endregion
  1041. #region card names
  1042. public List<string> CardNames
  1043. {
  1044. get
  1045. {
  1046. List<string> cardNames = BaseCardNames.Clone();
  1047. #region the effects of itself
  1048. EffectList_ExceptAddedEffects(EffectTiming.None)
  1049. .Filter(cardEffect => cardEffect != null)
  1050. .Filter(cardEffect => cardEffect is IChangeCardNamesEffect && cardEffect.CanUse(null))
  1051. .ForEach(cardEffect => cardNames = ((IChangeCardNamesEffect)cardEffect).ChangeCardNames(cardNames, this));
  1052. #endregion
  1053. return cardNames.Distinct().ToList();
  1054. }
  1055. }
  1056. #endregion
  1057. #region Whether target other card's name has same name as this
  1058. public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => EqualsCardName(cardName)) >= 1;
  1059. //public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => CardNames.Contains(cardName)) >= 1;
  1060. #endregion
  1061. #region whether this card has at least 1 card name that equals the string
  1062. /// <summary>
  1063. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1064. /// </summary>
  1065. /// <param name="string">value to check for</param>
  1066. /// <author>Mike Bunch</author>
  1067. public bool EqualsCardName(string name)
  1068. {
  1069. if (string.IsNullOrEmpty(name))
  1070. {
  1071. return false;
  1072. }
  1073. string replaced = name.Replace(" ", "");
  1074. string lower = name.ToLower();
  1075. return CardNames.Some((cardName) =>
  1076. cardName.Equals(name)
  1077. || cardName.Equals(replaced)
  1078. || cardName.Replace(" ", "").Equals(replaced)
  1079. || cardName.Equals(lower)
  1080. || cardName.ToLower().Equals(lower));
  1081. }
  1082. #endregion
  1083. #region whether this card has at least 1 card name that contains the string
  1084. /// <summary>
  1085. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1086. /// </summary>
  1087. /// <param trait="string">value to check for</param>
  1088. /// <author>Mike Bunch</author>
  1089. public bool ContainsCardName(string name)
  1090. {
  1091. if (string.IsNullOrEmpty(name))
  1092. {
  1093. return false;
  1094. }
  1095. string replaced = name.Replace(" ", "");
  1096. string lower = name.ToLower();
  1097. return CardNames.Some((cardName) =>
  1098. cardName.Contains(name)
  1099. || cardName.Contains(replaced)
  1100. || cardName.Contains(lower)
  1101. || cardName.ToLower().Contains(lower));
  1102. }
  1103. #endregion
  1104. #region All colors of a Digimon Card
  1105. public List<CardColor> DigimonCardColors
  1106. {
  1107. get
  1108. {
  1109. if (!IsDigimon)
  1110. {
  1111. return new List<CardColor>();
  1112. }
  1113. return CardColors;
  1114. }
  1115. }
  1116. #endregion
  1117. #region All Colors of an Option Card
  1118. public List<CardColor> OptionCardColors
  1119. {
  1120. get
  1121. {
  1122. if (!IsOption)
  1123. return new List<CardColor>();
  1124. if (IsDigimon) //Dual Card
  1125. {
  1126. return DualCardColors;
  1127. }
  1128. return CardColors;
  1129. }
  1130. }
  1131. #endregion
  1132. #region All colors of a card
  1133. public List<CardColor> AllCardColors
  1134. {
  1135. get
  1136. {
  1137. return CardColors.Concat(DualCardColors).ToList();
  1138. }
  1139. }
  1140. #endregion
  1141. #region whether this card has the mentioned color
  1142. public bool HasCardColor(CardColor cardColor, bool isOptionOnly = false, bool isDigimonOnly = false)
  1143. {
  1144. if (isOptionOnly && isDigimonOnly)
  1145. return false; //Shouldn't be done, just here to cover all bases with consistency
  1146. if (isOptionOnly)
  1147. {
  1148. return OptionCardColors.Contains(cardColor);
  1149. }
  1150. else if (isDigimonOnly)
  1151. {
  1152. return DigimonCardColors.Contains(cardColor);
  1153. }
  1154. return AllCardColors.Contains(cardColor); //check entire card
  1155. }
  1156. public bool HasDigimonColor(CardColor cardColor)
  1157. {
  1158. if (!IsDigimon)
  1159. return false;
  1160. return HasCardColor(cardColor, isDigimonOnly: true);
  1161. }
  1162. public bool HasOptionColor(CardColor cardColor)
  1163. {
  1164. if (!IsOption)
  1165. return false;
  1166. return HasCardColor(cardColor, isOptionOnly: true);
  1167. }
  1168. #endregion
  1169. #region whether this card has at least 1 card name that contains "Greymon"
  1170. public bool HasGreymonName
  1171. {
  1172. get
  1173. {
  1174. if (CardNames.Some((cardName) => (cardName.Contains("Greymon") || cardName.Contains("greymon"))
  1175. && cardName != "DoruGreymon"
  1176. && cardName != "BurningGreymon"
  1177. && cardName != "DexDoruGreymon"))
  1178. {
  1179. return true;
  1180. }
  1181. return false;
  1182. }
  1183. }
  1184. #endregion
  1185. #region whether this card has at least 1 card name that contains "Garurumon"
  1186. public bool HasGarurumonName
  1187. {
  1188. get
  1189. {
  1190. if (CardNames.Some((cardName) => (cardName.Contains("Garurumon") || cardName.Contains("garurumon"))
  1191. && cardName != "KendoGarurumon"))
  1192. {
  1193. return true;
  1194. }
  1195. return false;
  1196. }
  1197. }
  1198. #endregion
  1199. #region whether this card has at least 1 card name that contains "Impmon"
  1200. public bool HasImpmonName
  1201. {
  1202. get
  1203. {
  1204. if (CardNames.Some((cardName) => (cardName.Contains("Impmon") || cardName.Contains("impmon"))
  1205. && cardName != "Blimpmon"))
  1206. {
  1207. return true;
  1208. }
  1209. return false;
  1210. }
  1211. }
  1212. #endregion
  1213. #region whether this card has at least 1 card name that contains "Dramon"
  1214. public bool HasDramonName
  1215. {
  1216. get
  1217. {
  1218. if (CardNames.Some((cardName) => (cardName.Contains("Dramon") || cardName.Contains("dramon"))
  1219. && cardName != "Indramon"))
  1220. {
  1221. return true;
  1222. }
  1223. return false;
  1224. }
  1225. }
  1226. #endregion
  1227. #region whether this card has at least 1 card name that contains "AAntibody"
  1228. public bool HasXAntiBodyName => CardNames.Some(DataBase.IsContainingXAntibodyString);
  1229. #endregion
  1230. #region whether this card has at least 1 trait that equals the string
  1231. /// <summary>
  1232. /// Used to check if specified trait is exactly in cards trait values ("Sky Dragon" is not "Dragon")
  1233. /// </summary>
  1234. /// <param trait="string">value to check for</param>
  1235. /// <author>Mike Bunch</author>
  1236. public bool EqualsTraits(string trait)
  1237. {
  1238. if (string.IsNullOrEmpty(trait))
  1239. return false;
  1240. string replaced = trait.Replace(" ", "").ToLower();
  1241. return CardTraits.Some(cardTrait => cardTrait.Equals(trait) || cardTrait.ToLower().Equals(replaced));
  1242. }
  1243. #endregion
  1244. #region whether this card has at least 1 trait that contains the string
  1245. /// <summary>
  1246. /// Used to check if specified trait is within cards trait values ("Sky Dragon" contains "Dragon")
  1247. /// </summary>
  1248. /// <param trait="string">value to check for</param>
  1249. /// <author>Mike Bunch</author>
  1250. public bool ContainsTraits(string trait)
  1251. {
  1252. if (string.IsNullOrEmpty(trait))
  1253. return false;
  1254. string replaced = trait.Replace(" ", "").ToLower();
  1255. return CardTraits.Some(cardTrait => cardTrait.Contains(trait) || cardTrait.ToLower().Contains(replaced));
  1256. }
  1257. #endregion
  1258. #region whether this card has at least 1 trait that contains "Bird"
  1259. public bool HasBirdTraits
  1260. {
  1261. get
  1262. {
  1263. if (ContainsTraits("Avian"))
  1264. {
  1265. return true;
  1266. }
  1267. if (ContainsTraits("Bird"))
  1268. {
  1269. return true;
  1270. }
  1271. return false;
  1272. }
  1273. }
  1274. #endregion
  1275. #region whether this card has at least 1 trait that contains "Beast"
  1276. public bool HasBeastTraits
  1277. {
  1278. get
  1279. {
  1280. if (ContainsTraits("Beast"))
  1281. {
  1282. return true;
  1283. }
  1284. if (ContainsTraits("Animal") && !ContainsTraits("Sea"))
  1285. {
  1286. return true;
  1287. }
  1288. if (ContainsTraits("Sovereign"))
  1289. {
  1290. return true;
  1291. }
  1292. return false;
  1293. }
  1294. }
  1295. #endregion
  1296. #region whether this card has at least 1 trait that contains "Plant"
  1297. public bool HasPlantTraits
  1298. {
  1299. get
  1300. {
  1301. if (ContainsTraits("Vegetation"))
  1302. {
  1303. return true;
  1304. }
  1305. if (ContainsTraits("Plant"))
  1306. {
  1307. return true;
  1308. }
  1309. return false;
  1310. }
  1311. }
  1312. #endregion
  1313. #region whether this card has at least 1 trait that contains "Fairy"
  1314. public bool HasFairyTraits
  1315. {
  1316. get
  1317. {
  1318. if (ContainsTraits("Fairy"))
  1319. {
  1320. return true;
  1321. }
  1322. return false;
  1323. }
  1324. }
  1325. #endregion
  1326. #region whether this card has at least 1 trait that contains "Dragon"
  1327. public bool HasDragonTraits
  1328. {
  1329. get
  1330. {
  1331. if (ContainsTraits("Dragon"))
  1332. {
  1333. return true;
  1334. }
  1335. if (ContainsTraits("saur"))
  1336. {
  1337. return true;
  1338. }
  1339. if (ContainsTraits("Ceratopsian"))
  1340. {
  1341. return true;
  1342. }
  1343. return false;
  1344. }
  1345. }
  1346. #endregion
  1347. #region whether this card has at least 1 trait that contains "Aqua"
  1348. public bool HasAquaTraits
  1349. {
  1350. get
  1351. {
  1352. if (ContainsTraits("Aqua"))
  1353. {
  1354. return true;
  1355. }
  1356. if (ContainsTraits("Sea Animal"))
  1357. {
  1358. return true;
  1359. }
  1360. if (ContainsTraits("SeaAnimal"))
  1361. {
  1362. return true;
  1363. }
  1364. return false;
  1365. }
  1366. }
  1367. #endregion
  1368. #region whether this card has at least 1 trait that contains "Angel"
  1369. public bool HasAngelTraits
  1370. {
  1371. get
  1372. {
  1373. if (CardTraits.Count((trait) => (trait.Contains("Angel") || trait.Contains("angel")) && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1374. {
  1375. return true;
  1376. }
  1377. if (ContainsTraits("Cherub"))
  1378. {
  1379. return true;
  1380. }
  1381. if (ContainsTraits("Throne"))
  1382. {
  1383. return true;
  1384. }
  1385. if (ContainsTraits("Authority"))
  1386. {
  1387. return true;
  1388. }
  1389. if (ContainsTraits("Seraph"))
  1390. {
  1391. return true;
  1392. }
  1393. if (ContainsTraits("Virtue"))
  1394. {
  1395. return true;
  1396. }
  1397. return false;
  1398. }
  1399. }
  1400. #endregion
  1401. #region whether this card has 1 of the "Angel", "Archangel" or "Three Great Angels" trait
  1402. public bool HasAngelTraitRestrictive
  1403. {
  1404. get
  1405. {
  1406. if (ContainsTraits("Three Great Angels") || ContainsTraits("ThreeGreatAngels"))
  1407. {
  1408. return true;
  1409. }
  1410. if (ContainsTraits("Archangel"))
  1411. {
  1412. return true;
  1413. }
  1414. if (CardTraits.Count(trait =>
  1415. (trait.Contains("Angel") || trait.Contains("angel"))
  1416. && trait != "Archangel"
  1417. && trait != "Fallen Angel" && trait != "FallenAngel"
  1418. && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1419. {
  1420. return true;
  1421. }
  1422. return false;
  1423. }
  1424. }
  1425. #endregion
  1426. #region whether this card has at least 1 trait that contains "Avian", "Bird", "Beast", "Animal", "Sovereign", other than "Sea Animal"
  1427. public bool HasAvianBeastAnimalTraits
  1428. {
  1429. get
  1430. {
  1431. if (ContainsTraits("Avian"))
  1432. return true;
  1433. if (ContainsTraits("Bird"))
  1434. return true;
  1435. if (ContainsTraits("Beast"))
  1436. return true;
  1437. if (ContainsTraits("Animal") && !ContainsTraits("Sea Animal"))
  1438. return true;
  1439. if (ContainsTraits("Sovereign"))
  1440. return true;
  1441. return false;
  1442. }
  1443. }
  1444. #endregion
  1445. #region whether this card has at least 1 trait that contains "Hybrid", "Ten Warriors"
  1446. public bool HasHybridTenWarriorsTraits
  1447. {
  1448. get
  1449. {
  1450. if (ContainsTraits("Hybrid"))
  1451. return true;
  1452. if (ContainsTraits("Ten Warriors"))
  1453. return true;
  1454. return false;
  1455. }
  1456. }
  1457. #endregion
  1458. #region whether this card has "XAntibody" trait
  1459. public bool HasXAntibodyTraits => CardTraits.Some(DataBase.IsXAntibodyString);
  1460. #endregion
  1461. #region whether this card has "Royal Knight" trait
  1462. public bool HasRoyalKnightTraits
  1463. {
  1464. get
  1465. {
  1466. return EqualsTraits("Royal Knight");
  1467. }
  1468. }
  1469. #endregion
  1470. #region whether this card has "SoC" trait
  1471. public bool HasSocTraits
  1472. {
  1473. get
  1474. {
  1475. if (CardTraits.Contains("SoC"))
  1476. {
  1477. return true;
  1478. }
  1479. return false;
  1480. }
  1481. }
  1482. #endregion
  1483. #region whether this card has "D-Brigade"/"DigiPolice trait
  1484. public bool HasDBrigadeorDigiPoliceTraits
  1485. {
  1486. get
  1487. {
  1488. if (CardTraits.Contains("D-Brigade"))
  1489. {
  1490. return true;
  1491. }
  1492. if (CardTraits.Contains("DigiPolice"))
  1493. {
  1494. return true;
  1495. }
  1496. return false;
  1497. }
  1498. }
  1499. #endregion
  1500. #region whether this card has at least 1 trait that contains "Beast Dragon"
  1501. public bool HasBeastDragonTraits
  1502. {
  1503. get
  1504. {
  1505. if (ContainsTraits("BeastDragon"))
  1506. {
  1507. return true;
  1508. }
  1509. if (ContainsTraits("Beast Dragon"))
  1510. {
  1511. return true;
  1512. }
  1513. return false;
  1514. }
  1515. }
  1516. #endregion
  1517. #region whether this card has at least 1 trait that contains "DigiPolice"
  1518. public bool HasDigiPoliceTraits
  1519. {
  1520. get
  1521. {
  1522. if (ContainsTraits("DigiPolice"))
  1523. {
  1524. return true;
  1525. }
  1526. return false;
  1527. }
  1528. }
  1529. #endregion
  1530. #region whether this card has at least 1 trait that contains "Light Fang" or "Night Claw"
  1531. public bool HasLightFangNightClawTraits => ContainsTraits("Light Fang") || ContainsTraits("Night Claw");
  1532. #endregion
  1533. #region whether this card has at least 1 trait that contains "Light Fang/Night Claw"
  1534. public bool HasLightFangOrNightClawTraits
  1535. {
  1536. get
  1537. {
  1538. if (ContainsTraits("Light Fang"))
  1539. {
  1540. return true;
  1541. }
  1542. if (ContainsTraits("Night Claw"))
  1543. {
  1544. return true;
  1545. }
  1546. return false;
  1547. }
  1548. }
  1549. #endregion
  1550. #region [Onmyōjutsu] or [Plug-In] trait
  1551. public bool HasOnmyoOrPluginTraits
  1552. {
  1553. get
  1554. {
  1555. if (EqualsTraits("Plug-In"))
  1556. {
  1557. return true;
  1558. }
  1559. if (EqualsTraits("Onmyōjutsu"))
  1560. {
  1561. return true;
  1562. }
  1563. return false;
  1564. }
  1565. }
  1566. #endregion
  1567. #region whether this card has the string in text
  1568. public bool HasText(string text)
  1569. {
  1570. if (String.IsNullOrEmpty(text)) return false;
  1571. text = DataBase.ReplaceToASCII(text);
  1572. string replaced = text.Replace(" ", "");
  1573. string lower = text.ToLower();
  1574. List<string> checkStrings = new List<string>()
  1575. {
  1576. DataBase.ReplaceToASCII(_cEntity_Base.CardName_ENG),
  1577. DataBase.ReplaceToASCII(_cEntity_Base.EffectDiscription_ENG),
  1578. DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG),
  1579. DataBase.ReplaceToASCII(_cEntity_Base.SecurityEffectDiscription_ENG),
  1580. };
  1581. foreach (string attribute in _cEntity_Base.Attribute_ENG)
  1582. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1583. foreach (string attribute in _cEntity_Base.Type_ENG)
  1584. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1585. if (jogressCondition.Count > 0)
  1586. {
  1587. foreach (JogressCondition jogress in jogressCondition)
  1588. {
  1589. foreach (JogressConditionElement element in jogress.elements)
  1590. checkStrings.Add(element.SelectMessage);
  1591. }
  1592. }
  1593. foreach (string checkString in checkStrings)
  1594. {
  1595. if (!string.IsNullOrEmpty(checkString))
  1596. {
  1597. if (checkString.Contains(text))
  1598. {
  1599. return true;
  1600. }
  1601. if (checkString.Contains(replaced))
  1602. {
  1603. return true;
  1604. }
  1605. if (checkString.Contains(lower))
  1606. {
  1607. return true;
  1608. }
  1609. }
  1610. }
  1611. return false;
  1612. }
  1613. #endregion
  1614. #region whether this card has <Save> in text
  1615. public bool HasSaveText => HasText("<Save>");
  1616. #endregion
  1617. #region whether this card has "Pulsemon" in text
  1618. public bool HasPulsemonText => HasText("Pulsemon");
  1619. #endregion
  1620. #region card names checked when digixros
  1621. public List<string> CardNames_DigiXros
  1622. {
  1623. get
  1624. {
  1625. List<string> cardNames_DigiXros = CardNames.Clone();
  1626. #region the effects of itself
  1627. EffectList(EffectTiming.None)
  1628. .Filter(cardEffect => cardEffect is IChangeCardNamesForDigiXrosEffect && cardEffect.CanUse(null))
  1629. .ForEach(cardEffect => cardNames_DigiXros = ((IChangeCardNamesForDigiXrosEffect)cardEffect).ChangeCardNamesForDigiXros(cardNames_DigiXros, this));
  1630. #endregion
  1631. return cardNames_DigiXros;
  1632. }
  1633. }
  1634. #endregion
  1635. #region card level checked when Assembly
  1636. public List<int> Level_Assembly
  1637. {
  1638. get
  1639. {
  1640. List<int> cardLevel_Assembly = new List<int>();
  1641. cardLevel_Assembly.Add(TreatedLevel);
  1642. #region the effects of itself
  1643. EffectList(EffectTiming.None)
  1644. .Filter(cardEffect => cardEffect is IChangeCardLevelForAssemblyEffect && cardEffect.CanUse(null))
  1645. .ForEach(cardEffect => cardLevel_Assembly = ((IChangeCardLevelForAssemblyEffect)cardEffect).ChangeCardLevelForAssembly(cardLevel_Assembly, this));
  1646. #endregion
  1647. return cardLevel_Assembly;
  1648. }
  1649. }
  1650. #endregion
  1651. #region whether this card has at least 1 card name checked when digixros that equals the string
  1652. /// <summary>
  1653. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1654. /// </summary>
  1655. /// <param name="string">value to check for</param>
  1656. /// <author>Mike Bunch</author>
  1657. public bool EqualsCardNameDigiXros(string name)
  1658. {
  1659. if (string.IsNullOrEmpty(name))
  1660. {
  1661. return false;
  1662. }
  1663. string replaced = name.Replace(" ", "");
  1664. string lower = name.ToLower();
  1665. return CardNames_DigiXros.Some((cardName) =>
  1666. cardName.Equals(name)
  1667. || cardName.Equals(replaced)
  1668. || cardName.Equals(lower)
  1669. || cardName.ToLower().Equals(lower));
  1670. }
  1671. #endregion
  1672. #region whether this card has at least 1 card name that contains the string
  1673. /// <summary>
  1674. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1675. /// </summary>
  1676. /// <param trait="string">value to check for</param>
  1677. /// <author>Mike Bunch</author>
  1678. public bool ContainsCardNameDigiXros(string name)
  1679. {
  1680. if (string.IsNullOrEmpty(name))
  1681. {
  1682. return false;
  1683. }
  1684. string replaced = name.Replace(" ", "");
  1685. string lower = name.ToLower();
  1686. return CardNames_DigiXros.Some((cardName) =>
  1687. cardName.Contains(name)
  1688. || cardName.Contains(replaced)
  1689. || cardName.Contains(lower)
  1690. || cardName.ToLower().Contains(lower));
  1691. }
  1692. #endregion
  1693. #region preferered frame to play
  1694. public FieldCardFrame PreferredFrame()
  1695. {
  1696. FieldCardFrame PreferredFrame = Owner.fieldCardFrames[0];
  1697. List<FieldCardFrame> fieldCardFrames =
  1698. Owner.fieldCardFrames
  1699. .Filter(fieldCardFrame => fieldCardFrame.IsBattleAreaFrame()
  1700. && fieldCardFrame.IsEmptyFrame());
  1701. if (_cEntity_Base != null)
  1702. {
  1703. if (IsDigimon || IsDigiEgg)
  1704. {
  1705. if (Owner.isYou)
  1706. {
  1707. fieldCardFrames = fieldCardFrames
  1708. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1709. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1710. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1711. .ToList();
  1712. }
  1713. else
  1714. {
  1715. fieldCardFrames = fieldCardFrames
  1716. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1717. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1718. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1719. .ToList();
  1720. int[] correctOrder = new int[] { 4, 3, 5, 2, 6, 1, 7, 0, 8, 11, 10, 12, 9, 13, 14, 15, };
  1721. List<FieldCardFrame> correctOrderFrames = new List<FieldCardFrame>();
  1722. for (int i = 0; i < correctOrder.Length; i++)
  1723. {
  1724. foreach (FieldCardFrame frame in fieldCardFrames)
  1725. {
  1726. if (frame.FrameID == correctOrder[i])
  1727. {
  1728. correctOrderFrames.Add(frame);
  1729. }
  1730. }
  1731. }
  1732. fieldCardFrames = correctOrderFrames;
  1733. }
  1734. }
  1735. else if (IsTamer || IsOption)
  1736. {
  1737. if (Owner.isYou)
  1738. {
  1739. fieldCardFrames = fieldCardFrames
  1740. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1741. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1742. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1743. .ToList();
  1744. }
  1745. else
  1746. {
  1747. fieldCardFrames = fieldCardFrames
  1748. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1749. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1750. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1751. .ToList();
  1752. }
  1753. }
  1754. if (fieldCardFrames.Count >= 1)
  1755. {
  1756. PreferredFrame = fieldCardFrames[0];
  1757. }
  1758. }
  1759. return PreferredFrame;
  1760. }
  1761. #endregion
  1762. #region Whether this card has DP
  1763. public bool HasDP => IsDigimon || _cEntity_Base.DP > 0 || BaseDP > 0;
  1764. #endregion
  1765. #region base card DP
  1766. public int BaseCardDP => _cEntity_Base.DP;
  1767. public int BaseDP = 0;
  1768. #endregion
  1769. #region DP
  1770. public int CardDP
  1771. {
  1772. get
  1773. {
  1774. int cardDP = -1;
  1775. if (HasDP)
  1776. {
  1777. cardDP = BaseCardDP;
  1778. cardDP += BaseDP;
  1779. #region card effects that change card DP
  1780. List<ICardEffect> changeCardDPCardEffects = new List<ICardEffect>();
  1781. #region the effects of permanents
  1782. changeCardDPCardEffects = changeCardDPCardEffects
  1783. .Concat(
  1784. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1785. .Map(player => player.GetFieldPermanents())
  1786. .Flat()
  1787. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1788. .Flat()
  1789. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1790. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1791. .ToList();
  1792. #endregion
  1793. #region the effects of players
  1794. changeCardDPCardEffects = changeCardDPCardEffects
  1795. .Concat(
  1796. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1797. .Map(player => player.EffectList(EffectTiming.None))
  1798. .Flat()
  1799. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1800. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1801. .ToList();
  1802. #endregion
  1803. List<ICardEffect> cardEffects_ChangeDP_IsUpDown = changeCardDPCardEffects
  1804. .Filter(cardEffect => ((IChangeCardDPEffect)cardEffect).IsUpDown());
  1805. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = changeCardDPCardEffects
  1806. .Filter(cardEffect => !((IChangeCardDPEffect)cardEffect).IsUpDown());
  1807. cardEffects_ChangeDP_IsUpDown
  1808. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1809. cardEffects_ChangeDP_NotIsUpDown
  1810. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1811. #endregion
  1812. }
  1813. return Math.Max(0, cardDP);
  1814. }
  1815. }
  1816. #endregion
  1817. #region Link DP
  1818. public int LinkDP => _cEntity_Base.LinkDP;
  1819. #endregion
  1820. #region Set DP - Must be used in conjunction with when removed field
  1821. public void SetDP(int value)
  1822. {
  1823. BaseDP = value;
  1824. }
  1825. #endregion
  1826. #region whether this card is token
  1827. public bool IsToken { get; private set; } = false;
  1828. public void SetIsToken(bool isToken) => IsToken = isToken;
  1829. #endregion
  1830. #region Will this card be trashed from sources
  1831. public bool willBeRemoveSources { get; set; } = false;
  1832. #endregion
  1833. #region whether this card can not be trashed from digivolution cards
  1834. public bool CanNotTrashFromDigivolutionCards(ICardEffect _cardEffect)
  1835. {
  1836. if (willBeRemoveSources)
  1837. return true;
  1838. #region the effects of permanents
  1839. if (GManager.instance.turnStateMachine.gameContext.Players
  1840. .Map(player => player.GetFieldPermanents())
  1841. .Flat()
  1842. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1843. .Flat()
  1844. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1845. && cardEffect.CanUse(null)
  1846. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1847. {
  1848. return true;
  1849. }
  1850. #endregion
  1851. #region the effects of players
  1852. if (GManager.instance.turnStateMachine.gameContext.Players
  1853. .Map(player => player.EffectList(EffectTiming.None))
  1854. .Flat()
  1855. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1856. && cardEffect.CanUse(null)
  1857. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1858. {
  1859. return true;
  1860. }
  1861. #endregion
  1862. #region the effects of itself
  1863. if (PermanentOfThisCard() == null)
  1864. {
  1865. if (EffectList(EffectTiming.None)
  1866. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1867. && cardEffect.CanUse(null)
  1868. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1869. {
  1870. return true;
  1871. }
  1872. }
  1873. #endregion
  1874. return false;
  1875. }
  1876. #endregion
  1877. #region whether this card has [Blocker]
  1878. public bool HasBlocker =>
  1879. EffectList(EffectTiming.None)
  1880. .Some(cardEffect => cardEffect is BlockerClass
  1881. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect);
  1882. #endregion
  1883. #region whether this card has [DigiBurst]
  1884. public bool HasDigiBurst
  1885. {
  1886. get
  1887. {
  1888. if (_cEntity_Base != null)
  1889. {
  1890. if (!string.IsNullOrEmpty(_cEntity_Base.EffectDiscription_JPN))
  1891. {
  1892. bool result = Regex.IsMatch(_cEntity_Base.EffectDiscription_JPN, DataBase.DigiburstRegex);
  1893. if (result)
  1894. {
  1895. return true;
  1896. }
  1897. }
  1898. }
  1899. return false;
  1900. }
  1901. }
  1902. #endregion
  1903. #region whether this card has [DigiXros]
  1904. public bool HasDigiXros => digiXrosCondition != null;
  1905. #endregion
  1906. #region whether this card has [Assembly]
  1907. public bool HasAssembly => assemblyCondition != null;
  1908. #endregion
  1909. #region traits
  1910. public List<string> CardTraits
  1911. {
  1912. get
  1913. {
  1914. List<string> traits =
  1915. _cEntity_Base.Form_ENG
  1916. .Filter(s => !string.IsNullOrEmpty(s))
  1917. .Concat(_cEntity_Base.Attribute_ENG
  1918. .Filter(s => !string.IsNullOrEmpty(s)))
  1919. .Concat(_cEntity_Base.Type_ENG
  1920. .Filter(s => !string.IsNullOrEmpty(s)))
  1921. .ToList();
  1922. #region the effects of itself
  1923. EffectList(EffectTiming.None)
  1924. .Filter(cardEffect => cardEffect is IChangeTraitsEffect && cardEffect.CanUse(null))
  1925. .ForEach(cardEffect => traits = ((IChangeTraitsEffect)cardEffect).ChangTraits(traits, this));
  1926. #endregion
  1927. return traits;
  1928. }
  1929. }
  1930. #endregion
  1931. #region whether this card has [On Deletion] effect
  1932. public bool HasOnDeletionEffect =>
  1933. EffectList(EffectTiming.OnDestroyedAnyone)
  1934. .Some(cardEffect => cardEffect is ActivateICardEffect
  1935. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1936. && cardEffect.IsOnDeletion);
  1937. #endregion
  1938. #region whether this card has [On Play] effect
  1939. public bool HasOnPlayEffect =>
  1940. EffectList(EffectTiming.OnEnterFieldAnyone)
  1941. .Some(cardEffect => cardEffect is ActivateICardEffect
  1942. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1943. && cardEffect.IsOnPlay);
  1944. #endregion
  1945. #region whether this card has [When Digivolving] effect
  1946. public bool HasWhenDigivolvingEffect =>
  1947. EffectList(EffectTiming.OnEnterFieldAnyone)
  1948. .Some(cardEffect => cardEffect is ActivateICardEffect
  1949. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1950. && cardEffect.IsWhenDigivolving);
  1951. #endregion
  1952. #region whether this card has [Digisorption]
  1953. public bool HasDigisorption =>
  1954. EffectList(EffectTiming.BeforePayCost)
  1955. .Some(cardEffect => cardEffect is ActivateICardEffect
  1956. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1957. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1958. && cardEffect.EffectDiscription.Contains("Digisorption -"));
  1959. #endregion
  1960. #region whether this card has [Blitz]
  1961. public bool HasBlitz =>
  1962. EffectList(EffectTiming.OnEnterFieldAnyone)
  1963. .Some(cardEffect => cardEffect is ActivateICardEffect
  1964. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1965. && (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfCard(this)))
  1966. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1967. && cardEffect.EffectDiscription.Contains("Blitz"));
  1968. #endregion
  1969. #region whether this card has [Retaliation]
  1970. public bool HasRetaliation =>
  1971. EffectList(EffectTiming.OnDestroyedAnyone)
  1972. .Some(cardEffect => cardEffect is ActivateICardEffect
  1973. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1974. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1975. && cardEffect.EffectName == "Retaliation");
  1976. #endregion
  1977. #region whether this card has [Fortitude]
  1978. public bool HasFortitude =>
  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 == "Fortitude");
  1984. #endregion
  1985. #region whether this card has inherited effect
  1986. public bool HasInheritedEffect
  1987. {
  1988. get
  1989. {
  1990. foreach (EffectTiming timing in Enum.GetValues(typeof(EffectTiming)))
  1991. {
  1992. if (EffectList(timing)
  1993. .Some(cardEffect => cardEffect.IsInheritedEffect
  1994. && !cardEffect.IsDisabled))
  1995. {
  1996. return true;
  1997. }
  1998. }
  1999. return false;
  2000. }
  2001. }
  2002. #endregion
  2003. #region DNA digivolution requirement
  2004. public List<JogressCondition> jogressCondition
  2005. {
  2006. get
  2007. {
  2008. List<JogressCondition> addJogressConditionEffect =
  2009. EffectList(EffectTiming.None)
  2010. .Filter(cardEffect => cardEffect is IAddJogressConditionEffect
  2011. && cardEffect.CanUse(null)
  2012. && ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this) != null)
  2013. .Select(cardEffect => ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this))
  2014. .ToList();
  2015. return addJogressConditionEffect;
  2016. }
  2017. }
  2018. #endregion
  2019. #region Link requirement
  2020. public LinkCondition linkCondition
  2021. {
  2022. get
  2023. {
  2024. ICardEffect addLinkConditonEffect =
  2025. EffectList(EffectTiming.None)
  2026. .Find(cardEffect => cardEffect is IAddLinkConditionEffect
  2027. && cardEffect.CanUse(null)
  2028. && ((IAddLinkConditionEffect)cardEffect).GetLinkCondition(this) != null);
  2029. if (addLinkConditonEffect != null) return ((IAddLinkConditionEffect)addLinkConditonEffect).GetLinkCondition(this);
  2030. return null;
  2031. }
  2032. }
  2033. #endregion
  2034. #region whether this card can DNA digivolve
  2035. public bool CanPlayJogress(bool PayCost)
  2036. {
  2037. if (jogressCondition != null)
  2038. {
  2039. foreach (JogressCondition condition in jogressCondition)
  2040. {
  2041. if (Owner.GetBattleAreaDigimons().Count >= condition.elements.Length)
  2042. {
  2043. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(Owner.GetBattleAreaDigimons(), condition.elements.Length).ToList();
  2044. foreach (Permanent[] permanents in permanentsList)
  2045. {
  2046. if (permanents != null)
  2047. {
  2048. if (permanents.Length == condition.elements.Length)
  2049. {
  2050. if (permanents.Length == 2)
  2051. {
  2052. if (condition.elements[0].EvoRootCondition(permanents[0]) && !this.CanNotEvolve(permanents[0]))
  2053. {
  2054. if (condition.elements[1].EvoRootCondition(permanents[1]) && !this.CanNotEvolve(permanents[1]))
  2055. {
  2056. if (PayCost)
  2057. {
  2058. int cost = condition.cost;
  2059. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, permanents.ToList(), checkAvailability: true);
  2060. if (Owner.MaxMemoryCost < cost)
  2061. {
  2062. return false;
  2063. }
  2064. }
  2065. return true;
  2066. }
  2067. }
  2068. }
  2069. }
  2070. }
  2071. }
  2072. }
  2073. }
  2074. }
  2075. return false;
  2076. }
  2077. #endregion
  2078. #region whether target permanent can DNA digivolve into this card
  2079. public bool CanJogressFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2080. {
  2081. if (targetPermanent != null)
  2082. {
  2083. if (targetPermanent.TopCard != null)
  2084. {
  2085. foreach (JogressCondition condition in jogressCondition)
  2086. {
  2087. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  2088. {
  2089. if (this.CanPlayJogress(PayCost))
  2090. {
  2091. if (condition != null)
  2092. {
  2093. if (condition.elements.ToList().Count((element) => element.EvoRootCondition(targetPermanent)) >= 1)
  2094. {
  2095. if (!this.CanNotEvolve(targetPermanent))
  2096. {
  2097. if (PayCost)
  2098. {
  2099. int cost = condition.cost;
  2100. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent, new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2101. if (Owner.MaxMemoryCost < cost)
  2102. {
  2103. return false;
  2104. }
  2105. }
  2106. return true;
  2107. }
  2108. }
  2109. }
  2110. }
  2111. }
  2112. }
  2113. }
  2114. }
  2115. return false;
  2116. }
  2117. #endregion
  2118. #region whether target permanents can DNA digivolve into this card
  2119. public bool CanJogressFromTargetPermanents(List<Permanent> targetPermanents, bool PayCost)
  2120. {
  2121. if (targetPermanents != null)
  2122. {
  2123. if (targetPermanents.Count == 2)
  2124. {
  2125. if (this.CanPlayJogress(PayCost))
  2126. {
  2127. foreach (JogressCondition condition in jogressCondition)
  2128. {
  2129. if (condition != null)
  2130. {
  2131. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(targetPermanents, 2).ToList();
  2132. foreach (Permanent[] permanents in permanentsList)
  2133. {
  2134. if (condition.elements.Length == permanents.Length)
  2135. {
  2136. bool canJogress = true;
  2137. for (int i = 0; i < permanents.Length; i++)
  2138. {
  2139. if (permanents[i] != null)
  2140. {
  2141. if (permanents[i].TopCard != null)
  2142. {
  2143. if ((!condition.elements[i].EvoRootCondition(permanents[i])) || this.CanNotEvolve(permanents[i]))
  2144. {
  2145. canJogress = false;
  2146. break;
  2147. }
  2148. }
  2149. }
  2150. }
  2151. if (canJogress)
  2152. {
  2153. return true;
  2154. }
  2155. }
  2156. }
  2157. }
  2158. }
  2159. }
  2160. }
  2161. }
  2162. return false;
  2163. }
  2164. #endregion
  2165. #region whether this card has level
  2166. public bool HasLevel
  2167. {
  2168. get
  2169. {
  2170. if (_cEntity_Base == null || _cEntity_Base.HasLevel)
  2171. {
  2172. return true;
  2173. }
  2174. return false;
  2175. }
  2176. }
  2177. #endregion
  2178. #region whether this card is level 2
  2179. public bool IsLevel2 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 2;
  2180. #endregion
  2181. #region whether this card is level 3
  2182. public bool IsLevel3 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 3;
  2183. #endregion
  2184. #region whether this card is level 4
  2185. public bool IsLevel4 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 4;
  2186. #endregion
  2187. #region whether this card is level 5
  2188. public bool IsLevel5 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 5;
  2189. #endregion
  2190. #region whether this card is level 6
  2191. public bool IsLevel6 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 6;
  2192. #endregion
  2193. #region whether this card is linked
  2194. public bool IsLinked
  2195. {
  2196. get
  2197. {
  2198. return PermanentOfThisCard().LinkedCards.Contains(this);
  2199. }
  2200. }
  2201. #endregion
  2202. #region DigiXros requirement
  2203. public DigiXrosCondition digiXrosCondition
  2204. {
  2205. get
  2206. {
  2207. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2208. {
  2209. if (cardEffect is IAddDigiXrosConditionEffect)
  2210. {
  2211. if (cardEffect.CanUse(null))
  2212. {
  2213. DigiXrosCondition digiXrosCondition = ((IAddDigiXrosConditionEffect)cardEffect).GetDigiXrosCondition(this);
  2214. if (digiXrosCondition != null)
  2215. {
  2216. return digiXrosCondition;
  2217. }
  2218. }
  2219. }
  2220. }
  2221. return null;
  2222. }
  2223. }
  2224. #endregion
  2225. #region Blast Digivolution requirement
  2226. public BurstDigivolutionCondition burstDigivolutionCondition
  2227. {
  2228. get
  2229. {
  2230. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2231. {
  2232. if (cardEffect is IAddBurstDigivolutionConditionEffect)
  2233. {
  2234. if (cardEffect.CanUse(null))
  2235. {
  2236. BurstDigivolutionCondition burstDigivolutionCondition = ((IAddBurstDigivolutionConditionEffect)cardEffect).GetBurstDigivolutionCondition(this);
  2237. if (burstDigivolutionCondition != null)
  2238. {
  2239. return burstDigivolutionCondition;
  2240. }
  2241. }
  2242. }
  2243. }
  2244. return null;
  2245. }
  2246. }
  2247. #endregion
  2248. #region App Fusion requirement
  2249. public AppFusionCondition appFusionCondition
  2250. {
  2251. get
  2252. {
  2253. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2254. {
  2255. if (cardEffect is IAddAppFusionConditionEffect)
  2256. {
  2257. if (cardEffect.CanUse(null))
  2258. {
  2259. AppFusionCondition appFusionCondition = ((IAddAppFusionConditionEffect)cardEffect).GetAppFusionCondition(this);
  2260. if (appFusionCondition != null)
  2261. {
  2262. return appFusionCondition;
  2263. }
  2264. }
  2265. }
  2266. }
  2267. return null;
  2268. }
  2269. }
  2270. #endregion
  2271. #region Assembly requirement
  2272. public AssemblyCondition assemblyCondition
  2273. {
  2274. get
  2275. {
  2276. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2277. {
  2278. if (cardEffect is IAddAssemblyConditionEffect)
  2279. {
  2280. if (cardEffect.CanUse(null))
  2281. {
  2282. AssemblyCondition assemblyCondition = ((IAddAssemblyConditionEffect)cardEffect).GetAssemblyCondition(this);
  2283. if (assemblyCondition != null)
  2284. {
  2285. return assemblyCondition;
  2286. }
  2287. }
  2288. }
  2289. }
  2290. return null;
  2291. }
  2292. }
  2293. #endregion
  2294. #region whether this card can Burst digivolve
  2295. public bool CanPlayBurst(bool PayCost)
  2296. {
  2297. if (burstDigivolutionCondition != null)
  2298. {
  2299. if (PayCost)
  2300. {
  2301. int cost = burstDigivolutionCondition.cost;
  2302. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2303. if (Owner.MaxMemoryCost < cost)
  2304. {
  2305. return false;
  2306. }
  2307. }
  2308. List<Permanent> availableDigimon = new List<Permanent>();
  2309. availableDigimon.AddRange(Owner.GetBattleAreaDigimons());
  2310. availableDigimon.AddRange(Owner.GetBreedingAreaPermanents());
  2311. if (availableDigimon.Count >= 1)
  2312. {
  2313. foreach (Permanent digimon in availableDigimon)
  2314. {
  2315. if (digimon != null)
  2316. {
  2317. if (!this.CanNotEvolve(digimon))
  2318. {
  2319. if (burstDigivolutionCondition.digimonCondition(digimon))
  2320. {
  2321. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2322. {
  2323. if (tamer != digimon)
  2324. {
  2325. if (burstDigivolutionCondition.tamerCondition(tamer))
  2326. {
  2327. if (!tamer.CannotReturnToHand(null))
  2328. {
  2329. if (PayCost)
  2330. {
  2331. int cost = burstDigivolutionCondition.cost;
  2332. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
  2333. if (Owner.MaxMemoryCost < cost)
  2334. {
  2335. return false;
  2336. }
  2337. }
  2338. return true;
  2339. }
  2340. }
  2341. }
  2342. }
  2343. }
  2344. }
  2345. }
  2346. }
  2347. }
  2348. }
  2349. return false;
  2350. }
  2351. #endregion
  2352. #region whether this card can Link
  2353. public bool CanLink(bool PayCost, bool allowBreeding = false)
  2354. {
  2355. if (linkCondition != null)
  2356. {
  2357. SelectCardEffect.Root root = CardEffectCommons.IsExistOnHand(this) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.None;
  2358. if (allowBreeding)
  2359. {
  2360. if (Owner.GetFieldPermanents().Count >= 1)
  2361. {
  2362. foreach (Permanent digimon in Owner.GetFieldPermanents())
  2363. {
  2364. if (digimon != null)
  2365. {
  2366. if (linkCondition.digimonCondition(digimon))
  2367. {
  2368. if (PayCost)
  2369. {
  2370. int cost = GetChangedLinkCost(digimon, root);
  2371. if (Owner.MaxMemoryCost >= cost)
  2372. {
  2373. return true;
  2374. }
  2375. }
  2376. else
  2377. {
  2378. return true;
  2379. }
  2380. }
  2381. }
  2382. }
  2383. }
  2384. }
  2385. else
  2386. {
  2387. if (Owner.GetBattleAreaDigimons().Count >= 1)
  2388. {
  2389. foreach (Permanent digimon in Owner.GetBattleAreaDigimons())
  2390. {
  2391. if (digimon != null)
  2392. {
  2393. if (linkCondition.digimonCondition(digimon))
  2394. {
  2395. if (PayCost)
  2396. {
  2397. int cost = GetChangedLinkCost(digimon, root);
  2398. if (Owner.MaxMemoryCost >= cost)
  2399. {
  2400. return true;
  2401. }
  2402. }
  2403. else
  2404. {
  2405. return true;
  2406. }
  2407. }
  2408. }
  2409. }
  2410. }
  2411. }
  2412. }
  2413. return false;
  2414. }
  2415. #endregion
  2416. #region whether target permanent can Burst digivolve into this card
  2417. public bool CanBurstDigivolutionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2418. {
  2419. if (targetPermanent != null)
  2420. {
  2421. if (targetPermanent.TopCard != null)
  2422. {
  2423. if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent) || targetPermanent.TopCard.Owner.GetBreedingAreaPermanents().Contains(targetPermanent))
  2424. {
  2425. if (this.CanPlayBurst(PayCost))
  2426. {
  2427. if (burstDigivolutionCondition != null)
  2428. {
  2429. if (!this.CanNotEvolve(targetPermanent))
  2430. {
  2431. if (burstDigivolutionCondition.digimonCondition(targetPermanent))
  2432. {
  2433. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2434. {
  2435. if (tamer != targetPermanent)
  2436. {
  2437. if (burstDigivolutionCondition.tamerCondition(tamer))
  2438. {
  2439. if (!tamer.CannotReturnToHand(null))
  2440. {
  2441. if (PayCost)
  2442. {
  2443. int cost = burstDigivolutionCondition.cost;
  2444. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2445. if (Owner.MaxMemoryCost < cost)
  2446. {
  2447. return false;
  2448. }
  2449. }
  2450. return true;
  2451. }
  2452. }
  2453. }
  2454. }
  2455. }
  2456. }
  2457. }
  2458. }
  2459. }
  2460. }
  2461. }
  2462. return false;
  2463. }
  2464. #endregion
  2465. #region Get Link Cost Accounting for Cost Reduction
  2466. public int GetChangedLinkCost(Permanent targetPermanent, SelectCardEffect.Root root)
  2467. {
  2468. if (linkCondition == null) return 0;
  2469. int Cost = linkCondition.cost;
  2470. List<ICardEffect> changeLinkCostCardEffects = new List<ICardEffect>();
  2471. #region the effects of permanents
  2472. changeLinkCostCardEffects = changeLinkCostCardEffects
  2473. .Concat(
  2474. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  2475. .Map(player => player.GetFieldPermanents())
  2476. .Flat()
  2477. .Filter(permanent => permanent != PermanentOfThisCard())
  2478. .Map(permanent => permanent.EffectList(EffectTiming.None))
  2479. .Flat()
  2480. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2481. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2482. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2483. .ToList();
  2484. #endregion
  2485. #region the effects of players
  2486. changeLinkCostCardEffects = changeLinkCostCardEffects
  2487. .Concat(
  2488. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  2489. .Map(player => player.EffectList(EffectTiming.None))
  2490. .Flat()
  2491. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2492. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2493. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2494. .ToList();
  2495. #endregion
  2496. #region the effects of itself
  2497. changeLinkCostCardEffects = changeLinkCostCardEffects
  2498. .Concat(
  2499. EffectList(EffectTiming.None)
  2500. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2501. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2502. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2503. .ToList();
  2504. #endregion
  2505. List<ICardEffect> changeLinkCostCardEffects_NotIsUpDown = changeLinkCostCardEffects
  2506. .Filter(cardEffect => !((IChangeLinkCostEffect)cardEffect).IsUpDown());
  2507. List<ICardEffect> changeLinkCostCardEffects_IsUpDown = changeLinkCostCardEffects
  2508. .Filter(cardEffect => ((IChangeLinkCostEffect)cardEffect).IsUpDown());
  2509. changeLinkCostCardEffects_NotIsUpDown
  2510. .ForEach(cardEffect => Cost = ((IChangeLinkCostEffect)cardEffect).GetCost(Cost, this, targetPermanent, root));
  2511. changeLinkCostCardEffects_IsUpDown
  2512. .ForEach(cardEffect => Cost = ((IChangeLinkCostEffect)cardEffect).GetCost(Cost, this, targetPermanent, root));
  2513. return Math.Max(0, Cost);
  2514. }
  2515. #endregion
  2516. #region whether target permanent can Link into this card
  2517. public bool CanLinkToTargetPermanent(Permanent targetPermanent, bool PayCost, bool allowBreeding = false)
  2518. {
  2519. if (targetPermanent != null)
  2520. {
  2521. if (targetPermanent.TopCard != null && !targetPermanent.TopCard.IsToken)
  2522. {
  2523. if(allowBreeding || !targetPermanent.TopCard.Owner.GetBreedingAreaPermanents().Contains(targetPermanent))
  2524. {
  2525. if (this.CanLink(false, allowBreeding)) // Don't check PayCost in CanLink since this method will check again anyway
  2526. {
  2527. if (linkCondition != null)
  2528. {
  2529. if (linkCondition.digimonCondition(targetPermanent))
  2530. {
  2531. if (PayCost)
  2532. {
  2533. SelectCardEffect.Root root = CardEffectCommons.IsExistOnHand(this) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.None;
  2534. int cost = GetChangedLinkCost(targetPermanent, root);
  2535. if (Owner.MaxMemoryCost < cost)
  2536. {
  2537. return false;
  2538. }
  2539. }
  2540. return true;
  2541. }
  2542. }
  2543. }
  2544. }
  2545. }
  2546. }
  2547. return false;
  2548. }
  2549. #endregion
  2550. #region whether target permanent can App Fusion into this card
  2551. public bool CanAppFusionFromTargetPermanent(Permanent targetPermanent, bool PayCost, SelectCardEffect.Root root = SelectCardEffect.Root.Hand)
  2552. {
  2553. if (targetPermanent != null)
  2554. {
  2555. if (targetPermanent.TopCard != null)
  2556. {
  2557. if (appFusionCondition != null)
  2558. {
  2559. if (!this.CanNotEvolve(targetPermanent))
  2560. {
  2561. if (appFusionCondition.digimonCondition(targetPermanent))
  2562. {
  2563. foreach (CardSource linkedCard in targetPermanent.LinkedCards)
  2564. {
  2565. if (appFusionCondition.linkedCondition(targetPermanent, linkedCard))
  2566. {
  2567. if (PayCost)
  2568. {
  2569. int cost = appFusionCondition.cost;
  2570. cost = GetChangedCostItselef(cost, root, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2571. if (Owner.MaxMemoryCost < cost)
  2572. {
  2573. return false;
  2574. }
  2575. }
  2576. return true;
  2577. }
  2578. }
  2579. }
  2580. }
  2581. }
  2582. }
  2583. }
  2584. return false;
  2585. }
  2586. #endregion
  2587. #region Whether this card's digiXrosCondition contains target card
  2588. public bool IsContainDigiXrosCondition(CardSource cardSource)
  2589. {
  2590. if (cardSource != null)
  2591. {
  2592. if (cardSource.Owner == Owner)
  2593. {
  2594. if (PermanentOfThisCard() != null)
  2595. {
  2596. if (PermanentOfThisCard().TopCard.HasDigiXros)
  2597. {
  2598. if (this == PermanentOfThisCard().TopCard)
  2599. {
  2600. if (digiXrosCondition != null)
  2601. {
  2602. if (digiXrosCondition.elements.Count((element) => element.CardCondition(cardSource)) >= 1)
  2603. {
  2604. return true;
  2605. }
  2606. }
  2607. }
  2608. }
  2609. }
  2610. }
  2611. }
  2612. return false;
  2613. }
  2614. #endregion
  2615. #region CardID
  2616. public string CardID => _cEntity_Base.CardID;
  2617. #endregion
  2618. #region whether this card is Digimon
  2619. public bool IsDigimon => CardKinds.Contains(CardKind.Digimon);
  2620. #endregion
  2621. #region whether this card is DigiEgg
  2622. public bool IsDigiEgg => CardKinds.Contains(CardKind.DigiEgg);
  2623. #endregion
  2624. #region whether this card is Tamer
  2625. public bool IsTamer => CardKinds.Contains(CardKind.Tamer);
  2626. #endregion
  2627. #region whether this card is Option
  2628. public bool IsOption => CardKinds.Contains(CardKind.Option);
  2629. #endregion
  2630. #region Wheter this card is permanent
  2631. public bool IsPermanent => _cEntity_Base.IsPermanent;
  2632. #endregion
  2633. #region Whether to have Play Cost
  2634. public bool HasPlayCost => _cEntity_Base.HasPlayCost;
  2635. #endregion
  2636. #region Whether to have Use Cost
  2637. public bool HasUseCost => _cEntity_Base.HasUseCost;
  2638. #endregion
  2639. #region Inherited Effects ENG discription
  2640. public string InheritedEffectDiscription_ENG => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG);
  2641. #endregion
  2642. #region Inherited Effects JPN discription
  2643. public string InheritedEffectDiscription_JPN => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_JPN);
  2644. #endregion
  2645. #region Link Effects
  2646. public string LinkEffectDiscription => DataBase.ReplaceToASCII(_cEntity_Base.LinkEffect);
  2647. #endregion
  2648. #region Card Sprite
  2649. public Sprite CardSprite => _cEntity_Base.CardSprite;
  2650. public async Task<Sprite> GetCardSprite()
  2651. {
  2652. return await _cEntity_Base.GetCardSprite();
  2653. }
  2654. #endregion
  2655. #region SetID
  2656. public string SetID => _cEntity_Base.SetID;
  2657. #endregion
  2658. #region CardEntityIndex
  2659. public int CardEntityIndex => _cEntity_Base.CardIndex;
  2660. #endregion
  2661. #region Card Kind
  2662. public List<CardKind> CardKinds => _cEntity_Base.cardKind;
  2663. #endregion
  2664. #region ACE
  2665. public bool IsACE => _cEntity_Base.IsACE;
  2666. #endregion
  2667. #region OverflowMemory
  2668. public int OverflowMemory => _cEntity_Base.OverflowMemory;
  2669. #endregion
  2670. #region Whether this card is being revealed
  2671. public bool IsBeingRevealed { get; set; } = false;
  2672. #endregion
  2673. #region The permanent that belonged to this card just before it left the field
  2674. public Permanent PermanentJustBeforeRemoveField { get; set; } = null;
  2675. #endregion
  2676. #region whether this card has "SEEKERS" trait
  2677. public bool HasSeekersTraits
  2678. {
  2679. get
  2680. {
  2681. if (CardTraits.Contains("SEEKERS"))
  2682. {
  2683. return true;
  2684. }
  2685. return false;
  2686. }
  2687. }
  2688. #endregion
  2689. #region whether this card has "ADVENTURE" trait
  2690. public bool HasAdventureTraits
  2691. {
  2692. get
  2693. {
  2694. if (CardTraits.Contains("ADVENTURE"))
  2695. {
  2696. return true;
  2697. }
  2698. return false;
  2699. }
  2700. }
  2701. #endregion
  2702. #region whether this card has "Hero" trait
  2703. public bool HasHeroTraits
  2704. {
  2705. get
  2706. {
  2707. return EqualsTraits("Hero");
  2708. }
  2709. }
  2710. #endregion
  2711. #region whether this card has "Chronicle" trait
  2712. public bool HasChronicleTraits
  2713. {
  2714. get
  2715. {
  2716. if (CardTraits.Contains("Chronicle"))
  2717. {
  2718. return true;
  2719. }
  2720. return false;
  2721. }
  2722. }
  2723. #endregion
  2724. #region whether this card has "Device" trait
  2725. public bool HasDeviceTraits
  2726. {
  2727. get
  2728. {
  2729. if (CardTraits.Contains("Device"))
  2730. {
  2731. return true;
  2732. }
  2733. return false;
  2734. }
  2735. }
  2736. #endregion
  2737. #region whether this card has "Three Musketeers" trait
  2738. public bool HasThreeMusketeersTraits
  2739. {
  2740. get
  2741. {
  2742. if (CardTraits.Contains("Three Musketeers"))
  2743. {
  2744. return true;
  2745. }
  2746. return false;
  2747. }
  2748. }
  2749. #endregion
  2750. #region whether this card has "Royal Base" trait
  2751. public bool HasRoyalBaseTraits
  2752. {
  2753. get
  2754. {
  2755. if (CardTraits.Contains("Royal Base"))
  2756. {
  2757. return true;
  2758. }
  2759. return false;
  2760. }
  2761. }
  2762. #endregion
  2763. #region whether this card has "Appmon" trait
  2764. public bool HasAppmonTraits
  2765. {
  2766. get
  2767. {
  2768. return EqualsTraits("Appmon");
  2769. }
  2770. }
  2771. #endregion
  2772. #region whether this card has "WG" trait
  2773. public bool HasWGTraits
  2774. {
  2775. get
  2776. {
  2777. return EqualsTraits("WG");
  2778. }
  2779. }
  2780. #endregion
  2781. #region whether this card has "DM" trait
  2782. public bool HasDMTraits
  2783. {
  2784. get
  2785. {
  2786. return EqualsTraits("DM");
  2787. }
  2788. }
  2789. #endregion
  2790. #region whether this card has "CS" trait
  2791. public bool HasCSTraits
  2792. {
  2793. get
  2794. {
  2795. return EqualsTraits("CS");
  2796. }
  2797. }
  2798. #endregion
  2799. #region whether this card has "TS" trait
  2800. public bool HasTSTraits
  2801. {
  2802. get
  2803. {
  2804. return EqualsTraits("TS");
  2805. }
  2806. }
  2807. #endregion
  2808. #region whether this card has "Iliad" trait
  2809. public bool HasIliadTraits
  2810. {
  2811. get
  2812. {
  2813. return EqualsTraits("Iliad");
  2814. }
  2815. }
  2816. #endregion
  2817. #region whether this card has "Unidentified" trait
  2818. public bool HasUnidentifiedTraits
  2819. {
  2820. get
  2821. {
  2822. return EqualsTraits("Unidentified");
  2823. }
  2824. }
  2825. #endregion
  2826. #region whether this card has "Flame" trait
  2827. public bool HasFlameTraits
  2828. {
  2829. get
  2830. {
  2831. return EqualsTraits("Flame");
  2832. }
  2833. }
  2834. #endregion
  2835. #region whether this card has "Eater" trait
  2836. public bool HasEaterTraits
  2837. {
  2838. get
  2839. {
  2840. return EqualsTraits("Eater");
  2841. }
  2842. }
  2843. #endregion
  2844. #region whether this card has "Hudie" trait
  2845. public bool HasHudieTraits
  2846. {
  2847. get
  2848. {
  2849. return EqualsTraits("Hudie");
  2850. }
  2851. }
  2852. #endregion
  2853. #region whether this card has "Sea Animal" trait
  2854. public bool HasSeaAnimalTraits
  2855. {
  2856. get
  2857. {
  2858. return EqualsTraits("Sea Animal");
  2859. }
  2860. }
  2861. #endregion
  2862. #region whether this card has "Puppet" trait
  2863. public bool HasPuppetTraits
  2864. {
  2865. get
  2866. {
  2867. return EqualsTraits("Puppet");
  2868. }
  2869. }
  2870. #endregion
  2871. #region whether this card has "Ver.1" trait
  2872. public bool HasVer1Traits
  2873. {
  2874. get
  2875. {
  2876. return EqualsTraits("Ver.1");
  2877. }
  2878. }
  2879. #endregion
  2880. #region whether this card has "Ver.2" trait
  2881. public bool HasVer2Traits
  2882. {
  2883. get
  2884. {
  2885. return EqualsTraits("Ver.2");
  2886. }
  2887. }
  2888. #endregion
  2889. #region whether this card has "Ver.3" trait
  2890. public bool HasVer3Traits
  2891. {
  2892. get
  2893. {
  2894. return EqualsTraits("Ver.3");
  2895. }
  2896. }
  2897. #endregion
  2898. #region whether this card has "Ver.4" trait
  2899. public bool HasVer4Traits
  2900. {
  2901. get
  2902. {
  2903. return EqualsTraits("Ver.4");
  2904. }
  2905. }
  2906. #endregion
  2907. #region whether this card has "Ver.5" trait
  2908. public bool HasVer5Traits
  2909. {
  2910. get
  2911. {
  2912. return EqualsTraits("Ver.5");
  2913. }
  2914. }
  2915. #endregion
  2916. #region whether this card has "Aquatic" trait
  2917. public bool HasAquaticTraits
  2918. {
  2919. get
  2920. {
  2921. return EqualsTraits("Aquatic");
  2922. }
  2923. }
  2924. #endregion
  2925. #region whether this card has "LIBERATOR" trait
  2926. public bool HasLiberatorTraits
  2927. {
  2928. get
  2929. {
  2930. return EqualsTraits("LIBERATOR");
  2931. }
  2932. }
  2933. #endregion
  2934. #region whether this card has "Standard" Appmon Grade trait
  2935. public bool HasStandardAppTraits
  2936. {
  2937. get
  2938. {
  2939. return EqualsTraits("Stnd.");
  2940. }
  2941. }
  2942. #endregion
  2943. #region whether this card has "Super" Appmon Grade trait
  2944. public bool HasSuperAppTraits
  2945. {
  2946. get
  2947. {
  2948. return EqualsTraits("Sup.");
  2949. }
  2950. }
  2951. #endregion
  2952. #region whether this card has "Ultimate" Appmon Grade trait
  2953. public bool HasUltimateAppTraits
  2954. {
  2955. get
  2956. {
  2957. return EqualsTraits("Ult.");
  2958. }
  2959. }
  2960. #endregion
  2961. #region whether this card has "Holy Beast" trait
  2962. public bool HasHolyBeastTraits
  2963. {
  2964. get
  2965. {
  2966. return EqualsTraits("Holy Beast");
  2967. }
  2968. }
  2969. #endregion
  2970. #region whether this card has "Archangel" trait
  2971. public bool HasArchAngelTraits
  2972. {
  2973. get
  2974. {
  2975. return EqualsTraits("Archangel");
  2976. }
  2977. }
  2978. #endregion
  2979. #region whether this card has "Fallen Angel" trait
  2980. public bool HasFallenAngelTraits
  2981. {
  2982. get
  2983. {
  2984. return EqualsTraits("Fallen Angel");
  2985. }
  2986. }
  2987. #endregion
  2988. #region whether this card has "Bagra Army" trait
  2989. public bool HasBagraArmyTraits
  2990. {
  2991. get
  2992. {
  2993. return EqualsTraits("Bagra Army");
  2994. }
  2995. }
  2996. #endregion
  2997. #region whether this card has "Evil" trait
  2998. public bool HasEvilTraits
  2999. {
  3000. get
  3001. {
  3002. return EqualsTraits("Evil");
  3003. }
  3004. }
  3005. #endregion
  3006. #region whether this card has "Wizard" trait
  3007. public bool HasWizardTraits
  3008. {
  3009. get
  3010. {
  3011. return EqualsTraits("Wizard");
  3012. }
  3013. }
  3014. #endregion
  3015. #region whether this card has "Leviathan" trait
  3016. public bool HasLeviathanTraits
  3017. {
  3018. get
  3019. {
  3020. return EqualsTraits("Leviathan");
  3021. }
  3022. }
  3023. #endregion
  3024. #region whether this card has "Undead" trait
  3025. public bool HasUndeadTraits
  3026. {
  3027. get
  3028. {
  3029. return EqualsTraits("Undead");
  3030. }
  3031. }
  3032. #endregion
  3033. #region whether this card has "Galaxy" trait
  3034. public bool HasGalaxyTraits
  3035. {
  3036. get
  3037. {
  3038. return EqualsTraits("Galaxy");
  3039. }
  3040. }
  3041. #endregion
  3042. #region whether this card has "Rock"/"Mineral trait
  3043. public bool HasRockMineralTraits
  3044. {
  3045. get
  3046. {
  3047. return EqualsTraits("Rock") || EqualsTraits("Mineral");
  3048. }
  3049. }
  3050. #endregion
  3051. #region whether this card has Sea Beast trait
  3052. public bool HasSeaBeastTraits
  3053. {
  3054. get
  3055. {
  3056. return EqualsTraits("Sea Beast");
  3057. }
  3058. }
  3059. #endregion
  3060. #region whether this card has Twilight trait
  3061. public bool HasTwilightTrait
  3062. {
  3063. get
  3064. {
  3065. return EqualsTraits("Twilight");
  3066. }
  3067. }
  3068. #endregion
  3069. #region whether this card has Angel trait
  3070. public bool HasAngelStrictTraits
  3071. {
  3072. get
  3073. {
  3074. return EqualsTraits("Angel");
  3075. }
  3076. }
  3077. #endregion
  3078. #region whether this card has Dark Masters trait
  3079. public bool HasDarkMastersTrait
  3080. {
  3081. get
  3082. {
  3083. return EqualsTraits("Dark Masters");
  3084. }
  3085. }
  3086. #endregion
  3087. #region whether this card has Ghost trait
  3088. public bool HasGhostTraits
  3089. {
  3090. get
  3091. {
  3092. return EqualsTraits("Ghost");
  3093. }
  3094. }
  3095. #endregion
  3096. #region whether this card has Dark Animal trait
  3097. public bool HasDarkAnimalTraits
  3098. {
  3099. get
  3100. {
  3101. return EqualsTraits("Dark Animal");
  3102. }
  3103. }
  3104. #endregion
  3105. }
  3106. public class JogressCondition
  3107. {
  3108. public JogressCondition(JogressConditionElement[] elements, int cost)
  3109. {
  3110. this.elements = new JogressConditionElement[2];
  3111. if (this.elements.Length == elements.Length)
  3112. {
  3113. for (int i = 0; i < elements.Length; i++)
  3114. {
  3115. this.elements[i] = elements[i];
  3116. }
  3117. }
  3118. this.cost = cost;
  3119. }
  3120. public JogressConditionElement[] elements { get; private set; } = new JogressConditionElement[2];
  3121. public int cost { get; private set; } = 0;
  3122. }
  3123. public class JogressConditionElement
  3124. {
  3125. public JogressConditionElement(Func<Permanent, bool> evoRootCondition, string selectMessage)
  3126. {
  3127. EvoRootCondition = evoRootCondition;
  3128. SelectMessage = selectMessage;
  3129. }
  3130. Func<Permanent, bool> _evoRootCondition = null;
  3131. public Func<Permanent, bool> EvoRootCondition
  3132. {
  3133. get
  3134. {
  3135. return permanent => _evoRootCondition == null || _evoRootCondition(permanent);
  3136. }
  3137. private set
  3138. {
  3139. _evoRootCondition = value;
  3140. }
  3141. }
  3142. public string SelectMessage { get; private set; } = "";
  3143. }
  3144. public class DigiXrosCondition
  3145. {
  3146. public DigiXrosCondition(List<DigiXrosConditionElement> elements, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, int reduceCostPerCard)
  3147. {
  3148. this.elements = new List<DigiXrosConditionElement>();
  3149. foreach (DigiXrosConditionElement element in elements)
  3150. {
  3151. this.elements.Add(element);
  3152. }
  3153. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3154. this.reduceCostPerCard = reduceCostPerCard;
  3155. }
  3156. public List<DigiXrosConditionElement> elements { get; private set; } = new List<DigiXrosConditionElement>();
  3157. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; private set; } = null;
  3158. public int reduceCostPerCard { get; private set; } = 0;
  3159. }
  3160. public class DigiXrosConditionElement
  3161. {
  3162. public DigiXrosConditionElement(Func<CardSource, bool> cardCondition, string selectMessage, bool skipAllIfNoSelect = false)
  3163. {
  3164. this.CardCondition = cardCondition;
  3165. this.selectMessage = selectMessage;
  3166. this.skipAllIfNoSelect = skipAllIfNoSelect;
  3167. }
  3168. public Func<CardSource, bool> CardCondition { get; private set; } = null;
  3169. public string selectMessage { get; private set; } = "";
  3170. public bool skipAllIfNoSelect { get; private set; } = false;
  3171. }
  3172. public class BurstDigivolutionCondition
  3173. {
  3174. public BurstDigivolutionCondition(Func<Permanent, bool> tamerCondition, string selectTamerMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
  3175. {
  3176. this.tamerCondition = tamerCondition;
  3177. this.selectTamerMessage = selectTamerMessage;
  3178. this.digimonCondition = digimonCondition;
  3179. this.selectDigimonMessage = selectDigimonMessage;
  3180. this.cost = cost;
  3181. }
  3182. public Func<Permanent, bool> tamerCondition { get; private set; } = null;
  3183. public string selectTamerMessage { get; private set; } = null;
  3184. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3185. public string selectDigimonMessage { get; private set; } = null;
  3186. public int cost { get; private set; } = 0;
  3187. }
  3188. public class LinkCondition
  3189. {
  3190. public LinkCondition(Func<Permanent, bool> digimonCondition, int cost)
  3191. {
  3192. this.digimonCondition = digimonCondition;
  3193. this.cost = cost;
  3194. }
  3195. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3196. public int cost { get; private set; } = 0;
  3197. }
  3198. public class AppFusionCondition
  3199. {
  3200. public AppFusionCondition(Func<Permanent, CardSource, bool> linkedCondition, Func<Permanent, bool> digimonCondition, int cost)
  3201. {
  3202. this.linkedCondition = linkedCondition;
  3203. this.digimonCondition = digimonCondition;
  3204. this.cost = cost;
  3205. }
  3206. public Func<Permanent, CardSource, bool> linkedCondition { get; private set; } = null;
  3207. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3208. public int cost { get; private set; } = 0;
  3209. }
  3210. public class AssemblyCondition
  3211. {
  3212. //Method to work with older form of Assembly, 1 single condition X times
  3213. public AssemblyCondition(AssemblyConditionElement element, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, string selectMessage, int elementCount, int reduceCost)
  3214. {
  3215. element.ElementCount = elementCount;
  3216. element.selectMessage = selectMessage;
  3217. element.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3218. this.elements = new List<AssemblyConditionElement>(){ element };
  3219. this.elementCount = elementCount;
  3220. this.reduceCost = reduceCost;
  3221. }
  3222. //Method to work with A x B x C... DigiXros like conditions
  3223. public AssemblyCondition(List<AssemblyConditionElement> elements, int reduceCost)
  3224. {
  3225. this.elements = elements;
  3226. this.elementCount = elements.Select(element => element.ElementCount).Sum();
  3227. this.reduceCost = reduceCost;
  3228. }
  3229. public List<AssemblyConditionElement> elements { get; private set; } = new List<AssemblyConditionElement>();
  3230. public int elementCount { get; private set; } = 0;
  3231. public int reduceCost { get; private set; } = 0;
  3232. }
  3233. public class AssemblyConditionElement
  3234. {
  3235. public AssemblyConditionElement(Func<CardSource, bool> cardCondition, bool skipAllIfNoSelect = true, string selectMessage = null, int elementCount = 0, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList = null)
  3236. {
  3237. this.CardCondition = cardCondition;
  3238. this.skipAllIfNoSelect = skipAllIfNoSelect;
  3239. this.selectMessage = selectMessage;
  3240. this.ElementCount = elementCount;
  3241. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3242. }
  3243. public Func<CardSource, bool> CardCondition { get; set; } = null;
  3244. public bool skipAllIfNoSelect { get; set; } = true;
  3245. public int ElementCount { get; set; } = 0;
  3246. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; set; } = null;
  3247. public string selectMessage { get; set; } = "";
  3248. }