This commit is contained in:
Rudy Masson 2024-02-24 15:05:23 +01:00
parent 80bdf4afb5
commit ab084d515a
5 changed files with 77 additions and 35 deletions

View File

@ -137,6 +137,7 @@ function onInit() {
rpc.register("getPlayerParty"); rpc.register("getPlayerParty");
rpc.register("upsertPlayerParty"); rpc.register("upsertPlayerParty");
rpc.register("getPlayerPartys");
rpc.register("getPlayerPartyTile"); rpc.register("getPlayerPartyTile");
rpc.register("upsertlayerPartyTile"); rpc.register("upsertlayerPartyTile");
@ -324,6 +325,15 @@ async function getPlayerParty(ctx,ids) {
); );
return obj[0]; return obj[0];
} }
// Repository PlayerPartys
async function getPlayerPartys(ctx,partyid) {
var obj = await store.query(ctx, "PlayerParty",
{"eq":{ "partyid": partyid }}
);
return obj;
}
async function upsertPlayerParty(ctx,playerparty) { async function upsertPlayerParty(ctx,playerparty) {
var obj = await store.upsert(ctx, "PlayerParty", playerparty); var obj = await store.upsert(ctx, "PlayerParty", playerparty);
return obj; return obj;

View File

@ -327,7 +327,7 @@
.tile, .tilenone { width: 33.33333333333333333333333% } .tile, .tilenone { width: 33.33333333333333333333333% }
.tilenone {border: none;} .tilenone {border: none;}
.rencontre{border: 1px 5px}
.sortable > span { .sortable > span {
-webkit-touch-callout:none; -webkit-touch-callout:none;
-ms-touch-action:none; touch-action:none; -ms-touch-action:none; touch-action:none;

View File

@ -1,15 +1,36 @@
<script> <script>
export let size; export let size;
export let id; export let _id;
export let position; export let position;
export let img; export let img;
export let name; export let name;
export let price;
export let tiletype;
export let partyid;
export let playerposition;
var style="tile"; var style="tile";
if(size=="big") style="bigtile"; if(size=="big") style="bigtile";
var promise = Edge.Client.rpc("getPlayerPartys",partyid);
</script> </script>
<div class="{style}" style="background-image: url({img});">{position} = {name}</div> <div class="{style} {tiletype}" style="background-image: url({img});">
<span style="color: white; margin: 5px; padding: 5px;font-size: 700; background-color: rgba(0,0,0,0.4)">{name}</span>
<span style="color: white; margin: 5px; padding: 5px;font-size: 700; background-color: rgba(0,0,0,0.4)">{position}</span>
{#await promise}
<p>wainting ...</p>
{:then players}
{#each players as player}
{#if player.tileid == _id }
<div style="background-color: {player.color}; width:40px;height:40px; border-radius:100%"></div>
{/if}
{/each}
{:catch err}
{err.message}
{/await}
</div>

View File

@ -98,12 +98,12 @@
} }
// Mise à jour de la position du joueur // Mise à jour de la position du joueur
data.party.playertile.position=position;
console.log(data.party.playertile.position) console.log(data.party.playertile.position)
data.party.playertile = await Edge.Client.rpc("getTilebyorder",data.party.playertile.position).catch(err => console.error(err)); data.party.playertile = await Edge.Client.rpc("getTilebyorder",position).catch(err => console.error(err));
console.log(data.party.playertile); console.log(data.party.playertile);
data.party.playerparty.tileid=data.party.playertile._id; data.party.playerparty.tileid=data.party.playertile._id;
Edge.Client.rpc("upsertPlayerParty",data.party.playerparty); Edge.Client.rpc("upsertPlayerParty",data.party.playerparty);
data.party.playertile.position=position;
// temporaire on passe au suivant // temporaire on passe au suivant
//playernext(); //playernext();
@ -376,78 +376,79 @@
{/if} {/if}
</div> </div>
{#key data.party.playertile.position}
<div style="width:600px; max-width:100%; display:flex; flex-direction: column; margin:auto;"> <div style="width:600px; max-width:100%; display:flex; flex-direction: column; margin:auto;">
<Tile partyid={data.party._id} {...data.tiles[14]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[14]} />
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[13]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[13]}/>
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[15]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[15]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[12]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[12]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[16]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[16]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[11]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[11]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[17]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[17]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[10]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[10]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[18]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[18]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[9]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[9]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[19]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[19]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[8]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[8]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[20]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[20]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[7]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[7]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[21]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[21]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[6]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[6]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[22]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[22]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[5]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[5]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[23]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[23]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[4]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[4]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[24]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[24]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[3]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[3]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[25]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[25]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[2]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[2]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[26]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[26]} />
</div> </div>
<div style="display:flex"> <div style="display:flex">
<Tile {...data.tiles[1]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[1]} />
<div class="tilenone"></div> <div class="tilenone"></div>
<Tile {...data.tiles[27]} /> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[27]} />
</div> </div>
<div class="bigtile" style="background-image: url({data.tiles[0].img});"></div> <Tile playerposition="{data.party.playertile.position}" partyid={data.party._id} {...data.tiles[0]} />
</div> </div>
{/key}
<!-- KILL --> <!-- KILL -->
{#if data.party.status==="partyplay" && my._id===data.party.playerid } {#if data.party.status==="partyplay" && my._id===data.party.playerid }

View File

@ -34,14 +34,24 @@
// Si playernb ne depasse pas playernbmax = on affecte le jour à la party // Si playernb ne depasse pas playernbmax = on affecte le jour à la party
if(data.party.playernb<=data.party.playernbmax&&data.party.status==="playerwait") { if(data.party.playernb<=data.party.playernbmax&&data.party.status==="playerwait") {
data.party.status="playerwait"; data.party.status="playerwait";
data.party.playertile = await Edge.Client.rpc("getTile", 'st').catch(err => console.error(err));
// Submit de la party // Submit de la party
let party=await Edge.Client.rpc("upsertParty", data.party).catch(err => console.error(err)); let party=await Edge.Client.rpc("upsertParty", data.party).catch(err => console.error(err));
data.party._id=party._id;
// On affecte la party au player submiter // On affecte la party au player submiter
data.player.partyid=party._id; data.player.partyid=party._id;
let randomColor = Math.floor(Math.random()*16777215).toString(16);
await Edge.Client.rpc("upsertPlayer", data.player).catch(err => console.error(err)); 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));
// Génération du player party
let playerparty = { "playerid": data.player._id, "partyid": party._id, "tileid": "st", "cash": 100, "nbhappy": 0, "player": data.player, "color": "#"+ randomColor}
await Edge.Client.rpc("upsertPlayerParty", playerparty).catch(err => console.error(err));
// Sauvegarde du player party
data.party.playerparty=playerparty;
await Edge.Client.rpc("upsertParty", data.party).catch(err => console.error(err));
} }
// refresh des party // refresh des party