svg
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<script>
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
export let id;
|
||||
export let selected;
|
||||
export let value;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
@@ -25,9 +24,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if !selected}
|
||||
<span id={id} class="dice cursor-pointer text-3xl flex justify-center items-center bg-red-600 text-white rounded-lg m-1 w-14 h-14">
|
||||
{value}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
|
@@ -14,42 +14,7 @@ export async function load({ params }) {
|
||||
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;
|
||||
console.log("wait");
|
||||
}
|
||||
|
||||
let data = {
|
||||
|
@@ -29,7 +29,7 @@
|
||||
let dice5;
|
||||
let results=[];
|
||||
|
||||
Edge.Client.addEventListener("message", function(evt) {
|
||||
Edge.Client.addEventListener("message", async function(evt) {
|
||||
if(evt.detail.hasOwnProperty(data.party._id)) {
|
||||
console.log("RECEPTION MESSAGE");
|
||||
|
||||
@@ -55,25 +55,53 @@
|
||||
|
||||
// Action retour
|
||||
if(my._id===data.party.playercurrent._id) {
|
||||
console.log("here");
|
||||
console.log("ACTION = "+data.party.playerstatus);
|
||||
|
||||
switch (data.party.playerstatus) {
|
||||
case "":
|
||||
case "dice":
|
||||
data.party.playerparty = await Edge.Client.rpc("getPlayerParty", {playerid: data.party.playercurrent._id, partyid: data.party._id}).catch(err => console.error(err));
|
||||
console.log(data.party.playerparty.tileid);
|
||||
data.party.playertile = await Edge.Client.rpc("getTile",data.party.playerparty.tileid).catch(err => console.error(err));
|
||||
console.log(data.party.playerparty);
|
||||
console.log(data.party.playertile);
|
||||
break;
|
||||
|
||||
case "diceroll":
|
||||
data.party.playerdice+=data.party.dices[0].value+data.party.dices[1].value;
|
||||
|
||||
// si resulat > 0 et non double = on passe à l'étape suivant sinon on peut rejeter
|
||||
if(data.party.playerdice&&data.party.dices[0].value!=data.party.dices[1].value)
|
||||
data.party.playerstatus="move";
|
||||
else
|
||||
data.party.playerstatus="dice";
|
||||
if(data.party.dices[0].value>0&&data.party.dices[1].value>0) {
|
||||
data.party.playerdice+=data.party.dices[0].value;
|
||||
data.party.playerdice+=data.party.dices[1].value;
|
||||
// si resulat > 0 et non double = on passe à l'étape suivant sinon on peut rejeter
|
||||
if(data.party.playerdice&&data.party.dices[0].value!=data.party.dices[1].value)
|
||||
data.party.playerstatus="move";
|
||||
else
|
||||
data.party.playerstatus="dice";
|
||||
|
||||
sendMessage("DICEROLL to "+data.party.playerstatus);
|
||||
}
|
||||
break;
|
||||
|
||||
case "move":
|
||||
console.log("MOVE + "+data.party.playerdice);
|
||||
let position=parseInt(data.party.playertile.position)+parseInt(data.party.playerdice);
|
||||
|
||||
// Là il faut faire la régle de passage à par la casse week enk
|
||||
// Voir si le mouve et super gros gérer le multipassage par weekend
|
||||
if(position>27) position=position-27
|
||||
|
||||
// Mise à jour de la position du joueur
|
||||
data.party.playertile.position=position;
|
||||
console.log(data.party.playertile.position)
|
||||
data.party.playertile = await Edge.Client.rpc("getTilebyorder",data.party.playertile.position).catch(err => console.error(err));
|
||||
console.log(data.party.playertile);
|
||||
data.party.playerparty.tileid=data.party.playertile._id;
|
||||
Edge.Client.rpc("upsertPlayerParty",data.party.playerparty);
|
||||
|
||||
// temporaire on passe au suivant
|
||||
playernext();
|
||||
|
||||
sendMessage("DICEROLL to "+data.party.playerstatus);
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -89,37 +117,64 @@
|
||||
sendMessage("START PARTY");
|
||||
Edge.Client.send({ "cmd": "REFRESH"});
|
||||
}
|
||||
|
||||
async function partykill() {
|
||||
if (window.confirm("Voulez-vous vraiment supprimer la partie ?")) {
|
||||
data.party.status="partykill";
|
||||
sendMessage("KILL PARTY");
|
||||
}
|
||||
}
|
||||
|
||||
function diceresult(event) {
|
||||
data.party.dices.forEach(async (dice,id) => {
|
||||
if(dice.id===event.detail.id) {
|
||||
data.party.dices[id].value=event.detail.value;
|
||||
async function playerkill(id) {
|
||||
if (window.confirm("Voulez-vous êtes sure de vous ?")) {
|
||||
// On supprime son resultat
|
||||
|
||||
// Si le player courrant et celui killé on passe au suivant
|
||||
if(data.party.playercurrent._id==id) {
|
||||
// Rechercher le player suivant
|
||||
let nextplayer=0;
|
||||
data.players.forEach(async (player,i) => {
|
||||
if(player._id===data.party.playercurrent._id) {
|
||||
if(data.players.hasOwnProperty(i+1))
|
||||
nextplayer=i+1;
|
||||
else
|
||||
nextplayer=0;
|
||||
}
|
||||
});
|
||||
|
||||
// Passer sur le player suivant
|
||||
data.party.playercurrent=data.players[nextplayer];
|
||||
|
||||
// Reint les dices et round et diceresultchoiced
|
||||
var dices=[
|
||||
{"id":1,"value":""},
|
||||
{"id":2,"value":""},
|
||||
];
|
||||
data.party.round=0;
|
||||
data.party.dices=dices;
|
||||
data.party.diceresultchoiced=false;
|
||||
}
|
||||
});
|
||||
|
||||
sendMessage("RESULT ROLL");
|
||||
}
|
||||
|
||||
async function roll() {
|
||||
await data.party.dices.forEach(async (dice) => {
|
||||
if(!dice.selected||data.party.round==0) {
|
||||
switch (dice.id) {
|
||||
case 1: await dice1.roll(); break;
|
||||
case 2: await dice2.roll(); break;
|
||||
case 3: await dice3.roll(); break;
|
||||
case 4: await dice4.roll(); break;
|
||||
case 5: await dice5.roll(); break;
|
||||
// On supprime le player de la liste des players et on lui enlève la partie courrante
|
||||
data.players.forEach(async (player,i) => {
|
||||
if(player._id===id) {
|
||||
player.partyid=null;
|
||||
Edge.Client.rpc("upsertPlayer",player);
|
||||
data.players.splice(i,1);
|
||||
}
|
||||
});
|
||||
|
||||
// Si la partie est wait on libère une place
|
||||
if(data.party.status=="playerwait") {
|
||||
data.party.playernb-=1;
|
||||
Edge.Client.rpc("upsertParty",data.party);
|
||||
Edge.Client.send({ "cmd": "REFRESH"});
|
||||
}
|
||||
});
|
||||
|
||||
data.party.playerstatus="diceroll";
|
||||
|
||||
sendMessage("NEXT ROLL");
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
sendMessage("KILL PLAYER");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function playernext() {
|
||||
// Rechercher le player suivant
|
||||
let nextplayer=0;
|
||||
@@ -165,66 +220,36 @@
|
||||
await Edge.Client.rpc("upsertPlayer", my).catch(err => console.error(err));
|
||||
goto("/");
|
||||
}
|
||||
|
||||
async function playerkill(id) {
|
||||
if (window.confirm("Voulez-vous êtes sure de vous ?")) {
|
||||
// On supprime son resultat
|
||||
|
||||
// Si le player courrant et celui killé on passe au suivant
|
||||
if(data.party.playercurrent._id==id) {
|
||||
// Rechercher le player suivant
|
||||
let nextplayer=0;
|
||||
data.players.forEach(async (player,i) => {
|
||||
if(player._id===data.party.playercurrent._id) {
|
||||
if(data.players.hasOwnProperty(i+1))
|
||||
nextplayer=i+1;
|
||||
else
|
||||
nextplayer=0;
|
||||
}
|
||||
});
|
||||
|
||||
// Passer sur le player suivant
|
||||
data.party.playercurrent=data.players[nextplayer];
|
||||
|
||||
// Reint les dices et round et diceresultchoiced
|
||||
var dices=[
|
||||
{"id":1,"value":"","selected":false,"order":1},
|
||||
{"id":2,"value":"","selected":false,"order":2},
|
||||
{"id":3,"value":"","selected":false,"order":3},
|
||||
{"id":4,"value":"","selected":false,"order":4},
|
||||
{"id":5,"value":"","selected":false,"order":5}
|
||||
];
|
||||
data.party.round=0;
|
||||
data.party.dices=dices;
|
||||
data.party.diceresultchoiced=false;
|
||||
|
||||
function diceresult(event) {
|
||||
data.party.dices.forEach(async (dice,id) => {
|
||||
if(dice.id===event.detail.id) {
|
||||
data.party.dices[id].value=event.detail.value;
|
||||
}
|
||||
});
|
||||
|
||||
// On supprime le player de la liste des players et on lui enlève la partie courrante
|
||||
data.players.forEach(async (player,i) => {
|
||||
if(player._id===id) {
|
||||
player.partyid=null;
|
||||
Edge.Client.rpc("upsertPlayer",player);
|
||||
data.players.splice(i,1);
|
||||
}
|
||||
});
|
||||
|
||||
// Si la partie est wait on libère une place
|
||||
if(data.party.status=="playerwait") {
|
||||
data.party.playernb-=1;
|
||||
Edge.Client.rpc("upsertParty",data.party);
|
||||
Edge.Client.send({ "cmd": "REFRESH"});
|
||||
}
|
||||
|
||||
sendMessage("KILL PLAYER");
|
||||
}
|
||||
data.party.playerstatus="diceroll";
|
||||
sendMessage("RESULT ROLL");
|
||||
}
|
||||
|
||||
async function partykill() {
|
||||
if (window.confirm("Voulez-vous vraiment supprimer la partie ?")) {
|
||||
data.party.status="partykill";
|
||||
sendMessage("KILL PARTY");
|
||||
}
|
||||
}
|
||||
async function roll() {
|
||||
await data.party.dices.forEach(async (dice) => {
|
||||
switch (dice.id) {
|
||||
case 1: await dice1.roll(); break;
|
||||
case 2: await dice2.roll(); break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//sendMessage("NEXT ROLL");
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{#if data.party }
|
||||
@@ -305,39 +330,44 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- DICE -->
|
||||
{#if data.party.status==="partyplay"}
|
||||
<!-- PARTY -->
|
||||
{#if data.party.status!=="playerwait" && data.party.status!=="partyend"}
|
||||
{#if data.party.playercurrent._id===my._id}
|
||||
<div class="flex flex-wrap">
|
||||
<div class="w-1/2 flex flex-wrap mb-3 my-auto">
|
||||
<div use:sortable={{cursor:'grabbing', zIndex:100}} class="w-full flex flex-wrap p-1 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
|
||||
{#each data.party.dices as mydice}
|
||||
{#if mydice.id === 1}
|
||||
<Dice bind:this={dice1} {...mydice} on:diceresult={diceresult} />
|
||||
{:else if mydice.id === 2}
|
||||
<Dice bind:this={dice2} {...mydice} on:diceresult={diceresult} />
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
<div use:sortable={{cursor:'grabbing', zIndex:100}} class="w-full flex flex-wrap p-1 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
|
||||
{#each data.party.dices as mydice}
|
||||
{#if mydice.id === 1}
|
||||
<Dice bind:this={dice1} {...mydice} on:diceresult={diceresult} />
|
||||
{:else if mydice.id === 2}
|
||||
<Dice bind:this={dice2} {...mydice} on:diceresult={diceresult} />
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex flex-wrap">
|
||||
<div class="w-full md:w-1/2 flex flex-wrap mb-3 md:pr-3">
|
||||
<div class="w-full flex flex-wrap p-1 md:p-5 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
|
||||
{#each data.party.dices as mydice}
|
||||
{#if !mydice.selected}
|
||||
<span class="cursor-pointer text-3xl flex justify-center items-center bg-red-600 text-white rounded-lg m-1 w-14 h-14 md:m-3 md:w-20 md:h-20">
|
||||
{mydice.value}
|
||||
</span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
<div class="w-full flex flex-wrap p-1 md:p-5 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
|
||||
{#each data.party.dices as mydice}
|
||||
{#if !mydice.selected}
|
||||
<span class="cursor-pointer text-3xl flex justify-center items-center bg-red-600 text-white rounded-lg m-1 w-14 h-14 md:m-3 md:w-20 md:h-20">
|
||||
{mydice.value}
|
||||
</span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
{#if data.party.playertile }
|
||||
Nom = {data.party.playertile.name}<br>
|
||||
Position = {data.party.playertile.position}<br>
|
||||
|
||||
<img src="{data.party.playertile.img}" alt="tile" style="width:800px; max-width: 100%; margin:auto;">
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- KILL -->
|
||||
{#if data.party.status==="partyplay" && my._id===data.party.playerid }
|
||||
<button class="w-full bg-red-500 hover:bg-red-400 mt-3 text-black md:text-3xl p-1 md:p-3" on:click={partykill}>
|
||||
|
@@ -13,8 +13,10 @@ export async function load({ params }) {
|
||||
"playernbmax": 3,
|
||||
"status": "playerwait",
|
||||
"playercurrent": player,
|
||||
"playerdata": null,
|
||||
"playerstatus": "dice",
|
||||
"playerdice": null,
|
||||
"playerdice": 0,
|
||||
"dices": [ {"id":1,"value":""}, {"id":2,"value":""} ]
|
||||
};
|
||||
|
||||
let partyplayer=player;
|
||||
|
@@ -41,7 +41,7 @@
|
||||
// On affecte la party au player submiter
|
||||
data.player.partyid=party._id;
|
||||
await Edge.Client.rpc("upsertPlayer", data.player).catch(err => console.error(err));
|
||||
|
||||
await Edge.Client.rpc("upsertPlayerParty", { "playerid": data.player._id, "partyid": party._id, "tileid": "st", "cash": 100, "nbhappy": 0}).catch(err => console.error(err));
|
||||
}
|
||||
|
||||
// refresh des party
|
||||
|
Reference in New Issue
Block a user