CardSource.cs 97 KB

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