CardSource.cs 97 KB

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