CardSource.cs 90 KB

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