CardSource.cs 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947
  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()
  39. {
  40. IsFlipped = false;
  41. GManager.OnCardFlippedChanged?.Invoke();
  42. GManager.OnSecurityStackChanged?.Invoke(Owner);
  43. }
  44. #endregion
  45. #region set reverse
  46. public void SetReverse()
  47. {
  48. IsFlipped = true;
  49. GManager.OnCardFlippedChanged?.Invoke();
  50. GManager.OnSecurityStackChanged?.Invoke(Owner);
  51. }
  52. #endregion
  53. #endregion
  54. #region Card ID setup
  55. public void SetUpCardIndex(int _cardIndex)
  56. {
  57. PhotonView _PhotonView = GetComponent<PhotonView>();
  58. _PhotonView ??= gameObject.AddComponent<PhotonView>();
  59. CardIndex = _cardIndex;
  60. _PhotonView.ViewID = CardIndex + 60;
  61. PhotonView = _PhotonView;
  62. }
  63. #endregion
  64. #region whether this card can be played
  65. public bool CanPlayFromHandDuringMainPhase
  66. {
  67. get
  68. {
  69. if (CanNotPlayThisOption)
  70. {
  71. return false;
  72. }
  73. if (_cEntity_Base.IsPermanent)
  74. {
  75. if (!CanPlayJogress(true))
  76. {
  77. if (!CanPutFieldThisPermanentCard(true, null))
  78. {
  79. return false;
  80. }
  81. }
  82. }
  83. else if (IsOption)
  84. {
  85. #region whether cost can be paid
  86. List<int> costs = new List<int>() { this.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: true) };
  87. bool canPayCost = costs.Some(cost => Owner.MaxMemoryCost >= cost);
  88. if (!canPayCost) return false;
  89. #endregion
  90. }
  91. return true;
  92. }
  93. }
  94. #endregion
  95. #region Whether this option card's effect prevents it from being played
  96. public bool CanNotPlayThisOption
  97. {
  98. get
  99. {
  100. if (!IsOption)
  101. {
  102. return false;
  103. }
  104. #region the effects of players
  105. if (GManager.instance.turnStateMachine.gameContext.Players
  106. .Map(player => player.EffectList(EffectTiming.None))
  107. .Flat()
  108. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  109. && cardEffect.CanUse(null)
  110. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  111. {
  112. return true;
  113. }
  114. #endregion
  115. #region the effects of permanents
  116. if (GManager.instance.turnStateMachine.gameContext.Players
  117. .Map(player => player.GetFieldPermanents())
  118. .Flat()
  119. .Map(permanent => permanent.EffectList(EffectTiming.None))
  120. .Flat()
  121. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  122. && cardEffect.CanUse(null)
  123. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  124. {
  125. return true;
  126. }
  127. #endregion
  128. #region the effects of itself
  129. if (PermanentOfThisCard() == null)
  130. {
  131. if (EffectList(EffectTiming.None)
  132. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  133. && cardEffect.CanUse(null)
  134. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  135. {
  136. return true;
  137. }
  138. }
  139. #endregion
  140. #region Whether the color requirement is met
  141. if (!MatchColorRequirement)
  142. {
  143. return true;
  144. }
  145. #endregion
  146. return false;
  147. }
  148. }
  149. #endregion
  150. #region Whether the color requirement is met
  151. public bool MatchColorRequirement
  152. {
  153. get
  154. {
  155. if (IsOption)
  156. {
  157. #region "ignore color requirement" effects
  158. #region the effects of permanents
  159. if (GManager.instance.turnStateMachine.gameContext.Players
  160. .Map(player => player.GetFieldPermanents())
  161. .Flat()
  162. .Map(permanent => permanent.EffectList(EffectTiming.None))
  163. .Flat()
  164. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  165. && cardEffect.CanUse(null)
  166. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  167. {
  168. return true;
  169. }
  170. #endregion
  171. #region the effects of players
  172. if (GManager.instance.turnStateMachine.gameContext.Players
  173. .Map(player => player.EffectList(EffectTiming.None))
  174. .Flat()
  175. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  176. && cardEffect.CanUse(null)
  177. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  178. {
  179. return true;
  180. }
  181. #endregion
  182. #region the effects of itself
  183. if (PermanentOfThisCard() == null)
  184. {
  185. if (EffectList(EffectTiming.None)
  186. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  187. && cardEffect.CanUse(null)
  188. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  189. {
  190. return true;
  191. }
  192. }
  193. #endregion
  194. #endregion
  195. bool matchColorRequirement = CardColors.Every(cardColor =>
  196. Owner.GetFieldPermanents().Some(permanent =>
  197. !permanent.TopCard.IsOption && permanent.TopCard.CardColors.Contains(cardColor)));
  198. if (!matchColorRequirement)
  199. {
  200. return false;
  201. }
  202. }
  203. return true;
  204. }
  205. }
  206. #endregion
  207. #region Card object in hand displaying this card
  208. public HandCard ShowingHandCard { get; private set; }
  209. public void SetShowingHandCard(HandCard showingHandCard) => ShowingHandCard = showingHandCard;
  210. #endregion
  211. #region Permanent in the field containing this card
  212. public Permanent PermanentOfThisCard()
  213. {
  214. return Owner.GetFieldPermanents().Find(permanent =>
  215. (permanent.cardSources.Contains(this)) && !IsFlipped);
  216. }
  217. #endregion
  218. #region initialize
  219. public void Init()
  220. {
  221. cEntity_EffectController.InitUseCountThisTurn();
  222. SetFace();
  223. }
  224. #endregion
  225. #region base card colors from entity
  226. public List<CardColor> BaseCardColorsFromEntity => _cEntity_Base.cardColors.Distinct().ToList();
  227. #endregion
  228. #region base card colors
  229. public List<CardColor> BaseCardColors
  230. {
  231. get
  232. {
  233. List<CardColor> baseCardColors = BaseCardColorsFromEntity;
  234. #region the effects that changes base card colors
  235. #region the effects of itself
  236. if (PermanentOfThisCard() == null)
  237. {
  238. EffectList(EffectTiming.None)
  239. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  240. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  241. }
  242. #endregion
  243. #region the effects of permanents
  244. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  245. .Map(player => player.GetFieldPermanents())
  246. .Flat()
  247. .Map(permanent => permanent.EffectList(EffectTiming.None))
  248. .Flat()
  249. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  250. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  251. #endregion
  252. #endregion
  253. baseCardColors = baseCardColors.Distinct().ToList();
  254. return baseCardColors;
  255. }
  256. }
  257. #endregion
  258. #region card colors
  259. public List<CardColor> CardColors
  260. {
  261. get
  262. {
  263. List<CardColor> cardColors = BaseCardColors;
  264. #region the effects that changes card colors
  265. #region the effects of itself
  266. if (PermanentOfThisCard() == null)
  267. {
  268. EffectList(EffectTiming.None)
  269. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  270. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  271. }
  272. #endregion
  273. #region the effects of permanents
  274. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  275. .Map(player => player.GetFieldPermanents())
  276. .Flat()
  277. .Map(permanent => permanent.EffectList(EffectTiming.None))
  278. .Flat()
  279. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  280. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  281. #endregion
  282. #endregion
  283. cardColors = cardColors.Distinct().ToList();
  284. return cardColors;
  285. }
  286. }
  287. #endregion
  288. #region evoCosts from entity
  289. public List<EvoCost> BaseEvoCostsFromEntity => _cEntity_Base.EvoCosts;
  290. #endregion
  291. #region Link Cost
  292. public int LinkCost => _cEntity_Base.LinkCost;
  293. #endregion
  294. #region evoCosts
  295. public List<Func<Permanent, int>> EvoCosts(CardEffectCommons.IgnoreRequirement ignore, bool checkAvailability)
  296. {
  297. List<Func<Permanent, int>> EvoCosts = new List<Func<Permanent, int>>();
  298. #region the effects that add evoCosts
  299. #region the effects of players
  300. EvoCosts = EvoCosts
  301. .Concat(
  302. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  303. .Map(player => player.EffectList(EffectTiming.None))
  304. .Flat()
  305. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  306. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  307. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, checkAvailability)))
  308. .ToList();
  309. #endregion
  310. #region the effects of permanents
  311. EvoCosts = EvoCosts
  312. .Concat(
  313. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  314. .Map(player => player.GetFieldPermanents())
  315. .Flat()
  316. .Map(permanent => permanent.EffectList(EffectTiming.None))
  317. .Flat()
  318. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  319. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  320. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, checkAvailability)))
  321. .ToList();
  322. #endregion
  323. #region the effects of itself
  324. if (PermanentOfThisCard() == null || PermanentOfThisCard().DigivolutionCards.Contains(this))
  325. {
  326. EvoCosts = EvoCosts
  327. .Concat(
  328. EffectList(EffectTiming.None)
  329. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  330. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  331. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, checkAvailability)))
  332. .ToList();
  333. }
  334. #endregion
  335. #endregion
  336. EvoCosts = EvoCosts
  337. .Concat(
  338. BaseEvoCostsFromEntity
  339. .Map<EvoCost, Func<Permanent, int>>(evoCost =>
  340. (targetPermanent) =>
  341. {
  342. if (ignore.Equals(CardEffectCommons.IgnoreRequirement.All) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  343. return evoCost.MemoryCost;
  344. if ((ignore.Equals(CardEffectCommons.IgnoreRequirement.Color) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  345. || targetPermanent.TopCard.CardColors.Contains(evoCost.CardColor))
  346. {
  347. if ((ignore.Equals(CardEffectCommons.IgnoreRequirement.Level) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  348. || targetPermanent.Level == evoCost.Level)
  349. {
  350. return evoCost.MemoryCost;
  351. }
  352. }
  353. return -1;
  354. }))
  355. .ToList();
  356. return EvoCosts;
  357. }
  358. #endregion
  359. #region evo cost list
  360. public List<int> CostList(Permanent targetPermanent, bool ignoreLevel, bool checkAvailability)
  361. {
  362. CardEffectCommons.IgnoreRequirement ignore = CardEffectCommons.IgnoreRequirement.None;
  363. if (ignoreLevel)
  364. ignore = CardEffectCommons.IgnoreRequirement.Level;
  365. return EvoCosts(ignore, checkAvailability)
  366. .Filter(evoCost => evoCost(targetPermanent) >= 0)
  367. .Map(evoCost => evoCost(targetPermanent));
  368. }
  369. #endregion
  370. #region cost list
  371. #region cost to pay
  372. public int PayingCost(SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false, bool ignoreLevel = false, int FixedCost = -1)
  373. {
  374. int baseCost = _cEntity_Base.PlayCost;
  375. if (targetPermanents != null)
  376. {
  377. if (targetPermanents.Count == 1)
  378. {
  379. Permanent targetPermanent = targetPermanents[0];
  380. if (targetPermanent != null)
  381. {
  382. List<int> costList = CostList(targetPermanent, ignoreLevel: ignoreLevel, checkAvailability: checkAvailability);
  383. if (costList.Count >= 1)
  384. {
  385. baseCost = costList.Min();
  386. }
  387. }
  388. }
  389. }
  390. return GetPayingCostWithBaseCost(baseCost, root, targetPermanents, checkAvailability: checkAvailability, FixedCost: FixedCost);
  391. }
  392. #endregion
  393. #region cost that will be paid taking into account baseCost
  394. public int GetPayingCostWithBaseCost(int baseCost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false, int FixedCost = -1)
  395. {
  396. int Cost = FixedCost >= 0 ? FixedCost : baseCost;
  397. bool isEvolution = targetPermanents != null && targetPermanents.Some((permanent) => permanent != null);
  398. #region DigiXros
  399. if (!isEvolution)
  400. {
  401. if (HasDigiXros)
  402. {
  403. if (Owner.CanReduceCost(null, this))
  404. {
  405. //AI
  406. if (!(!Owner.isYou && GManager.instance.IsAI))
  407. {
  408. if (checkAvailability)
  409. {
  410. return 0;
  411. }
  412. }
  413. if (!checkAvailability)
  414. {
  415. SelectDigiXrosClass selectDigiXrosClass = GManager.instance.GetComponent<SelectDigiXrosClass>();
  416. if (selectDigiXrosClass != null)
  417. {
  418. if (selectDigiXrosClass.playCard == this)
  419. {
  420. Cost -= selectDigiXrosClass.selectedDigicrossCards.Count * digiXrosCondition.reduceCostPerCard;
  421. }
  422. }
  423. }
  424. }
  425. }
  426. }
  427. #endregion
  428. Cost = GetChangedCostItselef(Cost, root, targetPermanents, checkAvailability);
  429. Cost = GetChangedPayingCost(Cost, root, targetPermanents, checkAvailability);
  430. if (Cost < 0)
  431. {
  432. Cost = 0;
  433. }
  434. return Cost;
  435. }
  436. #endregion
  437. #region base play cost from entity
  438. public int BasePlayCostFromEntity => _cEntity_Base.PlayCost;
  439. #endregion
  440. #region get card cost of itself (refered by card effects)
  441. public int GetCostItself => Math.Max(0, GetChangedCostItselef(BasePlayCostFromEntity, SelectCardEffect.Root.None, new List<Permanent>() { PermanentOfThisCard() }));
  442. #endregion
  443. #region get card cost of itself taking into account card effects
  444. public int GetChangedCostItselef(int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false)
  445. {
  446. if (checkAvailability)
  447. {
  448. if (GManager.instance.IsAI)
  449. {
  450. if (targetPermanents != null)
  451. {
  452. if (targetPermanents.Some(permanent => permanent != null && permanent.TopCard != null && !permanent.TopCard.Owner.isYou))
  453. {
  454. return Math.Max(0, Cost);
  455. }
  456. }
  457. }
  458. }
  459. #region card effects that changes card cost
  460. List<ICardEffect> changeCostCardEffects = new List<ICardEffect>();
  461. #region the effects of permanents
  462. changeCostCardEffects = changeCostCardEffects
  463. .Concat(
  464. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  465. .Map(player => player.GetFieldPermanents())
  466. .Flat()
  467. .Map(permanent => permanent.EffectList(EffectTiming.None))
  468. .Flat()
  469. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  470. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  471. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  472. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  473. .ToList();
  474. #endregion
  475. #region the effects of players
  476. changeCostCardEffects = changeCostCardEffects
  477. .Concat(
  478. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  479. .Map(player => player.EffectList(EffectTiming.None))
  480. .Flat()
  481. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  482. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  483. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  484. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  485. .ToList();
  486. #endregion
  487. #region the effects of itself
  488. if (PermanentOfThisCard() == null)
  489. {
  490. changeCostCardEffects = changeCostCardEffects
  491. .Concat(
  492. EffectList(EffectTiming.None)
  493. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  494. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  495. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  496. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  497. .ToList();
  498. }
  499. #endregion
  500. List<ICardEffect> changeCostCardEffects_NotIsUpDown = changeCostCardEffects
  501. .Filter(cardEffect => !((IChangeCostEffect)cardEffect).IsUpDown());
  502. List<ICardEffect> changeCostCardEffects_IsUpDown = changeCostCardEffects
  503. .Filter(cardEffect => ((IChangeCostEffect)cardEffect).IsUpDown());
  504. changeCostCardEffects_NotIsUpDown
  505. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  506. changeCostCardEffects_IsUpDown
  507. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  508. #endregion
  509. return Math.Max(0, Cost);
  510. }
  511. #endregion
  512. #region get card cost to pay of itself taking into account card effects
  513. public int GetChangedPayingCost(int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false)
  514. {
  515. #region card effects that changes card cost to pay
  516. List<ICardEffect> changePayingCostCardEffects = new List<ICardEffect>();
  517. #region the effects of permanents
  518. changePayingCostCardEffects = changePayingCostCardEffects
  519. .Concat(
  520. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  521. .Map(player => player.GetFieldPermanents())
  522. .Flat()
  523. .Map(permanent => permanent.EffectList(EffectTiming.None))
  524. .Flat()
  525. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  526. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  527. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  528. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  529. .ToList();
  530. #endregion
  531. #region the effects of players
  532. changePayingCostCardEffects = changePayingCostCardEffects
  533. .Concat(
  534. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  535. .Map(player => player.EffectList(EffectTiming.None))
  536. .Flat()
  537. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  538. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  539. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  540. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  541. .ToList();
  542. #endregion
  543. #region the effects of itself
  544. if (PermanentOfThisCard() == null)
  545. {
  546. changePayingCostCardEffects = changePayingCostCardEffects
  547. .Concat(
  548. EffectList(EffectTiming.None)
  549. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  550. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  551. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  552. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  553. .ToList();
  554. }
  555. #endregion
  556. List<ICardEffect> changePayingCostCardEffects_NotIsUpDown = changePayingCostCardEffects
  557. .Filter(cardEffect => !((IChangeCostEffect)cardEffect).IsUpDown());
  558. List<ICardEffect> changePayingCostCardEffects_IsUpDown = changePayingCostCardEffects
  559. .Filter(cardEffect => ((IChangeCostEffect)cardEffect).IsUpDown());
  560. changePayingCostCardEffects_NotIsUpDown
  561. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  562. changePayingCostCardEffects_IsUpDown
  563. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  564. #endregion
  565. return Math.Max(0, Cost);
  566. }
  567. #endregion
  568. #endregion
  569. #region level
  570. public int Level => TreatedLevel;
  571. #endregion
  572. #region Level
  573. public int TreatedLevel
  574. {
  575. get
  576. {
  577. int treatedLevel = 0;
  578. treatedLevel = _cEntity_Base.Level;
  579. if (!HasLevel)
  580. treatedLevel = 1145140;
  581. #region Check Card Change Level Effects
  582. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  583. {
  584. if (cardEffect is IChangeCardLevelEffect)
  585. {
  586. if (cardEffect.CanUse(null))
  587. {
  588. treatedLevel = ((IChangeCardLevelEffect)cardEffect).GetCardLevel(treatedLevel, this);
  589. }
  590. }
  591. }
  592. #endregion
  593. return treatedLevel;
  594. }
  595. }
  596. #endregion
  597. #region effect list
  598. public List<ICardEffect> EffectList(EffectTiming timing)
  599. {
  600. return EffectList_ForCard(timing, this);
  601. }
  602. #endregion
  603. #region effect list for 1 card
  604. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource cardSource)
  605. {
  606. List<ICardEffect> _EffectList = cEntity_EffectController
  607. .GetCardEffects(timing, cardSource)
  608. .Filter(cardEffect => cardEffect != null);
  609. foreach (ICardEffect cardEffect in _EffectList)
  610. {
  611. if (cardEffect.EffectSourceCard == null)
  612. {
  613. cardEffect.SetEffectSourceCard(this);
  614. }
  615. }
  616. return _EffectList;
  617. }
  618. #endregion
  619. #region effect list except added effects
  620. public List<ICardEffect> EffectList_ExceptAddedEffects(EffectTiming timing)
  621. {
  622. return EffectList_ForCard_ExceptAddedEffects(timing, this);
  623. }
  624. #endregion
  625. #region effect list for 1 card
  626. public List<ICardEffect> EffectList_ForCard_ExceptAddedEffects(EffectTiming timing, CardSource cardSource)
  627. {
  628. List<ICardEffect> _EffectList = cEntity_EffectController
  629. .GetCardEffects_ExceptAddedEffects(timing, cardSource)
  630. .Filter(cardEffect => cardEffect != null);
  631. foreach (ICardEffect cardEffect in _EffectList)
  632. {
  633. if (cardEffect.EffectSourceCard == null)
  634. {
  635. cardEffect.SetEffectSourceCard(this);
  636. }
  637. }
  638. return _EffectList;
  639. }
  640. #endregion
  641. #region whether this card can declare skill
  642. public bool CanDeclareSkill => CanDeclareSkillList.Count > 0;
  643. #endregion
  644. #region effect list that this card can declare
  645. public List<ICardEffect> CanDeclareSkillList
  646. {
  647. get
  648. {
  649. return EffectList(EffectTiming.OnDeclaration)
  650. .Filter(cardEffect => cardEffect is ActivateICardEffect && cardEffect.CanUse(null));
  651. }
  652. }
  653. #endregion
  654. #region whether this card can not be affected by the effect
  655. public bool CanNotBeAffected(ICardEffect _cardEffect)
  656. {
  657. if (_cardEffect == null) return false;
  658. #region the effects of permanents
  659. if (GManager.instance.turnStateMachine.gameContext.Players
  660. .Map(player => player.GetFieldPermanents())
  661. .Flat()
  662. .Map(permanent => permanent.EffectList(EffectTiming.None))
  663. .Flat()
  664. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  665. && cardEffect.CanUse(null)
  666. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  667. {
  668. return true;
  669. }
  670. #endregion
  671. #region the effects of players
  672. if (GManager.instance.turnStateMachine.gameContext.Players
  673. .Map(player => player.EffectList(EffectTiming.None))
  674. .Flat()
  675. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  676. && cardEffect.CanUse(null)
  677. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  678. {
  679. return true;
  680. }
  681. #endregion
  682. #region the effects of itself
  683. if (PermanentOfThisCard() == null)
  684. {
  685. if (EffectList(EffectTiming.None)
  686. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  687. && cardEffect.CanUse(null)
  688. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  689. {
  690. return true;
  691. }
  692. }
  693. #endregion
  694. return false;
  695. }
  696. #endregion
  697. #region whether this card can be played at the frame
  698. 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)
  699. {
  700. bool isBattleAreaFrame = FieldCardFrame.isBattleAreaFrameID(frame.FrameID);
  701. if (isBreedingArea)
  702. {
  703. if (isBattleAreaFrame)
  704. {
  705. return false;
  706. }
  707. }
  708. if (PermanentOfThisCard() != null)
  709. {
  710. if (this == PermanentOfThisCard().TopCard)
  711. {
  712. if (PermanentOfThisCard().HasNoDigivolutionCards)
  713. {
  714. return false;
  715. }
  716. }
  717. }
  718. if (frame.player != Owner)
  719. {
  720. return false;
  721. }
  722. if (PayCost && frame.GetFramePermanent() == null)
  723. {
  724. int cost = PayingCost(root, new List<Permanent>() { frame.GetFramePermanent() }, checkAvailability: true, FixedCost: fixedCost);
  725. if (Owner.MaxMemoryCost < cost)
  726. {
  727. return false;
  728. }
  729. }
  730. if (frame.GetFramePermanent() != null)
  731. {
  732. if (!CanEvolve(frame.GetFramePermanent(), true, ignore))
  733. {
  734. return false;
  735. }
  736. }
  737. else
  738. {
  739. if (!CanEnterField(cardEffect))
  740. {
  741. return false;
  742. }
  743. }
  744. if (IsDigiEgg)
  745. {
  746. if (isBattleAreaFrame)
  747. {
  748. return false;
  749. }
  750. }
  751. else
  752. {
  753. if (!isBattleAreaFrame && frame.GetFramePermanent() == null && !isBreedingArea)
  754. {
  755. return false;
  756. }
  757. }
  758. return true;
  759. }
  760. #endregion
  761. #region whether there is at least 1 frame where this card can be placed
  762. public bool CanPutFieldThisPermanentCard(bool PayCost, ICardEffect cardEffect, bool isBreedingArea = false)
  763. {
  764. return Owner.fieldCardFrames.Some((frame) => CanPlayCardTargetFrame(frame, PayCost, cardEffect, isBreedingArea: isBreedingArea));
  765. }
  766. #endregion
  767. #region whether this card can be placed on the field by the effect
  768. public bool CanEnterField(ICardEffect _cardEffect)
  769. {
  770. #region the effects of permanents
  771. if (GManager.instance.turnStateMachine.gameContext.Players
  772. .Map(player => player.GetFieldPermanents())
  773. .Flat()
  774. .Map(permanent => permanent.EffectList(EffectTiming.None))
  775. .Flat()
  776. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  777. && cardEffect.CanUse(null)
  778. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  779. {
  780. return false;
  781. }
  782. #endregion
  783. #region the effects of players
  784. if (GManager.instance.turnStateMachine.gameContext.Players
  785. .Map(player => player.EffectList(EffectTiming.None))
  786. .Flat()
  787. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  788. && cardEffect.CanUse(null)
  789. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  790. {
  791. return false;
  792. }
  793. #endregion
  794. #region the effects of itself
  795. if (PermanentOfThisCard() == null)
  796. {
  797. if (EffectList(EffectTiming.None)
  798. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  799. && cardEffect.CanUse(null)
  800. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  801. {
  802. return false;
  803. }
  804. }
  805. #endregion
  806. return true;
  807. }
  808. #endregion
  809. #region whether the permanent can digivolve into this card
  810. public bool CanEvolve(Permanent targetPermanent, bool checkAvailability, CardEffectCommons.IgnoreRequirement ignore = CardEffectCommons.IgnoreRequirement.None)
  811. {
  812. if (targetPermanent != null)
  813. {
  814. if (CanNotEvolve(targetPermanent))
  815. {
  816. return false;
  817. }
  818. if (targetPermanent.TopCard != null)
  819. {
  820. foreach (Func<Permanent, int> EvoCost in EvoCosts(ignore, checkAvailability))
  821. {
  822. if (EvoCost(targetPermanent) >= 0)
  823. {
  824. return true;
  825. }
  826. }
  827. }
  828. }
  829. return false;
  830. }
  831. #endregion
  832. #region whether the permanent's digivolution into this card is prohibited
  833. public bool CanNotEvolve(Permanent targetPermanent)
  834. {
  835. if (targetPermanent.IsToken)
  836. {
  837. return true;
  838. }
  839. if (IsToken)
  840. {
  841. return true;
  842. }
  843. #region card effects that can't digivolve
  844. #region the effects of permanents
  845. if (GManager.instance.turnStateMachine.gameContext.Players
  846. .Map(player => player.GetFieldPermanents())
  847. .Flat()
  848. .Map(permanent => permanent.EffectList(EffectTiming.None))
  849. .Flat()
  850. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  851. && cardEffect.CanUse(null)
  852. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  853. {
  854. return true;
  855. }
  856. #endregion
  857. #region the effects of players
  858. if (GManager.instance.turnStateMachine.gameContext.Players
  859. .Map(player => player.EffectList(EffectTiming.None))
  860. .Flat()
  861. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  862. && cardEffect.CanUse(null)
  863. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  864. {
  865. return true;
  866. }
  867. #endregion
  868. #region the effects of itself
  869. if (PermanentOfThisCard() == null)
  870. {
  871. if (EffectList(EffectTiming.None)
  872. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  873. && cardEffect.CanUse(null)
  874. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  875. {
  876. return true;
  877. }
  878. }
  879. #endregion
  880. #endregion
  881. return false;
  882. }
  883. #endregion
  884. #region ENG card name from entity
  885. public string BaseENGCardNameFromEntity => _cEntity_Base.CardName_ENG;
  886. #endregion
  887. #region JPN card name from entity
  888. public string BaseJPNCardNameFromEntity => _cEntity_Base.CardName_ENG;
  889. #endregion
  890. #region base card names
  891. public List<string> BaseCardNames
  892. {
  893. get
  894. {
  895. List<string> baseCardNames = new List<string>() { BaseENGCardNameFromEntity };
  896. Permanent thisPermanent = PermanentOfThisCard();
  897. bool isPermanent = PermanentOfThisCard() != null;
  898. bool isDigivolutionCard = isPermanent && thisPermanent.DigivolutionCards.Contains(this);
  899. #region card effects that change base card names
  900. if (isDigivolutionCard)
  901. {
  902. EffectList_ExceptAddedEffects(EffectTiming.None)
  903. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  904. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  905. }
  906. else
  907. {
  908. #region the effects of itself
  909. if (PermanentOfThisCard() == null)
  910. {
  911. EffectList(EffectTiming.None)
  912. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  913. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  914. }
  915. #endregion
  916. #region the effects of permanents
  917. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  918. .Map(player => player.GetFieldPermanents())
  919. .Flat()
  920. .Map(permanent => permanent.EffectList(EffectTiming.None))
  921. .Flat()
  922. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  923. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  924. #endregion
  925. #region the effects of players
  926. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  927. .Map(player => player.EffectList(EffectTiming.None))
  928. .Flat()
  929. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  930. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  931. #endregion
  932. }
  933. #endregion
  934. return baseCardNames;
  935. }
  936. }
  937. #endregion
  938. #region card names
  939. public List<string> CardNames
  940. {
  941. get
  942. {
  943. List<string> cardNames = BaseCardNames.Clone();
  944. #region the effects of itself
  945. EffectList_ExceptAddedEffects(EffectTiming.None)
  946. .Filter(cardEffect => cardEffect != null)
  947. .Filter(cardEffect => cardEffect is IChangeCardNamesEffect && cardEffect.CanUse(null))
  948. .ForEach(cardEffect => cardNames = ((IChangeCardNamesEffect)cardEffect).ChangeCardNames(cardNames, this));
  949. #endregion
  950. return cardNames.Distinct().ToList();
  951. }
  952. }
  953. #endregion
  954. #region Whether target other card's name has same name as this
  955. public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => EqualsCardName(cardName)) >= 1;
  956. //public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => CardNames.Contains(cardName)) >= 1;
  957. #endregion
  958. #region whether this card has at least 1 card name that equals the string
  959. /// <summary>
  960. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  961. /// </summary>
  962. /// <param name="string">value to check for</param>
  963. /// <author>Mike Bunch</author>
  964. public bool EqualsCardName(string name)
  965. {
  966. if (string.IsNullOrEmpty(name))
  967. {
  968. return false;
  969. }
  970. string replaced = name.Replace(" ", "");
  971. string lower = name.ToLower();
  972. return CardNames.Some((cardName) =>
  973. cardName.Equals(name)
  974. || cardName.Equals(replaced)
  975. || cardName.Replace(" ", "").Equals(replaced)
  976. || cardName.Equals(lower)
  977. || cardName.ToLower().Equals(lower));
  978. }
  979. #endregion
  980. #region whether this card has at least 1 card name that contains the string
  981. /// <summary>
  982. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  983. /// </summary>
  984. /// <param trait="string">value to check for</param>
  985. /// <author>Mike Bunch</author>
  986. public bool ContainsCardName(string name)
  987. {
  988. if (string.IsNullOrEmpty(name))
  989. {
  990. return false;
  991. }
  992. string replaced = name.Replace(" ", "");
  993. string lower = name.ToLower();
  994. return CardNames.Some((cardName) =>
  995. cardName.Contains(name)
  996. || cardName.Contains(replaced)
  997. || cardName.Contains(lower)
  998. || cardName.ToLower().Contains(lower));
  999. }
  1000. #endregion
  1001. #region whether this card has at least 1 card name that contains "Greymon"
  1002. public bool HasGreymonName
  1003. {
  1004. get
  1005. {
  1006. if (CardNames.Some((cardName) => (cardName.Contains("Greymon") || cardName.Contains("greymon"))
  1007. && cardName != "DoruGreymon"
  1008. && cardName != "BurningGreymon"
  1009. && cardName != "DexDoruGreymon"))
  1010. {
  1011. return true;
  1012. }
  1013. return false;
  1014. }
  1015. }
  1016. #endregion
  1017. #region whether this card has at least 1 card name that contains "Garurumon"
  1018. public bool HasGarurumonName
  1019. {
  1020. get
  1021. {
  1022. if (CardNames.Some((cardName) => (cardName.Contains("Garurumon") || cardName.Contains("garurumon"))
  1023. && cardName != "KendoGarurumon"))
  1024. {
  1025. return true;
  1026. }
  1027. return false;
  1028. }
  1029. }
  1030. #endregion
  1031. #region whether this card has at least 1 card name that contains "Impmon"
  1032. public bool HasImpmonName
  1033. {
  1034. get
  1035. {
  1036. if (CardNames.Some((cardName) => (cardName.Contains("Impmon") || cardName.Contains("impmon"))
  1037. && cardName != "Blimpmon"))
  1038. {
  1039. return true;
  1040. }
  1041. return false;
  1042. }
  1043. }
  1044. #endregion
  1045. #region whether this card has at least 1 card name that contains "Dramon"
  1046. public bool HasDramonName
  1047. {
  1048. get
  1049. {
  1050. if (CardNames.Some((cardName) => (cardName.Contains("Dramon") || cardName.Contains("dramon"))
  1051. && cardName != "Indramon"))
  1052. {
  1053. return true;
  1054. }
  1055. return false;
  1056. }
  1057. }
  1058. #endregion
  1059. #region whether this card has at least 1 card name that contains "AAntibody"
  1060. public bool HasXAntiBodyName => CardNames.Some(DataBase.IsContainingXAntibodyString);
  1061. #endregion
  1062. #region whether this card has at least 1 trait that equals the string
  1063. /// <summary>
  1064. /// Used to check if specified trait is exactly in cards trait values ("Sky Dragon" is not "Dragon")
  1065. /// </summary>
  1066. /// <param trait="string">value to check for</param>
  1067. /// <author>Mike Bunch</author>
  1068. public bool EqualsTraits(string trait)
  1069. {
  1070. if (string.IsNullOrEmpty(trait))
  1071. return false;
  1072. string replaced = trait.Replace(" ", "");
  1073. return CardTraits.Some(cardTrait => cardTrait.Equals(trait) || cardTrait.Equals(replaced));
  1074. }
  1075. #endregion
  1076. #region whether this card has at least 1 trait that contains the string
  1077. /// <summary>
  1078. /// Used to check if specified trait is within cards trait values ("Sky Dragon" contains "Dragon")
  1079. /// </summary>
  1080. /// <param trait="string">value to check for</param>
  1081. /// <author>Mike Bunch</author>
  1082. public bool ContainsTraits(string trait)
  1083. {
  1084. if (string.IsNullOrEmpty(trait))
  1085. return false;
  1086. string replaced = trait.Replace(" ", "");
  1087. return CardTraits.Some(cardTrait => cardTrait.Contains(trait) || cardTrait.Contains(replaced));
  1088. }
  1089. #endregion
  1090. #region whether this card has at least 1 trait that contains "Bird"
  1091. public bool HasBirdTraits
  1092. {
  1093. get
  1094. {
  1095. if (ContainsTraits("Avian"))
  1096. {
  1097. return true;
  1098. }
  1099. if (ContainsTraits("Bird"))
  1100. {
  1101. return true;
  1102. }
  1103. return false;
  1104. }
  1105. }
  1106. #endregion
  1107. #region whether this card has at least 1 trait that contains "Beast"
  1108. public bool HasBeastTraits
  1109. {
  1110. get
  1111. {
  1112. if (ContainsTraits("Beast"))
  1113. {
  1114. return true;
  1115. }
  1116. if (ContainsTraits("Animal") && !ContainsTraits("Sea"))
  1117. {
  1118. return true;
  1119. }
  1120. if (ContainsTraits("Sovereign"))
  1121. {
  1122. return true;
  1123. }
  1124. return false;
  1125. }
  1126. }
  1127. #endregion
  1128. #region whether this card has at least 1 trait that contains "Plant"
  1129. public bool HasPlantTraits
  1130. {
  1131. get
  1132. {
  1133. if (ContainsTraits("Vegetation"))
  1134. {
  1135. return true;
  1136. }
  1137. if (ContainsTraits("Plant"))
  1138. {
  1139. return true;
  1140. }
  1141. return false;
  1142. }
  1143. }
  1144. #endregion
  1145. #region whether this card has at least 1 trait that contains "Fairy"
  1146. public bool HasFairyTraits
  1147. {
  1148. get
  1149. {
  1150. if (ContainsTraits("Fairy"))
  1151. {
  1152. return true;
  1153. }
  1154. return false;
  1155. }
  1156. }
  1157. #endregion
  1158. #region whether this card has at least 1 trait that contains "Dragon"
  1159. public bool HasDragonTraits
  1160. {
  1161. get
  1162. {
  1163. if (ContainsTraits("Dragon"))
  1164. {
  1165. return true;
  1166. }
  1167. if (ContainsTraits("saur"))
  1168. {
  1169. return true;
  1170. }
  1171. if (ContainsTraits("Ceratopsian"))
  1172. {
  1173. return true;
  1174. }
  1175. return false;
  1176. }
  1177. }
  1178. #endregion
  1179. #region whether this card has at least 1 trait that contains "Aqua"
  1180. public bool HasAquaTraits
  1181. {
  1182. get
  1183. {
  1184. if (ContainsTraits("Aqua"))
  1185. {
  1186. return true;
  1187. }
  1188. if (ContainsTraits("Sea Animal"))
  1189. {
  1190. return true;
  1191. }
  1192. if (ContainsTraits("SeaAnimal"))
  1193. {
  1194. return true;
  1195. }
  1196. return false;
  1197. }
  1198. }
  1199. #endregion
  1200. #region whether this card has at least 1 trait that contains "Angel"
  1201. public bool HasAngelTraits
  1202. {
  1203. get
  1204. {
  1205. if (CardTraits.Count((trait) => (trait.Contains("Angel") || trait.Contains("angel")) && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1206. {
  1207. return true;
  1208. }
  1209. if (ContainsTraits("Cherub"))
  1210. {
  1211. return true;
  1212. }
  1213. if (ContainsTraits("Throne"))
  1214. {
  1215. return true;
  1216. }
  1217. if (ContainsTraits("Authority"))
  1218. {
  1219. return true;
  1220. }
  1221. if (ContainsTraits("Seraph"))
  1222. {
  1223. return true;
  1224. }
  1225. if (ContainsTraits("Virtue"))
  1226. {
  1227. return true;
  1228. }
  1229. return false;
  1230. }
  1231. }
  1232. #endregion
  1233. #region whether this card has 1 of the "Angel", "Archangel" or "Three Great Angels" trait
  1234. public bool HasAngelTraitRestrictive
  1235. {
  1236. get
  1237. {
  1238. if (ContainsTraits("Three Great Angels") || ContainsTraits("ThreeGreatAngels"))
  1239. {
  1240. return true;
  1241. }
  1242. if (ContainsTraits("Archangel"))
  1243. {
  1244. return true;
  1245. }
  1246. if (CardTraits.Count(trait =>
  1247. (trait.Contains("Angel") || trait.Contains("angel"))
  1248. && trait != "Archangel"
  1249. && trait != "Fallen Angel" && trait != "FallenAngel"
  1250. && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1251. {
  1252. return true;
  1253. }
  1254. return false;
  1255. }
  1256. }
  1257. #endregion
  1258. #region whether this card has at least 1 trait that contains "Avian", "Bird", "Beast", "Animal", "Sovereign", other than "Sea Animal"
  1259. public bool HasAvianBeastAnimalTraits
  1260. {
  1261. get
  1262. {
  1263. if (ContainsTraits("Avian"))
  1264. return true;
  1265. if (ContainsTraits("Bird"))
  1266. return true;
  1267. if (ContainsTraits("Beast"))
  1268. return true;
  1269. if (ContainsTraits("Animal") && !ContainsTraits("Sea Animal"))
  1270. return true;
  1271. if (ContainsTraits("Sovereign"))
  1272. return true;
  1273. return false;
  1274. }
  1275. }
  1276. #endregion
  1277. #region whether this card has at least 1 trait that contains "Hybrid", "Ten Warriors"
  1278. public bool HasHybridTenWarriorsTraits
  1279. {
  1280. get
  1281. {
  1282. if (ContainsTraits("Hybrid"))
  1283. return true;
  1284. if (ContainsTraits("Ten Warriors"))
  1285. return true;
  1286. return false;
  1287. }
  1288. }
  1289. #endregion
  1290. #region whether this card has "XAntibody" trait
  1291. public bool HasXAntibodyTraits => CardTraits.Some(DataBase.IsXAntibodyString);
  1292. #endregion
  1293. #region whether this card has "Royal Knight" trait
  1294. public bool HasRoyalKnightTraits
  1295. {
  1296. get
  1297. {
  1298. return EqualsTraits("Royal Knight");
  1299. }
  1300. }
  1301. #endregion
  1302. #region whether this card has "SoC" trait
  1303. public bool HasSocTraits
  1304. {
  1305. get
  1306. {
  1307. if (CardTraits.Contains("SoC"))
  1308. {
  1309. return true;
  1310. }
  1311. return false;
  1312. }
  1313. }
  1314. #endregion
  1315. #region whether this card has "D-Brigade"/"DigiPolice trait
  1316. public bool HasDBrigadeorDigiPoliceTraits
  1317. {
  1318. get
  1319. {
  1320. if (CardTraits.Contains("D-Brigade"))
  1321. {
  1322. return true;
  1323. }
  1324. if (CardTraits.Contains("DigiPolice"))
  1325. {
  1326. return true;
  1327. }
  1328. return false;
  1329. }
  1330. }
  1331. #endregion
  1332. #region whether this card has at least 1 trait that contains "Beast Dragon"
  1333. public bool HasBeastDragonTraits
  1334. {
  1335. get
  1336. {
  1337. if (ContainsTraits("BeastDragon"))
  1338. {
  1339. return true;
  1340. }
  1341. if (ContainsTraits("Beast Dragon"))
  1342. {
  1343. return true;
  1344. }
  1345. return false;
  1346. }
  1347. }
  1348. #endregion
  1349. #region whether this card has at least 1 trait that contains "DigiPolice"
  1350. public bool HasDigiPoliceTraits
  1351. {
  1352. get
  1353. {
  1354. if (ContainsTraits("DigiPolice"))
  1355. {
  1356. return true;
  1357. }
  1358. return false;
  1359. }
  1360. }
  1361. #endregion
  1362. #region whether this card has at least 1 trait that contains "Light Fang" or "Night Claw"
  1363. public bool HasLightFangNightClawTraits => ContainsTraits("Light Fang") || ContainsTraits("Night Claw");
  1364. #endregion
  1365. #region whether this card has at least 1 trait that contains "Light Fang/Night Claw"
  1366. public bool HasLightFangOrNightClawTraits
  1367. {
  1368. get
  1369. {
  1370. if (ContainsTraits("Light Fang"))
  1371. {
  1372. return true;
  1373. }
  1374. if (ContainsTraits("Night Claw"))
  1375. {
  1376. return true;
  1377. }
  1378. return false;
  1379. }
  1380. }
  1381. #endregion
  1382. #region whether this card has the string in text
  1383. public bool HasText(string text)
  1384. {
  1385. if (String.IsNullOrEmpty(text)) return false;
  1386. text = DataBase.ReplaceToASCII(text);
  1387. string replaced = text.Replace(" ", "");
  1388. string lower = text.ToLower();
  1389. List<string> checkStrings = new List<string>()
  1390. {
  1391. DataBase.ReplaceToASCII(_cEntity_Base.CardName_ENG),
  1392. DataBase.ReplaceToASCII(_cEntity_Base.EffectDiscription_ENG),
  1393. DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG),
  1394. DataBase.ReplaceToASCII(_cEntity_Base.SecurityEffectDiscription_ENG),
  1395. };
  1396. foreach (string attribute in _cEntity_Base.Attribute_ENG)
  1397. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1398. foreach (string attribute in _cEntity_Base.Type_ENG)
  1399. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1400. if (jogressCondition != null)
  1401. {
  1402. foreach (JogressConditionElement element in jogressCondition.elements)
  1403. checkStrings.Add(element.SelectMessage);
  1404. }
  1405. foreach (string checkString in checkStrings)
  1406. {
  1407. if (!string.IsNullOrEmpty(checkString))
  1408. {
  1409. if (checkString.Contains(text))
  1410. {
  1411. return true;
  1412. }
  1413. if (checkString.Contains(replaced))
  1414. {
  1415. return true;
  1416. }
  1417. if (checkString.Contains(lower))
  1418. {
  1419. return true;
  1420. }
  1421. }
  1422. }
  1423. return false;
  1424. }
  1425. #endregion
  1426. #region whether this card has <Save> in text
  1427. public bool HasSaveText => HasText("<Save>");
  1428. #endregion
  1429. #region whether this card has "Pulsemon" in text
  1430. public bool HasPulsemonText => HasText("Pulsemon");
  1431. #endregion
  1432. #region card names checked when digixros
  1433. public List<string> CardNames_DigiXros
  1434. {
  1435. get
  1436. {
  1437. List<string> cardNames_DigiXros = CardNames.Clone();
  1438. #region the effects of itself
  1439. EffectList(EffectTiming.None)
  1440. .Filter(cardEffect => cardEffect is IChangeCardNamesForDigiXrosEffect && cardEffect.CanUse(null))
  1441. .ForEach(cardEffect => cardNames_DigiXros = ((IChangeCardNamesForDigiXrosEffect)cardEffect).ChangeCardNamesForDigiXros(cardNames_DigiXros, this));
  1442. #endregion
  1443. return cardNames_DigiXros;
  1444. }
  1445. }
  1446. #endregion
  1447. #region whether this card has at least 1 card name checked when digixros that equals the string
  1448. /// <summary>
  1449. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1450. /// </summary>
  1451. /// <param name="string">value to check for</param>
  1452. /// <author>Mike Bunch</author>
  1453. public bool EqualsCardNameDigiXros(string name)
  1454. {
  1455. if (string.IsNullOrEmpty(name))
  1456. {
  1457. return false;
  1458. }
  1459. string replaced = name.Replace(" ", "");
  1460. string lower = name.ToLower();
  1461. return CardNames_DigiXros.Some((cardName) =>
  1462. cardName.Equals(name)
  1463. || cardName.Equals(replaced)
  1464. || cardName.Equals(lower)
  1465. || cardName.ToLower().Equals(lower));
  1466. }
  1467. #endregion
  1468. #region whether this card has at least 1 card name that contains the string
  1469. /// <summary>
  1470. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1471. /// </summary>
  1472. /// <param trait="string">value to check for</param>
  1473. /// <author>Mike Bunch</author>
  1474. public bool ContainsCardNameDigiXros(string name)
  1475. {
  1476. if (string.IsNullOrEmpty(name))
  1477. {
  1478. return false;
  1479. }
  1480. string replaced = name.Replace(" ", "");
  1481. string lower = name.ToLower();
  1482. return CardNames_DigiXros.Some((cardName) =>
  1483. cardName.Contains(name)
  1484. || cardName.Contains(replaced)
  1485. || cardName.Contains(lower)
  1486. || cardName.ToLower().Contains(lower));
  1487. }
  1488. #endregion
  1489. #region preferered frame to play
  1490. public FieldCardFrame PreferredFrame()
  1491. {
  1492. FieldCardFrame PreferredFrame = Owner.fieldCardFrames[0];
  1493. List<FieldCardFrame> fieldCardFrames =
  1494. Owner.fieldCardFrames
  1495. .Filter(fieldCardFrame => fieldCardFrame.IsBattleAreaFrame()
  1496. && fieldCardFrame.IsEmptyFrame());
  1497. if (_cEntity_Base != null)
  1498. {
  1499. if (IsDigimon || IsDigiEgg)
  1500. {
  1501. if (Owner.isYou)
  1502. {
  1503. fieldCardFrames = fieldCardFrames
  1504. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1505. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1506. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1507. .ToList();
  1508. }
  1509. else
  1510. {
  1511. fieldCardFrames = fieldCardFrames
  1512. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1513. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1514. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1515. .ToList();
  1516. int[] correctOrder = new int[] { 4, 3, 5, 2, 6, 1, 7, 0, 8, 11, 10, 12, 9, 13, 14, 15, };
  1517. List<FieldCardFrame> correctOrderFrames = new List<FieldCardFrame>();
  1518. for (int i = 0; i < correctOrder.Length; i++)
  1519. {
  1520. foreach (FieldCardFrame frame in fieldCardFrames)
  1521. {
  1522. if (frame.FrameID == correctOrder[i])
  1523. {
  1524. correctOrderFrames.Add(frame);
  1525. }
  1526. }
  1527. }
  1528. fieldCardFrames = correctOrderFrames;
  1529. }
  1530. }
  1531. else if (IsTamer || IsOption)
  1532. {
  1533. if (Owner.isYou)
  1534. {
  1535. fieldCardFrames = fieldCardFrames
  1536. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1537. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1538. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1539. .ToList();
  1540. }
  1541. else
  1542. {
  1543. fieldCardFrames = fieldCardFrames
  1544. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1545. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1546. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1547. .ToList();
  1548. }
  1549. }
  1550. if (fieldCardFrames.Count >= 1)
  1551. {
  1552. PreferredFrame = fieldCardFrames[0];
  1553. }
  1554. }
  1555. return PreferredFrame;
  1556. }
  1557. #endregion
  1558. #region Whether this card has DP
  1559. public bool HasDP => IsDigimon || _cEntity_Base.DP > 0;
  1560. #endregion
  1561. #region base card DP
  1562. public int BaseCardDP => _cEntity_Base.DP;
  1563. #endregion
  1564. #region DP
  1565. public int CardDP
  1566. {
  1567. get
  1568. {
  1569. int cardDP = -1;
  1570. if (HasDP)
  1571. {
  1572. cardDP = BaseCardDP;
  1573. #region card effects that change card DP
  1574. List<ICardEffect> changeCardDPCardEffects = new List<ICardEffect>();
  1575. #region the effects of permanents
  1576. changeCardDPCardEffects = changeCardDPCardEffects
  1577. .Concat(
  1578. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1579. .Map(player => player.GetFieldPermanents())
  1580. .Flat()
  1581. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1582. .Flat()
  1583. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1584. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1585. .ToList();
  1586. #endregion
  1587. #region the effects of players
  1588. changeCardDPCardEffects = changeCardDPCardEffects
  1589. .Concat(
  1590. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1591. .Map(player => player.EffectList(EffectTiming.None))
  1592. .Flat()
  1593. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1594. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1595. .ToList();
  1596. #endregion
  1597. List<ICardEffect> cardEffects_ChangeDP_IsUpDown = changeCardDPCardEffects
  1598. .Filter(cardEffect => ((IChangeCardDPEffect)cardEffect).IsUpDown());
  1599. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = changeCardDPCardEffects
  1600. .Filter(cardEffect => !((IChangeCardDPEffect)cardEffect).IsUpDown());
  1601. cardEffects_ChangeDP_IsUpDown
  1602. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1603. cardEffects_ChangeDP_NotIsUpDown
  1604. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1605. #endregion
  1606. }
  1607. return Math.Max(0, cardDP);
  1608. }
  1609. }
  1610. #endregion
  1611. #region Link DP
  1612. public int LinkDP => _cEntity_Base.LinkDP;
  1613. #endregion
  1614. #region whether this card is token
  1615. public bool IsToken { get; private set; } = false;
  1616. public void SetIsToken(bool isToken) => IsToken = isToken;
  1617. #endregion
  1618. #region Will this card be trashed from sources
  1619. public bool willBeRemoveSources { get; set; } = false;
  1620. #endregion
  1621. #region whether this card can not be trashed from digivolution cards
  1622. public bool CanNotTrashFromDigivolutionCards(ICardEffect _cardEffect)
  1623. {
  1624. if (willBeRemoveSources)
  1625. return true;
  1626. #region the effects of permanents
  1627. if (GManager.instance.turnStateMachine.gameContext.Players
  1628. .Map(player => player.GetFieldPermanents())
  1629. .Flat()
  1630. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1631. .Flat()
  1632. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1633. && cardEffect.CanUse(null)
  1634. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1635. {
  1636. return true;
  1637. }
  1638. #endregion
  1639. #region the effects of players
  1640. if (GManager.instance.turnStateMachine.gameContext.Players
  1641. .Map(player => player.EffectList(EffectTiming.None))
  1642. .Flat()
  1643. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1644. && cardEffect.CanUse(null)
  1645. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1646. {
  1647. return true;
  1648. }
  1649. #endregion
  1650. #region the effects of itself
  1651. if (PermanentOfThisCard() == null)
  1652. {
  1653. if (EffectList(EffectTiming.None)
  1654. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1655. && cardEffect.CanUse(null)
  1656. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1657. {
  1658. return true;
  1659. }
  1660. }
  1661. #endregion
  1662. return false;
  1663. }
  1664. #endregion
  1665. #region whether this card has [Blocker]
  1666. public bool HasBlocker =>
  1667. EffectList(EffectTiming.None)
  1668. .Some(cardEffect => cardEffect is BlockerClass
  1669. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect);
  1670. #endregion
  1671. #region whether this card has [DigiBurst]
  1672. public bool HasDigiBurst
  1673. {
  1674. get
  1675. {
  1676. if (_cEntity_Base != null)
  1677. {
  1678. if (!string.IsNullOrEmpty(_cEntity_Base.EffectDiscription_JPN))
  1679. {
  1680. bool result = Regex.IsMatch(_cEntity_Base.EffectDiscription_JPN, DataBase.DigiburstRegex);
  1681. if (result)
  1682. {
  1683. return true;
  1684. }
  1685. }
  1686. }
  1687. return false;
  1688. }
  1689. }
  1690. #endregion
  1691. #region whether this card has [DigiXros]
  1692. public bool HasDigiXros => digiXrosCondition != null;
  1693. #endregion
  1694. #region traits
  1695. public List<string> CardTraits
  1696. {
  1697. get
  1698. {
  1699. List<string> traits =
  1700. _cEntity_Base.Form_ENG
  1701. .Filter(s => !string.IsNullOrEmpty(s))
  1702. .Concat(_cEntity_Base.Attribute_ENG
  1703. .Filter(s => !string.IsNullOrEmpty(s)))
  1704. .Concat(_cEntity_Base.Type_ENG
  1705. .Filter(s => !string.IsNullOrEmpty(s)))
  1706. .ToList();
  1707. #region the effects of itself
  1708. EffectList(EffectTiming.None)
  1709. .Filter(cardEffect => cardEffect is IChangeTraitsEffect && cardEffect.CanUse(null))
  1710. .ForEach(cardEffect => traits = ((IChangeTraitsEffect)cardEffect).ChangTraits(traits, this));
  1711. #endregion
  1712. return traits;
  1713. }
  1714. }
  1715. #endregion
  1716. #region whether this card has [On Deletion] effect
  1717. public bool HasOnDeletionEffect =>
  1718. EffectList(EffectTiming.OnDestroyedAnyone)
  1719. .Some(cardEffect => cardEffect is ActivateICardEffect
  1720. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1721. && cardEffect.IsOnDeletion);
  1722. #endregion
  1723. #region whether this card has [On Play] effect
  1724. public bool HasOnPlayEffect =>
  1725. EffectList(EffectTiming.OnEnterFieldAnyone)
  1726. .Some(cardEffect => cardEffect is ActivateICardEffect
  1727. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1728. && cardEffect.IsOnPlay);
  1729. #endregion
  1730. #region whether this card has [When Digivolving] effect
  1731. public bool HasWhenDigivolvingEffect =>
  1732. EffectList(EffectTiming.OnEnterFieldAnyone)
  1733. .Some(cardEffect => cardEffect is ActivateICardEffect
  1734. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1735. && cardEffect.IsWhenDigivolving);
  1736. #endregion
  1737. #region whether this card has [Digisorption]
  1738. public bool HasDigisorption =>
  1739. EffectList(EffectTiming.BeforePayCost)
  1740. .Some(cardEffect => cardEffect is ActivateICardEffect
  1741. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1742. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1743. && cardEffect.EffectDiscription.Contains("Digisorption -"));
  1744. #endregion
  1745. #region whether this card has [Blitz]
  1746. public bool HasBlitz =>
  1747. EffectList(EffectTiming.OnEnterFieldAnyone)
  1748. .Some(cardEffect => cardEffect is ActivateICardEffect
  1749. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1750. && (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfCard(this)))
  1751. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1752. && cardEffect.EffectDiscription.Contains("Blitz"));
  1753. #endregion
  1754. #region whether this card has [Retaliation]
  1755. public bool HasRetaliation =>
  1756. EffectList(EffectTiming.OnDestroyedAnyone)
  1757. .Some(cardEffect => cardEffect is ActivateICardEffect
  1758. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1759. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1760. && cardEffect.EffectName == "Retaliation");
  1761. #endregion
  1762. #region whether this card has [Fortitude]
  1763. public bool HasFortitude =>
  1764. EffectList(EffectTiming.OnDestroyedAnyone)
  1765. .Some(cardEffect => cardEffect is ActivateICardEffect
  1766. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1767. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1768. && cardEffect.EffectName == "Fortitude");
  1769. #endregion
  1770. #region whether this card has inherited effect
  1771. public bool HasInheritedEffect
  1772. {
  1773. get
  1774. {
  1775. foreach (EffectTiming timing in Enum.GetValues(typeof(EffectTiming)))
  1776. {
  1777. if (EffectList(timing)
  1778. .Some(cardEffect => cardEffect.IsInheritedEffect
  1779. && !cardEffect.IsDisabled))
  1780. {
  1781. return true;
  1782. }
  1783. }
  1784. return false;
  1785. }
  1786. }
  1787. #endregion
  1788. #region DNA digivolution requirement
  1789. public JogressCondition jogressCondition
  1790. {
  1791. get
  1792. {
  1793. ICardEffect addJogressConditionEffect =
  1794. EffectList(EffectTiming.None)
  1795. .Find(cardEffect => cardEffect is IAddJogressConditionEffect
  1796. && cardEffect.CanUse(null)
  1797. && ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this) != null);
  1798. if (addJogressConditionEffect != null) return ((IAddJogressConditionEffect)addJogressConditionEffect).GetJogressCondition(this);
  1799. return null;
  1800. }
  1801. }
  1802. #endregion
  1803. #region whether this card can DNA digivolve
  1804. public bool CanPlayJogress(bool PayCost)
  1805. {
  1806. if (jogressCondition != null)
  1807. {
  1808. if (Owner.GetBattleAreaDigimons().Count >= jogressCondition.elements.Length)
  1809. {
  1810. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(Owner.GetBattleAreaDigimons(), jogressCondition.elements.Length).ToList();
  1811. foreach (Permanent[] permanents in permanentsList)
  1812. {
  1813. if (permanents != null)
  1814. {
  1815. if (permanents.Length == jogressCondition.elements.Length)
  1816. {
  1817. if (permanents.Length == 2)
  1818. {
  1819. if (jogressCondition.elements[0].EvoRootCondition(permanents[0]) && !this.CanNotEvolve(permanents[0]))
  1820. {
  1821. if (jogressCondition.elements[1].EvoRootCondition(permanents[1]) && !this.CanNotEvolve(permanents[1]))
  1822. {
  1823. if (PayCost)
  1824. {
  1825. int cost = jogressCondition.cost;
  1826. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, permanents.ToList(), checkAvailability: true);
  1827. if (Owner.MaxMemoryCost < cost)
  1828. {
  1829. return false;
  1830. }
  1831. }
  1832. return true;
  1833. }
  1834. }
  1835. }
  1836. }
  1837. }
  1838. }
  1839. }
  1840. }
  1841. return false;
  1842. }
  1843. #endregion
  1844. #region whether target permanent can DNA digivolve into this card
  1845. public bool CanJogressFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  1846. {
  1847. if (targetPermanent != null)
  1848. {
  1849. if (targetPermanent.TopCard != null)
  1850. {
  1851. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  1852. {
  1853. if (this.CanPlayJogress(PayCost))
  1854. {
  1855. if (jogressCondition != null)
  1856. {
  1857. if (jogressCondition.elements.ToList().Count((element) => element.EvoRootCondition(targetPermanent)) >= 1)
  1858. {
  1859. if (!this.CanNotEvolve(targetPermanent))
  1860. {
  1861. if (PayCost)
  1862. {
  1863. int cost = jogressCondition.cost;
  1864. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent, new Permanent(new List<CardSource>()) }, checkAvailability: true);
  1865. if (Owner.MaxMemoryCost < cost)
  1866. {
  1867. return false;
  1868. }
  1869. }
  1870. return true;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. }
  1876. }
  1877. }
  1878. return false;
  1879. }
  1880. #endregion
  1881. #region whether target permanents can DNA digivolve into this card
  1882. public bool CanJogressFromTargetPermanents(List<Permanent> targetPermanents, bool PayCost)
  1883. {
  1884. if (targetPermanents != null)
  1885. {
  1886. if (targetPermanents.Count == 2)
  1887. {
  1888. if (this.CanPlayJogress(PayCost))
  1889. {
  1890. if (jogressCondition != null)
  1891. {
  1892. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(targetPermanents, 2).ToList();
  1893. foreach (Permanent[] permanents in permanentsList)
  1894. {
  1895. if (jogressCondition.elements.Length == permanents.Length)
  1896. {
  1897. bool canJogress = true;
  1898. for (int i = 0; i < permanents.Length; i++)
  1899. {
  1900. if (permanents[i] != null)
  1901. {
  1902. if (permanents[i].TopCard != null)
  1903. {
  1904. if ((!jogressCondition.elements[i].EvoRootCondition(permanents[i])) || this.CanNotEvolve(permanents[i]))
  1905. {
  1906. canJogress = false;
  1907. break;
  1908. }
  1909. }
  1910. }
  1911. }
  1912. if (canJogress)
  1913. {
  1914. return true;
  1915. }
  1916. }
  1917. }
  1918. }
  1919. }
  1920. }
  1921. }
  1922. return false;
  1923. }
  1924. #endregion
  1925. #region whether this card has level
  1926. public bool HasLevel => _cEntity_Base == null || _cEntity_Base.HasLevel;
  1927. #endregion
  1928. #region whether this card is level 2
  1929. public bool IsLevel2 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 2;
  1930. #endregion
  1931. #region whether this card is level 3
  1932. public bool IsLevel3 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 3;
  1933. #endregion
  1934. #region whether this card is level 4
  1935. public bool IsLevel4 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 4;
  1936. #endregion
  1937. #region whether this card is level 5
  1938. public bool IsLevel5 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 5;
  1939. #endregion
  1940. #region whether this card is level 6
  1941. public bool IsLevel6 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 6;
  1942. #endregion
  1943. #region DigiXros requirement
  1944. public DigiXrosCondition digiXrosCondition
  1945. {
  1946. get
  1947. {
  1948. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1949. {
  1950. if (cardEffect is IAddDigiXrosConditionEffect)
  1951. {
  1952. if (cardEffect.CanUse(null))
  1953. {
  1954. DigiXrosCondition digiXrosCondition = ((IAddDigiXrosConditionEffect)cardEffect).GetDigiXrosCondition(this);
  1955. if (digiXrosCondition != null)
  1956. {
  1957. return digiXrosCondition;
  1958. }
  1959. }
  1960. }
  1961. }
  1962. return null;
  1963. }
  1964. }
  1965. #endregion
  1966. #region Blast Digivolution requirement
  1967. public BurstDigivolutionCondition burstDigivolutionCondition
  1968. {
  1969. get
  1970. {
  1971. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1972. {
  1973. if (cardEffect is IAddBurstDigivolutionConditionEffect)
  1974. {
  1975. if (cardEffect.CanUse(null))
  1976. {
  1977. BurstDigivolutionCondition burstDigivolutionCondition = ((IAddBurstDigivolutionConditionEffect)cardEffect).GetBurstDigivolutionCondition(this);
  1978. if (burstDigivolutionCondition != null)
  1979. {
  1980. return burstDigivolutionCondition;
  1981. }
  1982. }
  1983. }
  1984. }
  1985. return null;
  1986. }
  1987. }
  1988. #endregion
  1989. #region App Fusion requirement
  1990. public AppFusionCondition appFusionCondition
  1991. {
  1992. get
  1993. {
  1994. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1995. {
  1996. if (cardEffect is IAddAppFusionConditionEffect)
  1997. {
  1998. if (cardEffect.CanUse(null))
  1999. {
  2000. AppFusionCondition appFusionCondition = ((IAddAppFusionConditionEffect)cardEffect).GetAppFusionCondition(this);
  2001. if (appFusionCondition != null)
  2002. {
  2003. return appFusionCondition;
  2004. }
  2005. }
  2006. }
  2007. }
  2008. return null;
  2009. }
  2010. }
  2011. #endregion
  2012. #region whether this card can Burst digivolve
  2013. public bool CanPlayBurst(bool PayCost)
  2014. {
  2015. if (burstDigivolutionCondition != null)
  2016. {
  2017. if (PayCost)
  2018. {
  2019. int cost = burstDigivolutionCondition.cost;
  2020. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2021. if (Owner.MaxMemoryCost < cost)
  2022. {
  2023. return false;
  2024. }
  2025. }
  2026. if (Owner.GetBattleAreaDigimons().Count >= 1)
  2027. {
  2028. foreach (Permanent digimon in Owner.GetFieldPermanents())
  2029. {
  2030. if (digimon != null)
  2031. {
  2032. if (!this.CanNotEvolve(digimon))
  2033. {
  2034. if (burstDigivolutionCondition.digimonCondition(digimon))
  2035. {
  2036. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2037. {
  2038. if (tamer != digimon)
  2039. {
  2040. if (burstDigivolutionCondition.tamerCondition(tamer))
  2041. {
  2042. if (!tamer.CannotReturnToHand(null))
  2043. {
  2044. if (PayCost)
  2045. {
  2046. int cost = burstDigivolutionCondition.cost;
  2047. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
  2048. if (Owner.MaxMemoryCost < cost)
  2049. {
  2050. return false;
  2051. }
  2052. }
  2053. return true;
  2054. }
  2055. }
  2056. }
  2057. }
  2058. }
  2059. }
  2060. }
  2061. }
  2062. }
  2063. }
  2064. return false;
  2065. }
  2066. #endregion
  2067. #region whether this card can App Fusion
  2068. public bool CanPlayAppFusion(bool PayCost)
  2069. {
  2070. if (appFusionCondition != null)
  2071. {
  2072. if (PayCost)
  2073. {
  2074. int cost = appFusionCondition.cost;
  2075. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2076. if (Owner.MaxMemoryCost < cost)
  2077. {
  2078. return false;
  2079. }
  2080. }
  2081. if (Owner.GetBattleAreaDigimons().Count >= 1)
  2082. {
  2083. foreach (Permanent digimon in Owner.GetFieldPermanents())
  2084. {
  2085. if (digimon != null)
  2086. {
  2087. if (!this.CanNotEvolve(digimon))
  2088. {
  2089. if (appFusionCondition.digimonCondition(digimon))
  2090. {
  2091. foreach (CardSource linkedCard in digimon.LinkedCards)
  2092. {
  2093. if (appFusionCondition.linkedCondition(linkedCard))
  2094. {
  2095. if (PayCost)
  2096. {
  2097. int cost = appFusionCondition.cost;
  2098. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
  2099. if (Owner.MaxMemoryCost < cost)
  2100. {
  2101. return false;
  2102. }
  2103. }
  2104. }
  2105. }
  2106. }
  2107. }
  2108. }
  2109. }
  2110. }
  2111. }
  2112. return false;
  2113. }
  2114. #endregion
  2115. #region whether target permanent can Burst digivolve into this card
  2116. public bool CanBurstDigivolutionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2117. {
  2118. if (targetPermanent != null)
  2119. {
  2120. if (targetPermanent.TopCard != null)
  2121. {
  2122. if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent))
  2123. {
  2124. if (this.CanPlayBurst(PayCost))
  2125. {
  2126. if (burstDigivolutionCondition != null)
  2127. {
  2128. if (!this.CanNotEvolve(targetPermanent))
  2129. {
  2130. if (burstDigivolutionCondition.digimonCondition(targetPermanent))
  2131. {
  2132. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2133. {
  2134. if (tamer != targetPermanent)
  2135. {
  2136. if (burstDigivolutionCondition.tamerCondition(tamer))
  2137. {
  2138. if (!tamer.CannotReturnToHand(null))
  2139. {
  2140. if (PayCost)
  2141. {
  2142. int cost = burstDigivolutionCondition.cost;
  2143. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2144. if (Owner.MaxMemoryCost < cost)
  2145. {
  2146. return false;
  2147. }
  2148. }
  2149. return true;
  2150. }
  2151. }
  2152. }
  2153. }
  2154. }
  2155. }
  2156. }
  2157. }
  2158. }
  2159. }
  2160. }
  2161. return false;
  2162. }
  2163. #endregion
  2164. #region whether target permanent can App Fusion into this card
  2165. public bool CanAppFusionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2166. {
  2167. if (targetPermanent != null)
  2168. {
  2169. if (targetPermanent.TopCard != null)
  2170. {
  2171. if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent))
  2172. {
  2173. if (this.CanPlayAppFusion(PayCost))
  2174. {
  2175. if (appFusionCondition != null)
  2176. {
  2177. if (!this.CanNotEvolve(targetPermanent))
  2178. {
  2179. if (appFusionCondition.digimonCondition(targetPermanent))
  2180. {
  2181. foreach (CardSource linkedCard in targetPermanent.LinkedCards)
  2182. {
  2183. if (appFusionCondition.linkedCondition(linkedCard))
  2184. {
  2185. if (PayCost)
  2186. {
  2187. int cost = appFusionCondition.cost;
  2188. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2189. if (Owner.MaxMemoryCost < cost)
  2190. {
  2191. return false;
  2192. }
  2193. }
  2194. }
  2195. }
  2196. }
  2197. }
  2198. }
  2199. }
  2200. }
  2201. }
  2202. }
  2203. return false;
  2204. }
  2205. #endregion
  2206. #region Whether this card's digiXrosCondition contains target card
  2207. public bool IsContainDigiXrosCondition(CardSource cardSource)
  2208. {
  2209. if (cardSource != null)
  2210. {
  2211. if (cardSource.Owner == Owner)
  2212. {
  2213. if (PermanentOfThisCard() != null)
  2214. {
  2215. if (PermanentOfThisCard().TopCard.HasDigiXros)
  2216. {
  2217. if (this == PermanentOfThisCard().TopCard)
  2218. {
  2219. if (digiXrosCondition != null)
  2220. {
  2221. if (digiXrosCondition.elements.Count((element) => element.CardCondition(cardSource)) >= 1)
  2222. {
  2223. return true;
  2224. }
  2225. }
  2226. }
  2227. }
  2228. }
  2229. }
  2230. }
  2231. return false;
  2232. }
  2233. #endregion
  2234. #region CardID
  2235. public string CardID => _cEntity_Base.CardID;
  2236. #endregion
  2237. #region whether this card is Digimon
  2238. public bool IsDigimon => CardKind == CardKind.Digimon;
  2239. #endregion
  2240. #region whether this card is DigiEgg
  2241. public bool IsDigiEgg => CardKind == CardKind.DigiEgg;
  2242. #endregion
  2243. #region whether this card is Tamer
  2244. public bool IsTamer => CardKind == CardKind.Tamer;
  2245. #endregion
  2246. #region whether this card is Option
  2247. public bool IsOption => CardKind == CardKind.Option;
  2248. #endregion
  2249. #region Wheter this card is permanent
  2250. public bool IsPermanent => _cEntity_Base.IsPermanent;
  2251. #endregion
  2252. #region Whether to have Play Cost
  2253. public bool HasPlayCost => _cEntity_Base.HasPlayCost;
  2254. #endregion
  2255. #region Whether to have Use Cost
  2256. public bool HasUseCost => _cEntity_Base.HasUseCost;
  2257. #endregion
  2258. #region Inherited Effects ENG discription
  2259. public string InheritedEffectDiscription_ENG => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG);
  2260. #endregion
  2261. #region Inherited Effects JPN discription
  2262. public string InheritedEffectDiscription_JPN => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_JPN);
  2263. #endregion
  2264. #region Card Sprite
  2265. public Sprite CardSprite => _cEntity_Base.CardSprite;
  2266. public async Task<Sprite> GetCardSprite()
  2267. {
  2268. return await _cEntity_Base.GetCardSprite();
  2269. }
  2270. #endregion
  2271. #region SetID
  2272. public string SetID => _cEntity_Base.SetID;
  2273. #endregion
  2274. #region CardEntityIndex
  2275. public int CardEntityIndex => _cEntity_Base.CardIndex;
  2276. #endregion
  2277. #region Card Kind
  2278. public CardKind CardKind => _cEntity_Base.cardKind;
  2279. #endregion
  2280. #region ACE
  2281. public bool IsACE => _cEntity_Base.IsACE;
  2282. #endregion
  2283. #region OverflowMemory
  2284. public int OverflowMemory => _cEntity_Base.OverflowMemory;
  2285. #endregion
  2286. #region Whether this card is being revealed
  2287. public bool IsBeingRevealed { get; set; } = false;
  2288. #endregion
  2289. #region The permanent that belonged to this card just before it left the field
  2290. public Permanent PermanentJustBeforeRemoveField { get; set; } = null;
  2291. #endregion
  2292. #region whether this card has "SEEKERS" trait
  2293. public bool HasSeekersTraits
  2294. {
  2295. get
  2296. {
  2297. if (CardTraits.Contains("SEEKERS"))
  2298. {
  2299. return true;
  2300. }
  2301. return false;
  2302. }
  2303. }
  2304. #endregion
  2305. #region whether this card has "ADVENTURE" trait
  2306. public bool HasAdventureTraits
  2307. {
  2308. get
  2309. {
  2310. if (CardTraits.Contains("ADVENTURE"))
  2311. {
  2312. return true;
  2313. }
  2314. return false;
  2315. }
  2316. }
  2317. #endregion
  2318. #region whether this card has "Hero" trait
  2319. public bool HasHeroTraits
  2320. {
  2321. get
  2322. {
  2323. if (CardTraits.Contains("Hero"))
  2324. {
  2325. return true
  2326. }
  2327. return float
  2328. }
  2329. }
  2330. #endregion
  2331. #region whether this card has "Chronicle" trait
  2332. public bool HasChronicleTraits
  2333. {
  2334. get
  2335. {
  2336. if (CardTraits.Contains("Chronicle"))
  2337. {
  2338. return true;
  2339. }
  2340. return false;
  2341. }
  2342. }
  2343. #endregion
  2344. #region whether this card has "Device" trait
  2345. public bool HasDeviceTraits
  2346. {
  2347. get
  2348. {
  2349. if (CardTraits.Contains("Device"))
  2350. {
  2351. return true;
  2352. }
  2353. return false;
  2354. }
  2355. }
  2356. #endregion
  2357. #region whether this card has "Three Musketeers" trait
  2358. public bool HasThreeMusketeersTraits
  2359. {
  2360. get
  2361. {
  2362. if (CardTraits.Contains("Three Musketeers"))
  2363. {
  2364. return true;
  2365. }
  2366. return false;
  2367. }
  2368. }
  2369. #endregion
  2370. #region whether this card has "Royal Base" trait
  2371. public bool HasRoyalBaseTraits
  2372. {
  2373. get
  2374. {
  2375. if (CardTraits.Contains("Royal Base"))
  2376. {
  2377. return true;
  2378. }
  2379. return false;
  2380. }
  2381. }
  2382. #endregion
  2383. }
  2384. public class JogressCondition
  2385. {
  2386. public JogressCondition(JogressConditionElement[] elements, int cost)
  2387. {
  2388. this.elements = new JogressConditionElement[2];
  2389. if (this.elements.Length == elements.Length)
  2390. {
  2391. for (int i = 0; i < elements.Length; i++)
  2392. {
  2393. this.elements[i] = elements[i];
  2394. }
  2395. }
  2396. this.cost = cost;
  2397. }
  2398. public JogressConditionElement[] elements { get; private set; } = new JogressConditionElement[2];
  2399. public int cost { get; private set; } = 0;
  2400. }
  2401. public class JogressConditionElement
  2402. {
  2403. public JogressConditionElement(Func<Permanent, bool> evoRootCondition, string selectMessage)
  2404. {
  2405. EvoRootCondition = evoRootCondition;
  2406. SelectMessage = selectMessage;
  2407. }
  2408. Func<Permanent, bool> _evoRootCondition = null;
  2409. public Func<Permanent, bool> EvoRootCondition
  2410. {
  2411. get
  2412. {
  2413. return permanent => _evoRootCondition == null || _evoRootCondition(permanent);
  2414. }
  2415. private set
  2416. {
  2417. _evoRootCondition = value;
  2418. }
  2419. }
  2420. public string SelectMessage { get; private set; } = "";
  2421. }
  2422. public class DigiXrosCondition
  2423. {
  2424. public DigiXrosCondition(List<DigiXrosConditionElement> elements, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, int reduceCostPerCard)
  2425. {
  2426. this.elements = new List<DigiXrosConditionElement>();
  2427. foreach (DigiXrosConditionElement element in elements)
  2428. {
  2429. this.elements.Add(element);
  2430. }
  2431. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  2432. this.reduceCostPerCard = reduceCostPerCard;
  2433. }
  2434. public List<DigiXrosConditionElement> elements { get; private set; } = new List<DigiXrosConditionElement>();
  2435. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; private set; } = null;
  2436. public int reduceCostPerCard { get; private set; } = 0;
  2437. }
  2438. public class DigiXrosConditionElement
  2439. {
  2440. public DigiXrosConditionElement(Func<CardSource, bool> cardCondition, string selectMessage, bool skipAllIfNoSelect = false)
  2441. {
  2442. this.CardCondition = cardCondition;
  2443. this.selectMessage = selectMessage;
  2444. this.skipAllIfNoSelect = skipAllIfNoSelect;
  2445. }
  2446. public Func<CardSource, bool> CardCondition { get; private set; } = null;
  2447. public string selectMessage { get; private set; } = "";
  2448. public bool skipAllIfNoSelect { get; private set; } = false;
  2449. }
  2450. public class BurstDigivolutionCondition
  2451. {
  2452. public BurstDigivolutionCondition(Func<Permanent, bool> tamerCondition, string selectTamerMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
  2453. {
  2454. this.tamerCondition = tamerCondition;
  2455. this.selectTamerMessage = selectTamerMessage;
  2456. this.digimonCondition = digimonCondition;
  2457. this.selectDigimonMessage = selectDigimonMessage;
  2458. this.cost = cost;
  2459. }
  2460. public Func<Permanent, bool> tamerCondition { get; private set; } = null;
  2461. public string selectTamerMessage { get; private set; } = null;
  2462. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  2463. public string selectDigimonMessage { get; private set; } = null;
  2464. public int cost { get; private set; } = 0;
  2465. }
  2466. public class AppFusionCondition
  2467. {
  2468. public AppFusionCondition(Func<CardSource, bool> linkedCondition, string selectLinkMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
  2469. {
  2470. this.linkedCondition = linkedCondition;
  2471. this.selectLinkMessage = selectLinkMessage;
  2472. this.digimonCondition = digimonCondition;
  2473. this.selectDigimonMessage = selectDigimonMessage;
  2474. this.cost = cost;
  2475. }
  2476. public Func<CardSource, bool> linkedCondition { get; private set; } = null;
  2477. public string selectLinkMessage { get; private set; } = null;
  2478. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  2479. public string selectDigimonMessage { get; private set; } = null;
  2480. public int cost { get; private set; } = 0;
  2481. }