mirror of
https://github.com/Vale54321/schafkopf-bot.git
synced 2025-12-16 11:49:33 +01:00
Message types and server2 (#46)
* fixed building issue * fixed building issue
This commit is contained in:
committed by
GitHub
parent
a0a1cfaa4a
commit
2cd8359518
@@ -29,11 +29,11 @@ function joinGame(): void {
|
||||
}
|
||||
|
||||
function sendCard(cardInput: Card): void {
|
||||
const index = botCards.value.findIndex(card => card === cardInput);
|
||||
const index = botCards.value!.findIndex(card => card === cardInput);
|
||||
|
||||
// If card exists in the array, remove it
|
||||
if (index !== -1) {
|
||||
botCards.value.splice(index, 1);
|
||||
botCards.value!.splice(index, 1);
|
||||
}
|
||||
backendConnection.sendMessage(MessageType.PLAYER_CARD, {card: cardInput});
|
||||
}
|
||||
@@ -90,11 +90,11 @@ onMounted(() => {
|
||||
const messageListener = (message: string) => {
|
||||
const message1: BackendMessage = JSON.parse(message);
|
||||
console.log(message1)
|
||||
if (message1.message_type === "GAME_STATE") {
|
||||
if (message1.message_type === "GAME_STATE" && "gamestate" in message1.content) {
|
||||
console.log(message1.content)
|
||||
showGameState(message1.content)
|
||||
showGameState(message1.content.gamestate)
|
||||
}
|
||||
if (message1.message_type === "ONLINE_PLAYER_HAND") {
|
||||
if (message1.message_type === "ONLINE_PLAYER_HAND" && "cards" in message1.content) {
|
||||
botCards.value = message1.content.cards;
|
||||
console.log(message1.content.cards)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user