diff --git a/src/channels/minesweeper/Face.tsx b/src/channels/minesweeper/Face.tsx index 0557396..86c837d 100644 --- a/src/channels/minesweeper/Face.tsx +++ b/src/channels/minesweeper/Face.tsx @@ -1,9 +1,12 @@ import { css } from '@emotion/react'; + import { FACE_DIMENSION, FACE_ORDER } from './constants'; +import type { FaceType } from './types'; import faces from './assets/faces.png'; -export type FaceType = (typeof FACE_ORDER)[number]; +const SPRITES_PER_ROW = 5; +const SPRITESHEET_ROWS = 1; function getFaceOffset(face: FaceType) { const faceIndex = FACE_ORDER.indexOf(face); @@ -18,11 +21,11 @@ export function Face({ face }: FaceProps) { return (
); diff --git a/src/channels/minesweeper/Tile.tsx b/src/channels/minesweeper/Tile.tsx index 62c232d..c93f4dd 100644 --- a/src/channels/minesweeper/Tile.tsx +++ b/src/channels/minesweeper/Tile.tsx @@ -1,13 +1,12 @@ import { css } from '@emotion/react'; + import { TILE_DIMENSION } from './constants'; +import type { TileData } from './types'; import tiles from './assets/tiles.png'; -export type TileData = { - id: string; - tileType: readonly [number, number]; - isMine: boolean; -}; +const SPRITES_PER_ROW = 8; +const SPRITESHEET_ROWS = 2; export function Tile({ tileType }: TileData) { const [x, y] = tileType; @@ -15,10 +14,11 @@ export function Tile({ tileType }: TileData) { return ( ); diff --git a/src/channels/minesweeper/constants.ts b/src/channels/minesweeper/constants.ts index 038fb6a..c6db45b 100644 --- a/src/channels/minesweeper/constants.ts +++ b/src/channels/minesweeper/constants.ts @@ -1,12 +1,14 @@ -export const FACE_DIMENSION = 24; +import type { TileData } from './types'; + +export const FACE_DIMENSION = 36; export const FACE_ORDER = ['smile', 'smile_pressed', 'open_mouth', 'sunglasses', 'heart_eyes'] as const; export const MINE_CHANCE = 0.17; export const GRID_ROWS = 16; -export const GRID_COLUMNS = 67; +export const GRID_COLUMNS = 66; -export const TILE_DIMENSION = 16; +export const TILE_DIMENSION = 16.24; export const TILE_MAP = { HIDDEN: [0, 0], @@ -35,8 +37,8 @@ export const mineNumberTiles = [ TILE_MAP.EIGHT, ]; -export const MIN_REVEAL_DONATION = 20; +export const MIN_REVEAL_DONATION = 25; /** maximum donation amount for determining reveal threshold */ export const REVEAL_DONATION_CAP = 500; export const MIN_REVEALED_TILES = 1; -export const MAX_REVEALED_TILES = 25; +export const MAX_REVEALED_TILES = 15; diff --git a/src/channels/minesweeper/index.tsx b/src/channels/minesweeper/index.tsx index 7c2bc83..b130102 100644 --- a/src/channels/minesweeper/index.tsx +++ b/src/channels/minesweeper/index.tsx @@ -6,24 +6,19 @@ import { ChannelProps, registerChannel } from '../channels'; import { useListenFor, useReplicant } from 'use-nodecg'; import type { Event, FormattedDonation, Total } from '@gdq/types/tracker'; -import { Face, FaceType } from './Face'; -import { Tile, TileData } from './Tile'; +import { Face } from './Face'; +import { Tile } from './Tile'; import { TILE_DIMENSION, GRID_COLUMNS, GRID_ROWS, TILE_MAP, MINE_CHANCE, MIN_REVEAL_DONATION } from './constants'; import { createTileCluster, getTileRevealThreshold, random, randomFromArray, splitTileIndex } from './utils'; import { usePreloadedReplicant } from '@gdq/lib/hooks/usePreloadedReplicant'; import { cloneDeep } from 'lodash'; +import type { FaceType, GridState, TileData } from './types'; registerChannel('Minesweeper', 132, Minesweeper, { position: 'bottomRight', handle: 'rshig', }); -type GridState = { - grid: TileData[][]; - mines: string[]; - nonMines: string[]; -}; - function generateInitialGridState(): GridState { const state: GridState = { grid: [], mines: [], nonMines: [] }; for (let i = 0; i < GRID_ROWS; i++) { @@ -182,8 +177,8 @@ export function Minesweeper(props: ChannelProps) { const flagTimeoutRef = useRef