This commit is contained in:
@@ -25,13 +25,21 @@ function killErika() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="games-list-zone">
|
<div class="games-list-zone">
|
||||||
<div v-for="g in goStore.lobby?.games"><button @click="join_game(g)">{{ g }}</button></div>
|
<div v-for="g in goStore.lobby?.games">
|
||||||
|
<button v-if="g" @click="join_game(g.uuid)">
|
||||||
|
started:{{ g.started }}
|
||||||
|
ended:{{ g.ended }}
|
||||||
|
players:<span v-for="p in g.players">{{ p.username }},</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="overlay" v-if="erika_alive">
|
<div class="overlay" v-if="erika_alive">
|
||||||
<div class="erika-zone">
|
<div class="erika-zone">
|
||||||
<img @click="router.push({ path: 'rules'})" class="overlay-image" src="https://static.wikia.nocookie.net/umineko/images/9/9d/PC_Erika.Casual.Sprite_36.png" alt="pétasse" />
|
<img @click="router.push({ path: 'rules' })" class="overlay-image"
|
||||||
|
src="https://static.wikia.nocookie.net/umineko/images/9/9d/PC_Erika.Casual.Sprite_36.png"
|
||||||
|
alt="pétasse" />
|
||||||
<div class="overlay-button">
|
<div class="overlay-button">
|
||||||
<button class="kill-erika-button" @click.stop="killErika()">Tuer Erika</button>
|
<button class="kill-erika-button" @click.stop="killErika()">Tuer Erika</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -101,7 +109,7 @@ function killErika() {
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
transition-duration: 0.4s;
|
transition-duration: 0.4s;
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
||||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,7 +135,7 @@ function killErika() {
|
|||||||
height: 120px;
|
height: 120px;
|
||||||
transition-duration: 0.4s;
|
transition-duration: 0.4s;
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
||||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,7 +188,7 @@ function killErika() {
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
transition-duration: 0.4s;
|
transition-duration: 0.4s;
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
||||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,24 +13,25 @@ const props = defineProps<Props>()
|
|||||||
<template>
|
<template>
|
||||||
<div class="turn_icon">
|
<div class="turn_icon">
|
||||||
<span class="icon_img">🖕</span>
|
<span class="icon_img">🖕</span>
|
||||||
<span class="turn_icon_number">{{ player.turn.discard_markers + player.turn.fuck_u_markers }}</span>
|
<span class="turn_icon_number">{{ (player.turn?.discard_markers ?? 0) + (player.turn?.fuck_u_markers ?? 0)
|
||||||
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="turn_icon">
|
<div class="turn_icon">
|
||||||
<img src="/images/damage.png" class="icon_img" draggable="false" />
|
<img src="/images/damage.png" class="icon_img" draggable="false" />
|
||||||
<span class="turn_icon_number">
|
<span class="turn_icon_number">
|
||||||
{{ player.turn.damage_reserve }}
|
{{ player.turn?.damage_reserve }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="turn_icon">
|
<div class="turn_icon">
|
||||||
<img src="/images/gold.png" class="icon_img" draggable="false" />
|
<img src="/images/gold.png" class="icon_img" draggable="false" />
|
||||||
<span class="turn_icon_number">
|
<span class="turn_icon_number">
|
||||||
{{ player.turn.gold_reserve }}
|
{{ player.turn?.gold_reserve }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="turn_icon">
|
<div class="turn_icon">
|
||||||
<img src="/images/champion-shield.png" class="icon_img" draggable="false" />
|
<img src="/images/champion-shield.png" class="icon_img" draggable="false" />
|
||||||
<span class="turn_icon_number">
|
<span class="turn_icon_number">
|
||||||
{{ player.team.health }}
|
{{ player.team?.health }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+8
-1
@@ -2,6 +2,7 @@ import { type GameObjectRegister } from "."
|
|||||||
import { type Team } from "./Team"
|
import { type Team } from "./Team"
|
||||||
import { type GameObjectNetcode } from "./GameObject"
|
import { type GameObjectNetcode } from "./GameObject"
|
||||||
import type { Card } from "./Card"
|
import type { Card } from "./Card"
|
||||||
|
import type { Player } from "./Player"
|
||||||
|
|
||||||
export interface GameNetcode extends GameObjectNetcode {
|
export interface GameNetcode extends GameObjectNetcode {
|
||||||
market_stack: Array<string>
|
market_stack: Array<string>
|
||||||
@@ -9,14 +10,17 @@ export interface GameNetcode extends GameObjectNetcode {
|
|||||||
gem_stack: Array<string>
|
gem_stack: Array<string>
|
||||||
started: boolean
|
started: boolean
|
||||||
current_turn: string
|
current_turn: string
|
||||||
|
players: Array<string>
|
||||||
|
ended: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type Game = Omit<GameNetcode, 'market_stack' | 'market' | 'gem_stack' | 'current_turn'> & {
|
export type Game = Omit<GameNetcode, 'market_stack' | 'market' | 'gem_stack' | 'current_turn' | 'player'> & {
|
||||||
market_stack: Array<Card>
|
market_stack: Array<Card>
|
||||||
market: Array<Card | null>
|
market: Array<Card | null>
|
||||||
gem_stack: Array<Card>
|
gem_stack: Array<Card>
|
||||||
current_turn: Team
|
current_turn: Team
|
||||||
|
players: Array<Player>
|
||||||
}
|
}
|
||||||
export function create_game(input: GameNetcode, register: GameObjectRegister) {
|
export function create_game(input: GameNetcode, register: GameObjectRegister) {
|
||||||
return new Proxy<any>(input, {
|
return new Proxy<any>(input, {
|
||||||
@@ -34,6 +38,9 @@ export function create_game(input: GameNetcode, register: GameObjectRegister) {
|
|||||||
if (prop == "current_turn") {
|
if (prop == "current_turn") {
|
||||||
return register.teams.get(input.current_turn)
|
return register.teams.get(input.current_turn)
|
||||||
}
|
}
|
||||||
|
if (prop == "players") {
|
||||||
|
return target.players.map(e => register.players.get(e))
|
||||||
|
}
|
||||||
return Reflect.get(target, prop, reciever);
|
return Reflect.get(target, prop, reciever);
|
||||||
},
|
},
|
||||||
set(target, prop, val, receiver) {
|
set(target, prop, val, receiver) {
|
||||||
|
|||||||
+4
-4
@@ -7,15 +7,15 @@ export interface LobbyNetcode extends GameObjectNetcode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type Lobby = LobbyNetcode & {
|
export type Lobby = Omit<LobbyNetcode, 'games'> & {
|
||||||
games: Array<Game>
|
games: Array<Game>
|
||||||
}
|
}
|
||||||
export function create_lobby(input: LobbyNetcode, register: GameObjectRegister) {
|
export function create_lobby(input: LobbyNetcode, register: GameObjectRegister) {
|
||||||
return new Proxy<any>(input, {
|
return new Proxy<any>(input, {
|
||||||
get(target: LobbyNetcode, prop, reciever) {
|
get(target: LobbyNetcode, prop, reciever) {
|
||||||
// if (prop == "games") {
|
if (prop == "games") {
|
||||||
// return target.games.map(e => register.games.get(e))
|
return target.games.map(e => register.games.get(e))
|
||||||
// }
|
}
|
||||||
return Reflect.get(target, prop, reciever);
|
return Reflect.get(target, prop, reciever);
|
||||||
},
|
},
|
||||||
set(target, prop, val, receiver) {
|
set(target, prop, val, receiver) {
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@ export type Player = Omit<PlayerNetcode, 'discard_pile' | 'stack_pile' | 'hand'
|
|||||||
discard_pile: Array<Card>
|
discard_pile: Array<Card>
|
||||||
hand: Array<Card | null>
|
hand: Array<Card | null>
|
||||||
board: Array<Card>
|
board: Array<Card>
|
||||||
team: Team
|
team: Team | undefined
|
||||||
turn: Turn
|
turn: Turn | undefined
|
||||||
}
|
}
|
||||||
export function create_player(input: PlayerNetcode, register: GameObjectRegister) {
|
export function create_player(input: PlayerNetcode, register: GameObjectRegister) {
|
||||||
return new Proxy<any>(input, {
|
return new Proxy<any>(input, {
|
||||||
|
|||||||
+51
-40
@@ -23,11 +23,11 @@ export class GameObjectRegister {
|
|||||||
readonly teams: Map<string, Team>;
|
readonly teams: Map<string, Team>;
|
||||||
readonly players: Map<string, Player>;
|
readonly players: Map<string, Player>;
|
||||||
readonly turns: Map<string, Turn>;
|
readonly turns: Map<string, Turn>;
|
||||||
readonly games: Map<string, Game>
|
readonly games: Map<string, Game>;
|
||||||
|
|
||||||
context: "lobby" | "login" | "pregame" | "game" | "rules" = "login";
|
context: "lobby" | "login" | "pregame" | "game" | "rules" = "login";
|
||||||
private readonly objects: Map<string, GameObjectNetcode>;
|
private readonly objects: Map<string, GameObjectNetcode>;
|
||||||
current_game: Ref<Game | null>
|
current_game: Ref<Game | null>;
|
||||||
lobby: Ref<Lobby | null>;
|
lobby: Ref<Lobby | null>;
|
||||||
self: Ref<Player | null>;
|
self: Ref<Player | null>;
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -36,18 +36,25 @@ export class GameObjectRegister {
|
|||||||
this.teams = reactive(new Map());
|
this.teams = reactive(new Map());
|
||||||
this.players = reactive(new Map());
|
this.players = reactive(new Map());
|
||||||
this.turns = reactive(new Map());
|
this.turns = reactive(new Map());
|
||||||
this.games = reactive(new Map())
|
this.games = reactive(new Map());
|
||||||
|
|
||||||
this.objects = reactive(new Map());
|
this.objects = reactive(new Map());
|
||||||
this.current_game = ref(null)
|
this.current_game = ref(null);
|
||||||
this.lobby = ref(null);
|
this.lobby = ref(null);
|
||||||
this.self = ref(null);
|
this.self = ref(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_object(obj: GameObjectNetcode) {
|
update_object(obj: GameObjectNetcode) {
|
||||||
console.log(obj)
|
if (unref(this.current_game)?.uuid === obj.uuid) {
|
||||||
console.log(obj.uuid)
|
Object.assign(this.current_game as any, obj);
|
||||||
console.log(this.objects.get(obj.uuid))
|
} else if (unref(this.lobby)?.uuid === obj.uuid) {
|
||||||
|
Object.assign(this.lobby as any, obj);
|
||||||
|
} else if (unref(this.self)?.uuid === obj.uuid) {
|
||||||
|
Object.assign(this.self as any, obj);
|
||||||
|
}
|
||||||
|
console.log(obj);
|
||||||
|
console.log(obj.uuid);
|
||||||
|
console.log(this.objects.get(obj.uuid));
|
||||||
Object.assign(this.objects.get(obj.uuid) as GameNetcode, obj);
|
Object.assign(this.objects.get(obj.uuid) as GameNetcode, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +112,7 @@ export const setup_websocket = () =>
|
|||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
const config = useRuntimeConfig();
|
const config = useRuntimeConfig();
|
||||||
const heron_session = useCookie('heron_session')
|
const heron_session = useCookie("heron_session");
|
||||||
socket = new WebSocket(config.public.websocketEndpoint);
|
socket = new WebSocket(config.public.websocketEndpoint);
|
||||||
|
|
||||||
socket.onopen = function (e) {
|
socket.onopen = function (e) {
|
||||||
@@ -148,12 +155,12 @@ export const setup_websocket = () =>
|
|||||||
goStore.context = data.data;
|
goStore.context = data.data;
|
||||||
// console.log(data.data);
|
// console.log(data.data);
|
||||||
} else if (data.type === "set") {
|
} else if (data.type === "set") {
|
||||||
if(data.data_type == "self"){
|
if (data.data_type == "self") {
|
||||||
goStore.set_self(data.data);
|
goStore.set_self(data.data);
|
||||||
} else if (data.data_type == "current_game"){
|
} else if (data.data_type == "current_game") {
|
||||||
goStore.set_current_game(data.data)
|
goStore.set_current_game(data.data);
|
||||||
} else if (data.data_type == "session_cookie"){
|
} else if (data.data_type == "session_cookie") {
|
||||||
heron_session.value = data.data
|
heron_session.value = data.data;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// console.log(data.type, data.data_type, data.data);
|
// console.log(data.type, data.data_type, data.data);
|
||||||
@@ -161,7 +168,7 @@ export const setup_websocket = () =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function heron_cookie_login(cookie:string){
|
export async function heron_cookie_login(cookie: string) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
@@ -184,7 +191,7 @@ export async function oauth2_register_discord(code: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function register(username: string) {
|
export async function register(username: string) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
|
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
@@ -196,7 +203,7 @@ export async function register(username: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function login(username: string) {
|
export async function login(username: string) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "login",
|
type: "login",
|
||||||
@@ -207,7 +214,7 @@ export async function login(username: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function setReady(value: boolean) {
|
export async function setReady(value: boolean) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "ready",
|
type: "ready",
|
||||||
@@ -218,7 +225,7 @@ export async function setReady(value: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function buy(card: Card) {
|
export async function buy(card: Card) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -229,7 +236,7 @@ export async function buy(card: Card) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function endTurn() {
|
export async function endTurn() {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -246,7 +253,7 @@ export function playAllCards(cards: Card[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function playCard(card: Card) {
|
export async function playCard(card: Card) {
|
||||||
// console.log(card.uuid);
|
// console.log(card.uuid);
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
@@ -258,7 +265,7 @@ export async function playCard(card: Card) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function lockCard(card: Card) {
|
export async function lockCard(card: Card) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -272,7 +279,7 @@ export async function useEffect(
|
|||||||
effect: Effect,
|
effect: Effect,
|
||||||
target?: Effect | Card | Player | Team
|
target?: Effect | Card | Player | Team
|
||||||
) {
|
) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -283,7 +290,7 @@ export async function useEffect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function discard(card: Card) {
|
export async function discard(card: Card) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -294,7 +301,7 @@ export async function discard(card: Card) {
|
|||||||
}
|
}
|
||||||
h;
|
h;
|
||||||
export async function heal() {
|
export async function heal() {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -305,7 +312,7 @@ export async function heal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function damage_team(target: Team) {
|
export async function damage_team(target: Team) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -316,7 +323,7 @@ export async function damage_team(target: Team) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function damage_champion(target: Card) {
|
export async function damage_champion(target: Card) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
@@ -326,21 +333,25 @@ export async function damage_champion(target: Card) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function netcode_create_game(){
|
export async function netcode_create_game() {
|
||||||
await setup_websocket()
|
await setup_websocket();
|
||||||
socket.send(JSON.stringify({
|
socket.send(
|
||||||
type: "create",
|
JSON.stringify({
|
||||||
data_type: "game",
|
type: "create",
|
||||||
data: "bite"
|
data_type: "game",
|
||||||
}))
|
data: "bite",
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function join_game(game_uuid: string){
|
export async function join_game(game_uuid: string) {
|
||||||
await setup_websocket()
|
await setup_websocket();
|
||||||
socket.send(JSON.stringify({
|
socket.send(
|
||||||
type: "join",
|
JSON.stringify({
|
||||||
data_type: "game",
|
type: "join",
|
||||||
data: game_uuid
|
data_type: "game",
|
||||||
}))
|
data: game_uuid,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
export default goStore;
|
export default goStore;
|
||||||
|
|||||||
Reference in New Issue
Block a user