-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
361 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNetCore.SignalR; | ||
using SignalRSwaggerGen.Attributes; | ||
using Wordle.Api.Models; | ||
|
||
namespace Wordle.Api; | ||
[SignalRHub] | ||
public class WordleHub : Hub | ||
{ | ||
[SignalRMethod] | ||
public async void SendMessage(string message) | ||
{ | ||
await Clients.All.SendAsync("ReceiveMessage", message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<v-card height="92%" variant="tonal" :color="cardColor"> | ||
<v-card-text> | ||
<p v-for="(message, i) of signalRService.messages.value" :key="i"> | ||
<v-avatar | ||
icon="mdi-account" | ||
:color="cardColor" | ||
size="small" | ||
class="mr-2" | ||
/> | ||
<ChatMessage :message="message" /> | ||
<v-divider class="my-2" /> | ||
</p> | ||
</v-card-text> | ||
</v-card> | ||
<v-text-field | ||
class="mt-2" | ||
label="Message" | ||
@keyup.stop | ||
@keyup.enter="sendMessage" | ||
v-model="message" | ||
@click:append-inner="sendMessage" | ||
append-inner-icon="mdi-send" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import SignalRService from "~/scripts/signalRService"; | ||
import { useTheme } from "vuetify"; | ||
const message = ref<string>(""); | ||
const signalRService = new SignalRService(); | ||
const theme = useTheme(); | ||
const cardColor = computed(() => { | ||
return theme.global.name.value == "dark" ? "secondary" : "primary"; | ||
}); | ||
function parseWord(message: string) { | ||
return message.split(" ")[1]; | ||
} | ||
function sendMessage() { | ||
signalRService.sendMessage(message.value); | ||
message.value = ""; | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<span v-for="(msg, i) in messageArray" :key="msg + i"> | ||
<span v-if="isWordToTry(msg)"> | ||
<v-btn @click="tryWord(msg)" variant="text" class="pa-1"> | ||
{{ msg }} | ||
</v-btn> | ||
{{ " " }} | ||
</span> | ||
<span v-else> | ||
{{ msg + " " }} | ||
</span> | ||
</span> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { defineProps } from 'vue'; | ||
import type { Game } from '~/scripts/game'; | ||
const props = defineProps<{ | ||
message: string; | ||
}>(); | ||
const game: Game = inject("GAME")!; | ||
const messageArray = props.message.split(" "); | ||
function isWordToTry(messageFragment: string): boolean { | ||
const pattern = /^'\w{5}'.*$/; | ||
return pattern.test(messageFragment); | ||
} | ||
function tryWord(word: string) { | ||
console.log(word); | ||
const match = word.match(/^'(\w{5})'/); | ||
if (match) { | ||
const extractedWord = match[1]; | ||
for (const letter of extractedWord) { | ||
game.addLetter(letter.toUpperCase()); | ||
} | ||
} | ||
} | ||
</script> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.