67 lines
3.6 KiB
JavaScript
67 lines
3.6 KiB
JavaScript
|
export async function load({ params }) {
|
||
|
|
||
|
let authid=await Edge.Client.rpc("getAuthid");
|
||
|
let authpseudo=await Edge.Client.rpc("getAuthpseudo");
|
||
|
let authisuser=await Edge.Client.rpc("getAuthisuser");
|
||
|
let player=await Edge.Client.rpc("initPlayer",{"_id":authid,"name":authpseudo,"isuser":(authisuser!="anon")});
|
||
|
|
||
|
let party;
|
||
|
let players;
|
||
|
if(player.partyid) {
|
||
|
party = await Edge.Client.rpc("getParty",player.partyid).catch(err => console.error(err));
|
||
|
players= await Edge.Client.rpc("getPartyplayers",party._id).catch(err => console.error(err));
|
||
|
}
|
||
|
else window.location.href = '/';
|
||
|
|
||
|
if(party.status=="playerwait") {
|
||
|
let plateau=[
|
||
|
{"_id":0 ,"type":"week" ,"buyable":false,"value":50 ,"owner":[],update:0,"name":"WEEK END"},
|
||
|
{"_id":1 ,"type":"bar" ,"buyable":true ,"value":2 ,"owner":[],update:0,"name":"BAR 1-1"},
|
||
|
{"_id":2 ,"type":"bar" ,"buyable":true ,"value":2 ,"owner":[],update:0,"name":"BAR 1-2"},
|
||
|
{"_id":3 ,"type":"question" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Chance - Malchance"},
|
||
|
{"_id":4 ,"type":"bar" ,"buyable":true ,"value":4 ,"owner":[],update:0,"name":"BAR 3-1"},
|
||
|
{"_id":5 ,"type":"bar" ,"buyable":true ,"value":4 ,"owner":[],update:0,"name":"BAR 3-2"},
|
||
|
{"_id":6 ,"type":"bar" ,"buyable":true ,"value":4 ,"owner":[],update:0,"name":"BAR 3-3"},
|
||
|
{"_id":7 ,"type":"happy" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Happy Hour"},
|
||
|
{"_id":8 ,"type":"bar" ,"buyable":true ,"value":6 ,"owner":[],update:0,"name":"BAR 3-1"},
|
||
|
{"_id":9 ,"type":"bar" ,"buyable":true ,"value":6 ,"owner":[],update:0,"name":"BAR 3-2"},
|
||
|
{"_id":10,"type":"bar" ,"buyable":true ,"value":6 ,"owner":[],update:0,"name":"BAR 3-3"},
|
||
|
{"_id":11,"type":"prison" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Cellule de Dégrissement"},
|
||
|
{"_id":12,"type":"bar" ,"buyable":true ,"value":8 ,"owner":[],update:0,"name":"BAR 4-1"},
|
||
|
{"_id":13,"type":"bar" ,"buyable":true ,"value":8 ,"owner":[],update:0,"name":"BAR 4-2"},
|
||
|
{"_id":14,"type":"bar" ,"buyable":true ,"value":8 ,"owner":[],update:0,"name":"BAR 4-3"},
|
||
|
{"_id":15,"type":"happy" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Happy Hour"},
|
||
|
{"_id":16,"type":"bar" ,"buyable":true ,"value":10 ,"owner":[],update:0,"name":"BAR 5-1"},
|
||
|
{"_id":17,"type":"bar" ,"buyable":true ,"value":10 ,"owner":[],update:0,"name":"BAR 5-2"},
|
||
|
{"_id":18,"type":"bar" ,"buyable":true ,"value":10 ,"owner":[],update:0,"name":"BAR 5-3"},
|
||
|
{"_id":19,"type":"question" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Chance - Malchance"},
|
||
|
{"_id":20,"type":"bar" ,"buyable":true ,"value":12 ,"owner":[],update:0,"name":"BAR 6-1"},
|
||
|
{"_id":21,"type":"bar" ,"buyable":true ,"value":12 ,"owner":[],update:0,"name":"BAR 6-2"},
|
||
|
];
|
||
|
|
||
|
let score=[];
|
||
|
players.forEach(async(player) => {
|
||
|
score.push({"_id":player._id,"money":100,"plateauid":0});
|
||
|
});
|
||
|
party.score=score;
|
||
|
|
||
|
let dices=[
|
||
|
{"id":1,"value":""},
|
||
|
{"id":2,"value":""},
|
||
|
];
|
||
|
party.dices=dices;
|
||
|
}
|
||
|
|
||
|
let data = {
|
||
|
params,
|
||
|
party,
|
||
|
players,
|
||
|
player,
|
||
|
};
|
||
|
|
||
|
Edge.Client.send({ [party._id]: data });
|
||
|
|
||
|
// Return data
|
||
|
return data;
|
||
|
}
|