Files
PhaseWeb3-Vue/assets/GameView.2cafa021.js

6 lines
4.7 KiB
JavaScript

import{A as N,E as j,a as c,i as m,g as n,b as u,ai as C,t as L,e as a,G as M,k as d,u as E,s as T,N as q,ad as z,r as k,o as H,c as h,w as g,aj as V,F as U,f as P,ak as O,al as X,ac as J,P as K,am as Q,_ as W,l as Y,n as Z,p as ee,q as se}from"./index.fd9dd979.js";import{_ as te}from"./FormControl.128d83b0.js";import{_ as ae}from"./ProfileCard.0fba38e3.js";import{_ as re}from"./GeneralTable.57a0064e.js";import{d as le}from"./userData.bcc92478.js";import{g as S}from"./danClass.233b0381.js";const oe={class:"pt-6 mb-6 flex items-center justify-between"},ne={class:"flex items-center justify-start space-x-2"},ie={class:"text-2xl md:text-3xl leading-tight"},ce={__name:"GameTitleLine",props:{path:{type:String,default:null},title:{type:String,required:!0}},setup(v){const y=N(()=>j().default);return(_,x)=>(c(),m("section",oe,[n("div",ne,[u(C,{path:v.path,class:"w-12 h-12 p-1 drop-shadow-md"},null,8,["path"]),n("h1",ie,L(v.title),1)]),a(y)?M(_.$slots,"default",{key:0}):d("",!0)]))}},ue={class:"bg-white dark:bg-slate-900/90 rounded-2xl p-3"},de={class:"w-full"},fe={class:"md:flex md:px-5 md:space-x-10 md:justify-between md:items-center"},me={key:0,class:"md:w-1/3 md:text-right"},_e=n("h2",{class:"text-md sm:text-lg md:text-xl font-bold p-2"}," Select Version ",-1),pe={key:0,class:"w-full pt-6"},he={class:"grid grid-cols-2 gap-6 pt-6"},ge={key:1,class:"md:w-1/2 grid grid-cols-1 md:grid-cols-2 gap-3"},ve={class:"bg-white dark:bg-slate-900/95 rounded-2xl lg:flex lg:justify-between"},ye={class:"w-full"},Se={__name:"GameView",setup(v){const y=ee(),_=se(),x=E();var i=null,t=null;const l=T({currentVersion:null});q(()=>l.currentVersion,()=>{b()}),i=y.params.id,t=z(i),t==null&&_.push({name:"ErrorPage",params:{catchAll:"404"}});const o=k(null),w=k([]);H(async()=>{try{const e=await x.getGameProfiles(i);w.value=G(e)}catch(e){console.error("Failed to fetch profile data:",e)}b()}),t.versions||(l.currentVersion=1);async function b(){try{o.value=null;const e=await x.getUserProfile(i,l.currentVersion);o.value=e,e&&!l.currentVersion&&(l.currentVersion=e.versions[e.versions.length-1])}catch(e){console.error("Failed to fetch user profile data:",e)}}function I(){var e=null;return l.currentVersion?e=`/assets/games/${t.id}/card/${l.currentVersion}.webp`:e=t.cardBG,e}function B(){return`
background-image: url('${I()}');
background-size: cover;
background-repeat: no-repeat;
`}const f=[];if(f.push({text:"Player",value:"username",sortable:!0,width:120}),t.noRivals||f.push({text:"Rival ID",value:"extid",width:100}),f.push({text:"Last Play",value:"stats.last_play_timestamp",width:150},{text:"Last Arcade",value:"stats.last_play_arcade",width:150},{text:"Plays",value:"stats.total_plays",sortable:!0,width:50}),t.playerHeaders)for(var D of t.playerHeaders)f.push(D);function G(e){var r=[];for(var s of e){if(s.extid&&(s.extid=le(s.extid)),s.stats){if(s.stats.last_play_timestamp){const p=new Date(s.stats.last_play_timestamp*1e3);s.stats.last_play_timestamp=p.toLocaleString()}s.sgrade&&(s.sgrade=S(s.sgrade).short),s.dgrade&&(s.dgrade=S(s.dgrade).short)}r.push(s)}return r.sort((p,$)=>{const F=p.stats&&p.stats.total_plays||0;return($.stats&&$.stats.total_plays||0)-F}),r}function R(e){var r=[];for(const s of t.versions)e.includes(s.id)&&r.push(s);return r}const A=e=>{const r=e.userId;_.push(`/games/${i}/profiles/${r}`)};return(e,r)=>(c(),h(Z,null,{default:g(()=>[u(Y,null,{default:g(()=>[n("div",{style:J(B()),class:"rounded-2xl mb-6"},[n("div",ue,[n("div",de,[n("div",fe,[u(ce,{path:a(t).icon,title:a(t).name},null,8,["path","title"]),a(t).versions&&o.value?(c(),m("div",me,[_e,u(te,{modelValue:l.currentVersion,"onUpdate:modelValue":r[0]||(r[0]=s=>l.currentVersion=s),options:R(o.value.versions)},null,8,["modelValue","options"])])):d("",!0)])]),o.value?(c(),m("div",pe,[u(ae,{game:a(i),version:l.currentVersion,profile:o.value},{default:g(()=>[n("div",he,[u(V,{number:o.value.stats.total_plays,label:"Plays"},null,8,["number"]),o.value.records?(c(),m(U,{key:0},[o.value.records.skill?(c(),h(V,{key:0,number:o.value.records.skill/100,label:"Skill Points"},null,8,["number"])):d("",!0)],64)):d("",!0)])]),_:1},8,["game","version","profile"])])):(c(),m("div",ge,[a(t).noScores?d("",!0):(c(),h(P,{key:0,href:`/#/games/${a(i)}/scores`,icon:a(O),outline:!1,color:"info",label:"Network Scores"},null,8,["href","icon"])),a(t).noRecords?d("",!0):(c(),h(P,{key:1,href:`/#/games/${a(i)}/records`,icon:a(X),outline:!1,color:"info",label:"Network Records"},null,8,["href","icon"]))]))])],4),u(K,{icon:a(Q),title:"All Players",main:""},null,8,["icon"]),u(W,{"has-table":""},{default:g(()=>[n("div",ve,[n("div",ye,[u(re,{headers:f,items:w.value,path:`/#/${a(i)}/profiles/`,onRowClicked:A},null,8,["items","path"])])])]),_:1})]),_:1})]),_:1}))}};export{Se as default};