CardSource.cs 121 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. using UnityEngine;
  8. public class CardSource : MonoBehaviour
  9. {
  10. #region card base entity
  11. CEntity_Base _cEntity_Base = null;
  12. #endregion
  13. #region PhotonView
  14. public PhotonView PhotonView { get; set; }
  15. #endregion
  16. #region owner
  17. public Player Owner { get; private set; } = null;
  18. #endregion
  19. #region card index
  20. public int CardIndex { get; private set; } = 0;
  21. #endregion
  22. #region set card base entity
  23. public void SetBaseData(CEntity_Base cEntity_Base, Player owner)
  24. {
  25. _cEntity_Base = cEntity_Base;
  26. Owner = owner;
  27. gameObject.name = _cEntity_Base.CardName_ENG;
  28. SetFace();
  29. }
  30. #endregion
  31. #region card effect controller
  32. public CEntity_EffectController cEntity_EffectController;
  33. #endregion
  34. #region whether this card is reversed
  35. public bool IsFlipped { get; private set; }
  36. #region set face
  37. public void SetFace(string str = "")
  38. {
  39. IsFlipped = false;
  40. if (str != "")
  41. UnityEngine.Debug.Log($"CARD FLIPPED: {this.BaseENGCardNameFromEntity}, from - {str}");
  42. GManager.OnCardFlippedChanged?.Invoke();
  43. GManager.OnSecurityStackChanged?.Invoke(Owner);
  44. }
  45. #endregion
  46. #region set reverse
  47. public void SetReverse()
  48. {
  49. IsFlipped = true;
  50. GManager.OnCardFlippedChanged?.Invoke();
  51. GManager.OnSecurityStackChanged?.Invoke(Owner);
  52. }
  53. #endregion
  54. #endregion
  55. #region Card ID setup
  56. public void SetUpCardIndex(int _cardIndex)
  57. {
  58. PhotonView _PhotonView = GetComponent<PhotonView>();
  59. _PhotonView ??= gameObject.AddComponent<PhotonView>();
  60. CardIndex = _cardIndex;
  61. _PhotonView.ViewID = CardIndex + 60;
  62. PhotonView = _PhotonView;
  63. }
  64. #endregion
  65. #region whether this card can be played
  66. public bool CanPlayFromHandDuringMainPhase
  67. {
  68. get
  69. {
  70. if (IsDigimon && Owner.GetBattleAreaDigimons().Some(permanent => CanPlayCardTargetFrame(permanent.PermanentFrame, true, null)))
  71. {
  72. return true;
  73. }
  74. if (_cEntity_Base.IsPermanent && !IsOption)
  75. {
  76. if (!CanPlayJogress(true))
  77. {
  78. if (!CanPutFieldThisPermanentCard(true, null))
  79. {
  80. return false;
  81. }
  82. }
  83. }
  84. else if (IsOption)
  85. {
  86. if (CanNotPlayThisOption)
  87. {
  88. return false;
  89. }
  90. #region whether cost can be paid
  91. List<int> costs = new List<int>() { this.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: true) };
  92. bool canPayCost = costs.Some(cost => Owner.MaxMemoryCost >= cost);
  93. if (!canPayCost) return false;
  94. #endregion
  95. }
  96. return true;
  97. }
  98. }
  99. #endregion
  100. #region Whether this option card's effect prevents it from being played
  101. public bool CanNotPlayThisOption
  102. {
  103. get
  104. {
  105. if (!IsOption)
  106. {
  107. return false;
  108. }
  109. #region the effects of players
  110. if (GManager.instance.turnStateMachine.gameContext.Players
  111. .Map(player => player.EffectList(EffectTiming.None))
  112. .Flat()
  113. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  114. && cardEffect.CanUse(null)
  115. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  116. {
  117. return true;
  118. }
  119. #endregion
  120. #region the effects of permanents
  121. if (GManager.instance.turnStateMachine.gameContext.Players
  122. .Map(player => player.GetFieldPermanents())
  123. .Flat()
  124. .Map(permanent => permanent.EffectList(EffectTiming.None))
  125. .Flat()
  126. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  127. && cardEffect.CanUse(null)
  128. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  129. {
  130. return true;
  131. }
  132. #endregion
  133. #region the effects of itself
  134. if (PermanentOfThisCard() == null)
  135. {
  136. if (EffectList(EffectTiming.None)
  137. .Some(cardEffect => cardEffect is ICanNotPlayCardEffect
  138. && cardEffect.CanUse(null)
  139. && ((ICanNotPlayCardEffect)cardEffect).CanNotPlay(this)))
  140. {
  141. return true;
  142. }
  143. }
  144. #endregion
  145. #region Whether the color requirement is met
  146. if (!MatchColorRequirement)
  147. {
  148. return true;
  149. }
  150. #endregion
  151. return false;
  152. }
  153. }
  154. #endregion
  155. #region Whether the color requirement is met
  156. public bool MatchColorRequirement
  157. {
  158. get
  159. {
  160. if (IsOption)
  161. {
  162. #region "ignore color requirement" effects
  163. #region the effects of permanents
  164. if (GManager.instance.turnStateMachine.gameContext.Players
  165. .Map(player => player.GetFieldPermanents())
  166. .Flat()
  167. .Map(permanent => permanent.EffectList(EffectTiming.None))
  168. .Flat()
  169. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  170. && cardEffect.CanUse(null)
  171. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  172. {
  173. return true;
  174. }
  175. #endregion
  176. #region the effects of players
  177. if (GManager.instance.turnStateMachine.gameContext.Players
  178. .Map(player => player.EffectList(EffectTiming.None))
  179. .Flat()
  180. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  181. && cardEffect.CanUse(null)
  182. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  183. {
  184. return true;
  185. }
  186. #endregion
  187. #region the effects of itself
  188. if (EffectList(EffectTiming.None)
  189. .Some(cardEffect => cardEffect is IIgnoreColorConditionEffect
  190. && cardEffect.CanUse(null)
  191. && ((IIgnoreColorConditionEffect)cardEffect).IgnoreColorCondition(this)))
  192. {
  193. return true;
  194. }
  195. #endregion
  196. #endregion
  197. List<CardColor> colorsToCheck = IsDigimon ? DualCardColors : CardColors;
  198. bool matchColorRequirement = colorsToCheck.Every(cardColor =>
  199. Owner.GetFieldPermanents().Some(permanent =>
  200. permanent.TopCard.IsPermanent && permanent.TopCard.CardColors.Contains(cardColor)));
  201. if (!matchColorRequirement)
  202. {
  203. return false;
  204. }
  205. }
  206. return true;
  207. }
  208. }
  209. #endregion
  210. #region Card object in hand displaying this card
  211. public HandCard ShowingHandCard { get; private set; }
  212. public void SetShowingHandCard(HandCard showingHandCard) => ShowingHandCard = showingHandCard;
  213. #endregion
  214. #region Permanent in the field containing this card
  215. public Permanent PermanentOfThisCard()
  216. {
  217. return Owner.GetFieldPermanents().Find(permanent =>
  218. (permanent.cardSources.Contains(this)));
  219. }
  220. #endregion
  221. #region initialize
  222. public void Init()
  223. {
  224. cEntity_EffectController.InitUseCountThisTurn();
  225. SetFace();
  226. }
  227. #endregion
  228. #region base card colors from entity
  229. public List<CardColor> BaseCardColorsFromEntity => _cEntity_Base.cardColors.Distinct().ToList();
  230. public List<CardColor> BaseDualCardColorsFromEntity => _cEntity_Base.OptionCardColorRequirements.Distinct().ToList();
  231. #endregion
  232. #region base card colors
  233. public List<CardColor> BaseCardColors
  234. {
  235. get
  236. {
  237. List<CardColor> baseCardColors = BaseCardColorsFromEntity;
  238. #region the effects that changes base card colors
  239. #region the effects of itself
  240. if (PermanentOfThisCard() == null)
  241. {
  242. EffectList(EffectTiming.None)
  243. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  244. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  245. }
  246. #endregion
  247. #region the effects of permanents
  248. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  249. .Map(player => player.GetFieldPermanents())
  250. .Flat()
  251. .Map(permanent => permanent.EffectList(EffectTiming.None))
  252. .Flat()
  253. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  254. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  255. #endregion
  256. #endregion
  257. baseCardColors = baseCardColors.Distinct().ToList();
  258. return baseCardColors;
  259. }
  260. }
  261. public List<CardColor> BaseDualCardColors
  262. {
  263. get
  264. {
  265. List<CardColor> baseCardColors = BaseDualCardColorsFromEntity;
  266. #region the effects that changes base card colors
  267. #region the effects of itself
  268. if (PermanentOfThisCard() == null)
  269. {
  270. EffectList(EffectTiming.None)
  271. .Filter(cardEffect => cardEffect is IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  272. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, 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 IChangeBaseCardColorEffect && cardEffect.CanUse(null))
  282. .ForEach(cardEffect => baseCardColors = ((IChangeBaseCardColorEffect)cardEffect).GetBaseCardColors(baseCardColors, this));
  283. #endregion
  284. #endregion
  285. baseCardColors = baseCardColors.Distinct().ToList();
  286. return baseCardColors;
  287. }
  288. }
  289. #endregion
  290. #region card colors
  291. public List<CardColor> CardColors
  292. {
  293. get
  294. {
  295. List<CardColor> cardColors = BaseCardColors;
  296. #region the effects that changes card colors
  297. #region the effects of itself
  298. if (PermanentOfThisCard() == null)
  299. {
  300. EffectList(EffectTiming.None)
  301. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  302. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  303. }
  304. #endregion
  305. #region the effects of permanents
  306. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  307. .Map(player => player.GetFieldPermanents())
  308. .Flat()
  309. .Map(permanent => permanent.EffectList(EffectTiming.None))
  310. .Flat()
  311. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  312. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  313. #endregion
  314. #endregion
  315. cardColors = cardColors.Distinct().ToList();
  316. return cardColors;
  317. }
  318. }
  319. public List<CardColor> DualCardColors
  320. {
  321. get
  322. {
  323. List<CardColor> cardColors = BaseDualCardColors;
  324. #region the effects that changes card colors
  325. #region the effects of itself
  326. if (PermanentOfThisCard() == null)
  327. {
  328. EffectList(EffectTiming.None)
  329. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  330. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  331. }
  332. #endregion
  333. #region the effects of permanents
  334. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  335. .Map(player => player.GetFieldPermanents())
  336. .Flat()
  337. .Map(permanent => permanent.EffectList(EffectTiming.None))
  338. .Flat()
  339. .Filter(cardEffect => cardEffect is IChangeCardColorEffect && cardEffect.CanUse(null))
  340. .ForEach(cardEffect => cardColors = ((IChangeCardColorEffect)cardEffect).GetCardColors(cardColors, this));
  341. #endregion
  342. #endregion
  343. cardColors = cardColors.Distinct().ToList();
  344. return cardColors;
  345. }
  346. }
  347. #endregion
  348. #region evoCosts from entity
  349. public List<EvoCost> BaseEvoCostsFromEntity => _cEntity_Base.EvoCosts;
  350. #endregion
  351. #region evoCosts
  352. public List<Func<Permanent, int>> EvoCosts(CardEffectCommons.IgnoreRequirement ignore, bool checkAvailability)
  353. {
  354. List<Func<Permanent, int>> EvoCosts = new List<Func<Permanent, int>>();
  355. #region the effects that add evoCosts
  356. #region the effects of players
  357. EvoCosts = EvoCosts
  358. .Concat(
  359. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  360. .Map(player => player.EffectList(EffectTiming.None))
  361. .Flat()
  362. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  363. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  364. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, ignore, checkAvailability)))
  365. .ToList();
  366. #endregion
  367. #region the effects of permanents
  368. EvoCosts = EvoCosts
  369. .Concat(
  370. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  371. .Map(player => player.GetFieldPermanents())
  372. .Flat()
  373. .Map(permanent => permanent.EffectList(EffectTiming.None))
  374. .Flat()
  375. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  376. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  377. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, ignore, checkAvailability)))
  378. .ToList();
  379. #endregion
  380. #region the effects of itself
  381. if (PermanentOfThisCard() == null || PermanentOfThisCard().DigivolutionCards.Contains(this))
  382. {
  383. EvoCosts = EvoCosts
  384. .Concat(
  385. EffectList(EffectTiming.None)
  386. .Filter(cardEffect => cardEffect is IAddDigivolutionRequirementEffect && cardEffect.CanUse(null))
  387. .Map<ICardEffect, Func<Permanent, int>>(cardEffect =>
  388. (targetPermanent) => ((IAddDigivolutionRequirementEffect)cardEffect).GetEvoCost(targetPermanent, this, ignore, checkAvailability)))
  389. .ToList();
  390. }
  391. #endregion
  392. #endregion
  393. EvoCosts = EvoCosts
  394. .Concat(
  395. BaseEvoCostsFromEntity
  396. .Map<EvoCost, Func<Permanent, int>>(evoCost =>
  397. (targetPermanent) =>
  398. {
  399. if (ignore.Equals(CardEffectCommons.IgnoreRequirement.All) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  400. return evoCost.MemoryCost;
  401. if ((ignore.Equals(CardEffectCommons.IgnoreRequirement.Color) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  402. || targetPermanent.TopCard.CardColors.Contains(evoCost.CardColor))
  403. {
  404. if ((ignore.Equals(CardEffectCommons.IgnoreRequirement.Level) && Owner.CanIgnoreDigivolutionRequirement(targetPermanent, this))
  405. || targetPermanent.Level == evoCost.Level)
  406. {
  407. return evoCost.MemoryCost;
  408. }
  409. }
  410. return -1;
  411. }))
  412. .ToList();
  413. return EvoCosts;
  414. }
  415. #endregion
  416. #region evo cost list
  417. public List<int> CostList(Permanent targetPermanent, bool ignoreLevel, bool checkAvailability)
  418. {
  419. CardEffectCommons.IgnoreRequirement ignore = CardEffectCommons.IgnoreRequirement.None;
  420. if (ignoreLevel)
  421. ignore = CardEffectCommons.IgnoreRequirement.Level;
  422. return EvoCosts(ignore, checkAvailability)
  423. .Filter(evoCost => evoCost(targetPermanent) >= 0)
  424. .Map(evoCost => evoCost(targetPermanent));
  425. }
  426. #endregion
  427. #region cost list
  428. #region cost to pay
  429. public int PayingCost(SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false, bool ignoreLevel = false, int FixedCost = -1)
  430. {
  431. int baseCost = _cEntity_Base.PlayCost;
  432. if (targetPermanents != null)
  433. {
  434. if (targetPermanents.Count == 1)
  435. {
  436. Permanent targetPermanent = targetPermanents[0];
  437. if (targetPermanent != null)
  438. {
  439. List<int> costList = CostList(targetPermanent, ignoreLevel: ignoreLevel, checkAvailability: checkAvailability);
  440. if (costList.Count >= 1)
  441. {
  442. baseCost = costList.Min();
  443. }
  444. }
  445. }
  446. }
  447. return GetPayingCostWithBaseCost(baseCost, root, targetPermanents, checkAvailability: checkAvailability, FixedCost: FixedCost);
  448. }
  449. #endregion
  450. #region cost that will be paid taking into account baseCost
  451. public int GetPayingCostWithBaseCost(int baseCost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false, int FixedCost = -1)
  452. {
  453. int Cost = FixedCost >= 0 ? FixedCost : baseCost;
  454. bool isEvolution = targetPermanents != null && targetPermanents.Some((permanent) => permanent != null);
  455. #region DigiXros
  456. if (!isEvolution)
  457. {
  458. if (HasDigiXros)
  459. {
  460. if (Owner.CanReduceCost(null, this))
  461. {
  462. //AI
  463. if (!(!Owner.isYou && GManager.instance.IsAI))
  464. {
  465. if (checkAvailability)
  466. {
  467. return 0;
  468. }
  469. }
  470. if (!checkAvailability)
  471. {
  472. SelectDigiXrosClass selectDigiXrosClass = GManager.instance.GetComponent<SelectDigiXrosClass>();
  473. if (selectDigiXrosClass != null)
  474. {
  475. if (selectDigiXrosClass.playCard == this)
  476. {
  477. Cost -= selectDigiXrosClass.selectedDigicrossCards.Count * digiXrosCondition.reduceCostPerCard;
  478. }
  479. }
  480. }
  481. }
  482. }
  483. }
  484. #endregion
  485. #region Assembly
  486. if (!isEvolution)
  487. {
  488. if (HasAssembly)
  489. {
  490. if (Owner.CanReduceCost(null, this))
  491. {
  492. //AI
  493. if (!(!Owner.isYou && GManager.instance.IsAI))
  494. {
  495. if (checkAvailability)
  496. {
  497. return 0;
  498. }
  499. }
  500. if (!checkAvailability)
  501. {
  502. SelectAssemblyClass selectAssemblyClass = GManager.instance.GetComponent<SelectAssemblyClass>();
  503. if (selectAssemblyClass != null)
  504. {
  505. if (selectAssemblyClass.playCard == this)
  506. {
  507. if (selectAssemblyClass.selectedAssemblyCards.Count == assemblyCondition.elementCount)
  508. Cost -= assemblyCondition.reduceCost;
  509. }
  510. }
  511. }
  512. }
  513. }
  514. }
  515. #endregion
  516. Cost = GetChangedCostItselef(Cost, root, targetPermanents, checkAvailability);
  517. Cost = GetChangedPayingCost(Cost, root, targetPermanents, checkAvailability);
  518. if (Cost < 0)
  519. {
  520. Cost = 0;
  521. }
  522. return Cost;
  523. }
  524. #endregion
  525. #region base play cost from entity
  526. public int BasePlayCostFromEntity
  527. {
  528. get
  529. {
  530. return _cEntity_Base.PlayCost;
  531. }
  532. }
  533. #endregion
  534. #region get card cost of itself (refered by card effects)
  535. public int GetCostItself => Math.Max(0, GetChangedCostItselef(BasePlayCostFromEntity, SelectCardEffect.Root.None, new List<Permanent>() { PermanentOfThisCard() }));
  536. #endregion
  537. #region get card cost of itself taking into account card effects
  538. public int GetChangedCostItselef(int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false)
  539. {
  540. if (checkAvailability)
  541. {
  542. if (GManager.instance.IsAI)
  543. {
  544. if (targetPermanents != null)
  545. {
  546. if (targetPermanents.Some(permanent => permanent != null && permanent.TopCard != null && !permanent.TopCard.Owner.isYou))
  547. {
  548. return Math.Max(0, Cost);
  549. }
  550. }
  551. }
  552. }
  553. #region card effects that changes card cost
  554. List<ICardEffect> changeCostCardEffects = new List<ICardEffect>();
  555. #region the effects of permanents
  556. changeCostCardEffects = changeCostCardEffects
  557. .Concat(
  558. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  559. .Map(player => player.GetFieldPermanents())
  560. .Flat()
  561. .Map(permanent => permanent.EffectList(EffectTiming.None))
  562. .Flat()
  563. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  564. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  565. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  566. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  567. .ToList();
  568. #endregion
  569. #region the effects of players
  570. changeCostCardEffects = changeCostCardEffects
  571. .Concat(
  572. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  573. .Map(player => player.EffectList(EffectTiming.None))
  574. .Flat()
  575. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  576. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  577. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  578. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  579. .ToList();
  580. #endregion
  581. #region the effects of itself
  582. if (PermanentOfThisCard() == null)
  583. {
  584. changeCostCardEffects = changeCostCardEffects
  585. .Concat(
  586. EffectList(EffectTiming.None)
  587. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  588. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  589. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  590. && !((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  591. .ToList();
  592. }
  593. #endregion
  594. List<ICardEffect> changeCostCardEffects_NotIsUpDown = changeCostCardEffects
  595. .Filter(cardEffect => !((IChangeCostEffect)cardEffect).IsUpDown());
  596. List<ICardEffect> changeCostCardEffects_IsUpDown = changeCostCardEffects
  597. .Filter(cardEffect => ((IChangeCostEffect)cardEffect).IsUpDown());
  598. changeCostCardEffects_NotIsUpDown
  599. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  600. changeCostCardEffects_IsUpDown
  601. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  602. #endregion
  603. return Math.Max(0, Cost);
  604. }
  605. #endregion
  606. #region get card cost to pay of itself taking into account card effects
  607. public int GetChangedPayingCost(int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents, bool checkAvailability = false)
  608. {
  609. #region card effects that changes card cost to pay
  610. List<ICardEffect> changePayingCostCardEffects = new List<ICardEffect>();
  611. #region the effects of permanents
  612. changePayingCostCardEffects = changePayingCostCardEffects
  613. .Concat(
  614. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  615. .Map(player => player.GetFieldPermanents())
  616. .Flat()
  617. .Map(permanent => permanent.EffectList(EffectTiming.None))
  618. .Flat()
  619. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  620. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  621. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  622. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  623. .ToList();
  624. #endregion
  625. #region the effects of players
  626. changePayingCostCardEffects = changePayingCostCardEffects
  627. .Concat(
  628. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  629. .Map(player => player.EffectList(EffectTiming.None))
  630. .Flat()
  631. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  632. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  633. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  634. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  635. .ToList();
  636. #endregion
  637. #region the effects of itself
  638. if (PermanentOfThisCard() == null)
  639. {
  640. changePayingCostCardEffects = changePayingCostCardEffects
  641. .Concat(
  642. EffectList(EffectTiming.None)
  643. .Filter(cardEffect => cardEffect is IChangeCostEffect && cardEffect.CanUse(null)
  644. && ((IChangeCostEffect)cardEffect).CardCondition(this)
  645. && !(((IChangeCostEffect)cardEffect).IsCheckAvailability() && !checkAvailability)
  646. && ((IChangeCostEffect)cardEffect).IsChangePayingCost()))
  647. .ToList();
  648. }
  649. #endregion
  650. List<ICardEffect> changePayingCostCardEffects_NotIsUpDown = changePayingCostCardEffects
  651. .Filter(cardEffect => !((IChangeCostEffect)cardEffect).IsUpDown());
  652. List<ICardEffect> changePayingCostCardEffects_IsUpDown = changePayingCostCardEffects
  653. .Filter(cardEffect => ((IChangeCostEffect)cardEffect).IsUpDown());
  654. changePayingCostCardEffects_NotIsUpDown
  655. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  656. changePayingCostCardEffects_IsUpDown
  657. .ForEach(cardEffect => Cost = ((IChangeCostEffect)cardEffect).GetCost(Cost, this, root, targetPermanents));
  658. #endregion
  659. return Math.Max(0, Cost);
  660. }
  661. #endregion
  662. #endregion
  663. #region level
  664. public int Level => TreatedLevel;
  665. #endregion
  666. #region Level
  667. public int TreatedLevel
  668. {
  669. get
  670. {
  671. int treatedLevel = 0;
  672. treatedLevel = _cEntity_Base.Level;
  673. if (!HasLevel)
  674. treatedLevel = 1145140;
  675. #region Check Card Change Level Effects
  676. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  677. {
  678. if (cardEffect is IChangeCardLevelEffect)
  679. {
  680. if (cardEffect.CanUse(null))
  681. {
  682. treatedLevel = ((IChangeCardLevelEffect)cardEffect).GetCardLevel(treatedLevel, this);
  683. }
  684. }
  685. }
  686. #endregion
  687. return treatedLevel;
  688. }
  689. }
  690. #endregion
  691. #region effect list
  692. public List<ICardEffect> EffectList(EffectTiming timing)
  693. {
  694. return EffectList_ForCard(timing, this);
  695. }
  696. #endregion
  697. #region effect list for 1 card
  698. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource cardSource)
  699. {
  700. List<ICardEffect> _EffectList = cEntity_EffectController
  701. .GetCardEffects(timing, cardSource)
  702. .Filter(cardEffect => cardEffect != null);
  703. foreach (ICardEffect cardEffect in _EffectList)
  704. {
  705. if (cardEffect.EffectSourceCard == null)
  706. {
  707. cardEffect.SetEffectSourceCard(this);
  708. }
  709. }
  710. return _EffectList;
  711. }
  712. #endregion
  713. #region effect list except added effects
  714. public List<ICardEffect> EffectList_ExceptAddedEffects(EffectTiming timing)
  715. {
  716. return EffectList_ForCard_ExceptAddedEffects(timing, this);
  717. }
  718. #endregion
  719. #region effect list for 1 card
  720. public List<ICardEffect> EffectList_ForCard_ExceptAddedEffects(EffectTiming timing, CardSource cardSource)
  721. {
  722. List<ICardEffect> _EffectList = cEntity_EffectController
  723. .GetCardEffects_ExceptAddedEffects(timing, cardSource)
  724. .Filter(cardEffect => cardEffect != null);
  725. foreach (ICardEffect cardEffect in _EffectList)
  726. {
  727. if (cardEffect.EffectSourceCard == null)
  728. {
  729. cardEffect.SetEffectSourceCard(this);
  730. }
  731. }
  732. return _EffectList;
  733. }
  734. #endregion
  735. #region whether this card can declare skill
  736. public bool CanDeclareSkill => CanDeclareSkillList.Count > 0;
  737. #endregion
  738. #region effect list that this card can declare
  739. public List<ICardEffect> CanDeclareSkillList
  740. {
  741. get
  742. {
  743. return EffectList(EffectTiming.OnDeclaration)
  744. .Filter(cardEffect => cardEffect is ActivateICardEffect && cardEffect.CanUse(null));
  745. }
  746. }
  747. #endregion
  748. #region whether this card can not be affected by the effect
  749. public bool CanNotBeAffected(ICardEffect _cardEffect)
  750. {
  751. if (_cardEffect == null) return false;
  752. #region the effects of permanents
  753. if (GManager.instance.turnStateMachine.gameContext.Players
  754. .Map(player => player.GetFieldPermanents())
  755. .Flat()
  756. .Map(permanent => permanent.EffectList(EffectTiming.None))
  757. .Flat()
  758. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  759. && cardEffect.CanUse(null)
  760. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  761. {
  762. return true;
  763. }
  764. #endregion
  765. #region the effects of players
  766. if (GManager.instance.turnStateMachine.gameContext.Players
  767. .Map(player => player.EffectList(EffectTiming.None))
  768. .Flat()
  769. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  770. && cardEffect.CanUse(null)
  771. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  772. {
  773. return true;
  774. }
  775. #endregion
  776. #region the effects of itself
  777. if (PermanentOfThisCard() == null)
  778. {
  779. if (EffectList(EffectTiming.None)
  780. .Some(cardEffect => cardEffect is ICanNotAffectedEffect
  781. && cardEffect.CanUse(null)
  782. && ((ICanNotAffectedEffect)cardEffect).CanNotAffect(this, _cardEffect)))
  783. {
  784. return true;
  785. }
  786. }
  787. #endregion
  788. return false;
  789. }
  790. #endregion
  791. #region whether this card can be played at the frame
  792. 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)
  793. {
  794. bool isBattleAreaFrame = FieldCardFrame.isBattleAreaFrameID(frame.FrameID);
  795. if (isBreedingArea)
  796. {
  797. if (isBattleAreaFrame)
  798. {
  799. return false;
  800. }
  801. }
  802. if (PermanentOfThisCard() != null)
  803. {
  804. if (this == PermanentOfThisCard().TopCard)
  805. {
  806. if (PermanentOfThisCard().HasNoDigivolutionCards)
  807. {
  808. return false;
  809. }
  810. }
  811. }
  812. if (frame.player != Owner)
  813. {
  814. return false;
  815. }
  816. if (PayCost && frame.GetFramePermanent() == null)
  817. {
  818. if (IsOption)
  819. {
  820. return false;
  821. }
  822. int cost = PayingCost(root, new List<Permanent>() { frame.GetFramePermanent() }, checkAvailability: true, FixedCost: fixedCost);
  823. if (Owner.MaxMemoryCost < cost)
  824. {
  825. return false;
  826. }
  827. }
  828. if (frame.GetFramePermanent() != null)
  829. {
  830. if (!CanEvolve(frame.GetFramePermanent(), true, ignore))
  831. {
  832. return false;
  833. }
  834. }
  835. else
  836. {
  837. if (!CanEnterField(cardEffect))
  838. {
  839. return false;
  840. }
  841. }
  842. if (!isBattleAreaFrame && frame.GetFramePermanent() == null && !isBreedingArea)
  843. {
  844. return false;
  845. }
  846. /*if (IsDigiEgg)
  847. {
  848. if (isBattleAreaFrame)
  849. {
  850. return false;
  851. }
  852. }
  853. else
  854. {
  855. if (!isBattleAreaFrame && frame.GetFramePermanent() == null && !isBreedingArea)
  856. {
  857. return false;
  858. }
  859. }*/
  860. return true;
  861. }
  862. #endregion
  863. #region whether there is at least 1 frame where this card can be placed
  864. public bool CanPutFieldThisPermanentCard(bool PayCost, ICardEffect cardEffect, bool isBreedingArea = false)
  865. {
  866. return Owner.fieldCardFrames.Some((frame) => CanPlayCardTargetFrame(frame, PayCost, cardEffect, isBreedingArea: isBreedingArea));
  867. }
  868. #endregion
  869. #region whether this card can be placed on the field by the effect
  870. public bool CanEnterField(ICardEffect _cardEffect)
  871. {
  872. #region the effects of permanents
  873. if (GManager.instance.turnStateMachine.gameContext.Players
  874. .Map(player => player.GetFieldPermanents())
  875. .Flat()
  876. .Map(permanent => permanent.EffectList(EffectTiming.None))
  877. .Flat()
  878. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  879. && cardEffect.CanUse(null)
  880. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  881. {
  882. return false;
  883. }
  884. #endregion
  885. #region the effects of players
  886. if (GManager.instance.turnStateMachine.gameContext.Players
  887. .Map(player => player.EffectList(EffectTiming.None))
  888. .Flat()
  889. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  890. && cardEffect.CanUse(null)
  891. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  892. {
  893. return false;
  894. }
  895. #endregion
  896. #region the effects of itself
  897. if (PermanentOfThisCard() == null)
  898. {
  899. if (EffectList(EffectTiming.None)
  900. .Some(cardEffect => cardEffect is ICanNotPutFieldEffect
  901. && cardEffect.CanUse(null)
  902. && ((ICanNotPutFieldEffect)cardEffect).CanNotPutField(this, _cardEffect)))
  903. {
  904. return false;
  905. }
  906. }
  907. #endregion
  908. return true;
  909. }
  910. #endregion
  911. #region whether the permanent can digivolve into this card
  912. public bool CanEvolve(Permanent targetPermanent, bool checkAvailability, CardEffectCommons.IgnoreRequirement ignore = CardEffectCommons.IgnoreRequirement.None)
  913. {
  914. if (targetPermanent != null)
  915. {
  916. if (CanNotEvolve(targetPermanent))
  917. {
  918. return false;
  919. }
  920. if (targetPermanent.TopCard != null)
  921. {
  922. foreach (Func<Permanent, int> EvoCost in EvoCosts(ignore, checkAvailability))
  923. {
  924. if (EvoCost(targetPermanent) >= 0)
  925. {
  926. return true;
  927. }
  928. }
  929. }
  930. }
  931. return false;
  932. }
  933. #endregion
  934. #region whether the permanent's digivolution into this card is prohibited
  935. public bool CanNotEvolve(Permanent targetPermanent)
  936. {
  937. if (targetPermanent.IsToken)
  938. {
  939. return true;
  940. }
  941. if (IsToken)
  942. {
  943. return true;
  944. }
  945. #region card effects that can't digivolve
  946. #region the effects of permanents
  947. if (GManager.instance.turnStateMachine.gameContext.Players
  948. .Map(player => player.GetFieldPermanents())
  949. .Flat()
  950. .Map(permanent => permanent.EffectList(EffectTiming.None))
  951. .Flat()
  952. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  953. && cardEffect.CanUse(null)
  954. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  955. {
  956. return true;
  957. }
  958. #endregion
  959. #region the effects of players
  960. if (GManager.instance.turnStateMachine.gameContext.Players
  961. .Map(player => player.EffectList(EffectTiming.None))
  962. .Flat()
  963. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  964. && cardEffect.CanUse(null)
  965. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  966. {
  967. return true;
  968. }
  969. #endregion
  970. #region the effects of itself
  971. if (PermanentOfThisCard() == null)
  972. {
  973. if (EffectList(EffectTiming.None)
  974. .Some(cardEffect => cardEffect is ICanNotDigivolveEffect
  975. && cardEffect.CanUse(null)
  976. && ((ICanNotDigivolveEffect)cardEffect).CanNotEvolve(targetPermanent, this)))
  977. {
  978. return true;
  979. }
  980. }
  981. #endregion
  982. #endregion
  983. return false;
  984. }
  985. #endregion
  986. #region ENG card name from entity
  987. public string BaseENGCardNameFromEntity => _cEntity_Base.CardName_ENG;
  988. #endregion
  989. #region JPN card name from entity
  990. public string BaseJPNCardNameFromEntity => _cEntity_Base.CardName_ENG;
  991. #endregion
  992. #region base card names
  993. public List<string> BaseCardNames
  994. {
  995. get
  996. {
  997. List<string> baseCardNames = new List<string>() { BaseENGCardNameFromEntity };
  998. Permanent thisPermanent = PermanentOfThisCard();
  999. bool isPermanent = PermanentOfThisCard() != null;
  1000. bool isDigivolutionCard = isPermanent && thisPermanent.DigivolutionCards.Contains(this);
  1001. #region if dual card and not in play
  1002. if (!isPermanent && _cEntity_Base.IsDualCard)
  1003. {
  1004. baseCardNames.Add(_cEntity_Base.dualEffect);
  1005. }
  1006. #endregion
  1007. #region card effects that change base card names
  1008. if (isDigivolutionCard)
  1009. {
  1010. EffectList_ExceptAddedEffects(EffectTiming.None)
  1011. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1012. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1013. }
  1014. else
  1015. {
  1016. #region the effects of itself
  1017. if (PermanentOfThisCard() == null)
  1018. {
  1019. EffectList(EffectTiming.None)
  1020. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1021. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1022. }
  1023. #endregion
  1024. #region the effects of permanents
  1025. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1026. .Map(player => player.GetFieldPermanents())
  1027. .Flat()
  1028. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1029. .Flat()
  1030. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1031. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1032. #endregion
  1033. #region the effects of players
  1034. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1035. .Map(player => player.EffectList(EffectTiming.None))
  1036. .Flat()
  1037. .Filter(cardEffect => cardEffect is IChangeBaseCardNameEffect && cardEffect.CanUse(null))
  1038. .ForEach(cardEffect => baseCardNames = ((IChangeBaseCardNameEffect)cardEffect).ChangeBaseCardNames(baseCardNames, this));
  1039. #endregion
  1040. }
  1041. #endregion
  1042. return baseCardNames;
  1043. }
  1044. }
  1045. #endregion
  1046. #region card names
  1047. public List<string> CardNames
  1048. {
  1049. get
  1050. {
  1051. List<string> cardNames = BaseCardNames.Clone();
  1052. #region the effects of itself
  1053. EffectList_ExceptAddedEffects(EffectTiming.None)
  1054. .Filter(cardEffect => cardEffect != null)
  1055. .Filter(cardEffect => cardEffect is IChangeCardNamesEffect && cardEffect.CanUse(null))
  1056. .ForEach(cardEffect => cardNames = ((IChangeCardNamesEffect)cardEffect).ChangeCardNames(cardNames, this));
  1057. #endregion
  1058. return cardNames.Distinct().ToList();
  1059. }
  1060. }
  1061. #endregion
  1062. #region Whether target other card's name has same name as this
  1063. public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => EqualsCardName(cardName)) >= 1;
  1064. //public bool HasSameCardName(CardSource cardSource) => cardSource.CardNames.Count((cardName) => CardNames.Contains(cardName)) >= 1;
  1065. #endregion
  1066. #region whether this card has at least 1 card name that equals the string
  1067. /// <summary>
  1068. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1069. /// </summary>
  1070. /// <param name="string">value to check for</param>
  1071. /// <author>Mike Bunch</author>
  1072. public bool EqualsCardName(string name)
  1073. {
  1074. if (string.IsNullOrEmpty(name))
  1075. {
  1076. return false;
  1077. }
  1078. string replaced = name.Replace(" ", "");
  1079. string lower = name.ToLower();
  1080. return CardNames.Some((cardName) =>
  1081. cardName.Equals(name)
  1082. || cardName.Equals(replaced)
  1083. || cardName.Replace(" ", "").Equals(replaced)
  1084. || cardName.Equals(lower)
  1085. || cardName.ToLower().Equals(lower));
  1086. }
  1087. #endregion
  1088. #region whether this card has at least 1 card name that contains the string
  1089. /// <summary>
  1090. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1091. /// </summary>
  1092. /// <param trait="string">value to check for</param>
  1093. /// <author>Mike Bunch</author>
  1094. public bool ContainsCardName(string name)
  1095. {
  1096. if (string.IsNullOrEmpty(name))
  1097. {
  1098. return false;
  1099. }
  1100. string replaced = name.Replace(" ", "");
  1101. string lower = name.ToLower();
  1102. return CardNames.Some((cardName) =>
  1103. cardName.Contains(name)
  1104. || cardName.Contains(replaced)
  1105. || cardName.Contains(lower)
  1106. || cardName.ToLower().Contains(lower));
  1107. }
  1108. #endregion
  1109. #region All colors of a Digimon Card
  1110. public List<CardColor> DigimonCardColors
  1111. {
  1112. get
  1113. {
  1114. if (!IsDigimon)
  1115. {
  1116. return new List<CardColor>();
  1117. }
  1118. return CardColors;
  1119. }
  1120. }
  1121. #endregion
  1122. #region All Colors of an Option Card
  1123. public List<CardColor> OptionCardColors
  1124. {
  1125. get
  1126. {
  1127. if (!IsOption)
  1128. return new List<CardColor>();
  1129. if (IsDigimon) //Dual Card
  1130. {
  1131. return DualCardColors;
  1132. }
  1133. return CardColors;
  1134. }
  1135. }
  1136. #endregion
  1137. #region All colors of a card
  1138. public List<CardColor> AllCardColors
  1139. {
  1140. get
  1141. {
  1142. return CardColors.Concat(DualCardColors).ToList();
  1143. }
  1144. }
  1145. #endregion
  1146. #region whether this card has the mentioned color
  1147. public bool HasCardColor(CardColor cardColor, bool isOptionOnly = false, bool isDigimonOnly = false)
  1148. {
  1149. if (isOptionOnly && isDigimonOnly)
  1150. return false; //Shouldn't be done, just here to cover all bases with consistency
  1151. if (isOptionOnly)
  1152. {
  1153. return OptionCardColors.Contains(cardColor);
  1154. }
  1155. else if (isDigimonOnly)
  1156. {
  1157. return DigimonCardColors.Contains(cardColor);
  1158. }
  1159. return AllCardColors.Contains(cardColor); //check entire card
  1160. }
  1161. public bool HasDigimonColor(CardColor cardColor)
  1162. {
  1163. if (!IsDigimon)
  1164. return false;
  1165. return HasCardColor(cardColor, isDigimonOnly: true);
  1166. }
  1167. public bool HasOptionColor(CardColor cardColor)
  1168. {
  1169. if (!IsOption)
  1170. return false;
  1171. return HasCardColor(cardColor, isOptionOnly: true);
  1172. }
  1173. #endregion
  1174. #region whether this card has at least 1 card name that contains "Greymon"
  1175. public bool HasGreymonName
  1176. {
  1177. get
  1178. {
  1179. if (CardNames.Some((cardName) => (cardName.Contains("Greymon") || cardName.Contains("greymon"))
  1180. && cardName != "DoruGreymon"
  1181. && cardName != "BurningGreymon"
  1182. && cardName != "DexDoruGreymon"))
  1183. {
  1184. return true;
  1185. }
  1186. return false;
  1187. }
  1188. }
  1189. #endregion
  1190. #region whether this card has at least 1 card name that contains "Garurumon"
  1191. public bool HasGarurumonName
  1192. {
  1193. get
  1194. {
  1195. if (CardNames.Some((cardName) => (cardName.Contains("Garurumon") || cardName.Contains("garurumon"))
  1196. && cardName != "KendoGarurumon"))
  1197. {
  1198. return true;
  1199. }
  1200. return false;
  1201. }
  1202. }
  1203. #endregion
  1204. #region whether this card has at least 1 card name that contains "Impmon"
  1205. public bool HasImpmonName
  1206. {
  1207. get
  1208. {
  1209. if (CardNames.Some((cardName) => (cardName.Contains("Impmon") || cardName.Contains("impmon"))
  1210. && cardName != "Blimpmon"))
  1211. {
  1212. return true;
  1213. }
  1214. return false;
  1215. }
  1216. }
  1217. #endregion
  1218. #region whether this card has at least 1 card name that contains "Dramon"
  1219. public bool HasDramonName
  1220. {
  1221. get
  1222. {
  1223. if (CardNames.Some((cardName) => (cardName.Contains("Dramon") || cardName.Contains("dramon"))
  1224. && cardName != "Indramon"))
  1225. {
  1226. return true;
  1227. }
  1228. return false;
  1229. }
  1230. }
  1231. #endregion
  1232. #region whether this card has at least 1 card name that contains "AAntibody"
  1233. public bool HasXAntiBodyName => CardNames.Some(DataBase.IsContainingXAntibodyString);
  1234. #endregion
  1235. #region whether this card has at least 1 trait that equals the string
  1236. /// <summary>
  1237. /// Used to check if specified trait is exactly in cards trait values ("Sky Dragon" is not "Dragon")
  1238. /// </summary>
  1239. /// <param trait="string">value to check for</param>
  1240. /// <author>Mike Bunch</author>
  1241. public bool EqualsTraits(string trait)
  1242. {
  1243. if (string.IsNullOrEmpty(trait))
  1244. return false;
  1245. string replaced = trait.Replace(" ", "").ToLower();
  1246. return CardTraits.Some(cardTrait => cardTrait.Equals(trait) || cardTrait.ToLower().Equals(replaced));
  1247. }
  1248. #endregion
  1249. #region whether this card has at least 1 trait that contains the string
  1250. /// <summary>
  1251. /// Used to check if specified trait is within cards trait values ("Sky Dragon" contains "Dragon")
  1252. /// </summary>
  1253. /// <param trait="string">value to check for</param>
  1254. /// <author>Mike Bunch</author>
  1255. public bool ContainsTraits(string trait)
  1256. {
  1257. if (string.IsNullOrEmpty(trait))
  1258. return false;
  1259. string replaced = trait.Replace(" ", "").ToLower();
  1260. return CardTraits.Some(cardTrait => cardTrait.Contains(trait) || cardTrait.ToLower().Contains(replaced));
  1261. }
  1262. #endregion
  1263. #region whether this card has at least 1 trait that contains "Bird"
  1264. public bool HasBirdTraits
  1265. {
  1266. get
  1267. {
  1268. if (ContainsTraits("Avian"))
  1269. {
  1270. return true;
  1271. }
  1272. if (ContainsTraits("Bird"))
  1273. {
  1274. return true;
  1275. }
  1276. return false;
  1277. }
  1278. }
  1279. #endregion
  1280. #region whether this card has at least 1 trait that contains "Beast"
  1281. public bool HasBeastTraits
  1282. {
  1283. get
  1284. {
  1285. if (ContainsTraits("Beast"))
  1286. {
  1287. return true;
  1288. }
  1289. if (ContainsTraits("Animal") && !ContainsTraits("Sea"))
  1290. {
  1291. return true;
  1292. }
  1293. if (ContainsTraits("Sovereign"))
  1294. {
  1295. return true;
  1296. }
  1297. return false;
  1298. }
  1299. }
  1300. #endregion
  1301. #region whether this card has at least 1 trait that contains "Plant"
  1302. public bool HasPlantTraits
  1303. {
  1304. get
  1305. {
  1306. if (ContainsTraits("Vegetation"))
  1307. {
  1308. return true;
  1309. }
  1310. if (ContainsTraits("Plant"))
  1311. {
  1312. return true;
  1313. }
  1314. return false;
  1315. }
  1316. }
  1317. #endregion
  1318. #region whether this card has at least 1 trait that contains "Fairy"
  1319. public bool HasFairyTraits
  1320. {
  1321. get
  1322. {
  1323. if (ContainsTraits("Fairy"))
  1324. {
  1325. return true;
  1326. }
  1327. return false;
  1328. }
  1329. }
  1330. #endregion
  1331. #region whether this card has at least 1 trait that contains "Dragon"
  1332. public bool HasDragonTraits
  1333. {
  1334. get
  1335. {
  1336. if (ContainsTraits("Dragon"))
  1337. {
  1338. return true;
  1339. }
  1340. if (ContainsTraits("saur"))
  1341. {
  1342. return true;
  1343. }
  1344. if (ContainsTraits("Ceratopsian"))
  1345. {
  1346. return true;
  1347. }
  1348. return false;
  1349. }
  1350. }
  1351. #endregion
  1352. #region whether this card has at least 1 trait that contains "Aqua"
  1353. public bool HasAquaTraits
  1354. {
  1355. get
  1356. {
  1357. if (ContainsTraits("Aqua"))
  1358. {
  1359. return true;
  1360. }
  1361. if (ContainsTraits("Sea Animal"))
  1362. {
  1363. return true;
  1364. }
  1365. if (ContainsTraits("SeaAnimal"))
  1366. {
  1367. return true;
  1368. }
  1369. return false;
  1370. }
  1371. }
  1372. #endregion
  1373. #region whether this card has at least 1 trait that contains "Angel"
  1374. public bool HasAngelTraits
  1375. {
  1376. get
  1377. {
  1378. if (CardTraits.Count((trait) => (trait.Contains("Angel") || trait.Contains("angel")) && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1379. {
  1380. return true;
  1381. }
  1382. if (ContainsTraits("Cherub"))
  1383. {
  1384. return true;
  1385. }
  1386. if (ContainsTraits("Throne"))
  1387. {
  1388. return true;
  1389. }
  1390. if (ContainsTraits("Authority"))
  1391. {
  1392. return true;
  1393. }
  1394. if (ContainsTraits("Seraph"))
  1395. {
  1396. return true;
  1397. }
  1398. if (ContainsTraits("Virtue"))
  1399. {
  1400. return true;
  1401. }
  1402. return false;
  1403. }
  1404. }
  1405. #endregion
  1406. #region whether this card has 1 of the "Angel", "Archangel" or "Three Great Angels" trait
  1407. public bool HasAngelTraitRestrictive
  1408. {
  1409. get
  1410. {
  1411. if (ContainsTraits("Three Great Angels") || ContainsTraits("ThreeGreatAngels"))
  1412. {
  1413. return true;
  1414. }
  1415. if (ContainsTraits("Archangel"))
  1416. {
  1417. return true;
  1418. }
  1419. if (CardTraits.Count(trait =>
  1420. (trait.Contains("Angel") || trait.Contains("angel"))
  1421. && trait != "Archangel"
  1422. && trait != "Fallen Angel" && trait != "FallenAngel"
  1423. && trait != "Three Great Angels" && trait != "ThreeGreatAngels") >= 1)
  1424. {
  1425. return true;
  1426. }
  1427. return false;
  1428. }
  1429. }
  1430. #endregion
  1431. #region whether this card has at least 1 trait that contains "Avian", "Bird", "Beast", "Animal", "Sovereign", other than "Sea Animal"
  1432. public bool HasAvianBeastAnimalTraits
  1433. {
  1434. get
  1435. {
  1436. if (ContainsTraits("Avian"))
  1437. return true;
  1438. if (ContainsTraits("Bird"))
  1439. return true;
  1440. if (ContainsTraits("Beast"))
  1441. return true;
  1442. if (ContainsTraits("Animal") && !ContainsTraits("Sea Animal"))
  1443. return true;
  1444. if (ContainsTraits("Sovereign"))
  1445. return true;
  1446. return false;
  1447. }
  1448. }
  1449. #endregion
  1450. #region whether this card has at least 1 trait that contains "Hybrid", "Ten Warriors"
  1451. public bool HasHybridTenWarriorsTraits
  1452. {
  1453. get
  1454. {
  1455. if (ContainsTraits("Hybrid"))
  1456. return true;
  1457. if (ContainsTraits("Ten Warriors"))
  1458. return true;
  1459. return false;
  1460. }
  1461. }
  1462. #endregion
  1463. #region whether this card has "XAntibody" trait
  1464. public bool HasXAntibodyTraits => CardTraits.Some(DataBase.IsXAntibodyString);
  1465. #endregion
  1466. #region whether this card has "Royal Knight" trait
  1467. public bool HasRoyalKnightTraits
  1468. {
  1469. get
  1470. {
  1471. return EqualsTraits("Royal Knight");
  1472. }
  1473. }
  1474. #endregion
  1475. #region whether this card has "SoC" trait
  1476. public bool HasSocTraits
  1477. {
  1478. get
  1479. {
  1480. if (CardTraits.Contains("SoC"))
  1481. {
  1482. return true;
  1483. }
  1484. return false;
  1485. }
  1486. }
  1487. #endregion
  1488. #region whether this card has "D-Brigade"/"DigiPolice trait
  1489. public bool HasDBrigadeorDigiPoliceTraits
  1490. {
  1491. get
  1492. {
  1493. if (CardTraits.Contains("D-Brigade"))
  1494. {
  1495. return true;
  1496. }
  1497. if (CardTraits.Contains("DigiPolice"))
  1498. {
  1499. return true;
  1500. }
  1501. return false;
  1502. }
  1503. }
  1504. #endregion
  1505. #region whether this card has at least 1 trait that contains "Beast Dragon"
  1506. public bool HasBeastDragonTraits
  1507. {
  1508. get
  1509. {
  1510. if (ContainsTraits("BeastDragon"))
  1511. {
  1512. return true;
  1513. }
  1514. if (ContainsTraits("Beast Dragon"))
  1515. {
  1516. return true;
  1517. }
  1518. return false;
  1519. }
  1520. }
  1521. #endregion
  1522. #region whether this card has at least 1 trait that contains "DigiPolice"
  1523. public bool HasDigiPoliceTraits
  1524. {
  1525. get
  1526. {
  1527. if (ContainsTraits("DigiPolice"))
  1528. {
  1529. return true;
  1530. }
  1531. return false;
  1532. }
  1533. }
  1534. #endregion
  1535. #region whether this card has at least 1 trait that contains "Light Fang" or "Night Claw"
  1536. public bool HasLightFangNightClawTraits => ContainsTraits("Light Fang") || ContainsTraits("Night Claw");
  1537. #endregion
  1538. #region whether this card has at least 1 trait that contains "Light Fang/Night Claw"
  1539. public bool HasLightFangOrNightClawTraits
  1540. {
  1541. get
  1542. {
  1543. if (ContainsTraits("Light Fang"))
  1544. {
  1545. return true;
  1546. }
  1547. if (ContainsTraits("Night Claw"))
  1548. {
  1549. return true;
  1550. }
  1551. return false;
  1552. }
  1553. }
  1554. #endregion
  1555. #region [Onmyōjutsu] or [Plug-In] trait
  1556. public bool HasOnmyoOrPluginTraits
  1557. {
  1558. get
  1559. {
  1560. if (EqualsTraits("Plug-In"))
  1561. {
  1562. return true;
  1563. }
  1564. if (EqualsTraits("Onmyōjutsu"))
  1565. {
  1566. return true;
  1567. }
  1568. return false;
  1569. }
  1570. }
  1571. #endregion
  1572. #region whether this card has the string in text
  1573. public bool HasText(string text)
  1574. {
  1575. if (String.IsNullOrEmpty(text)) return false;
  1576. text = DataBase.ReplaceToASCII(text);
  1577. string replaced = text.Replace(" ", "");
  1578. string lower = text.ToLower();
  1579. List<string> checkStrings = new List<string>()
  1580. {
  1581. DataBase.ReplaceToASCII(_cEntity_Base.CardName_ENG),
  1582. DataBase.ReplaceToASCII(_cEntity_Base.dualEffect),
  1583. DataBase.ReplaceToASCII(_cEntity_Base.EffectDiscription_ENG),
  1584. DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG),
  1585. DataBase.ReplaceToASCII(_cEntity_Base.SecurityEffectDiscription_ENG),
  1586. DataBase.ReplaceToASCII(_cEntity_Base.OptionEffect),
  1587. };
  1588. foreach (string attribute in _cEntity_Base.Attribute_ENG)
  1589. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1590. foreach (string attribute in _cEntity_Base.Type_ENG)
  1591. checkStrings.Add(DataBase.ReplaceToASCII(attribute));
  1592. if (jogressCondition.Count > 0)
  1593. {
  1594. foreach (JogressCondition jogress in jogressCondition)
  1595. {
  1596. foreach (JogressConditionElement element in jogress.elements)
  1597. checkStrings.Add(element.SelectMessage);
  1598. }
  1599. }
  1600. foreach (string checkString in checkStrings)
  1601. {
  1602. if (!string.IsNullOrEmpty(checkString))
  1603. {
  1604. if (checkString.Contains(text))
  1605. {
  1606. return true;
  1607. }
  1608. if (checkString.Contains(replaced))
  1609. {
  1610. return true;
  1611. }
  1612. if (checkString.Contains(lower))
  1613. {
  1614. return true;
  1615. }
  1616. }
  1617. }
  1618. return false;
  1619. }
  1620. #endregion
  1621. #region whether this card has <Save> in text
  1622. public bool HasSaveText => HasText("<Save>");
  1623. #endregion
  1624. #region whether this card has "Pulsemon" in text
  1625. public bool HasPulsemonText => HasText("Pulsemon");
  1626. #endregion
  1627. #region card names checked when digixros
  1628. public List<string> CardNames_DigiXros
  1629. {
  1630. get
  1631. {
  1632. List<string> cardNames_DigiXros = CardNames.Clone();
  1633. #region the effects of itself
  1634. EffectList(EffectTiming.None)
  1635. .Filter(cardEffect => cardEffect is IChangeCardNamesForDigiXrosEffect && cardEffect.CanUse(null))
  1636. .ForEach(cardEffect => cardNames_DigiXros = ((IChangeCardNamesForDigiXrosEffect)cardEffect).ChangeCardNamesForDigiXros(cardNames_DigiXros, this));
  1637. #endregion
  1638. return cardNames_DigiXros;
  1639. }
  1640. }
  1641. #endregion
  1642. #region card level checked when Assembly
  1643. public List<int> Level_Assembly
  1644. {
  1645. get
  1646. {
  1647. List<int> cardLevel_Assembly = new List<int>();
  1648. cardLevel_Assembly.Add(TreatedLevel);
  1649. #region the effects of itself
  1650. EffectList(EffectTiming.None)
  1651. .Filter(cardEffect => cardEffect is IChangeCardLevelForAssemblyEffect && cardEffect.CanUse(null))
  1652. .ForEach(cardEffect => cardLevel_Assembly = ((IChangeCardLevelForAssemblyEffect)cardEffect).ChangeCardLevelForAssembly(cardLevel_Assembly, this));
  1653. #endregion
  1654. return cardLevel_Assembly;
  1655. }
  1656. }
  1657. #endregion
  1658. #region whether this card has at least 1 card name checked when digixros that equals the string
  1659. /// <summary>
  1660. /// Used to check if specified name is exactly in cards name values ("dra" is not "Commandramon")
  1661. /// </summary>
  1662. /// <param name="string">value to check for</param>
  1663. /// <author>Mike Bunch</author>
  1664. public bool EqualsCardNameDigiXros(string name)
  1665. {
  1666. if (string.IsNullOrEmpty(name))
  1667. {
  1668. return false;
  1669. }
  1670. string replaced = name.Replace(" ", "");
  1671. string lower = name.ToLower();
  1672. return CardNames_DigiXros.Some((cardName) =>
  1673. cardName.Equals(name)
  1674. || cardName.Equals(replaced)
  1675. || cardName.Equals(lower)
  1676. || cardName.ToLower().Equals(lower));
  1677. }
  1678. #endregion
  1679. #region whether this card has at least 1 card name that contains the string
  1680. /// <summary>
  1681. /// Used to check if specified trait is within cards name values ("dra" is in "Commandramon")
  1682. /// </summary>
  1683. /// <param trait="string">value to check for</param>
  1684. /// <author>Mike Bunch</author>
  1685. public bool ContainsCardNameDigiXros(string name)
  1686. {
  1687. if (string.IsNullOrEmpty(name))
  1688. {
  1689. return false;
  1690. }
  1691. string replaced = name.Replace(" ", "");
  1692. string lower = name.ToLower();
  1693. return CardNames_DigiXros.Some((cardName) =>
  1694. cardName.Contains(name)
  1695. || cardName.Contains(replaced)
  1696. || cardName.Contains(lower)
  1697. || cardName.ToLower().Contains(lower));
  1698. }
  1699. #endregion
  1700. #region preferered frame to play
  1701. public FieldCardFrame PreferredFrame()
  1702. {
  1703. FieldCardFrame PreferredFrame = Owner.fieldCardFrames[0];
  1704. List<FieldCardFrame> fieldCardFrames =
  1705. Owner.fieldCardFrames
  1706. .Filter(fieldCardFrame => fieldCardFrame.IsBattleAreaFrame()
  1707. && fieldCardFrame.IsEmptyFrame());
  1708. if (_cEntity_Base != null)
  1709. {
  1710. if (IsDigimon || IsDigiEgg)
  1711. {
  1712. if (Owner.isYou)
  1713. {
  1714. fieldCardFrames = fieldCardFrames
  1715. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1716. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1717. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1718. .ToList();
  1719. }
  1720. else
  1721. {
  1722. fieldCardFrames = fieldCardFrames
  1723. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1724. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1725. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1726. .ToList();
  1727. int[] correctOrder = new int[] { 4, 3, 5, 2, 6, 1, 7, 0, 8, 11, 10, 12, 9, 13, 14, 15, };
  1728. List<FieldCardFrame> correctOrderFrames = new List<FieldCardFrame>();
  1729. for (int i = 0; i < correctOrder.Length; i++)
  1730. {
  1731. foreach (FieldCardFrame frame in fieldCardFrames)
  1732. {
  1733. if (frame.FrameID == correctOrder[i])
  1734. {
  1735. correctOrderFrames.Add(frame);
  1736. }
  1737. }
  1738. }
  1739. fieldCardFrames = correctOrderFrames;
  1740. }
  1741. }
  1742. else if (IsTamer || IsOption)
  1743. {
  1744. if (Owner.isYou)
  1745. {
  1746. fieldCardFrames = fieldCardFrames
  1747. .OrderBy(value => value.Frame.transform.parent.localPosition.y)
  1748. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1749. .ThenBy(value => value.Frame.transform.parent.localPosition.x)
  1750. .ToList();
  1751. }
  1752. else
  1753. {
  1754. fieldCardFrames = fieldCardFrames
  1755. .OrderByDescending(value => value.Frame.transform.parent.localPosition.y)
  1756. .ThenBy(value => Mathf.Abs(value.Frame.transform.parent.localPosition.x))
  1757. .ThenByDescending(value => value.Frame.transform.parent.localPosition.x)
  1758. .ToList();
  1759. }
  1760. }
  1761. if (fieldCardFrames.Count >= 1)
  1762. {
  1763. PreferredFrame = fieldCardFrames[0];
  1764. }
  1765. }
  1766. return PreferredFrame;
  1767. }
  1768. #endregion
  1769. #region Whether this card has DP
  1770. public bool HasDP => IsDigimon || _cEntity_Base.DP > 0 || BaseDP > 0;
  1771. #endregion
  1772. #region base card DP
  1773. public int BaseCardDP => _cEntity_Base.DP;
  1774. public int BaseDP = 0;
  1775. #endregion
  1776. #region DP
  1777. public int CardDP
  1778. {
  1779. get
  1780. {
  1781. int cardDP = -1;
  1782. if (HasDP)
  1783. {
  1784. cardDP = BaseCardDP;
  1785. cardDP += BaseDP;
  1786. #region card effects that change card DP
  1787. List<ICardEffect> changeCardDPCardEffects = new List<ICardEffect>();
  1788. #region the effects of permanents
  1789. changeCardDPCardEffects = changeCardDPCardEffects
  1790. .Concat(
  1791. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1792. .Map(player => player.GetFieldPermanents())
  1793. .Flat()
  1794. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1795. .Flat()
  1796. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1797. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1798. .ToList();
  1799. #endregion
  1800. #region the effects of players
  1801. changeCardDPCardEffects = changeCardDPCardEffects
  1802. .Concat(
  1803. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  1804. .Map(player => player.EffectList(EffectTiming.None))
  1805. .Flat()
  1806. .Filter(cardEffect => cardEffect is IChangeCardDPEffect && cardEffect.CanUse(null)
  1807. && ((IChangeCardDPEffect)cardEffect).CardCondition(this)))
  1808. .ToList();
  1809. #endregion
  1810. List<ICardEffect> cardEffects_ChangeDP_IsUpDown = changeCardDPCardEffects
  1811. .Filter(cardEffect => ((IChangeCardDPEffect)cardEffect).IsUpDown());
  1812. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = changeCardDPCardEffects
  1813. .Filter(cardEffect => !((IChangeCardDPEffect)cardEffect).IsUpDown());
  1814. cardEffects_ChangeDP_IsUpDown
  1815. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1816. cardEffects_ChangeDP_NotIsUpDown
  1817. .ForEach(cardEffect => cardDP = ((IChangeCardDPEffect)cardEffect).GetDP(cardDP, this));
  1818. #endregion
  1819. }
  1820. return Math.Max(0, cardDP);
  1821. }
  1822. }
  1823. #endregion
  1824. #region Link DP
  1825. public int LinkDP => _cEntity_Base.LinkDP;
  1826. #endregion
  1827. #region Set DP - Must be used in conjunction with when removed field
  1828. public void SetDP(int value)
  1829. {
  1830. BaseDP = value;
  1831. }
  1832. #endregion
  1833. #region whether this card is token
  1834. public bool IsToken { get; private set; } = false;
  1835. public void SetIsToken(bool isToken) => IsToken = isToken;
  1836. #endregion
  1837. #region Will this card be trashed from sources
  1838. public bool willBeRemoveSources { get; set; } = false;
  1839. #endregion
  1840. #region whether this card can not be trashed from digivolution cards
  1841. public bool CanNotTrashFromDigivolutionCards(ICardEffect _cardEffect)
  1842. {
  1843. if (willBeRemoveSources)
  1844. return true;
  1845. #region the effects of permanents
  1846. if (GManager.instance.turnStateMachine.gameContext.Players
  1847. .Map(player => player.GetFieldPermanents())
  1848. .Flat()
  1849. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1850. .Flat()
  1851. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1852. && cardEffect.CanUse(null)
  1853. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1854. {
  1855. return true;
  1856. }
  1857. #endregion
  1858. #region the effects of players
  1859. if (GManager.instance.turnStateMachine.gameContext.Players
  1860. .Map(player => player.EffectList(EffectTiming.None))
  1861. .Flat()
  1862. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1863. && cardEffect.CanUse(null)
  1864. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1865. {
  1866. return true;
  1867. }
  1868. #endregion
  1869. #region the effects of itself
  1870. if (PermanentOfThisCard() == null)
  1871. {
  1872. if (EffectList(EffectTiming.None)
  1873. .Some(cardEffect => cardEffect is ICanNotTrashFromDigivolutionCardsEffect
  1874. && cardEffect.CanUse(null)
  1875. && ((ICanNotTrashFromDigivolutionCardsEffect)cardEffect).CanNotTrashFromDigivolutionCards(this, _cardEffect)))
  1876. {
  1877. return true;
  1878. }
  1879. }
  1880. #endregion
  1881. return false;
  1882. }
  1883. #endregion
  1884. #region whether this card has [Blocker]
  1885. public bool HasBlocker =>
  1886. EffectList(EffectTiming.None)
  1887. .Some(cardEffect => cardEffect is BlockerClass
  1888. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect);
  1889. #endregion
  1890. #region whether this card has [DigiBurst]
  1891. public bool HasDigiBurst
  1892. {
  1893. get
  1894. {
  1895. if (_cEntity_Base != null)
  1896. {
  1897. if (!string.IsNullOrEmpty(_cEntity_Base.EffectDiscription_JPN))
  1898. {
  1899. bool result = Regex.IsMatch(_cEntity_Base.EffectDiscription_JPN, DataBase.DigiburstRegex);
  1900. if (result)
  1901. {
  1902. return true;
  1903. }
  1904. }
  1905. }
  1906. return false;
  1907. }
  1908. }
  1909. #endregion
  1910. #region whether this card has [DigiXros]
  1911. public bool HasDigiXros => digiXrosCondition != null;
  1912. #endregion
  1913. #region whether this card has [Assembly]
  1914. public bool HasAssembly => assemblyCondition != null;
  1915. #endregion
  1916. #region traits
  1917. public List<string> CardTraits
  1918. {
  1919. get
  1920. {
  1921. List<string> traits =
  1922. _cEntity_Base.Form_ENG
  1923. .Filter(s => !string.IsNullOrEmpty(s))
  1924. .Concat(_cEntity_Base.Attribute_ENG
  1925. .Filter(s => !string.IsNullOrEmpty(s)))
  1926. .Concat(_cEntity_Base.Type_ENG
  1927. .Filter(s => !string.IsNullOrEmpty(s)))
  1928. .ToList();
  1929. #region the effects of itself
  1930. EffectList(EffectTiming.None)
  1931. .Filter(cardEffect => cardEffect is IChangeTraitsEffect && cardEffect.CanUse(null))
  1932. .ForEach(cardEffect => traits = ((IChangeTraitsEffect)cardEffect).ChangTraits(traits, this));
  1933. #endregion
  1934. return traits;
  1935. }
  1936. }
  1937. #endregion
  1938. #region whether this card has [On Deletion] effect
  1939. public bool HasOnDeletionEffect =>
  1940. EffectList(EffectTiming.OnDestroyedAnyone)
  1941. .Some(cardEffect => cardEffect is ActivateICardEffect
  1942. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1943. && cardEffect.IsOnDeletion);
  1944. #endregion
  1945. #region whether this card has [On Play] effect
  1946. public bool HasOnPlayEffect =>
  1947. EffectList(EffectTiming.OnEnterFieldAnyone)
  1948. .Some(cardEffect => cardEffect is ActivateICardEffect
  1949. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1950. && cardEffect.IsOnPlay);
  1951. #endregion
  1952. #region whether this card has [When Digivolving] effect
  1953. public bool HasWhenDigivolvingEffect =>
  1954. EffectList(EffectTiming.OnEnterFieldAnyone)
  1955. .Some(cardEffect => cardEffect is ActivateICardEffect
  1956. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1957. && cardEffect.IsWhenDigivolving);
  1958. #endregion
  1959. #region whether this card has [Digisorption]
  1960. public bool HasDigisorption =>
  1961. EffectList(EffectTiming.BeforePayCost)
  1962. .Some(cardEffect => cardEffect is ActivateICardEffect
  1963. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1964. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1965. && cardEffect.EffectDiscription.Contains("Digisorption -"));
  1966. #endregion
  1967. #region whether this card has [Blitz]
  1968. public bool HasBlitz =>
  1969. EffectList(EffectTiming.OnEnterFieldAnyone)
  1970. .Some(cardEffect => cardEffect is ActivateICardEffect
  1971. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1972. && (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfCard(this)))
  1973. && !string.IsNullOrEmpty(cardEffect.EffectDiscription)
  1974. && cardEffect.EffectDiscription.Contains("Blitz"));
  1975. #endregion
  1976. #region whether this card has [Retaliation]
  1977. public bool HasRetaliation =>
  1978. EffectList(EffectTiming.OnDestroyedAnyone)
  1979. .Some(cardEffect => cardEffect is ActivateICardEffect
  1980. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1981. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1982. && cardEffect.EffectName == "Retaliation");
  1983. #endregion
  1984. #region whether this card has [Fortitude]
  1985. public bool HasFortitude =>
  1986. EffectList(EffectTiming.OnDestroyedAnyone)
  1987. .Some(cardEffect => cardEffect is ActivateICardEffect
  1988. && !cardEffect.IsInheritedEffect && !cardEffect.IsSecurityEffect
  1989. && cardEffect.CanTrigger(CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { new Permanent(new List<CardSource>() { this }) }, null, null, false))
  1990. && cardEffect.EffectName == "Fortitude");
  1991. #endregion
  1992. #region whether this card has inherited effect
  1993. public bool HasInheritedEffect
  1994. {
  1995. get
  1996. {
  1997. foreach (EffectTiming timing in Enum.GetValues(typeof(EffectTiming)))
  1998. {
  1999. if (EffectList(timing)
  2000. .Some(cardEffect => cardEffect.IsInheritedEffect
  2001. && !cardEffect.IsDisabled))
  2002. {
  2003. return true;
  2004. }
  2005. }
  2006. return false;
  2007. }
  2008. }
  2009. #endregion
  2010. #region DNA digivolution requirement
  2011. public List<JogressCondition> jogressCondition
  2012. {
  2013. get
  2014. {
  2015. List<JogressCondition> addJogressConditionEffect =
  2016. EffectList(EffectTiming.None)
  2017. .Filter(cardEffect => cardEffect is IAddJogressConditionEffect
  2018. && cardEffect.CanUse(null)
  2019. && ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this) != null)
  2020. .Select(cardEffect => ((IAddJogressConditionEffect)cardEffect).GetJogressCondition(this))
  2021. .ToList();
  2022. return addJogressConditionEffect;
  2023. }
  2024. }
  2025. #endregion
  2026. #region Link requirement
  2027. public LinkCondition linkCondition
  2028. {
  2029. get
  2030. {
  2031. ICardEffect addLinkConditonEffect =
  2032. EffectList(EffectTiming.None)
  2033. .Find(cardEffect => cardEffect is IAddLinkConditionEffect
  2034. && cardEffect.CanUse(null)
  2035. && ((IAddLinkConditionEffect)cardEffect).GetLinkCondition(this) != null);
  2036. if (addLinkConditonEffect != null) return ((IAddLinkConditionEffect)addLinkConditonEffect).GetLinkCondition(this);
  2037. return null;
  2038. }
  2039. }
  2040. #endregion
  2041. #region whether this card can DNA digivolve
  2042. public bool CanPlayJogress(bool PayCost)
  2043. {
  2044. if (jogressCondition != null)
  2045. {
  2046. foreach (JogressCondition condition in jogressCondition)
  2047. {
  2048. if (Owner.GetBattleAreaDigimons().Count >= condition.elements.Length)
  2049. {
  2050. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(Owner.GetBattleAreaDigimons(), condition.elements.Length).ToList();
  2051. foreach (Permanent[] permanents in permanentsList)
  2052. {
  2053. if (permanents != null)
  2054. {
  2055. if (permanents.Length == condition.elements.Length)
  2056. {
  2057. if (permanents.Length == 2)
  2058. {
  2059. if (condition.elements[0].EvoRootCondition(permanents[0]) && !this.CanNotEvolve(permanents[0]))
  2060. {
  2061. if (condition.elements[1].EvoRootCondition(permanents[1]) && !this.CanNotEvolve(permanents[1]))
  2062. {
  2063. if (PayCost)
  2064. {
  2065. int cost = condition.cost;
  2066. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, permanents.ToList(), checkAvailability: true);
  2067. if (Owner.MaxMemoryCost < cost)
  2068. {
  2069. return false;
  2070. }
  2071. }
  2072. return true;
  2073. }
  2074. }
  2075. }
  2076. }
  2077. }
  2078. }
  2079. }
  2080. }
  2081. }
  2082. return false;
  2083. }
  2084. #endregion
  2085. #region whether target permanent can DNA digivolve into this card
  2086. public bool CanJogressFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2087. {
  2088. if (targetPermanent != null)
  2089. {
  2090. if (targetPermanent.TopCard != null)
  2091. {
  2092. foreach (JogressCondition condition in jogressCondition)
  2093. {
  2094. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  2095. {
  2096. if (this.CanPlayJogress(PayCost))
  2097. {
  2098. if (condition != null)
  2099. {
  2100. if (condition.elements.ToList().Count((element) => element.EvoRootCondition(targetPermanent)) >= 1)
  2101. {
  2102. if (!this.CanNotEvolve(targetPermanent))
  2103. {
  2104. if (PayCost)
  2105. {
  2106. int cost = condition.cost;
  2107. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent, new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2108. if (Owner.MaxMemoryCost < cost)
  2109. {
  2110. return false;
  2111. }
  2112. }
  2113. return true;
  2114. }
  2115. }
  2116. }
  2117. }
  2118. }
  2119. }
  2120. }
  2121. }
  2122. return false;
  2123. }
  2124. #endregion
  2125. #region whether target permanents can DNA digivolve into this card
  2126. public bool CanJogressFromTargetPermanents(List<Permanent> targetPermanents, bool PayCost)
  2127. {
  2128. if (targetPermanents != null)
  2129. {
  2130. if (targetPermanents.Count == 2)
  2131. {
  2132. if (this.CanPlayJogress(PayCost))
  2133. {
  2134. foreach (JogressCondition condition in jogressCondition)
  2135. {
  2136. if (condition != null)
  2137. {
  2138. List<Permanent[]> permanentsList = ParameterComparer.Enumerate(targetPermanents, 2).ToList();
  2139. foreach (Permanent[] permanents in permanentsList)
  2140. {
  2141. if (condition.elements.Length == permanents.Length)
  2142. {
  2143. bool canJogress = true;
  2144. for (int i = 0; i < permanents.Length; i++)
  2145. {
  2146. if (permanents[i] != null)
  2147. {
  2148. if (permanents[i].TopCard != null)
  2149. {
  2150. if ((!condition.elements[i].EvoRootCondition(permanents[i])) || this.CanNotEvolve(permanents[i]))
  2151. {
  2152. canJogress = false;
  2153. break;
  2154. }
  2155. }
  2156. }
  2157. }
  2158. if (canJogress)
  2159. {
  2160. return true;
  2161. }
  2162. }
  2163. }
  2164. }
  2165. }
  2166. }
  2167. }
  2168. }
  2169. return false;
  2170. }
  2171. #endregion
  2172. #region whether this card has level
  2173. public bool HasLevel
  2174. {
  2175. get
  2176. {
  2177. if (_cEntity_Base == null || _cEntity_Base.HasLevel)
  2178. {
  2179. return true;
  2180. }
  2181. return false;
  2182. }
  2183. }
  2184. #endregion
  2185. #region whether this card is level 2
  2186. public bool IsLevel2 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 2;
  2187. #endregion
  2188. #region whether this card is level 3
  2189. public bool IsLevel3 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 3;
  2190. #endregion
  2191. #region whether this card is level 4
  2192. public bool IsLevel4 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 4;
  2193. #endregion
  2194. #region whether this card is level 5
  2195. public bool IsLevel5 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 5;
  2196. #endregion
  2197. #region whether this card is level 6
  2198. public bool IsLevel6 => (_cEntity_Base == null || _cEntity_Base.HasLevel) && _cEntity_Base.Level == 6;
  2199. #endregion
  2200. #region whether this card is linked
  2201. public bool IsLinked
  2202. {
  2203. get
  2204. {
  2205. return PermanentOfThisCard().LinkedCards.Contains(this);
  2206. }
  2207. }
  2208. #endregion
  2209. #region DigiXros requirement
  2210. public DigiXrosCondition digiXrosCondition
  2211. {
  2212. get
  2213. {
  2214. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2215. {
  2216. if (cardEffect is IAddDigiXrosConditionEffect)
  2217. {
  2218. if (cardEffect.CanUse(null))
  2219. {
  2220. DigiXrosCondition digiXrosCondition = ((IAddDigiXrosConditionEffect)cardEffect).GetDigiXrosCondition(this);
  2221. if (digiXrosCondition != null)
  2222. {
  2223. return digiXrosCondition;
  2224. }
  2225. }
  2226. }
  2227. }
  2228. return null;
  2229. }
  2230. }
  2231. #endregion
  2232. #region Blast Digivolution requirement
  2233. public BurstDigivolutionCondition burstDigivolutionCondition
  2234. {
  2235. get
  2236. {
  2237. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2238. {
  2239. if (cardEffect is IAddBurstDigivolutionConditionEffect)
  2240. {
  2241. if (cardEffect.CanUse(null))
  2242. {
  2243. BurstDigivolutionCondition burstDigivolutionCondition = ((IAddBurstDigivolutionConditionEffect)cardEffect).GetBurstDigivolutionCondition(this);
  2244. if (burstDigivolutionCondition != null)
  2245. {
  2246. return burstDigivolutionCondition;
  2247. }
  2248. }
  2249. }
  2250. }
  2251. return null;
  2252. }
  2253. }
  2254. #endregion
  2255. #region App Fusion requirement
  2256. public AppFusionCondition appFusionCondition
  2257. {
  2258. get
  2259. {
  2260. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2261. {
  2262. if (cardEffect is IAddAppFusionConditionEffect)
  2263. {
  2264. if (cardEffect.CanUse(null))
  2265. {
  2266. AppFusionCondition appFusionCondition = ((IAddAppFusionConditionEffect)cardEffect).GetAppFusionCondition(this);
  2267. if (appFusionCondition != null)
  2268. {
  2269. return appFusionCondition;
  2270. }
  2271. }
  2272. }
  2273. }
  2274. return null;
  2275. }
  2276. }
  2277. #endregion
  2278. #region Assembly requirement
  2279. public AssemblyCondition assemblyCondition
  2280. {
  2281. get
  2282. {
  2283. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  2284. {
  2285. if (cardEffect is IAddAssemblyConditionEffect)
  2286. {
  2287. if (cardEffect.CanUse(null))
  2288. {
  2289. AssemblyCondition assemblyCondition = ((IAddAssemblyConditionEffect)cardEffect).GetAssemblyCondition(this);
  2290. if (assemblyCondition != null)
  2291. {
  2292. return assemblyCondition;
  2293. }
  2294. }
  2295. }
  2296. }
  2297. return null;
  2298. }
  2299. }
  2300. #endregion
  2301. #region whether this card can Burst digivolve
  2302. public bool CanPlayBurst(bool PayCost)
  2303. {
  2304. if (burstDigivolutionCondition != null)
  2305. {
  2306. if (PayCost)
  2307. {
  2308. int cost = burstDigivolutionCondition.cost;
  2309. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { new Permanent(new List<CardSource>()) }, checkAvailability: true);
  2310. if (Owner.MaxMemoryCost < cost)
  2311. {
  2312. return false;
  2313. }
  2314. }
  2315. List<Permanent> availableDigimon = new List<Permanent>();
  2316. availableDigimon.AddRange(Owner.GetBattleAreaDigimons());
  2317. availableDigimon.AddRange(Owner.GetBreedingAreaPermanents());
  2318. if (availableDigimon.Count >= 1)
  2319. {
  2320. foreach (Permanent digimon in availableDigimon)
  2321. {
  2322. if (digimon != null)
  2323. {
  2324. if (!this.CanNotEvolve(digimon))
  2325. {
  2326. if (burstDigivolutionCondition.digimonCondition(digimon))
  2327. {
  2328. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2329. {
  2330. if (tamer != digimon)
  2331. {
  2332. if (burstDigivolutionCondition.tamerCondition(tamer))
  2333. {
  2334. if (!tamer.CannotReturnToHand(null))
  2335. {
  2336. if (PayCost)
  2337. {
  2338. int cost = burstDigivolutionCondition.cost;
  2339. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
  2340. if (Owner.MaxMemoryCost < cost)
  2341. {
  2342. return false;
  2343. }
  2344. }
  2345. return true;
  2346. }
  2347. }
  2348. }
  2349. }
  2350. }
  2351. }
  2352. }
  2353. }
  2354. }
  2355. }
  2356. return false;
  2357. }
  2358. #endregion
  2359. #region whether this card can Link
  2360. public bool CanLink(bool PayCost, bool allowBreeding = false)
  2361. {
  2362. if (linkCondition != null)
  2363. {
  2364. SelectCardEffect.Root root = CardEffectCommons.IsExistOnHand(this) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.None;
  2365. if (allowBreeding)
  2366. {
  2367. if (Owner.GetFieldPermanents().Count >= 1)
  2368. {
  2369. foreach (Permanent digimon in Owner.GetFieldPermanents())
  2370. {
  2371. if (digimon != null)
  2372. {
  2373. if (linkCondition.digimonCondition(digimon))
  2374. {
  2375. if (PayCost)
  2376. {
  2377. int cost = GetChangedLinkCost(digimon, root);
  2378. if (Owner.MaxMemoryCost >= cost)
  2379. {
  2380. return true;
  2381. }
  2382. }
  2383. else
  2384. {
  2385. return true;
  2386. }
  2387. }
  2388. }
  2389. }
  2390. }
  2391. }
  2392. else
  2393. {
  2394. if (Owner.GetBattleAreaDigimons().Count >= 1)
  2395. {
  2396. foreach (Permanent digimon in Owner.GetBattleAreaDigimons())
  2397. {
  2398. if (digimon != null)
  2399. {
  2400. if (linkCondition.digimonCondition(digimon))
  2401. {
  2402. if (PayCost)
  2403. {
  2404. int cost = GetChangedLinkCost(digimon, root);
  2405. if (Owner.MaxMemoryCost >= cost)
  2406. {
  2407. return true;
  2408. }
  2409. }
  2410. else
  2411. {
  2412. return true;
  2413. }
  2414. }
  2415. }
  2416. }
  2417. }
  2418. }
  2419. }
  2420. return false;
  2421. }
  2422. #endregion
  2423. #region whether target permanent can Burst digivolve into this card
  2424. public bool CanBurstDigivolutionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
  2425. {
  2426. if (targetPermanent != null)
  2427. {
  2428. if (targetPermanent.TopCard != null)
  2429. {
  2430. if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent) || targetPermanent.TopCard.Owner.GetBreedingAreaPermanents().Contains(targetPermanent))
  2431. {
  2432. if (this.CanPlayBurst(PayCost))
  2433. {
  2434. if (burstDigivolutionCondition != null)
  2435. {
  2436. if (!this.CanNotEvolve(targetPermanent))
  2437. {
  2438. if (burstDigivolutionCondition.digimonCondition(targetPermanent))
  2439. {
  2440. foreach (Permanent tamer in Owner.GetBattleAreaPermanents())
  2441. {
  2442. if (tamer != targetPermanent)
  2443. {
  2444. if (burstDigivolutionCondition.tamerCondition(tamer))
  2445. {
  2446. if (!tamer.CannotReturnToHand(null))
  2447. {
  2448. if (PayCost)
  2449. {
  2450. int cost = burstDigivolutionCondition.cost;
  2451. cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2452. if (Owner.MaxMemoryCost < cost)
  2453. {
  2454. return false;
  2455. }
  2456. }
  2457. return true;
  2458. }
  2459. }
  2460. }
  2461. }
  2462. }
  2463. }
  2464. }
  2465. }
  2466. }
  2467. }
  2468. }
  2469. return false;
  2470. }
  2471. #endregion
  2472. #region Get Link Cost Accounting for Cost Reduction
  2473. public int GetChangedLinkCost(Permanent targetPermanent, SelectCardEffect.Root root)
  2474. {
  2475. if (linkCondition == null) return 0;
  2476. int Cost = linkCondition.cost;
  2477. List<ICardEffect> changeLinkCostCardEffects = new List<ICardEffect>();
  2478. #region the effects of permanents
  2479. changeLinkCostCardEffects = changeLinkCostCardEffects
  2480. .Concat(
  2481. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  2482. .Map(player => player.GetFieldPermanents())
  2483. .Flat()
  2484. .Filter(permanent => permanent != PermanentOfThisCard())
  2485. .Map(permanent => permanent.EffectList(EffectTiming.None))
  2486. .Flat()
  2487. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2488. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2489. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2490. .ToList();
  2491. #endregion
  2492. #region the effects of players
  2493. changeLinkCostCardEffects = changeLinkCostCardEffects
  2494. .Concat(
  2495. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  2496. .Map(player => player.EffectList(EffectTiming.None))
  2497. .Flat()
  2498. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2499. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2500. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2501. .ToList();
  2502. #endregion
  2503. #region the effects of itself
  2504. changeLinkCostCardEffects = changeLinkCostCardEffects
  2505. .Concat(
  2506. EffectList(EffectTiming.None)
  2507. .Filter(cardEffect => cardEffect is IChangeLinkCostEffect && cardEffect.CanUse(null)
  2508. && ((IChangeLinkCostEffect)cardEffect).CardCondition(this)
  2509. && ((IChangeLinkCostEffect)cardEffect).PermanentCondition(targetPermanent)))
  2510. .ToList();
  2511. #endregion
  2512. List<ICardEffect> changeLinkCostCardEffects_NotIsUpDown = changeLinkCostCardEffects
  2513. .Filter(cardEffect => !((IChangeLinkCostEffect)cardEffect).IsUpDown());
  2514. List<ICardEffect> changeLinkCostCardEffects_IsUpDown = changeLinkCostCardEffects
  2515. .Filter(cardEffect => ((IChangeLinkCostEffect)cardEffect).IsUpDown());
  2516. changeLinkCostCardEffects_NotIsUpDown
  2517. .ForEach(cardEffect => Cost = ((IChangeLinkCostEffect)cardEffect).GetCost(Cost, this, targetPermanent, root));
  2518. changeLinkCostCardEffects_IsUpDown
  2519. .ForEach(cardEffect => Cost = ((IChangeLinkCostEffect)cardEffect).GetCost(Cost, this, targetPermanent, root));
  2520. return Math.Max(0, Cost);
  2521. }
  2522. #endregion
  2523. #region whether target permanent can Link into this card
  2524. public bool CanLinkToTargetPermanent(Permanent targetPermanent, bool PayCost, bool allowBreeding = false)
  2525. {
  2526. if (targetPermanent != null)
  2527. {
  2528. if (targetPermanent.TopCard != null && !targetPermanent.TopCard.IsToken)
  2529. {
  2530. if (allowBreeding || !targetPermanent.TopCard.Owner.GetBreedingAreaPermanents().Contains(targetPermanent))
  2531. {
  2532. if (this.CanLink(false, allowBreeding)) // Don't check PayCost in CanLink since this method will check again anyway
  2533. {
  2534. if (linkCondition != null)
  2535. {
  2536. if (linkCondition.digimonCondition(targetPermanent))
  2537. {
  2538. if (PayCost)
  2539. {
  2540. SelectCardEffect.Root root = CardEffectCommons.IsExistOnHand(this) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.None;
  2541. int cost = GetChangedLinkCost(targetPermanent, root);
  2542. if (Owner.MaxMemoryCost < cost)
  2543. {
  2544. return false;
  2545. }
  2546. }
  2547. return true;
  2548. }
  2549. }
  2550. }
  2551. }
  2552. }
  2553. }
  2554. return false;
  2555. }
  2556. #endregion
  2557. #region whether target permanent can App Fusion into this card
  2558. public bool CanAppFusionFromTargetPermanent(Permanent targetPermanent, bool PayCost, SelectCardEffect.Root root = SelectCardEffect.Root.Hand)
  2559. {
  2560. if (targetPermanent != null)
  2561. {
  2562. if (targetPermanent.TopCard != null)
  2563. {
  2564. if (appFusionCondition != null)
  2565. {
  2566. if (!this.CanNotEvolve(targetPermanent))
  2567. {
  2568. if (appFusionCondition.digimonCondition(targetPermanent))
  2569. {
  2570. foreach (CardSource linkedCard in targetPermanent.LinkedCards)
  2571. {
  2572. if (appFusionCondition.linkedCondition(targetPermanent, linkedCard))
  2573. {
  2574. if (PayCost)
  2575. {
  2576. int cost = appFusionCondition.cost;
  2577. cost = GetChangedCostItselef(cost, root, new List<Permanent>() { targetPermanent }, checkAvailability: true);
  2578. if (Owner.MaxMemoryCost < cost)
  2579. {
  2580. return false;
  2581. }
  2582. }
  2583. return true;
  2584. }
  2585. }
  2586. }
  2587. }
  2588. }
  2589. }
  2590. }
  2591. return false;
  2592. }
  2593. #endregion
  2594. #region Whether this card's digiXrosCondition contains target card
  2595. public bool IsContainDigiXrosCondition(CardSource cardSource)
  2596. {
  2597. if (cardSource != null)
  2598. {
  2599. if (cardSource.Owner == Owner)
  2600. {
  2601. if (PermanentOfThisCard() != null)
  2602. {
  2603. if (PermanentOfThisCard().TopCard.HasDigiXros)
  2604. {
  2605. if (this == PermanentOfThisCard().TopCard)
  2606. {
  2607. if (digiXrosCondition != null)
  2608. {
  2609. if (digiXrosCondition.elements.Count((element) => element.CardCondition(cardSource)) >= 1)
  2610. {
  2611. return true;
  2612. }
  2613. }
  2614. }
  2615. }
  2616. }
  2617. }
  2618. }
  2619. return false;
  2620. }
  2621. #endregion
  2622. #region CardID
  2623. public string CardID => _cEntity_Base.CardID;
  2624. #endregion
  2625. #region whether this card is Digimon
  2626. public bool IsDigimon => CardKinds.Contains(CardKind.Digimon);
  2627. #endregion
  2628. #region whether this card is DigiEgg
  2629. public bool IsDigiEgg => CardKinds.Contains(CardKind.DigiEgg);
  2630. #endregion
  2631. #region whether this card is Tamer
  2632. public bool IsTamer => CardKinds.Contains(CardKind.Tamer);
  2633. #endregion
  2634. #region whether this card is Option
  2635. public bool IsOption => CardKinds.Contains(CardKind.Option);
  2636. #endregion
  2637. #region Wheter this card is permanent
  2638. public bool IsPermanent => _cEntity_Base.IsPermanent;
  2639. #endregion
  2640. #region Whether to have Play Cost
  2641. public bool HasPlayCost => _cEntity_Base.HasPlayCost;
  2642. #endregion
  2643. #region Whether to have Use Cost
  2644. public bool HasUseCost => _cEntity_Base.HasUseCost;
  2645. #endregion
  2646. #region Inherited Effects ENG discription
  2647. public string InheritedEffectDiscription_ENG => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_ENG);
  2648. #endregion
  2649. #region Inherited Effects JPN discription
  2650. public string InheritedEffectDiscription_JPN => DataBase.ReplaceToASCII(_cEntity_Base.InheritedEffectDiscription_JPN);
  2651. #endregion
  2652. #region Link Effects
  2653. public string LinkEffectDiscription => DataBase.ReplaceToASCII(_cEntity_Base.LinkEffect);
  2654. #endregion
  2655. #region Card Sprite
  2656. public Sprite CardSprite => _cEntity_Base.CardSprite;
  2657. public async Task<Sprite> GetCardSprite()
  2658. {
  2659. return await _cEntity_Base.GetCardSprite();
  2660. }
  2661. #endregion
  2662. #region SetID
  2663. public string SetID => _cEntity_Base.SetID;
  2664. #endregion
  2665. #region CardEntityIndex
  2666. public int CardEntityIndex => _cEntity_Base.CardIndex;
  2667. #endregion
  2668. #region Card Kind
  2669. public List<CardKind> CardKinds => _cEntity_Base.cardKind;
  2670. #endregion
  2671. #region ACE
  2672. public bool IsACE => _cEntity_Base.IsACE;
  2673. #endregion
  2674. #region OverflowMemory
  2675. public int OverflowMemory => _cEntity_Base.OverflowMemory;
  2676. #endregion
  2677. #region Whether this card is being revealed
  2678. public bool IsBeingRevealed { get; set; } = false;
  2679. #endregion
  2680. #region The permanent that belonged to this card just before it left the field
  2681. public Permanent PermanentJustBeforeRemoveField { get; set; } = null;
  2682. #endregion
  2683. #region whether this card has "SEEKERS" trait
  2684. public bool HasSeekersTraits
  2685. {
  2686. get
  2687. {
  2688. if (CardTraits.Contains("SEEKERS"))
  2689. {
  2690. return true;
  2691. }
  2692. return false;
  2693. }
  2694. }
  2695. #endregion
  2696. #region whether this card has "ADVENTURE" trait
  2697. public bool HasAdventureTraits
  2698. {
  2699. get
  2700. {
  2701. if (CardTraits.Contains("ADVENTURE"))
  2702. {
  2703. return true;
  2704. }
  2705. return false;
  2706. }
  2707. }
  2708. #endregion
  2709. #region whether this card has "Hero" trait
  2710. public bool HasHeroTraits
  2711. {
  2712. get
  2713. {
  2714. return EqualsTraits("Hero");
  2715. }
  2716. }
  2717. #endregion
  2718. #region whether this card has "Chronicle" trait
  2719. public bool HasChronicleTraits
  2720. {
  2721. get
  2722. {
  2723. if (CardTraits.Contains("Chronicle"))
  2724. {
  2725. return true;
  2726. }
  2727. return false;
  2728. }
  2729. }
  2730. #endregion
  2731. #region whether this card has "Device" trait
  2732. public bool HasDeviceTraits
  2733. {
  2734. get
  2735. {
  2736. if (CardTraits.Contains("Device"))
  2737. {
  2738. return true;
  2739. }
  2740. return false;
  2741. }
  2742. }
  2743. #endregion
  2744. #region whether this card has "Three Musketeers" trait
  2745. public bool HasThreeMusketeersTraits
  2746. {
  2747. get
  2748. {
  2749. if (CardTraits.Contains("Three Musketeers"))
  2750. {
  2751. return true;
  2752. }
  2753. return false;
  2754. }
  2755. }
  2756. #endregion
  2757. #region whether this card has "Royal Base" trait
  2758. public bool HasRoyalBaseTraits
  2759. {
  2760. get
  2761. {
  2762. if (CardTraits.Contains("Royal Base"))
  2763. {
  2764. return true;
  2765. }
  2766. return false;
  2767. }
  2768. }
  2769. #endregion
  2770. #region whether this card has "Appmon" trait
  2771. public bool HasAppmonTraits
  2772. {
  2773. get
  2774. {
  2775. return EqualsTraits("Appmon");
  2776. }
  2777. }
  2778. #endregion
  2779. #region whether this card has "WG" trait
  2780. public bool HasWGTraits
  2781. {
  2782. get
  2783. {
  2784. return EqualsTraits("WG");
  2785. }
  2786. }
  2787. #endregion
  2788. #region whether this card has "DM" trait
  2789. public bool HasDMTraits
  2790. {
  2791. get
  2792. {
  2793. return EqualsTraits("DM");
  2794. }
  2795. }
  2796. #endregion
  2797. #region whether this card has "CS" trait
  2798. public bool HasCSTraits
  2799. {
  2800. get
  2801. {
  2802. return EqualsTraits("CS");
  2803. }
  2804. }
  2805. #endregion
  2806. #region whether this card has "TS" trait
  2807. public bool HasTSTraits
  2808. {
  2809. get
  2810. {
  2811. return EqualsTraits("TS");
  2812. }
  2813. }
  2814. #endregion
  2815. #region whether this card has "Iliad" trait
  2816. public bool HasIliadTraits
  2817. {
  2818. get
  2819. {
  2820. return EqualsTraits("Iliad");
  2821. }
  2822. }
  2823. #endregion
  2824. #region whether this card has "Unidentified" trait
  2825. public bool HasUnidentifiedTraits
  2826. {
  2827. get
  2828. {
  2829. return EqualsTraits("Unidentified");
  2830. }
  2831. }
  2832. #endregion
  2833. #region whether this card has "Flame" trait
  2834. public bool HasFlameTraits
  2835. {
  2836. get
  2837. {
  2838. return EqualsTraits("Flame");
  2839. }
  2840. }
  2841. #endregion
  2842. #region whether this card has "Eater" trait
  2843. public bool HasEaterTraits
  2844. {
  2845. get
  2846. {
  2847. return EqualsTraits("Eater");
  2848. }
  2849. }
  2850. #endregion
  2851. #region whether this card has "Hudie" trait
  2852. public bool HasHudieTraits
  2853. {
  2854. get
  2855. {
  2856. return EqualsTraits("Hudie");
  2857. }
  2858. }
  2859. #endregion
  2860. #region whether this card has "Sea Animal" trait
  2861. public bool HasSeaAnimalTraits
  2862. {
  2863. get
  2864. {
  2865. return EqualsTraits("Sea Animal");
  2866. }
  2867. }
  2868. #endregion
  2869. #region whether this card has "Puppet" trait
  2870. public bool HasPuppetTraits
  2871. {
  2872. get
  2873. {
  2874. return EqualsTraits("Puppet");
  2875. }
  2876. }
  2877. #endregion
  2878. #region whether this card has "Ver.1" trait
  2879. public bool HasVer1Traits
  2880. {
  2881. get
  2882. {
  2883. return EqualsTraits("Ver.1");
  2884. }
  2885. }
  2886. #endregion
  2887. #region whether this card has "Ver.2" trait
  2888. public bool HasVer2Traits
  2889. {
  2890. get
  2891. {
  2892. return EqualsTraits("Ver.2");
  2893. }
  2894. }
  2895. #endregion
  2896. #region whether this card has "Ver.3" trait
  2897. public bool HasVer3Traits
  2898. {
  2899. get
  2900. {
  2901. return EqualsTraits("Ver.3");
  2902. }
  2903. }
  2904. #endregion
  2905. #region whether this card has "Ver.4" trait
  2906. public bool HasVer4Traits
  2907. {
  2908. get
  2909. {
  2910. return EqualsTraits("Ver.4");
  2911. }
  2912. }
  2913. #endregion
  2914. #region whether this card has "Ver.5" trait
  2915. public bool HasVer5Traits
  2916. {
  2917. get
  2918. {
  2919. return EqualsTraits("Ver.5");
  2920. }
  2921. }
  2922. #endregion
  2923. #region whether this card has "Aquatic" trait
  2924. public bool HasAquaticTraits
  2925. {
  2926. get
  2927. {
  2928. return EqualsTraits("Aquatic");
  2929. }
  2930. }
  2931. #endregion
  2932. #region whether this card has "LIBERATOR" trait
  2933. public bool HasLiberatorTraits
  2934. {
  2935. get
  2936. {
  2937. return EqualsTraits("LIBERATOR");
  2938. }
  2939. }
  2940. #endregion
  2941. #region whether this card has "Standard" Appmon Grade trait
  2942. public bool HasStandardAppTraits
  2943. {
  2944. get
  2945. {
  2946. return EqualsTraits("Stnd.");
  2947. }
  2948. }
  2949. #endregion
  2950. #region whether this card has "Super" Appmon Grade trait
  2951. public bool HasSuperAppTraits
  2952. {
  2953. get
  2954. {
  2955. return EqualsTraits("Sup.");
  2956. }
  2957. }
  2958. #endregion
  2959. #region whether this card has "Ultimate" Appmon Grade trait
  2960. public bool HasUltimateAppTraits
  2961. {
  2962. get
  2963. {
  2964. return EqualsTraits("Ult.");
  2965. }
  2966. }
  2967. #endregion
  2968. #region whether this card has "Holy Beast" trait
  2969. public bool HasHolyBeastTraits
  2970. {
  2971. get
  2972. {
  2973. return EqualsTraits("Holy Beast");
  2974. }
  2975. }
  2976. #endregion
  2977. #region whether this card has "Archangel" trait
  2978. public bool HasArchAngelTraits
  2979. {
  2980. get
  2981. {
  2982. return EqualsTraits("Archangel");
  2983. }
  2984. }
  2985. #endregion
  2986. #region whether this card has "Fallen Angel" trait
  2987. public bool HasFallenAngelTraits
  2988. {
  2989. get
  2990. {
  2991. return EqualsTraits("Fallen Angel");
  2992. }
  2993. }
  2994. #endregion
  2995. #region whether this card has "Bagra Army" trait
  2996. public bool HasBagraArmyTraits
  2997. {
  2998. get
  2999. {
  3000. return EqualsTraits("Bagra Army");
  3001. }
  3002. }
  3003. #endregion
  3004. #region whether this card has "Evil" trait
  3005. public bool HasEvilTraits
  3006. {
  3007. get
  3008. {
  3009. return EqualsTraits("Evil");
  3010. }
  3011. }
  3012. #endregion
  3013. #region whether this card has "Wizard" trait
  3014. public bool HasWizardTraits
  3015. {
  3016. get
  3017. {
  3018. return EqualsTraits("Wizard");
  3019. }
  3020. }
  3021. #endregion
  3022. #region whether this card has "Leviathan" trait
  3023. public bool HasLeviathanTraits
  3024. {
  3025. get
  3026. {
  3027. return EqualsTraits("Leviathan");
  3028. }
  3029. }
  3030. #endregion
  3031. #region whether this card has "Undead" trait
  3032. public bool HasUndeadTraits
  3033. {
  3034. get
  3035. {
  3036. return EqualsTraits("Undead");
  3037. }
  3038. }
  3039. #endregion
  3040. #region whether this card has "Galaxy" trait
  3041. public bool HasGalaxyTraits
  3042. {
  3043. get
  3044. {
  3045. return EqualsTraits("Galaxy");
  3046. }
  3047. }
  3048. #endregion
  3049. #region whether this card has "Rock"/"Mineral trait
  3050. public bool HasRockMineralTraits
  3051. {
  3052. get
  3053. {
  3054. return EqualsTraits("Rock") || EqualsTraits("Mineral");
  3055. }
  3056. }
  3057. #endregion
  3058. #region whether this card has Sea Beast trait
  3059. public bool HasSeaBeastTraits
  3060. {
  3061. get
  3062. {
  3063. return EqualsTraits("Sea Beast");
  3064. }
  3065. }
  3066. #endregion
  3067. #region whether this card has Twilight trait
  3068. public bool HasTwilightTrait
  3069. {
  3070. get
  3071. {
  3072. return EqualsTraits("Twilight");
  3073. }
  3074. }
  3075. #endregion
  3076. #region whether this card has Angel trait
  3077. public bool HasAngelStrictTraits
  3078. {
  3079. get
  3080. {
  3081. return EqualsTraits("Angel");
  3082. }
  3083. }
  3084. #endregion
  3085. #region whether this card has Dark Masters trait
  3086. public bool HasDarkMastersTrait
  3087. {
  3088. get
  3089. {
  3090. return EqualsTraits("Dark Masters");
  3091. }
  3092. }
  3093. #endregion
  3094. #region whether this card has Ghost trait
  3095. public bool HasGhostTraits
  3096. {
  3097. get
  3098. {
  3099. return EqualsTraits("Ghost");
  3100. }
  3101. }
  3102. #endregion
  3103. #region whether this card has Dark Animal trait
  3104. public bool HasDarkAnimalTraits
  3105. {
  3106. get
  3107. {
  3108. return EqualsTraits("Dark Animal");
  3109. }
  3110. }
  3111. #endregion
  3112. #region whether this card has Glowing Dawn trait
  3113. public bool HasGlowingDawnTraits
  3114. {
  3115. get
  3116. {
  3117. return EqualsTraits("Glowing Dawn");
  3118. }
  3119. }
  3120. #endregion
  3121. #region whether this card has Beat Break trait
  3122. public bool HasBeatBreakTraits
  3123. {
  3124. get
  3125. {
  3126. return EqualsTraits("BEATBREAK");
  3127. }
  3128. }
  3129. #endregion
  3130. }
  3131. public class JogressCondition
  3132. {
  3133. public JogressCondition(JogressConditionElement[] elements, int cost)
  3134. {
  3135. this.elements = new JogressConditionElement[2];
  3136. if (this.elements.Length == elements.Length)
  3137. {
  3138. for (int i = 0; i < elements.Length; i++)
  3139. {
  3140. this.elements[i] = elements[i];
  3141. }
  3142. }
  3143. this.cost = cost;
  3144. }
  3145. public JogressConditionElement[] elements { get; private set; } = new JogressConditionElement[2];
  3146. public int cost { get; private set; } = 0;
  3147. }
  3148. public class JogressConditionElement
  3149. {
  3150. public JogressConditionElement(Func<Permanent, bool> evoRootCondition, string selectMessage)
  3151. {
  3152. EvoRootCondition = evoRootCondition;
  3153. SelectMessage = selectMessage;
  3154. }
  3155. Func<Permanent, bool> _evoRootCondition = null;
  3156. public Func<Permanent, bool> EvoRootCondition
  3157. {
  3158. get
  3159. {
  3160. return permanent => _evoRootCondition == null || _evoRootCondition(permanent);
  3161. }
  3162. private set
  3163. {
  3164. _evoRootCondition = value;
  3165. }
  3166. }
  3167. public string SelectMessage { get; private set; } = "";
  3168. }
  3169. public class DigiXrosCondition
  3170. {
  3171. public DigiXrosCondition(List<DigiXrosConditionElement> elements, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, int reduceCostPerCard)
  3172. {
  3173. this.elements = new List<DigiXrosConditionElement>();
  3174. foreach (DigiXrosConditionElement element in elements)
  3175. {
  3176. this.elements.Add(element);
  3177. }
  3178. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3179. this.reduceCostPerCard = reduceCostPerCard;
  3180. }
  3181. public List<DigiXrosConditionElement> elements { get; private set; } = new List<DigiXrosConditionElement>();
  3182. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; private set; } = null;
  3183. public int reduceCostPerCard { get; private set; } = 0;
  3184. }
  3185. public class DigiXrosConditionElement
  3186. {
  3187. public DigiXrosConditionElement(Func<CardSource, bool> cardCondition, string selectMessage, bool skipAllIfNoSelect = false)
  3188. {
  3189. this.CardCondition = cardCondition;
  3190. this.selectMessage = selectMessage;
  3191. this.skipAllIfNoSelect = skipAllIfNoSelect;
  3192. }
  3193. public Func<CardSource, bool> CardCondition { get; private set; } = null;
  3194. public string selectMessage { get; private set; } = "";
  3195. public bool skipAllIfNoSelect { get; private set; } = false;
  3196. }
  3197. public class BurstDigivolutionCondition
  3198. {
  3199. public BurstDigivolutionCondition(Func<Permanent, bool> tamerCondition, string selectTamerMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
  3200. {
  3201. this.tamerCondition = tamerCondition;
  3202. this.selectTamerMessage = selectTamerMessage;
  3203. this.digimonCondition = digimonCondition;
  3204. this.selectDigimonMessage = selectDigimonMessage;
  3205. this.cost = cost;
  3206. }
  3207. public Func<Permanent, bool> tamerCondition { get; private set; } = null;
  3208. public string selectTamerMessage { get; private set; } = null;
  3209. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3210. public string selectDigimonMessage { get; private set; } = null;
  3211. public int cost { get; private set; } = 0;
  3212. }
  3213. public class LinkCondition
  3214. {
  3215. public LinkCondition(Func<Permanent, bool> digimonCondition, int cost)
  3216. {
  3217. this.digimonCondition = digimonCondition;
  3218. this.cost = cost;
  3219. }
  3220. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3221. public int cost { get; private set; } = 0;
  3222. }
  3223. public class AppFusionCondition
  3224. {
  3225. public AppFusionCondition(Func<Permanent, CardSource, bool> linkedCondition, Func<Permanent, bool> digimonCondition, int cost)
  3226. {
  3227. this.linkedCondition = linkedCondition;
  3228. this.digimonCondition = digimonCondition;
  3229. this.cost = cost;
  3230. }
  3231. public Func<Permanent, CardSource, bool> linkedCondition { get; private set; } = null;
  3232. public Func<Permanent, bool> digimonCondition { get; private set; } = null;
  3233. public int cost { get; private set; } = 0;
  3234. }
  3235. public class AssemblyCondition
  3236. {
  3237. //Method to work with older form of Assembly, 1 single condition X times
  3238. public AssemblyCondition(AssemblyConditionElement element, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList, string selectMessage, int elementCount, int reduceCost)
  3239. {
  3240. element.ElementCount = elementCount;
  3241. element.selectMessage = selectMessage;
  3242. element.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3243. this.elements = new List<AssemblyConditionElement>() { element };
  3244. this.elementCount = elementCount;
  3245. this.reduceCost = reduceCost;
  3246. }
  3247. //Method to work with A x B x C... DigiXros like conditions
  3248. public AssemblyCondition(List<AssemblyConditionElement> elements, int reduceCost)
  3249. {
  3250. this.elements = elements;
  3251. this.elementCount = elements.Select(element => element.ElementCount).Sum();
  3252. this.reduceCost = reduceCost;
  3253. }
  3254. public List<AssemblyConditionElement> elements { get; private set; } = new List<AssemblyConditionElement>();
  3255. public int elementCount { get; private set; } = 0;
  3256. public int reduceCost { get; private set; } = 0;
  3257. }
  3258. public class AssemblyConditionElement
  3259. {
  3260. public AssemblyConditionElement(Func<CardSource, bool> cardCondition, bool skipAllIfNoSelect = true, string selectMessage = null, int elementCount = 0, Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList = null)
  3261. {
  3262. this.CardCondition = cardCondition;
  3263. this.skipAllIfNoSelect = skipAllIfNoSelect;
  3264. this.selectMessage = selectMessage;
  3265. this.ElementCount = elementCount;
  3266. this.CanTargetCondition_ByPreSelecetedList = CanTargetCondition_ByPreSelecetedList;
  3267. }
  3268. public Func<CardSource, bool> CardCondition { get; set; } = null;
  3269. public bool skipAllIfNoSelect { get; set; } = true;
  3270. public int ElementCount { get; set; } = 0;
  3271. public Func<List<CardSource>, CardSource, bool> CanTargetCondition_ByPreSelecetedList { get; set; } = null;
  3272. public string selectMessage { get; set; } = "";
  3273. }