CardSource.cs 97 KB

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