CardSource.cs 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776
  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) || permanent.LinkedCards.Any(linked => linked.Source == 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 Whether target other card's name has same name as this
  952. public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => EqualsCardName(cardName)) >= 1;
  953. //public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => CardNames.Contains(cardName)) >= 1;
  954. #endregion
  955. #region whether this card has at least 1 card name that equals the string
  956. /// <summary>
  957. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  958. /// </summary>
  959. /// <param name="string">value to check for</param>
  960. /// <author>Mike Bunch</author>
  961. public bool EqualsCardName(string name)
  962. {
  963. if (string.IsNullOrEmpty(name))
  964. {
  965. return false;
  966. }
  967. string replaced = name.Replace(" ", "");
  968. string lower = name.ToLower();
  969. return CardNames.Some((cardName) =>
  970. cardName.Equals(name)
  971. || cardName.Equals(replaced)
  972. || cardName.Equals(lower)
  973. || cardName.ToLower().Equals(lower));
  974. }
  975. #endregion
  976. #region whether this card has at least 1 card name that contains the string
  977. /// <summary>
  978. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  979. /// </summary>
  980. /// <param trait="string">value to check for</param>
  981. /// <author>Mike Bunch</author>
  982. public bool ContainsCardName(string name)
  983. {
  984. if (string.IsNullOrEmpty(name))
  985. {
  986. return false;
  987. }
  988. string replaced = name.Replace(" ", "");
  989. string lower = name.ToLower();
  990. return CardNames.Some((cardName) =>
  991. cardName.Contains(name)
  992. || cardName.Contains(replaced)
  993. || cardName.Contains(lower)
  994. || cardName.ToLower().Contains(lower));
  995. }
  996. #endregion
  997. #region whether this card has at least 1 card name that contains "Greymon"
  998. public bool HasGreymonName
  999. {
  1000. get
  1001. {
  1002. if (CardNames.Some((cardName) => (cardName.Contains("Greymon") || cardName.Contains("greymon"))
  1003. && cardName != "DoruGreymon"
  1004. && cardName != "BurningGreymon"
  1005. && cardName != "DexDoruGreymon"))
  1006. {
  1007. return true;
  1008. }
  1009. return false;
  1010. }
  1011. }
  1012. #endregion
  1013. #region whether this card has at least 1 card name that contains "Garurumon"
  1014. public bool HasGarurumonName
  1015. {
  1016. get
  1017. {
  1018. if (CardNames.Some((cardName) => (cardName.Contains("Garurumon") || cardName.Contains("garurumon"))
  1019. && cardName != "KendoGarurumon"))
  1020. {
  1021. return true;
  1022. }
  1023. return false;
  1024. }
  1025. }
  1026. #endregion
  1027. #region whether this card has at least 1 card name that contains "Impmon"
  1028. public bool HasImpmonName
  1029. {
  1030. get
  1031. {
  1032. if (CardNames.Some((cardName) => (cardName.Contains("Impmon") || cardName.Contains("impmon"))
  1033. && cardName != "Blimpmon"))
  1034. {
  1035. return true;
  1036. }
  1037. return false;
  1038. }
  1039. }
  1040. #endregion
  1041. #region whether this card has at least 1 card name that contains "Dramon"
  1042. public bool HasDramonName
  1043. {
  1044. get
  1045. {
  1046. if (CardNames.Some((cardName) => (cardName.Contains("Dramon") || cardName.Contains("dramon"))
  1047. && cardName != "Indramon"))
  1048. {
  1049. return true;
  1050. }
  1051. return false;
  1052. }
  1053. }
  1054. #endregion
  1055. #region whether this card has at least 1 card name that contains "AAntibody"
  1056. public bool HasXAntiBodyName => CardNames.Some(DataBase.IsContainingXAntibodyString);
  1057. #endregion
  1058. #region whether this card has at least 1 trait that equals the string
  1059. /// <summary>
  1060. /// Used to check if specified trait is exactly in cards trait values ("Sky Dragon" is not "Dragon")
  1061. /// </summary>
  1062. /// <param trait="string">value to check for</param>
  1063. /// <author>Mike Bunch</author>
  1064. public bool EqualsTraits(string trait)
  1065. {
  1066. if (string.IsNullOrEmpty(trait))
  1067. return false;
  1068. string replaced = trait.Replace(" ", "");
  1069. return CardTraits.Some(cardTrait => cardTrait.Equals(trait) || cardTrait.Equals(replaced));
  1070. }
  1071. #endregion
  1072. #region whether this card has at least 1 trait that contains the string
  1073. /// <summary>
  1074. /// Used to check if specified trait is within cards trait values ("Sky Dragon" contains "Dragon")
  1075. /// </summary>
  1076. /// <param trait="string">value to check for</param>
  1077. /// <author>Mike Bunch</author>
  1078. public bool ContainsTraits(string trait)
  1079. {
  1080. if (string.IsNullOrEmpty(trait))
  1081. return false;
  1082. string replaced = trait.Replace(" ", "");
  1083. return CardTraits.Some(cardTrait => cardTrait.Contains(trait) || cardTrait.Contains(replaced));
  1084. }
  1085. #endregion
  1086. #region whether this card has at least 1 trait that contains "Bird"
  1087. public bool HasBirdTraits
  1088. {
  1089. get
  1090. {
  1091. if (ContainsTraits("Avian"))
  1092. {
  1093. return true;
  1094. }
  1095. if (ContainsTraits("Bird"))
  1096. {
  1097. return true;
  1098. }
  1099. return false;
  1100. }
  1101. }
  1102. #endregion
  1103. #region whether this card has at least 1 trait that contains "Beast"
  1104. public bool HasBeastTraits
  1105. {
  1106. get
  1107. {
  1108. if (ContainsTraits("Beast"))
  1109. {
  1110. return true;
  1111. }
  1112. if (ContainsTraits("Animal") && !ContainsTraits("Sea"))
  1113. {
  1114. return true;
  1115. }
  1116. if (ContainsTraits("Sovereign"))
  1117. {
  1118. return true;
  1119. }
  1120. return false;
  1121. }
  1122. }
  1123. #endregion
  1124. #region whether this card has at least 1 trait that contains "Plant"
  1125. public bool HasPlantTraits
  1126. {
  1127. get
  1128. {
  1129. if (ContainsTraits("Vegetation"))
  1130. {
  1131. return true;
  1132. }
  1133. if (ContainsTraits("Plant"))
  1134. {
  1135. return true;
  1136. }
  1137. return false;
  1138. }
  1139. }
  1140. #endregion
  1141. #region whether this card has at least 1 trait that contains "Fairy"
  1142. public bool HasFairyTraits
  1143. {
  1144. get
  1145. {
  1146. if (ContainsTraits("Fairy"))
  1147. {
  1148. return true;
  1149. }
  1150. return false;
  1151. }
  1152. }
  1153. #endregion
  1154. #region whether this card has at least 1 trait that contains "Dragon"
  1155. public bool HasDragonTraits
  1156. {
  1157. get
  1158. {
  1159. if (ContainsTraits("Dragon"))
  1160. {
  1161. return true;
  1162. }
  1163. if (ContainsTraits("saur"))
  1164. {
  1165. return true;
  1166. }
  1167. if (ContainsTraits("Ceratopsian"))
  1168. {
  1169. return true;
  1170. }
  1171. return false;
  1172. }
  1173. }
  1174. #endregion
  1175. #region whether this card has at least 1 trait that contains "Aqua"
  1176. public bool HasAquaTraits
  1177. {
  1178. get
  1179. {
  1180. if (ContainsTraits("Aqua"))
  1181. {
  1182. return true;
  1183. }
  1184. if (ContainsTraits("Sea Animal"))
  1185. {
  1186. return true;
  1187. }
  1188. if(ContainsTraits("SeaAnimal"))
  1189. {
  1190. return true;
  1191. }
  1192. return false;
  1193. }
  1194. }
  1195. #endregion
  1196. #region whether this card has at least 1 trait that contains "Angel"
  1197. public bool HasAngelTraits
  1198. {
  1199. get
  1200. {
  1201. if (CardTraits.Count((trait) => (trait.Contains("Angel") || trait.Contains("angel")) && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1202. {
  1203. return true;
  1204. }
  1205. if (ContainsTraits("Cherub"))
  1206. {
  1207. return true;
  1208. }
  1209. if (ContainsTraits("Throne"))
  1210. {
  1211. return true;
  1212. }
  1213. if (ContainsTraits("Authority"))
  1214. {
  1215. return true;
  1216. }
  1217. if (ContainsTraits("Seraph"))
  1218. {
  1219. return true;
  1220. }
  1221. if (ContainsTraits("Virtue"))
  1222. {
  1223. return true;
  1224. }
  1225. return false;
  1226. }
  1227. }
  1228. #endregion
  1229. #region whether this card has 1 of the "Angel", "Archangel" or "Three Great Angels" trait
  1230. public bool HasAngelTraitRestrictive
  1231. {
  1232. get
  1233. {
  1234. if (ContainsTraits("Three Great Angels") || ContainsTraits("ThreeGreatAngels"))
  1235. {
  1236. return true;
  1237. }
  1238. if (ContainsTraits("Archangel"))
  1239. {
  1240. return true;
  1241. }
  1242. if (CardTraits.Count(trait =>
  1243. (trait.Contains("Angel") || trait.Contains("angel"))
  1244. && trait != "Archangel"
  1245. && trait != "Fallen Angel" && trait != "FallenAngel"
  1246. && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1247. {
  1248. return true;
  1249. }
  1250. return false;
  1251. }
  1252. }
  1253. #endregion
  1254. #region whether this card has at least 1 trait that contains "Avian", "Bird", "Beast", "Animal", "Sovereign", other than "Sea Animal"
  1255. public bool HasAvianBeastAnimalTraits
  1256. {
  1257. get
  1258. {
  1259. if (ContainsTraits("Avian"))
  1260. return true;
  1261. if (ContainsTraits("Bird"))
  1262. return true;
  1263. if (ContainsTraits("Beast"))
  1264. return true;
  1265. if (ContainsTraits("Animal") && !ContainsTraits("Sea Animal"))
  1266. return true;
  1267. if (ContainsTraits("Sovereign"))
  1268. return true;
  1269. return false;
  1270. }
  1271. }
  1272. #endregion
  1273. #region whether this card has at least 1 trait that contains "Hybrid", "Ten Warriors"
  1274. public bool HasHybridTenWarriorsTraits
  1275. {
  1276. get
  1277. {
  1278. if (ContainsTraits("Hybrid"))
  1279. return true;
  1280. if (ContainsTraits("Ten Warriors"))
  1281. return true;
  1282. return false;
  1283. }
  1284. }
  1285. #endregion
  1286. #region whether this card has "XAntibody" trait
  1287. public bool HasXAntibodyTraits => CardTraits.Some(DataBase.IsXAntibodyString);
  1288. #endregion
  1289. #region whether this card has "Royal Knight" trait
  1290. public bool HasRoyalKnightTraits
  1291. {
  1292. get
  1293. {
  1294. return EqualsTraits("Royal Knight");
  1295. }
  1296. }
  1297. #endregion
  1298. #region whether this card has "SoC" trait
  1299. public bool HasSocTraits
  1300. {
  1301. get
  1302. {
  1303. if (CardTraits.Contains("SoC"))
  1304. {
  1305. return true;
  1306. }
  1307. return false;
  1308. }
  1309. }
  1310. #endregion
  1311. #region whether this card has "D-Brigade"/"DigiPolice trait
  1312. public bool HasDBrigadeorDigiPoliceTraits
  1313. {
  1314. get
  1315. {
  1316. if (CardTraits.Contains("D-Brigade"))
  1317. {
  1318. return true;
  1319. }
  1320. if (CardTraits.Contains("DigiPolice"))
  1321. {
  1322. return true;
  1323. }
  1324. return false;
  1325. }
  1326. }
  1327. #endregion
  1328. #region whether this card has at least 1 trait that contains "Beast Dragon"
  1329. public bool HasBeastDragonTraits
  1330. {
  1331. get
  1332. {
  1333. if (ContainsTraits("BeastDragon"))
  1334. {
  1335. return true;
  1336. }
  1337. if(ContainsTraits("Beast Dragon"))
  1338. {
  1339. return true;
  1340. }
  1341. return false;
  1342. }
  1343. }
  1344. #endregion
  1345. #region whether this card has at least 1 trait that contains "DigiPolice"
  1346. public bool HasDigiPoliceTraits
  1347. {
  1348. get
  1349. {
  1350. if (ContainsTraits("DigiPolice"))
  1351. {
  1352. return true;
  1353. }
  1354. return false;
  1355. }
  1356. }
  1357. #endregion
  1358. #region whether this card has at least 1 trait that contains "Light Fang" or "Night Claw"
  1359. public bool HasLightFangNightClawTraits => ContainsTraits("Light Fang") || ContainsTraits("Night Claw");
  1360. #endregion
  1361. #region whether this card has at least 1 trait that contains "Light Fang/Night Claw"
  1362. public bool HasLightFangOrNightClawTraits
  1363. {
  1364. get
  1365. {
  1366. if (ContainsTraits("Light Fang"))
  1367. {
  1368. return true;
  1369. }
  1370. if (ContainsTraits("Night Claw"))
  1371. {
  1372. return true;
  1373. }
  1374. return false;
  1375. }
  1376. }
  1377. #endregion
  1378. #region whether this card has the string in text
  1379. public bool HasText(string text)
  1380. {
  1381. if (String.IsNullOrEmpty(text)) return false;
  1382. text = DataBase.ReplaceToASCII(text);
  1383. string replaced = text.Replace(" ", "");
  1384. string lower = text.ToLower();
  1385. List<string> checkStrings = new List<string>()
  1386. {
  1387. DataBase.ReplaceToASCII(_cEntity_Base.CardName_ENG),
  1388. DataBase.ReplaceToASCII(_cEntity_Base.EffectDiscription_ENG),
  1389. DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG),
  1390. DataBase.ReplaceToASCII(_cEntity_Base.SecurityEffectDiscription_ENG),
  1391. };
  1392. foreach (string attribute in _cEntity_Base.Attribute_ENG)
  1393. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1394. foreach (string attribute in _cEntity_Base.Type_ENG)
  1395. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1396. if(jogressCondition != null){
  1397. foreach (JogressConditionElement element in jogressCondition.elements)
  1398. checkStrings.Add(element.SelectMessage);
  1399. }
  1400. foreach (string checkString in checkStrings)
  1401. {
  1402. if (!string.IsNullOrEmpty(checkString))
  1403. {
  1404. if (checkString.Contains(text))
  1405. {
  1406. return true;
  1407. }
  1408. if (checkString.Contains(replaced))
  1409. {
  1410. return true;
  1411. }
  1412. if (checkString.Contains(lower))
  1413. {
  1414. return true;
  1415. }
  1416. }
  1417. }
  1418. return false;
  1419. }
  1420. #endregion
  1421. #region whether this card has <Save> in text
  1422. public bool HasSaveText => HasText("<Save>");
  1423. #endregion
  1424. #region whether this card has "Pulsemon" in text
  1425. public bool HasPulsemonText => HasText("Pulsemon");
  1426. #endregion
  1427. #region card names checked when digixros
  1428. public List<string> CardNames_DigiXros
  1429. {
  1430. get
  1431. {
  1432. List<string> cardNames_DigiXros = CardNames.Clone();
  1433. #region the effects of itself
  1434. EffectList(EffectTiming.None)
  1435. .Filter(cardEffect => cardEffect is IChangeCardNamesForDigiXrosEffect && cardEffect.CanUse(null))
  1436. .ForEach(cardEffect => cardNames_DigiXros = ((IChangeCardNamesForDigiXrosEffect)cardEffect).ChangeCardNamesForDigiXros(cardNames_DigiXros, this));
  1437. #endregion
  1438. return cardNames_DigiXros;
  1439. }
  1440. }
  1441. #endregion
  1442. #region whether this card has at least 1 card name checked when digixros that equals the string
  1443. /// <summary>
  1444. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1445. /// </summary>
  1446. /// <param name="string">value to check for</param>
  1447. /// <author>Mike Bunch</author>
  1448. public bool EqualsCardNameDigiXros(string name)
  1449. {
  1450. if (string.IsNullOrEmpty(name))
  1451. {
  1452. return false;
  1453. }
  1454. string replaced = name.Replace(" ", "");
  1455. string lower = name.ToLower();
  1456. return CardNames_DigiXros.Some((cardName) =>
  1457. cardName.Equals(name)
  1458. || cardName.Equals(replaced)
  1459. || cardName.Equals(lower)
  1460. || cardName.ToLower().Equals(lower));
  1461. }
  1462. #endregion
  1463. #region whether this card has at least 1 card name that contains the string
  1464. /// <summary>
  1465. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1466. /// </summary>
  1467. /// <param trait="string">value to check for</param>
  1468. /// <author>Mike Bunch</author>
  1469. public bool ContainsCardNameDigiXros(string name)
  1470. {
  1471. if (string.IsNullOrEmpty(name))
  1472. {
  1473. return false;
  1474. }
  1475. string replaced = name.Replace(" ", "");
  1476. string lower = name.ToLower();
  1477. return CardNames_DigiXros.Some((cardName) =>
  1478. cardName.Contains(name)
  1479. || cardName.Contains(replaced)
  1480. || cardName.Contains(lower)
  1481. || cardName.ToLower().Contains(lower));
  1482. }
  1483. #endregion
  1484. #region preferered frame to play
  1485. public FieldCardFrame PreferredFrame()
  1486. {
  1487. FieldCardFrame PreferredFrame = Owner.fieldCardFrames[0];
  1488. List<FieldCardFrame> fieldCardFrames =
  1489. Owner.fieldCardFrames
  1490. .Filter(fieldCardFrame => fieldCardFrame.IsBattleAreaFrame()
  1491. && fieldCardFrame.IsEmptyFrame());
  1492. if (_cEntity_Base != null)
  1493. {
  1494. if (IsDigimon || IsDigiEgg)
  1495. {
  1496. if (Owner.isYou)
  1497. {
  1498. fieldCardFrames = fieldCardFrames
  1499. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1500. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1501. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1502. .ToList();
  1503. }
  1504. else
  1505. {
  1506. fieldCardFrames = fieldCardFrames
  1507. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1508. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1509. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1510. .ToList();
  1511. int[] correctOrder = new int[] { 4, 3, 5, 2, 6, 1, 7, 0, 8, 11, 10, 12, 9, 13, 14, 15, };
  1512. List<FieldCardFrame> correctOrderFrames = new List<FieldCardFrame>();
  1513. for (int i = 0; i < correctOrder.Length; i++)
  1514. {
  1515. foreach (FieldCardFrame frame in fieldCardFrames)
  1516. {
  1517. if (frame.FrameID == correctOrder[i])
  1518. {
  1519. correctOrderFrames.Add(frame);
  1520. }
  1521. }
  1522. }
  1523. fieldCardFrames = correctOrderFrames;
  1524. }
  1525. }
  1526. else if (IsTamer || IsOption)
  1527. {
  1528. if (Owner.isYou)
  1529. {
  1530. fieldCardFrames = fieldCardFrames
  1531. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1532. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1533. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1534. .ToList();
  1535. }
  1536. else
  1537. {
  1538. fieldCardFrames = fieldCardFrames
  1539. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1540. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1541. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1542. .ToList();
  1543. }
  1544. }
  1545. if (fieldCardFrames.Count >= 1)
  1546. {
  1547. PreferredFrame = fieldCardFrames[0];
  1548. }
  1549. }
  1550. return PreferredFrame;
  1551. }
  1552. #endregion
  1553. #region Whether this card has DP
  1554. public bool HasDP => IsDigimon || _cEntity_Base.DP > 0;
  1555. #endregion
  1556. #region base card DP
  1557. public int BaseCardDP => _cEntity_Base.DP;
  1558. #endregion
  1559. #region DP
  1560. public int CardDP
  1561. {
  1562. get
  1563. {
  1564. int cardDP = -1;
  1565. if (HasDP)
  1566. {
  1567. cardDP = BaseCardDP;
  1568. #region card effects that change card DP
  1569. List<ICardEffect> changeCardDPCardEffects = new List<ICardEffect>();
  1570. #region the effects of permanents
  1571. changeCardDPCardEffects = changeCardDPCardEffects
  1572. .Concat(
  1573. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1574. .Map(player => player.GetFieldPermanents())
  1575. .Flat()
  1576. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1577. .Flat()
  1578. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1579. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1580. .ToList();
  1581. #endregion
  1582. #region the effects of players
  1583. changeCardDPCardEffects = changeCardDPCardEffects
  1584. .Concat(
  1585. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1586. .Map(player => player.EffectList(EffectTiming.None))
  1587. .Flat()
  1588. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1589. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1590. .ToList();
  1591. #endregion
  1592. List<ICardEffect> cardEffects_ChangeDP_IsUpDown = changeCardDPCardEffects
  1593. .Filter(cardEffect => ((IChangeCardDPEffect)cardEffect).IsUpDown());
  1594. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = changeCardDPCardEffects
  1595. .Filter(cardEffect => !((IChangeCardDPEffect)cardEffect).IsUpDown());
  1596. cardEffects_ChangeDP_IsUpDown
  1597. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1598. cardEffects_ChangeDP_NotIsUpDown
  1599. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1600. #endregion
  1601. }
  1602. return Math.Max(0, cardDP);
  1603. }
  1604. }
  1605. #endregion
  1606. #region whether this card is token
  1607. public bool IsToken { get; private set; } = false;
  1608. public void SetIsToken(bool isToken) => IsToken = isToken;
  1609. #endregion
  1610. #region Will this card be trashed from sources
  1611. public bool willBeRemoveSources { get; set; } = false;
  1612. #endregion
  1613. #region whether this card can not be trashed from digivolution cards
  1614. public bool CanNotTrashFromDigivolutionCards(ICardEffect _cardEffect)
  1615. {
  1616. if (willBeRemoveSources)
  1617. return true;
  1618. #region the effects of permanents
  1619. if (GManager.instance.turnStateMachine.gameContext.Players
  1620. .Map(player => player.GetFieldPermanents())
  1621. .Flat()
  1622. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1623. .Flat()
  1624. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1625. && cardEffect.CanUse(null)
  1626. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1627. {
  1628. return true;
  1629. }
  1630. #endregion
  1631. #region the effects of players
  1632. if (GManager.instance.turnStateMachine.gameContext.Players
  1633. .Map(player => player.EffectList(EffectTiming.None))
  1634. .Flat()
  1635. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1636. && cardEffect.CanUse(null)
  1637. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1638. {
  1639. return true;
  1640. }
  1641. #endregion
  1642. #region the effects of itself
  1643. if (PermanentOfThisCard() == null)
  1644. {
  1645. if (EffectList(EffectTiming.None)
  1646. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1647. && cardEffect.CanUse(null)
  1648. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1649. {
  1650. return true;
  1651. }
  1652. }
  1653. #endregion
  1654. return false;
  1655. }
  1656. #endregion
  1657. #region whether this card has [Blocker]
  1658. public bool HasBlocker =>
  1659. EffectList(EffectTiming.None)
  1660. .Some(cardEffect => cardEffect is BlockerClass
  1661. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect);
  1662. #endregion
  1663. #region whether this card has [DigiBurst]
  1664. public bool HasDigiBurst
  1665. {
  1666. get
  1667. {
  1668. if (_cEntity_Base != null)
  1669. {
  1670. if (!string.IsNullOrEmpty(_cEntity_Base.EffectDiscription_JPN))
  1671. {
  1672. bool result = Regex.IsMatch(_cEntity_Base.EffectDiscription_JPN, DataBase.DigiburstRegex);
  1673. if (result)
  1674. {
  1675. return true;
  1676. }
  1677. }
  1678. }
  1679. return false;
  1680. }
  1681. }
  1682. #endregion
  1683. #region whether this card has [DigiXros]
  1684. public bool HasDigiXros => digiXrosCondition != null;
  1685. #endregion
  1686. #region traits
  1687. public List<string> CardTraits
  1688. {
  1689. get
  1690. {
  1691. List<string> traits =
  1692. _cEntity_Base.Form_ENG
  1693. .Filter(s => !string.IsNullOrEmpty(s))
  1694. .Concat(_cEntity_Base.Attribute_ENG
  1695. .Filter(s => !string.IsNullOrEmpty(s)))
  1696. .Concat(_cEntity_Base.Type_ENG
  1697. .Filter(s => !string.IsNullOrEmpty(s)))
  1698. .ToList();
  1699. #region the effects of itself
  1700. EffectList(EffectTiming.None)
  1701. .Filter(cardEffect => cardEffect is IChangeTraitsEffect && cardEffect.CanUse(null))
  1702. .ForEach(cardEffect => traits = ((IChangeTraitsEffect)cardEffect).ChangTraits(traits, this));
  1703. #endregion
  1704. return traits;
  1705. }
  1706. }
  1707. #endregion
  1708. #region whether this card has [On Deletion] effect
  1709. public bool HasOnDeletionEffect =>
  1710. EffectList(EffectTiming.OnDestroyedAnyone)
  1711. .Some(cardEffect => cardEffect is ActivateICardEffect
  1712. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1713. && cardEffect.IsOnDeletion);
  1714. #endregion
  1715. #region whether this card has [On Play] effect
  1716. public bool HasOnPlayEffect =>
  1717. EffectList(EffectTiming.OnEnterFieldAnyone)
  1718. .Some(cardEffect => cardEffect is ActivateICardEffect
  1719. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1720. && cardEffect.IsOnPlay);
  1721. #endregion
  1722. #region whether this card has [When Digivolving] effect
  1723. public bool HasWhenDigivolvingEffect =>
  1724. EffectList(EffectTiming.OnEnterFieldAnyone)
  1725. .Some(cardEffect => cardEffect is ActivateICardEffect
  1726. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1727. && cardEffect.IsWhenDigivolving);
  1728. #endregion
  1729. #region whether this card has [Digisorption]
  1730. public bool HasDigisorption =>
  1731. EffectList(EffectTiming.BeforePayCost)
  1732. .Some(cardEffect => cardEffect is ActivateICardEffect
  1733. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1734. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1735. && cardEffect.EffectDiscription.Contains("Digisorption -"));
  1736. #endregion
  1737. #region whether this card has [Blitz]
  1738. public bool HasBlitz =>
  1739. EffectList(EffectTiming.OnEnterFieldAnyone)
  1740. .Some(cardEffect => cardEffect is ActivateICardEffect
  1741. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1742. && (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfCard(this)))
  1743. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1744. && cardEffect.EffectDiscription.Contains("Blitz"));
  1745. #endregion
  1746. #region whether this card has [Retaliation]
  1747. public bool HasRetaliation =>
  1748. EffectList(EffectTiming.OnDestroyedAnyone)
  1749. .Some(cardEffect => cardEffect is ActivateICardEffect
  1750. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1751. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1752. && cardEffect.EffectName == "Retaliation");
  1753. #endregion
  1754. #region whether this card has [Fortitude]
  1755. public bool HasFortitude =>
  1756. EffectList(EffectTiming.OnDestroyedAnyone)
  1757. .Some(cardEffect => cardEffect is ActivateICardEffect
  1758. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1759. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1760. && cardEffect.EffectName == "Fortitude");
  1761. #endregion
  1762. #region whether this card has inherited effect
  1763. public bool HasInheritedEffect
  1764. {
  1765. get
  1766. {
  1767. foreach (EffectTiming timing in Enum.GetValues(typeof(EffectTiming)))
  1768. {
  1769. if (EffectList(timing)
  1770. .Some(cardEffect => cardEffect.IsInheritedEffect
  1771. && !cardEffect.IsDisabled))
  1772. {
  1773. return true;
  1774. }
  1775. }
  1776. return false;
  1777. }
  1778. }
  1779. #endregion
  1780. #region DNA digivolution requirement
  1781. public JogressCondition jogressCondition
  1782. {
  1783. get
  1784. {
  1785. ICardEffect addJogressConditionEffect =
  1786. EffectList(EffectTiming.None)
  1787. .Find(cardEffect => cardEffect is IAddJogressConditionEffect
  1788. && cardEffect.CanUse(null)
  1789. && ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this) != null);
  1790. if (addJogressConditionEffect != null) return ((IAddJogressConditionEffect)addJogressConditionEffect).GetJogressCondition(this);
  1791. return null;
  1792. }
  1793. }
  1794. #endregion
  1795. #region whether this card can DNA digivolve
  1796. public bool CanPlayJogress(bool PayCost)
  1797. {
  1798. if (jogressCondition != null)
  1799. {
  1800. if (Owner.GetBattleAreaDigimons().Count >= jogressCondition.elements.Length)
  1801. {
  1802. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(Owner.GetBattleAreaDigimons(), jogressCondition.elements.Length).ToList();
  1803. foreach (Permanent[] permanents in permanentsList)
  1804. {
  1805. if (permanents != null)
  1806. {
  1807. if (permanents.Length == jogressCondition.elements.Length)
  1808. {
  1809. if (permanents.Length == 2)
  1810. {
  1811. if (jogressCondition.elements[0].EvoRootCondition(permanents[0]) && !this.CanNotEvolve(permanents[0]))
  1812. {
  1813. if (jogressCondition.elements[1].EvoRootCondition(permanents[1]) && !this.CanNotEvolve(permanents[1]))
  1814. {
  1815. if (PayCost)
  1816. {
  1817. int cost = jogressCondition.cost;
  1818. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, permanents.ToList(), checkAvailability: true);
  1819. if (Owner.MaxMemoryCost < cost)
  1820. {
  1821. return false;
  1822. }
  1823. }
  1824. return true;
  1825. }
  1826. }
  1827. }
  1828. }
  1829. }
  1830. }
  1831. }
  1832. }
  1833. return false;
  1834. }
  1835. #endregion
  1836. #region whether target permanent can DNA digivolve into this card
  1837. public bool CanJogressFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  1838. {
  1839. if (targetPermanent != null)
  1840. {
  1841. if (targetPermanent.TopCard != null)
  1842. {
  1843. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  1844. {
  1845. if (this.CanPlayJogress(PayCost))
  1846. {
  1847. if (jogressCondition != null)
  1848. {
  1849. if (jogressCondition.elements.ToList().Count((element) => element.EvoRootCondition(targetPermanent)) >= 1)
  1850. {
  1851. if (!this.CanNotEvolve(targetPermanent))
  1852. {
  1853. if (PayCost)
  1854. {
  1855. int cost = jogressCondition.cost;
  1856. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent, new Permanent(new List<CardSource>()) }, checkAvailability: true);
  1857. if (Owner.MaxMemoryCost < cost)
  1858. {
  1859. return false;
  1860. }
  1861. }
  1862. return true;
  1863. }
  1864. }
  1865. }
  1866. }
  1867. }
  1868. }
  1869. }
  1870. return false;
  1871. }
  1872. #endregion
  1873. #region whether target permanents can DNA digivolve into this card
  1874. public bool CanJogressFromTargetPermanents(List<Permanent> targetPermanents, bool PayCost)
  1875. {
  1876. if (targetPermanents != null)
  1877. {
  1878. if (targetPermanents.Count == 2)
  1879. {
  1880. if (this.CanPlayJogress(PayCost))
  1881. {
  1882. if (jogressCondition != null)
  1883. {
  1884. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(targetPermanents, 2).ToList();
  1885. foreach (Permanent[] permanents in permanentsList)
  1886. {
  1887. if (jogressCondition.elements.Length == permanents.Length)
  1888. {
  1889. bool canJogress = true;
  1890. for (int i = 0; i < permanents.Length; i++)
  1891. {
  1892. if (permanents[i] != null)
  1893. {
  1894. if (permanents[i].TopCard != null)
  1895. {
  1896. if ((!jogressCondition.elements[i].EvoRootCondition(permanents[i])) || this.CanNotEvolve(permanents[i]))
  1897. {
  1898. canJogress = false;
  1899. break;
  1900. }
  1901. }
  1902. }
  1903. }
  1904. if (canJogress)
  1905. {
  1906. return true;
  1907. }
  1908. }
  1909. }
  1910. }
  1911. }
  1912. }
  1913. }
  1914. return false;
  1915. }
  1916. #endregion
  1917. #region whether this card has level
  1918. public bool HasLevel => _cEntity_Base == null || _cEntity_Base.HasLevel;
  1919. #endregion
  1920. #region whether this card is level 2
  1921. public bool IsLevel2 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 2;
  1922. #endregion
  1923. #region whether this card is level 3
  1924. public bool IsLevel3 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 3;
  1925. #endregion
  1926. #region whether this card is level 4
  1927. public bool IsLevel4 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 4;
  1928. #endregion
  1929. #region whether this card is level 5
  1930. public bool IsLevel5 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 5;
  1931. #endregion
  1932. #region whether this card is level 6
  1933. public bool IsLevel6 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 6;
  1934. #endregion
  1935. #region DigiXros requirement
  1936. public DigiXrosCondition digiXrosCondition
  1937. {
  1938. get
  1939. {
  1940. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1941. {
  1942. if (cardEffect is IAddDigiXrosConditionEffect)
  1943. {
  1944. if (cardEffect.CanUse(null))
  1945. {
  1946. DigiXrosCondition digiXrosCondition = ((IAddDigiXrosConditionEffect)cardEffect).GetDigiXrosCondition(this);
  1947. if (digiXrosCondition != null)
  1948. {
  1949. return digiXrosCondition;
  1950. }
  1951. }
  1952. }
  1953. }
  1954. return null;
  1955. }
  1956. }
  1957. #endregion
  1958. #region Blast Digivolution requirement
  1959. public BurstDigivolutionCondition burstDigivolutionCondition
  1960. {
  1961. get
  1962. {
  1963. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1964. {
  1965. if (cardEffect is IAddBurstDigivolutionConditionEffect)
  1966. {
  1967. if (cardEffect.CanUse(null))
  1968. {
  1969. BurstDigivolutionCondition burstDigivolutionCondition = ((IAddBurstDigivolutionConditionEffect)cardEffect).GetBurstDigivolutionCondition(this);
  1970. if (burstDigivolutionCondition != null)
  1971. {
  1972. return burstDigivolutionCondition;
  1973. }
  1974. }
  1975. }
  1976. }
  1977. return null;
  1978. }
  1979. }
  1980. #endregion
  1981. #region whether this card can Burst digivolve
  1982. public bool CanPlayBurst(bool PayCost)
  1983. {
  1984. if (burstDigivolutionCondition != null)
  1985. {
  1986. if (PayCost)
  1987. {
  1988. int cost = burstDigivolutionCondition.cost;
  1989. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { new Permanent(new List<CardSource>()) }, checkAvailability: true);
  1990. if (Owner.MaxMemoryCost < cost)
  1991. {
  1992. return false;
  1993. }
  1994. }
  1995. if (Owner.GetBattleAreaDigimons().Count >= 1)
  1996. {
  1997. foreach (Permanent digimon in Owner.GetFieldPermanents())
  1998. {
  1999. if (digimon != null)
  2000. {
  2001. if (!this.CanNotEvolve(digimon))
  2002. {
  2003. if (burstDigivolutionCondition.digimonCondition(digimon))
  2004. {
  2005. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2006. {
  2007. if (tamer != digimon)
  2008. {
  2009. if (burstDigivolutionCondition.tamerCondition(tamer))
  2010. {
  2011. if (!tamer.CannotReturnToHand(null))
  2012. {
  2013. if (PayCost)
  2014. {
  2015. int cost = burstDigivolutionCondition.cost;
  2016. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
  2017. if (Owner.MaxMemoryCost < cost)
  2018. {
  2019. return false;
  2020. }
  2021. }
  2022. return true;
  2023. }
  2024. }
  2025. }
  2026. }
  2027. }
  2028. }
  2029. }
  2030. }
  2031. }
  2032. }
  2033. return false;
  2034. }
  2035. #endregion
  2036. #region whether target permanent can Burst digivolve into this card
  2037. public bool CanBurstDigivolutionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2038. {
  2039. if (targetPermanent != null)
  2040. {
  2041. if (targetPermanent.TopCard != null)
  2042. {
  2043. if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent))
  2044. {
  2045. if (this.CanPlayBurst(PayCost))
  2046. {
  2047. if (burstDigivolutionCondition != null)
  2048. {
  2049. if (!this.CanNotEvolve(targetPermanent))
  2050. {
  2051. if (burstDigivolutionCondition.digimonCondition(targetPermanent))
  2052. {
  2053. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2054. {
  2055. if (tamer != targetPermanent)
  2056. {
  2057. if (burstDigivolutionCondition.tamerCondition(tamer))
  2058. {
  2059. if (!tamer.CannotReturnToHand(null))
  2060. {
  2061. if (PayCost)
  2062. {
  2063. int cost = burstDigivolutionCondition.cost;
  2064. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2065. if (Owner.MaxMemoryCost < cost)
  2066. {
  2067. return false;
  2068. }
  2069. }
  2070. return true;
  2071. }
  2072. }
  2073. }
  2074. }
  2075. }
  2076. }
  2077. }
  2078. }
  2079. }
  2080. }
  2081. }
  2082. return false;
  2083. }
  2084. #endregion
  2085. #region Whether this card's digiXrosCondition contains target card
  2086. public bool IsContainDigiXrosCondition(CardSource cardSource)
  2087. {
  2088. if (cardSource != null)
  2089. {
  2090. if (cardSource.Owner == Owner)
  2091. {
  2092. if (PermanentOfThisCard() != null)
  2093. {
  2094. if (PermanentOfThisCard().TopCard.HasDigiXros)
  2095. {
  2096. if (this == PermanentOfThisCard().TopCard)
  2097. {
  2098. if (digiXrosCondition != null)
  2099. {
  2100. if (digiXrosCondition.elements.Count((element) => element.CardCondition(cardSource)) >= 1)
  2101. {
  2102. return true;
  2103. }
  2104. }
  2105. }
  2106. }
  2107. }
  2108. }
  2109. }
  2110. return false;
  2111. }
  2112. #endregion
  2113. #region CardID
  2114. public string CardID => _cEntity_Base.CardID;
  2115. #endregion
  2116. #region whether this card is Digimon
  2117. public bool IsDigimon => CardKind == CardKind.Digimon;
  2118. #endregion
  2119. #region whether this card is DigiEgg
  2120. public bool IsDigiEgg => CardKind == CardKind.DigiEgg;
  2121. #endregion
  2122. #region whether this card is Tamer
  2123. public bool IsTamer => CardKind == CardKind.Tamer;
  2124. #endregion
  2125. #region whether this card is Option
  2126. public bool IsOption => CardKind == CardKind.Option;
  2127. #endregion
  2128. #region Wheter this card is permanent
  2129. public bool IsPermanent => _cEntity_Base.IsPermanent;
  2130. #endregion
  2131. #region Whether to have Play Cost
  2132. public bool HasPlayCost => _cEntity_Base.HasPlayCost;
  2133. #endregion
  2134. #region Whether to have Use Cost
  2135. public bool HasUseCost => _cEntity_Base.HasUseCost;
  2136. #endregion
  2137. #region Inherited Effects ENG discription
  2138. public string InheritedEffectDiscription_ENG => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG);
  2139. #endregion
  2140. #region Inherited Effects JPN discription
  2141. public string InheritedEffectDiscription_JPN => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_JPN);
  2142. #endregion
  2143. #region Card Sprite
  2144. public Sprite CardSprite => _cEntity_Base.CardSprite;
  2145. public async Task<Sprite> GetCardSprite()
  2146. {
  2147. return await _cEntity_Base.GetCardSprite();
  2148. }
  2149. #endregion
  2150. #region SetID
  2151. public string SetID => _cEntity_Base.SetID;
  2152. #endregion
  2153. #region CardEntityIndex
  2154. public int CardEntityIndex => _cEntity_Base.CardIndex;
  2155. #endregion
  2156. #region Card Kind
  2157. public CardKind CardKind => _cEntity_Base.cardKind;
  2158. #endregion
  2159. #region ACE
  2160. public bool IsACE => _cEntity_Base.IsACE;
  2161. #endregion
  2162. #region OverflowMemory
  2163. public int OverflowMemory => _cEntity_Base.OverflowMemory;
  2164. #endregion
  2165. #region Whether this card is being revealed
  2166. public bool IsBeingRevealed { get; set; } = false;
  2167. #endregion
  2168. #region The permanent that belonged to this card just before it left the field
  2169. public Permanent PermanentJustBeforeRemoveField { get; set; } = null;
  2170. #endregion
  2171. #region whether this card has "SEEKERS" trait
  2172. public bool HasSeekersTraits
  2173. {
  2174. get
  2175. {
  2176. if (CardTraits.Contains("SEEKERS"))
  2177. {
  2178. return true;
  2179. }
  2180. return false;
  2181. }
  2182. }
  2183. #endregion
  2184. #region whether this card has "ADVENTURE" trait
  2185. public bool HasAdventureTraits
  2186. {
  2187. get
  2188. {
  2189. if (CardTraits.Contains("ADVENTURE"))
  2190. {
  2191. return true;
  2192. }
  2193. return false;
  2194. }
  2195. }
  2196. #endregion
  2197. #region whether this card has "Chronicle" trait
  2198. public bool HasChronicleTraits
  2199. {
  2200. get
  2201. {
  2202. if (CardTraits.Contains("Chronicle"))
  2203. {
  2204. return true;
  2205. }
  2206. return false;
  2207. }
  2208. }
  2209. #endregion
  2210. #region whether this card has "Device" trait
  2211. public bool HasDeviceTraits
  2212. {
  2213. get
  2214. {
  2215. if (CardTraits.Contains("Device"))
  2216. {
  2217. return true;
  2218. }
  2219. return false;
  2220. }
  2221. }
  2222. #endregion
  2223. #region whether this card has "Three Musketeers" trait
  2224. public bool HasThreeMusketeersTraits
  2225. {
  2226. get
  2227. {
  2228. if (CardTraits.Contains("Three Musketeers"))
  2229. {
  2230. return true;
  2231. }
  2232. return false;
  2233. }
  2234. }
  2235. #endregion
  2236. #region whether this card has "Royal Base" trait
  2237. public bool HasRoyalBaseTraits
  2238. {
  2239. get
  2240. {
  2241. if (CardTraits.Contains("Royal Base"))
  2242. {
  2243. return true;
  2244. }
  2245. return false;
  2246. }
  2247. }
  2248. #endregion
  2249. }
  2250. public class JogressCondition
  2251. {
  2252. public JogressCondition(JogressConditionElement[] elements, int cost)
  2253. {
  2254. this.elements = new JogressConditionElement[2];
  2255. if (this.elements.Length == elements.Length)
  2256. {
  2257. for (int i = 0; i < elements.Length; i++)
  2258. {
  2259. this.elements[i] = elements[i];
  2260. }
  2261. }
  2262. this.cost = cost;
  2263. }
  2264. public JogressConditionElement[] elements { get; private set; } = new JogressConditionElement[2];
  2265. public int cost { get; private set; } = 0;
  2266. }
  2267. public class JogressConditionElement
  2268. {
  2269. public JogressConditionElement(Func<Permanent, bool> evoRootCondition, string selectMessage)
  2270. {
  2271. EvoRootCondition = evoRootCondition;
  2272. SelectMessage = selectMessage;
  2273. }
  2274. Func<Permanent, bool> _evoRootCondition = null;
  2275. public Func<Permanent, bool> EvoRootCondition
  2276. {
  2277. get
  2278. {
  2279. return permanent => _evoRootCondition == null || _evoRootCondition(permanent);
  2280. }
  2281. private set
  2282. {
  2283. _evoRootCondition = value;
  2284. }
  2285. }
  2286. public string SelectMessage { get; private set; } = "";
  2287. }
  2288. public class DigiXrosCondition
  2289. {
  2290. public DigiXrosCondition(List<DigiXrosConditionElement> elements, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, int reduceCostPerCard)
  2291. {
  2292. this.elements = new List<DigiXrosConditionElement>();
  2293. foreach (DigiXrosConditionElement element in elements)
  2294. {
  2295. this.elements.Add(element);
  2296. }
  2297. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  2298. this.reduceCostPerCard = reduceCostPerCard;
  2299. }
  2300. public List<DigiXrosConditionElement> elements { get; private set; } = new List<DigiXrosConditionElement>();
  2301. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; private set; } = null;
  2302. public int reduceCostPerCard { get; private set; } = 0;
  2303. }
  2304. public class DigiXrosConditionElement
  2305. {
  2306. public DigiXrosConditionElement(Func<CardSource, bool> cardCondition, string selectMessage, bool skipAllIfNoSelect = false)
  2307. {
  2308. this.CardCondition = cardCondition;
  2309. this.selectMessage = selectMessage;
  2310. this.skipAllIfNoSelect = skipAllIfNoSelect;
  2311. }
  2312. public Func<CardSource, bool> CardCondition { get; private set; } = null;
  2313. public string selectMessage { get; private set; } = "";
  2314. public bool skipAllIfNoSelect { get; private set; } = false;
  2315. }
  2316. public class BurstDigivolutionCondition
  2317. {
  2318. public BurstDigivolutionCondition(Func<Permanent, bool> tamerCondition, string selectTamerMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
  2319. {
  2320. this.tamerCondition = tamerCondition;
  2321. this.selectTamerMessage = selectTamerMessage;
  2322. this.digimonCondition = digimonCondition;
  2323. this.selectDigimonMessage = selectDigimonMessage;
  2324. this.cost = cost;
  2325. }
  2326. public Func<Permanent, bool> tamerCondition { get; private set; } = null;
  2327. public string selectTamerMessage { get; private set; } = null;
  2328. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  2329. public string selectDigimonMessage { get; private set; } = null;
  2330. public int cost { get; private set; } = 0;
  2331. }