Move the board into a writable store

This commit is contained in:
Oliver Akins 2022-07-20 21:13:41 -06:00
parent 4ca083e570
commit 9508a7e66a
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99
2 changed files with 13 additions and 33 deletions

View file

@ -1,38 +1,18 @@
<script lang="ts"> <script lang="ts">
import Spaceship from "./icons/spaceship.svelte"; import Spaceship from "./icons/spaceship.svelte";
import Hexagon from "./Hexagon.svelte"; import Hexagon from "./Hexagon.svelte";
import type { PlayerData } from "common"; import { board } from "../stores";
const board: PlayerData[] = new Array(54).fill(null); const ship = `space-shuttle`
// board[5] = {colour: {name: "Green",hex: `#00aa00`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
board[5] = { // board[10] = {colour: {name: "Magenta",hex: `#0077b6`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
colour: { // board[18] = {colour: {name: "Pink",hex: `#cb0b0a`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
name: "Green", // board[21] = {colour: {name: "Magenta",hex: `#7400b8`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
hex: `#00aa00` // board[26] = {colour: {name: "Magenta",hex: `#faa307`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
}, // board[32] = {colour: {name: "Magenta",hex: `#9ef01a`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
name: `Oliver`, // board[43] = {colour: {name: "Magenta",hex: `#b7094c`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
ship: { // board[47] = {colour: {name: "Magenta",hex: `#f72585`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
id: `space-shuttle`, board[53] = {colour: {name: "Magenta",hex: `#f9c80e`},name: `Oliver`,ship: {id: ship,name: `Space Shuttle`},host: false,}
name: `Space Shuttle`
},
host: false,
}
board[18] = {
colour: {
name: "Pink",
hex: `#f72585`
},
name: `Oliver`,
ship: {
id: `space-shuttle`,
name: `Space Shuttle`
},
host: false,
}
function calculateMidNumber(row: number, col: number) {
return col + (( row * 10 ) + (1 * row));
};
</script> </script>

View file

@ -1,8 +1,8 @@
import type { PlayerData } from "common"; import type { Board, PlayerData } from "common";
import { writable } from "svelte/store"; import { writable } from "svelte/store";
export const gameCode = writable<string>(""); export const gameCode = writable<string>("");
export const state = writable<string>("main-menu"); export const state = writable<string>("main-menu");
export const myName = writable<string>(""); export const myName = writable<string>("");
export const isHost = writable<boolean>(false); export const isHost = writable<boolean>(false);
export const players = writable<PlayerData[]>(); export const board = writable<Board>(new Array(54).fill(null));