CardSource.cs 96 KB

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