CardSource.cs 121 KB

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