Browse Source

* Lint

master
vvandenb 2 years ago
parent
commit
0bf1528d78
  1. 6
      back/volume/src/pong/game/Ball.ts
  2. 25
      front/volume/src/App.svelte
  3. 9
      front/volume/src/components/Channels.svelte
  4. 33
      front/volume/src/components/Chat.svelte
  5. 6
      front/volume/src/components/Pong/Game.ts
  6. 36
      front/volume/src/components/Pong/constants.ts

6
back/volume/src/pong/game/Ball.ts

@ -1,7 +1,11 @@
import { type Paddle } from './Paddle' import { type Paddle } from './Paddle'
import { type Point, Rect } from './utils' import { type Point, Rect } from './utils'
import { type MapDtoValidated } from '../dtos/MapDtoValidated' import { type MapDtoValidated } from '../dtos/MapDtoValidated'
import { DEFAULT_BALL_SIZE, DEFAULT_BALL_INITIAL_SPEED, GAME_TICKS } from './constants' import {
DEFAULT_BALL_SIZE,
DEFAULT_BALL_INITIAL_SPEED,
GAME_TICKS
} from './constants'
export class Ball { export class Ball {
rect: Rect rect: Rect

25
front/volume/src/App.svelte

@ -174,11 +174,14 @@
<div> <div>
{#if $store === null} {#if $store === null}
<div class="login-div"> <div class="login-div">
<h3 class="test"> <h3 class="test">Please log in with 42 api to access the website.</h3>
Please log in with 42 api to access the website. <img
</h3> class="img-42"
<img class="img-42" src="https://translate.intra.42.fr/assets/42_logo-7dfc9110a5319a308863b96bda33cea995046d1731cebb735e41b16255106c12.svg" alt="logo_42"> src="https://translate.intra.42.fr/assets/42_logo-7dfc9110a5319a308863b96bda33cea995046d1731cebb735e41b16255106c12.svg"
<button class="login-button" type="button" on:click={login}>Log In</button> alt="logo_42"
/>
<button class="login-button" type="button" on:click={login}>Log In</button
>
</div> </div>
{:else if $store.twoFA === true && $store.isVerified === false} {:else if $store.twoFA === true && $store.isVerified === false}
<h1><button type="button" on:click={verify}>verify</button></h1> <h1><button type="button" on:click={verify}>verify</button></h1>
@ -243,11 +246,7 @@
{/if} {/if}
{#if appState === APPSTATE.PROFILE} {#if appState === APPSTATE.PROFILE}
<div on:click={resetAppState} on:keydown={resetAppState}> <div on:click={resetAppState} on:keydown={resetAppState}>
<Profile <Profile user={userProfile} edit={1} on:view-history={openIdHistory} />
user={userProfile}
edit={1}
on:view-history={openIdHistory}
/>
</div> </div>
{/if} {/if}
{#if appState === APPSTATE.PROFILE_ID} {#if appState === APPSTATE.PROFILE_ID}
@ -257,11 +256,7 @@
on:keydown={() => on:keydown={() =>
setAppState(APPSTATE.CHANNELS + "#" + selectedChannel.name)} setAppState(APPSTATE.CHANNELS + "#" + selectedChannel.name)}
> >
<Profile <Profile user={userProfile} edit={0} on:view-history={openIdHistory} />
user={userProfile}
edit={0}
on:view-history={openIdHistory}
/>
</div> </div>
{/if} {/if}

9
front/volume/src/components/Channels.svelte

@ -63,7 +63,7 @@
channels = channels.filter((c) => c.id !== id); channels = channels.filter((c) => c.id !== id);
} }
// TODO: save to database // TODO: save to database
} };
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
</script> </script>
@ -77,8 +77,11 @@
<li> <li>
<span>{_channels.name}</span> <span>{_channels.name}</span>
<button on:click={() => selectChat(_channels.id)}>Enter</button> <button on:click={() => selectChat(_channels.id)}>Enter</button>
<button on:click={() => removeChannel(_channels.id)} on:keydown={() => removeChannel(_channels.id)}>delete</button> <button
{/each} on:click={() => removeChannel(_channels.id)}
on:keydown={() => removeChannel(_channels.id)}>delete</button
>
</li>{/each}
{:else} {:else}
<p>No channels available</p> <p>No channels available</p>
{/if} {/if}

33
front/volume/src/components/Chat.svelte

@ -68,7 +68,7 @@
{ username: "user7" }, { username: "user7" },
{ username: "user8" }, { username: "user8" },
{ username: "user9" }, { username: "user9" },
] ];
// let chatMembers: Array<Player> = []; // let chatMembers: Array<Player> = [];
// async function getChatMembers() { // async function getChatMembers() {
// console.log("Getting chat members"); // console.log("Getting chat members");
@ -105,19 +105,29 @@
> >
<ul> <ul>
<li> <li>
<button on:click={() => dispatch("send-message", selectedUser)}>Send Message</button> <button on:click={() => dispatch("send-message", selectedUser)}
>Send Message</button
>
</li> </li>
<li> <li>
<button on:click={() => dispatch("view-profile", selectedUser)}>View Profile</button> <button on:click={() => dispatch("view-profile", selectedUser)}
>View Profile</button
>
</li> </li>
<li> <li>
<button on:click={() => dispatch("add-friend", selectedUser)}>Add Friend</button> <button on:click={() => dispatch("add-friend", selectedUser)}
>Add Friend</button
>
</li> </li>
<li> <li>
<button on:click={() => dispatch("invite-to-game", selectedUser)}>Invite to Game</button> <button on:click={() => dispatch("invite-to-game", selectedUser)}
>Invite to Game</button
>
</li> </li>
<li> <li>
<button on:click={() => dispatch("block-user", selectedUser)}>Block User</button> <button on:click={() => dispatch("block-user", selectedUser)}
>Block User</button
>
</li> </li>
<li><button on:click={closeProfileMenu}>Close</button></li> <li><button on:click={closeProfileMenu}>Close</button></li>
</ul> </ul>
@ -129,9 +139,16 @@
<img src="img/send.png" alt="send" /> <img src="img/send.png" alt="send" />
</button> </button>
</form> </form>
<button on:click|stopPropagation={toggleChatMembers} on:keydown|stopPropagation>Chat Members</button> <button
on:click|stopPropagation={toggleChatMembers}
on:keydown|stopPropagation>Chat Members</button
>
{#if showChatMembers} {#if showChatMembers}
<div class="chatMembers" on:click|stopPropagation on:keydown|stopPropagation> <div
class="chatMembers"
on:click|stopPropagation
on:keydown|stopPropagation
>
<div> <div>
<ul> <ul>
{#each chatMembers as member} {#each chatMembers as member}

6
front/volume/src/components/Pong/Game.ts

@ -24,9 +24,9 @@ export class Game {
ranked: boolean; ranked: boolean;
youAreReady: boolean; youAreReady: boolean;
private readonly score_audio = new Audio('audio/score.wav'); private readonly score_audio = new Audio("audio/score.wav");
private readonly paddle_hit_audio = new Audio('audio/paddle_hit.wav'); private readonly paddle_hit_audio = new Audio("audio/paddle_hit.wav");
private readonly edge_hit_audio = new Audio('audio/edge_hit.wav'); private readonly edge_hit_audio = new Audio("audio/edge_hit.wav");
constructor( constructor(
renderCanvas: HTMLCanvasElement, renderCanvas: HTMLCanvasElement,

36
front/volume/src/components/Pong/constants.ts

@ -1,21 +1,21 @@
import { Point } from './utils' import { Point } from "./utils";
export const GAME_EVENTS = { export const GAME_EVENTS = {
START_GAME: 'START_GAME', START_GAME: "START_GAME",
READY: 'READY', READY: "READY",
GAME_TICK: 'GAME_TICK', GAME_TICK: "GAME_TICK",
PLAYER_MOVE: 'PLAYER_MOVE', PLAYER_MOVE: "PLAYER_MOVE",
GET_GAME_INFO: 'GET_GAME_INFO', GET_GAME_INFO: "GET_GAME_INFO",
CREATE_GAME: 'CREATE_GAME', CREATE_GAME: "CREATE_GAME",
REGISTER_PLAYER: 'REGISTER_PLAYER', REGISTER_PLAYER: "REGISTER_PLAYER",
MATCHMAKING: 'MATCHMAKING', MATCHMAKING: "MATCHMAKING",
LEAVE_GAME: 'LEAVE_GAME' LEAVE_GAME: "LEAVE_GAME",
} };
export const DEFAULT_MAP_SIZE = new Point(500, 400) export const DEFAULT_MAP_SIZE = new Point(500, 400);
export const DEFAULT_PADDLE_SIZE = new Point(6, 30) export const DEFAULT_PADDLE_SIZE = new Point(6, 30);
export const DEFAULT_BALL_SIZE = new Point(10, 10) export const DEFAULT_BALL_SIZE = new Point(10, 10);
export const DEFAULT_BALL_INITIAL_SPEED = new Point(10, 2) export const DEFAULT_BALL_INITIAL_SPEED = new Point(10, 2);
export const DEFAULT_PLAYER_X_OFFSET = 50 export const DEFAULT_PLAYER_X_OFFSET = 50;
export const DEFAULT_WIN_SCORE = 5 export const DEFAULT_WIN_SCORE = 5;
export const GAME_TICKS = 30 export const GAME_TICKS = 30;

Loading…
Cancel
Save