1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
import{Ct as e,Dt as t,In as n,Jt as r,Kt as i,Ln as a,Ot as o,Rn as s,Rt as c,St as l,Xt as u,Yt as d,an as f,bn as p,bt as m,hn as h,ht as g,in as _,kt as v,l as ee,wt as y,xt as b}from"./client-Bz0sY7Lm.js";import{n as te,t as x}from"./es-BMAt8N9j.js";import{t as ne}from"./Button-CSgxOeb2.js";import{t as S}from"./_plugin-vue_export-helper-CaiaXQaI.js";import{n as re,t as ie}from"./PlaceBlock-Cmy603WH.js";import{t as C}from"./Input-CSjr7ZoG.js";import{t as ae}from"./Alert-D7ko_M_w.js";import{t as w}from"./Flex-CetEEqUm.js";import{t as T}from"./Rate-CVfUhBQi.js";import{t as oe}from"./QrCode-MTPi5t58.js";import{i as se,o as ce,r as le,st as E,w as D}from"./index-XRA2PXGS.js";import{t as O}from"./HeaderText-DnXJEr19.js";import{t as ue}from"./useDeviceContext-Bbhlnk00.js";import{t as k}from"./MessagePaper-C6R1Irzd.js";var A={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,viewBox:`0 0 24 24`},j=v({name:`ContactMailRound`,render:function(e,t){return i(),y(`svg`,A,t[0]||=[b(`path`,{d:`M21 8V7l-3 2l-3-2v1l2.72 1.82a.5.5 0 0 0 .55 0L21 8zm1-5H2C.9 3 0 3.9 0 5v14c0 1.1.9 2 2 2h20c1.1 0 1.99-.9 1.99-2L24 5c0-1.1-.9-2-2-2zM8 6c1.66 0 3 1.34 3 3s-1.34 3-3 3s-3-1.34-3-3s1.34-3 3-3zm6 12H2v-1c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1zm7.5-6h-7c-.28 0-.5-.22-.5-.5v-5c0-.28.22-.5.5-.5h7c.28 0 .5.22.5.5v5c0 .28-.22.5-.5.5z`,fill:`currentColor`},null,-1)])}}),M={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,viewBox:`0 0 512 512`},N=v({name:`Footsteps`,render:function(e,t){return i(),y(`svg`,M,t[0]||=[b(`path`,{d:`M133.83 361.27c-22.61 0-41-8.17-54.79-24.39s-22.84-40.29-28.11-75.31c-7.76-51.61-.06-95.11 21.68-122.48c12.8-16.12 29.6-25.44 48.58-26.94c16.25-1.3 40.54 5.29 64 44c14.69 24.24 25.86 56.44 30.65 88.34c5.79 38.51 1.48 66.86-13.18 86.65c-11.64 15.72-29.54 25.46-53.21 29a106.46 106.46 0 0 1-15.62 1.13z`,fill:`currentColor`},null,-1),b(`path`,{d:`M173 496c-13.21 0-26.6-4.23-38.66-12.36a79.79 79.79 0 0 1-33.52-50.6c-2.85-14.66-1.14-26.31 5.22-35.64c10.33-15.15 28.87-18.56 48.49-22.18c2.07-.38 4.17-.76 6.3-1.17c4.52-.86 9.14-2 13.62-3.11c16.78-4.14 34.14-8.43 48.47 1.75c9.59 6.8 15 18.36 16.62 35.32c1.84 19.57-2.36 39.1-11.83 55c-10.19 17.11-25.47 28.42-43 31.86A61 61 0 0 1 173 496z`,fill:`currentColor`},null,-1),b(`path`,{d:`M378.17 265.27a106.69 106.69 0 0 1-15.6-1.2c-23.66-3.5-41.56-13.25-53.2-29c-14.66-19.79-19-48.13-13.18-86.65c4.79-31.93 15.93-64.1 30.55-88.25c23.34-38.57 47.66-45.26 64-44.08c18.92 1.38 35.69 10.57 48.51 26.6c21.89 27.37 29.65 71 21.86 122.84c-5.27 35-14.2 58.95-28.11 75.31s-32.22 24.43-54.83 24.43z`,fill:`currentColor`},null,-1),b(`path`,{d:`M339 400a61 61 0 0 1-11.68-1.13c-17.56-3.44-32.84-14.75-43-31.86c-9.47-15.9-13.67-35.43-11.83-55c1.6-17 7-28.52 16.62-35.33c14.33-10.17 31.69-5.89 48.47-1.74c4.48 1.1 9.1 2.24 13.62 3.11l6.29 1.17c19.63 3.61 38.17 7 48.5 22.17c6.36 9.33 8.07 21 5.22 35.64a79.78 79.78 0 0 1-33.52 50.61C365.56 395.78 352.17 400 339 400z`,fill:`currentColor`},null,-1)])}}),P={},F={class:`belt-block`};function I(e,t){return i(),y(`div`,null,[t[0]||=b(`div`,{class:`shadow shadow-top`},null,-1),t[1]||=b(`div`,{class:`shadow shadow-bottom`},null,-1),b(`div`,F,[d(e.$slots,`default`,{},void 0,!0)])])}var L=S(P,[[`render`,I],[`__scopeId`,`data-v-bec154c5`]]),R={},z={class:`plate-block`},B={class:`metal-plate-block`};function V(e,t){return i(),y(`div`,z,[b(`div`,B,[d(e.$slots,`default`,{},void 0,!0)]),t[0]||=b(`div`,{class:`pin pin-top-left`},null,-1),t[1]||=b(`div`,{class:`pin pin-top-right`},null,-1),t[2]||=b(`div`,{class:`pin pin-bottom-right`},null,-1),t[3]||=b(`div`,{class:`pin pin-bottom-left`},null,-1)])}var H=S(R,[[`render`,V],[`__scopeId`,`data-v-4833fe7e`]]),U={class:`form-custom`},W={class:`center-block-700`},G={class:`controller`},K={class:`counters-block`},q={class:`counter-block`},J={class:`places-text`},Y={class:`counter-block`},X={class:`places-text`},Z={class:`game-input`},Q=[`placeholder`,`disabled`],$=[`disabled`],de=S(v({__name:`GameInputForm`,props:{addAction:{type:Function},allPlacesCount:{},newPlacesCount:{},gameStatus:{}},setup(n){let a=n,c=h(``),u=h(!1);async function d(){if(!(u.value||a.gameStatus!=`run`||c.value.length==0)){u.value=!0;try{await a.addAction(c.value)&&(c.value=``)}finally{u.value=!1}}}function m(e){e%=100;let t=Math.floor(e/10)%10,n=e%10,r=`–`,i=`–`;return t>0&&(r=String(t)),(n>0||t>0)&&(i=String(n)),[r,i]}return(h,v)=>(i(),y(`div`,U,[o(L,{class:`input-form`},{default:_(()=>[o(H,{class:`controller-metal controller-metal-left`}),o(H,{class:`controller-metal controller-metal-right`}),b(`div`,W,[b(`div`,G,[b(`div`,K,[b(`div`,q,[b(`div`,J,[o(p(x),{class:`icon-for-counter`},{default:_(()=>[o(p(N))]),_:1})]),(i(!0),y(g,null,r(m(n.allPlacesCount),(e,t)=>(i(),y(`div`,{key:t,class:`places-text places-text-number`},s(e),1))),128))]),b(`div`,Y,[b(`div`,X,[o(p(x),{class:`icon-for-counter`},{default:_(()=>[o(p(j))]),_:1})]),(i(!0),y(g,null,r(m(n.newPlacesCount),(e,t)=>(i(),y(`div`,{key:t,class:`places-text places-text-number`},s(e),1))),128))])]),b(`div`,Z,[f(b(`input`,{id:`run`,class:`game-input-run`,"onUpdate:modelValue":v[0]||=e=>c.value=e,type:`text`,placeholder:a.gameStatus==`run`?`Место назначения`:`Ходы запрещены`,disabled:a.gameStatus!=`run`||u.value},null,8,Q),[[E,c.value]])]),v[4]||=b(`div`,{class:`game-button-run-shadow`},null,-1),b(`button`,{class:`game-button-run`,type:`submit`,disabled:a.gameStatus!=`run`||c.value.length==0||u.value,onClick:d},[a.gameStatus==`run`?(i(),l(O,{key:0},{default:_(()=>[...v[1]||=[t(`Поехали`,-1)]]),_:1})):e(``,!0),a.gameStatus==`pause`||a.gameStatus==`draft`?(i(),l(O,{key:1},{default:_(()=>[...v[2]||=[t(`Ждём`,-1)]]),_:1})):e(``,!0),a.gameStatus==`finish`?(i(),l(O,{key:2},{default:_(()=>[...v[3]||=[t(`Всё`,-1)]]),_:1})):e(``,!0)],8,$)])])]),_:1})]))}}),[[`__scopeId`,`data-v-31fd878a`]]),fe={key:0,class:`width700`},pe=[`disabled`],me={key:1,class:`width700`},he={class:`question-text`},ge={class:`qr-main-block-text`},_e={class:`qr-block`},ve={key:4,class:`edit-panel`},ye=S(v({__name:`TeamStoryPage`,setup(d){let f=ce(),v=se(),x=te(),S=ee(),E=String(S.params.id),O=S.query.password;ue(()=>({teamID:E,password:typeof O==`string`?O:void 0}));let A=h(0),j=h([]),M=h(``),N=h(),P=h({introduction:void 0,places:[],questions:[]}),F=h({ID:void 0,name:void 0,description:void 0,startAt:void 0,status:void 0,format:void 0,location:void 0,scenario:void 0,teams:void 0,export:void 0}),I=h(``),L=m(()=>F.value?.teams?.find(e=>e.ID===E)?.name),R=`game-review-${E}`,z=h(localStorage.getItem(R)===`1`),B=h(0),V=h(0),H=h(``),U=h(!1),W=window.location.href,G=()=>{let e=N.value;return e?e.scrollHeight-e.scrollTop-e.clientHeight<1:!1};async function K(){let e=P.value,t;try{t=await v.GetTeamStory({ID:E,password:O})}catch(e){M.value=`Не удалось загрузить дело. Попробуйте обновить страницу.`,console.error(`Failed to load team story:`,e);return}M.value=``,F.value=t.game;let n=G();n&&(A.value=0);let r=P.value.places.length;P.value={background:t.story.background,introduction:t.story.introduction,places:t.story.places?.map((t,n)=>(console.log(e?.places[n]?.mode),{place:t,mode:e?.places[n]?.mode||`show`}))||[],questions:t.story.questions||[]},j.value=t.actions||[];let i=P.value.places.length;if(i>r&&r!=0&&(A.value+=i-r),await c(),n&&r!=0){let e=N.value;if(!e)return!1;e.scrollTop=e.scrollHeight}}K(),Y();async function q(e){try{return await v.AddTeamAction({ID:E,password:O,code:e}),await K(),I.value=``,await c(),A.value=0,!0}catch(e){return x.error(e instanceof Error?e.message:`Не удалось сделать ход`),!1}}let J=h({});async function Y(){let e;try{e=await v.GetTeamAnswers({ID:E,password:O})}catch(e){M.value=`Не удалось загрузить ответы команды. Попробуйте обновить страницу.`,console.error(`Failed to load team answers:`,e);return}M.value=``;let t={};for(let n of e.answers||[])t[n.questionCode||``]=n.answer||``;J.value=t}async function X(){await v.SubmitTeamAnswers({ID:E,password:O,answers:(P.value.questions||[]).map(e=>({questionCode:e.code,answer:J.value[e.code||``]||``}))}),x.success(`Ответы сохранены`),await Y()}let Z=m(()=>F.value?.format!==`offline`&&(F.value?.status==`run`||F.value?.status==`pause`)),Q=m(()=>F.value?.format!==`offline`&&(P.value.questions?.length||0)>0),$={Input:{border:`1px dashed black`,borderDisabled:`1px dashed black`,borderFocus:`1px solid black`,borderHover:`1px dashed black`,boxShadowFocus:`0 0 0 1px black`,caretColor:`black`,color:`transparent`,colorDisabled:`transparent`,colorFocus:`transparent`,fontSizeMedium:`18px`,placeholderColor:`black`,placeholderColorDisabled:`black`,textColor:`black`,textColorDisabled:`black`},Rate:{itemColor:`black`,itemColorHover:`#b8860b`,itemColorActive:`#b8860b`}};async function ye(){if(!B.value||!V.value||H.value.trim()===``){x.error(`Поставьте оценки и напишите отзыв`);return}U.value=!0,await v.CreateGameReview({gameID:Number(F.value?.ID),teamID:E,password:O,rating:B.value,difficulty:V.value,text:H.value.trim()}),U.value=!1,z.value=!0,localStorage.setItem(R,`1`),x.success(`Спасибо за отзыв`)}async function be(){await v.DeleteLastTeamAction({ID:E}),await K(),I.value=``}return le(()=>{K()},2e3),(c,d)=>{let m=u(`n-space`);return i(),y(g,null,[P.value.background?(i(),y(`div`,{key:0,class:`case-background`,style:a({backgroundImage:`url(${JSON.stringify(P.value.background)})`}),"aria-hidden":`true`},null,4)):e(``,!0),b(`div`,{class:n([`center-block-custom bottom-margin smooth-scroll`,{"game-finished":F.value?.status===`finish`}]),ref_key:`scrollContainer`,ref:N},[F.value?.status===`finish`?(i(),y(`div`,fe,[o(k,{role:`status`},{default:_(()=>[...d[4]||=[b(`div`,{class:`font`},`Игра завершена. Спасибо за участие!`,-1)]]),_:1}),z.value?e(``,!0):(i(),l(k,{key:0,class:`review-block`},{default:_(()=>[d[7]||=b(`div`,{class:`font`},`Оцените игру`,-1),d[8]||=b(`hr`,{class:`questions-hr`},null,-1),o(p(D),{"theme-overrides":$},{default:_(()=>[d[5]||=b(`div`,{class:`review-rating font`},`Оценка`,-1),o(p(T),{value:B.value,"onUpdate:value":d[0]||=e=>B.value=e,count:5,class:`review-rate`},null,8,[`value`]),d[6]||=b(`div`,{class:`review-rating font`},`Сложность`,-1),o(p(T),{value:V.value,"onUpdate:value":d[1]||=e=>V.value=e,count:3,class:`review-rate`},null,8,[`value`]),o(p(C),{value:H.value,"onUpdate:value":d[2]||=e=>H.value=e,class:`review-input`,type:`textarea`,autosize:{minRows:4,maxRows:8},placeholder:`Расскажите, как прошла игра`},null,8,[`value`]),o(p(w),{justify:`end`,class:`questions-actions`},{default:_(()=>[b(`button`,{type:`button`,class:`paper-button`,disabled:U.value,onClick:ye},` Отправить отзыв `,8,pe)]),_:1})]),_:1})]),_:1}))])):(i(),y(`div`,me,[M.value?(i(),l(p(ae),{key:0,type:`error`,role:`alert`},{default:_(()=>[t(s(M.value),1)]),_:1})):e(``,!0),o(de,{addAction:q,allPlacesCount:P.value.places.length,newPlacesCount:A.value,gameStatus:F.value?.status||``},null,8,[`allPlacesCount`,`newPlacesCount`,`gameStatus`]),F.value?.format!==`offline`&&F.value?.status&&F.value.status!=`draft`&&P.value.introduction&&(P.value.introduction.text||P.value.introduction.audio)?(i(),l(re,{key:1,introduction:P.value.introduction,mode:`show`},null,8,[`introduction`])):e(``,!0),Q.value&&F.value?.status&&F.value.status!=`draft`?(i(),l(k,{key:2,class:`questions-block`},{default:_(()=>[d[9]||=b(`div`,{class:`font`},`Вопросы дела`,-1),d[10]||=b(`hr`,{class:`questions-hr`},null,-1),d[11]||=b(`p`,{class:`questions-hint font`},` Ответьте на вопросы дела. Ответы можно менять, пока игра идёт. `,-1),o(p(D),{"theme-overrides":$},{default:_(()=>[(i(!0),y(g,null,r(P.value.questions,e=>(i(),y(`div`,{key:e.code,class:`question-item font`},[b(`div`,he,s(e.code)+`: `+s(e.text),1),o(p(C),{value:J.value[e.code||``],"onUpdate:value":t=>J.value[e.code||``]=t,type:`textarea`,autosize:{minRows:2,maxRows:6},disabled:!Z.value,placeholder:`Ваш ответ...`},null,8,[`value`,`onUpdate:value`,`disabled`])]))),128)),Z.value?(i(),l(p(w),{key:0,justify:`end`,class:`questions-actions`},{default:_(()=>[b(`button`,{type:`button`,class:`paper-button`,onClick:d[3]||=e=>X()},` Сохранить ответы `)]),_:1})):e(``,!0)]),_:1})]),_:1})):e(``,!0),(i(!0),y(g,null,r(P.value.places,(e,t)=>(i(),l(ie,{place:e.place,mode:e.mode,"onUpdate:mode":t=>e.mode=t,key:`${F.value?.format}:${e.place.code}`,mcp:p(f).hasRole(`author`)&&j.value[t]?.mcp,addAction:q},null,8,[`place`,`mode`,`onUpdate:mode`,`mcp`]))),128)),P.value.places.length==0&&F.value?.status==`draft`?(i(),l(k,{key:3,class:`qr-main-block`},{default:_(()=>[o(m,{vertical:``},{default:_(()=>[b(`p`,ge,[b(`strong`,null,s(L.value),1)]),d[12]||=b(`h2`,{class:`qr-main-block-text`},`Код для подключения`,-1),b(`div`,_e,[o(p(oe),{value:p(W),size:300,padding:0},null,8,[`value`])]),d[13]||=b(`p`,{class:`qr-main-block-text`},`Игра скоро начнется`,-1)]),_:1})]),_:1})):e(``,!0),p(f).hasRole(`author`)&&P.value.places.length>0?(i(),y(`div`,ve,[o(p(w),{justify:`end`},{default:_(()=>[o(p(ne),{onClick:be},{default:_(()=>[...d[14]||=[t(`Удалить последний ход`,-1)]]),_:1})]),_:1})])):e(``,!0)]))],2)],64)}}}),[[`__scopeId`,`data-v-9de31d07`]]),be=v({__name:`TeamStoryView`,setup(e){let t=ee();return(e,n)=>(i(),l(ye,{key:p(t).fullPath}))}});export{be as default}; |