CardSource.cs 98 KB

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