CardSource.cs 111 KB

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