CardSource.cs 119 KB

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