composant player

This commit is contained in:
Rudy Masson 2024-02-24 17:35:24 +01:00
parent 0566cde540
commit 24508d811e
3 changed files with 42 additions and 12 deletions

34
src/lib/Player.svelte Normal file
View File

@ -0,0 +1,34 @@
<script>
import { get } from "svelte/store";
export let partyid;
export let playerid;
var player;
var tile;
async function getPlayer() {
player = await Edge.Client.rpc("getPlayerParty",{"partyid": partyid, "playerid": playerid });
tile = await Edge.Client.rpc("getTile", player.tileid)
}
let promise = getPlayer();
</script>
<div style="color: white; padding: 5px; background-color: rgba(0,0,0,0.8); text-align: center">
{#await promise}
<p>waiting ...</p>
{:then ok}
<div class="flex flex-col p-1 w-20 h-80 md:w-auto md:h-auto items-center justify-center mx-1 text-black" style="background-color: {player.color}">
<img src="./medias/logo/arnold.png" alt="arnold">
{player.player.name}<br>
Argent: {player.cash}<br>
Position: {tile.name}
<!-- <span class="text-xs text-center">Joueur<br><span class="{(player._id==my._id?"text-3xl":"")}">{(player._id==my._id?"MOI":player.name)}</span></span> -->
</div>
{:catch err}
{err.message}
{/await}
</div>

View File

@ -17,10 +17,9 @@
<div class="{style} {tiletype}" style="background-image: url({img});"> <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> <div style="color: white; padding: 5px; background-color: rgba(0,0,0,0.8); text-align: center">{name}</div>
<span style="color: white; margin: 5px; padding: 5px;font-size: 700; background-color: rgba(0,0,0,0.4)">{position}</span>
{#await promise} {#await promise}
<p>wainting ...</p> <p>waiting ...</p>
{:then players} {:then players}
{#each players as player} {#each players as player}
{#if player.tileid == _id } {#if player.tileid == _id }

View File

@ -1,6 +1,7 @@
<script> <script>
import Dice from '$lib/Dice.svelte'; import Dice from '$lib/Dice.svelte';
import Tile from '$lib/Tile.svelte'; import Tile from '$lib/Tile.svelte';
import Player from '$lib/Player.svelte';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { enableBodyScroll, disableBodyScroll } from 'body-scroll-lock'; import { enableBodyScroll, disableBodyScroll } from 'body-scroll-lock';
import { sortable } from 'svelte-agnostic-draggable' ; import { sortable } from 'svelte-agnostic-draggable' ;
@ -102,6 +103,7 @@
data.party.playertile = await Edge.Client.rpc("getTilebyorder",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;
data.party.playerparty.tile=data.party.playertile
Edge.Client.rpc("upsertPlayerParty",data.party.playerparty); Edge.Client.rpc("upsertPlayerParty",data.party.playerparty);
data.party.playertile.position=position; data.party.playertile.position=position;
data.party.playerstatus="moved"; data.party.playerstatus="moved";
@ -370,18 +372,13 @@
<div class="tilenone" style="display:flex; flex-direction: column;;width:50%;"> <div class="tilenone" style="display:flex; flex-direction: column;;width:50%;">
{#if data.party } {#if data.party }
{#if data.party.playertile }
<div>
Nom = {data.party.playertile.name}<br>
Position = {data.party.playertile.position}<br>
Cash = {data.party.playerparty.cash}<br>
</div>
{/if}
<!-- LISTE DES JOUEURS --> <!-- LISTE DES JOUEURS -->
<div class="flex wrap mb-3 items-center justify-center"> <div class="flex wrap mb-3 items-center justify-center">
{#each data.players as player} {#each data.players as player}
{#if player._id===data.party.playercurrent._id && data.party.status!="partyend"} <Player partyid={data.party._id} playerid={player._id}/>
<!-- {#if player._id===data.party.playercurrent._id && data.party.status!="partyend"}
<div class="flex flex-col p-1 w-20 h-20 md:w-28 md:h-28 items-center justify-center bg-lime-500 mx-1 text-black"> <div class="flex flex-col p-1 w-20 h-20 md:w-28 md:h-28 items-center justify-center bg-lime-500 mx-1 text-black">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="hidden md:block w-10 h-10 text-cyan-950"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="hidden md:block w-10 h-10 text-cyan-950">
<path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z" /> <path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z" />
@ -405,7 +402,7 @@
<button on:click={playerkill(player._id)}>sortir</button> <button on:click={playerkill(player._id)}>sortir</button>
{/if} {/if}
</div> </div>
{/if} {/if} -->
{/each} {/each}
</div> </div>
{/if} {/if}