CardSource.cs 115 KB

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