CardSource.cs 121 KB

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