diff --git a/back/src/main/java/be/naaturel/unluckiest/entities/ScoreEntity.java b/back/src/main/java/be/naaturel/unluckiest/entities/ScoreEntity.java index 678caea..3461486 100644 --- a/back/src/main/java/be/naaturel/unluckiest/entities/ScoreEntity.java +++ b/back/src/main/java/be/naaturel/unluckiest/entities/ScoreEntity.java @@ -2,6 +2,8 @@ package be.naaturel.unluckiest.entities; import jakarta.persistence.*; +import java.math.BigDecimal; + @Entity(name = "Score") public class ScoreEntity { @@ -13,6 +15,6 @@ public class ScoreEntity { public String owner; @Column - public int value; + public float value; } \ No newline at end of file diff --git a/back/src/main/java/be/naaturel/unluckiest/models/Score.java b/back/src/main/java/be/naaturel/unluckiest/models/Score.java index 1566ddf..67d9c3f 100644 --- a/back/src/main/java/be/naaturel/unluckiest/models/Score.java +++ b/back/src/main/java/be/naaturel/unluckiest/models/Score.java @@ -3,9 +3,9 @@ package be.naaturel.unluckiest.models; public class Score { private String owner; - private int value; + private float value; - public Score(String owner, int value){ + public Score(String owner, float value){ this.owner = owner; this.value = value; } @@ -14,7 +14,7 @@ public class Score { return this.owner; } - public int getValue(){ + public float getValue(){ return this.value; } diff --git a/front/.env.development b/front/.env.development index a0d265a..f3f699a 100644 --- a/front/.env.development +++ b/front/.env.development @@ -1,2 +1,2 @@ -VITE_CLIENT_API_URL=http://127.0.0.1:5000/api -VITE_SERVER_API_URL=http://127.0.0.1:5000/api \ No newline at end of file +VITE_CLIENT_API_URL=http://127.0.0.1:5000 +VITE_SERVER_API_URL=http://127.0.0.1:5000 \ No newline at end of file diff --git a/front/.gitignore b/front/.gitignore index 230a6d8..81d7c37 100644 --- a/front/.gitignore +++ b/front/.gitignore @@ -132,3 +132,5 @@ dist /.svelte-kit/ /.svelte-kit/ /.svelte-kit/ +/.idea/ +/.idea/ diff --git a/front/.idea/unluckiest.iml b/front/.idea/unluckiest.iml deleted file mode 100644 index d6ebd48..0000000 --- a/front/.idea/unluckiest.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/front/.svelte-kit/ambient.d.ts b/front/.svelte-kit/ambient.d.ts index f57c813..66f84fe 100644 --- a/front/.svelte-kit/ambient.d.ts +++ b/front/.svelte-kit/ambient.d.ts @@ -42,7 +42,7 @@ declare module '$env/static/private' { export const DB_USER: string; export const DriverData: string; export const EDITOR: string; - export const EFC_10388: string; + export const EFC_9404: string; export const ffmpeg: string; export const FPS_BROWSER_APP_PROFILE_STRING: string; export const FPS_BROWSER_USER_PROFILE_STRING: string; @@ -150,7 +150,7 @@ declare module '$env/dynamic/private' { DB_USER: string; DriverData: string; EDITOR: string; - EFC_10388: string; + EFC_9404: string; ffmpeg: string; FPS_BROWSER_APP_PROFILE_STRING: string; FPS_BROWSER_USER_PROFILE_STRING: string; diff --git a/front/.svelte-kit/generated/server/internal.js b/front/.svelte-kit/generated/server/internal.js index dc6322c..7cb4c7e 100644 --- a/front/.svelte-kit/generated/server/internal.js +++ b/front/.svelte-kit/generated/server/internal.js @@ -18,10 +18,10 @@ export const options = { root, service_worker: false, templates: { - app: ({ head, body, assets, nonce, env }) => "\n\n\t\n\t\tUnluckiest\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\n\t\t\n\n\t\t" + head + "\n\t\n\t\n\t\t
" + body + "
\n\t\n\n", + app: ({ head, body, assets, nonce, env }) => "\n\n\t\n\t\tUnluckiest\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\n\t\t\n\n\t\t\n\t\t\n\n\t\t" + head + "\n\t\n\n\t\n\n\t\t
" + body + "
\n\n\t\n\n", error: ({ status, message }) => "\n\n\t\n\t\t\n\t\t" + message + "\n\n\t\t\n\t\n\t\n\t\t
\n\t\t\t" + status + "\n\t\t\t
\n\t\t\t\t

" + message + "

\n\t\t\t
\n\t\t
\n\t\n\n" }, - version_hash: "3iwm3b" + version_hash: "feblej" }; export async function get_hooks() { diff --git a/front/src/app.d.ts b/front/src/app.d.ts index 743f07b..f0b4d45 100644 --- a/front/src/app.d.ts +++ b/front/src/app.d.ts @@ -1,5 +1,6 @@ // See https://kit.svelte.dev/docs/types#app // for information about these interfaces + declare global { namespace App { // interface Error {} diff --git a/front/src/app.html b/front/src/app.html index 1e34ab3..f6fc628 100644 --- a/front/src/app.html +++ b/front/src/app.html @@ -13,16 +13,22 @@ - + - + + + + %sveltekit.head% + +
%sveltekit.body%
+ diff --git a/front/src/lib/assets/about.svg b/front/src/lib/assets/about.svg new file mode 100644 index 0000000..09fd08b --- /dev/null +++ b/front/src/lib/assets/about.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/src/lib/assets/arrow.svg b/front/src/lib/assets/arrow.svg new file mode 100644 index 0000000..e403d07 --- /dev/null +++ b/front/src/lib/assets/arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/src/lib/assets/dice.svg b/front/src/lib/assets/dice.svg new file mode 100644 index 0000000..d578a1f --- /dev/null +++ b/front/src/lib/assets/dice.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/src/lib/assets/leaderboard.svg b/front/src/lib/assets/leaderboard.svg new file mode 100644 index 0000000..457af63 --- /dev/null +++ b/front/src/lib/assets/leaderboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/src/lib/assets/plain_arrow_left.svg b/front/src/lib/assets/plain_arrow_left.svg new file mode 100644 index 0000000..817bbc4 --- /dev/null +++ b/front/src/lib/assets/plain_arrow_left.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/src/lib/assets/plain_arrow_right.svg b/front/src/lib/assets/plain_arrow_right.svg new file mode 100644 index 0000000..da082da --- /dev/null +++ b/front/src/lib/assets/plain_arrow_right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/src/lib/components/LeaderBoard.svelte b/front/src/lib/components/LeaderBoard.svelte index 2366914..c949d92 100644 --- a/front/src/lib/components/LeaderBoard.svelte +++ b/front/src/lib/components/LeaderBoard.svelte @@ -12,9 +12,13 @@ {/if} {#each scores as score, i} -
  • -
    {score.owner}
    {score.value} pts.
    -
  • + {#if i <= 100} +
  • +
    {i+1}
    +
    {score.owner}
    +
    {score.value}%
    +
  • + {/if} {/each} @@ -26,7 +30,7 @@ display: flex; flex-direction: column; - width: 60vw; + width: 75vw; height: 65vh; padding: 0 2vw 2vw 2vw; @@ -38,40 +42,57 @@ display: none; } - li + .item { display: flex; justify-content: space-around; padding: 1.25vh; margin: 1.5vh; - border: 2px solid #A1674A; + background-color: #fcdcab; + border: 3px solid #4b0611; border-radius: 10px; - background-color: #f1ecec; - box-shadow: 0 0 10px #343232; + box-shadow: 5px 5px #4b0611; + outline: none; } - li:hover + .item:hover { + background-color: #dd3328; transform: scale(1.075); - background-color: #F5F5F5; + } + + .position, .name, .score + { + flex-basis: 0; } .name, .score { - color: black; - margin-left: 3vh; + padding-left: 7px; + border-left: 1px solid #A1674A; + } + + .position + { + flex-grow: 5; + margin-right: 10px; + text-align: center; } .name { + word-break: break-word; flex-grow: 100; - border-right: 1px solid #A1674A; } .score { - flex-grow: 20; + flex-grow: 10; text-align: center; } + + @media screen and (min-width: 601px) { + .leaderboard { width: 55vw; } + } diff --git a/front/src/lib/components/PageTitle.svelte b/front/src/lib/components/PageTitle.svelte new file mode 100644 index 0000000..749ad90 --- /dev/null +++ b/front/src/lib/components/PageTitle.svelte @@ -0,0 +1,10 @@ +

    + +

    + + \ No newline at end of file diff --git a/front/src/lib/components/SplashScreen.svelte b/front/src/lib/components/SplashScreen.svelte new file mode 100644 index 0000000..e9f4785 --- /dev/null +++ b/front/src/lib/components/SplashScreen.svelte @@ -0,0 +1,47 @@ + + +
    + +
    + + \ No newline at end of file diff --git a/front/src/lib/models/game.ts b/front/src/lib/models/game.ts new file mode 100644 index 0000000..8dedf7c --- /dev/null +++ b/front/src/lib/models/game.ts @@ -0,0 +1,41 @@ +export class Game { + + public playerName : string; + public result : number; + public state : GameState; + private readonly range : number; + + constructor() { + this.playerName = ""; + this.result = -1; + this.state = GameState.Unplayed; + this.range = 100 + } + + public play() { + this.result = this.getRandomNumber(); + } + + public playerExists() : boolean{ + return false; + } + + private getRandomNumber() : number{ + let unit = Math.floor(Math.random() * (this.range + 1)); + + if(unit === 100){ + let modifier = Math.floor(Math.random() * (this.range + 1)); + return unit*modifier; + } + + let dec = Math.floor(Math.random() * (this.range)); + return unit + (dec/100); + } + +} + +export enum GameState { + Unplayed, + Running, + Played, +} \ No newline at end of file diff --git a/front/src/lib/stores/scoreStore.ts b/front/src/lib/stores/scoreStore.ts index 59ce405..aceabba 100644 --- a/front/src/lib/stores/scoreStore.ts +++ b/front/src/lib/stores/scoreStore.ts @@ -5,7 +5,7 @@ import {getLeaderboard, submitScore} from "./requests"; let scores : Score[] = [] function sort(scores : Score[]){ - if(scores.length >= 2) scores.sort((s1 : Score, s2 : Score) => s1.value - s2.value) + if(scores.length >= 2) scores.sort((s1 : Score, s2 : Score) => s2.value - s1.value) return scores; } diff --git a/front/src/routes/+layout.svelte b/front/src/routes/+layout.svelte index 6fd30d7..72aff1f 100644 --- a/front/src/routes/+layout.svelte +++ b/front/src/routes/+layout.svelte @@ -1,33 +1,59 @@ -
    @@ -35,7 +61,10 @@
    \ No newline at end of file diff --git a/front/src/routes/+page.svelte b/front/src/routes/+page.svelte index d1b6806..e70a32e 100644 --- a/front/src/routes/+page.svelte +++ b/front/src/routes/+page.svelte @@ -2,15 +2,16 @@ import LeaderBoard from "$lib/components/LeaderBoard.svelte"; import {scoreStore} from "$lib/stores/scoreStore.ts"; import {onMount} from "svelte"; + import PageTitle from "$lib/components/PageTitle.svelte"; let { data } = $props() onMount(async () => { scoreStore.load(data.leaderboard) - } ) + }) - - +Qui va y passer ? + \ No newline at end of file diff --git a/front/src/routes/about/+page.svelte b/front/src/routes/about/+page.svelte index 1b00494..f401e03 100644 --- a/front/src/routes/about/+page.svelte +++ b/front/src/routes/about/+page.svelte @@ -1 +1,49 @@ -

    It was revealed to me in a dream

    \ No newline at end of file + +A propos + +
    +
    +

    Design

    +

    Arwen Hirsoux

    +
    + +
    + +
    +

    Développement

    +

    Laurent Crema

    +
    + +
    + + + \ No newline at end of file diff --git a/front/src/routes/play/+page.svelte b/front/src/routes/play/+page.svelte index 459e55a..8bfb7fc 100644 --- a/front/src/routes/play/+page.svelte +++ b/front/src/routes/play/+page.svelte @@ -1,61 +1,98 @@ +Évaluez vos chances de survie
    -
    - - - -
    Rolling a random numbers within range 0-{range}...
    -
    -
    - - -
    -
    + {#if isRunning} +
    + + + +
    Massacre en cours...
    +
    + {/if} + {#if !isRunning && !hasBeenPlayed} + +
    + debounce(value)} + on:blur={({ target: { value } }) => debounce(value)} + /> + Bomb +
    + + + {/if} + + {#if hasBeenPlayed} +
    Vous avez {game.result}% de chance de mourir
    + {/if} +
    \ No newline at end of file diff --git a/front/static/style/app.css b/front/static/style/app.css index 7972fdd..2018a26 100644 --- a/front/static/style/app.css +++ b/front/static/style/app.css @@ -1,11 +1,34 @@ -:root +@media screen and (min-width: 601px) { + :root { + --font-size : 18px; + } +} + +@media screen and (max-width: 600px) { + :root { + --font-size : 15px; + } +} + +/* For debugging purposes +* { + outline: 1px solid #2600ff; +} +*/ + +* { - --font-size : 1.25vmax; + color: #4b0611; +} + +*, +*::before, +*::after { + box-sizing: border-box; } * { - color: #F5F5F5; text-decoration: none; font-size: var(--font-size, 1vw); transition: 0.3s; @@ -13,7 +36,17 @@ h1 { - font-size: calc(var(--font-size, 1vw) * 2.5); + font-size: calc(var(--font-size, 1vw) * 2.15); + text-align: center; +} + +html, body +{ + height: 100%; + width: 100%; + margin: 0; + padding: 0; + overflow: hidden; } html @@ -35,8 +68,6 @@ body align-items: center; justify-content: center; - - height: 98vh; } .container @@ -58,7 +89,7 @@ hr { } -nav +/*nav { display: flex; flex-direction: column; @@ -81,7 +112,7 @@ nav a .nav_delimiter { margin-bottom: 5vh; -} +}*/ form { @@ -92,19 +123,7 @@ form margin-bottom: 10vh; } -input -{ - color: #424242; - font-size: 2.5vh; - width: 20vw; - height: 4.5vh; - - padding: 1vh; - margin: 1.5vh; - - text-align: center; -} .bordered { @@ -118,13 +137,18 @@ footer align-items: center; position: absolute; - bottom: 0.25vh; - margin-bottom: 0.25vh; + bottom: 0; width: 100vw; - height: 5vh; + height: 10vh; } footer a { margin-right: 2vh; } + +.footer-logo { + height: 100%; + margin-right: 10px; + margin-bottom: 10px; +} diff --git a/front/static/style/menu2.css b/front/static/style/menu2.css new file mode 100644 index 0000000..ec6c5b0 --- /dev/null +++ b/front/static/style/menu2.css @@ -0,0 +1,78 @@ +.menu-collapsed, .menu-expanded { + position: fixed; + top: 0; + left: 0; + margin: 0; + padding: 0; + height: 100vh; + z-index: 9999; + list-style-type: none; + background: rgb(252, 220, 171, 0.85); + overflow: hidden; + transition: width .3s; +} + +.menu-collapsed .menu-item{ + display: none; +} + +.menu-expanded, .menu-collapsed { + display: flex; + flex-direction: column; + align-items: start; +} + +.menu-expanded { + width: 300px; +} + +.expander, .menu-item { + display: flex; + flex-direction: row; + align-items: center; + margin: 15px 30px 0 5px; + border-radius: 5px; + height: fit-content; + width: 250px; +} + +.expander, .menu-item { + text-decoration: none; + margin: 15px 5px 5px 5px; + padding: 5px; +} + +.item-title { + margin-left: 5%; + color: #4b0611; +} + +.menu-item:hover { + background: #dd3328; +} + +.menu-item .item-hint:hover { + transition: 0.3s; + transform: rotate(360deg); +} + +.menu-expanded .expander .item-hint { + transform: rotate(180deg); +} + +@media screen and (max-width: 600px) { + .menu-collapsed { + width: 45px + } + + .item-hint { + width: 20px; + height: 20px; + } +} + +@media screen and (min-width: 601px) { + .menu-collapsed { + width: 60px; + } +} \ No newline at end of file