discord login
This commit is contained in:
@@ -1,9 +1,29 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
import goStore, { register, setReady } from "@/netcode";
|
import goStore, { register, setReady, oauth2_register_discord } from "@/netcode";
|
||||||
|
import { isStaticProperty } from "vue/compiler-sfc";
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
let username = ref<string>("legonzaur");
|
let username = ref<string>("legonzaur");
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (route.path != "/login") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const code = route.query.code
|
||||||
|
if (!code) { return }
|
||||||
|
if (Array.isArray(code)) { return }
|
||||||
|
oauth2_register_discord(code)
|
||||||
|
|
||||||
|
history.pushState(
|
||||||
|
{},
|
||||||
|
'',
|
||||||
|
'/'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div id="game_status">
|
<div id="game_status">
|
||||||
|
|||||||
@@ -82,9 +82,14 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
|
|||||||
</CardPreview>
|
</CardPreview>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<div id="player_banner">
|
||||||
|
<div id="player_info">
|
||||||
|
<img v-if="props.player.image" :src="props.player.image">
|
||||||
|
<b>{{ props.player.username }}</b>
|
||||||
|
</div>
|
||||||
<div id="player_stats">
|
<div id="player_stats">
|
||||||
<PlayerStats :player="props.player"></PlayerStats>
|
<PlayerStats :player="props.player"></PlayerStats>
|
||||||
<b>{{ props.player.username }}</b>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="current_player_board">
|
<div id="current_player_board">
|
||||||
<button @click.stop="damage_team(props.player.team)" v-if="isSelfTurn && isPlayerEnemy"
|
<button @click.stop="damage_team(props.player.team)" v-if="isSelfTurn && isPlayerEnemy"
|
||||||
@@ -162,6 +167,7 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
|
|||||||
.discard {
|
.discard {
|
||||||
margin-top: 50px;
|
margin-top: 50px;
|
||||||
grid-area: discard;
|
grid-area: discard;
|
||||||
|
justify-content: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
.player {
|
.player {
|
||||||
@@ -173,6 +179,11 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
|
|||||||
"player_stats player_stats"
|
"player_stats player_stats"
|
||||||
"stack player"
|
"stack player"
|
||||||
"discard player";
|
"discard player";
|
||||||
|
transition: all 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.player.turn {
|
||||||
|
margin-bottom: 75px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.player.discard_unwrapped {
|
.player.discard_unwrapped {
|
||||||
@@ -190,10 +201,10 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
#player_stats {
|
#player_banner {
|
||||||
display: flex;
|
display: flex;
|
||||||
grid-area: player_stats;
|
grid-area: player_stats;
|
||||||
flex-direction: row-reverse;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
@@ -202,6 +213,24 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#player_info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#player_stats {
|
||||||
|
display: flex;
|
||||||
|
grid-area: player_stats;
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#player_banner img {
|
||||||
|
height: 50px;
|
||||||
|
border-radius: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
.turn_icon img {
|
.turn_icon img {
|
||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ export interface PlayerNetcode extends GameObjectNetcode {
|
|||||||
team: string
|
team: string
|
||||||
username: string
|
username: string
|
||||||
turn: string
|
turn: string
|
||||||
|
discord_id?: string
|
||||||
|
image?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,14 @@ socket.onmessage = function (event) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export async function oauth2_register_discord(code: string){
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
type:"discord_login",
|
||||||
|
data_type:"code",
|
||||||
|
data:code
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
export async function register(username: string) {
|
export async function register(username: string) {
|
||||||
socket.send(JSON.stringify({
|
socket.send(JSON.stringify({
|
||||||
type: "register",
|
type: "register",
|
||||||
|
|||||||
Reference in New Issue
Block a user