CardSource.cs 97 KB

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