-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
aa308f8
commit 211ec59
Showing
10 changed files
with
151 additions
and
34 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
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,34 @@ | ||
import type { IPlayer } from '../types'; | ||
|
||
const CURSOR_STARTING_POSITION: number = 0; | ||
|
||
export default class GameState { | ||
private _cursorPosition: number = CURSOR_STARTING_POSITION; | ||
|
||
private get _playerPosition() { | ||
return Math.floor(this._cursorPosition / 2); | ||
} | ||
|
||
private get _playerCardPosition() { | ||
return this._cursorPosition % 2; | ||
} | ||
|
||
public players: IPlayer[] = [ | ||
{ name: 'Player 1', cards: [] }, | ||
{ name: 'Player 2', cards: [] }, | ||
{ name: 'Player 3', cards: [] } | ||
]; | ||
|
||
public setCard(card: string): void { | ||
this.players[this._playerPosition].cards[this._playerCardPosition] = card; | ||
this._cursorPosition++; | ||
} | ||
|
||
public reset(): void { | ||
this._cursorPosition = CURSOR_STARTING_POSITION; | ||
|
||
this.players.forEach((player) => { | ||
player.cards = []; | ||
}); | ||
} | ||
} |
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 @@ | ||
import { writable } from 'svelte/store'; | ||
|
||
function createCardIconStore() { | ||
const { subscribe, set, update } = writable<Record<string, boolean>>({}); | ||
|
||
return { | ||
subscribe, | ||
set, | ||
update, | ||
reset: () => set({}) | ||
}; | ||
} | ||
|
||
export const cardIconStore = createCardIconStore(); |
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,4 @@ | ||
export interface IPlayer { | ||
name: string; | ||
cards: (string | null)[]; | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
html { | ||
font-size: 62.5%; | ||
font-size: 62.5%; | ||
} | ||
|
||
body { | ||
font-family: 'Roboto', sans-serif; | ||
font-size: 1.6rem; | ||
font-family: 'Roboto', sans-serif; | ||
font-size: 1.6rem; | ||
} | ||
|
||
h4 { | ||
font-size: 2.1rem; | ||
} | ||
font-size: 2.1rem; | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"status": "passed", | ||
"failedTests": [] | ||
} | ||
"status": "passed", | ||
"failedTests": [] | ||
} |