Add levelling up mechanics through experience gained via killing enemies

This commit is contained in:
Peter Stockings
2026-01-04 18:36:31 +11:00
parent 42cd77998d
commit 29e46093f5
11 changed files with 373 additions and 84 deletions

View File

@@ -1,6 +1,8 @@
import { describe, it, expect } from 'vitest';
import { idx, inBounds, isWall, isBlocked } from '../world/world-logic';
import { type World, type Tile } from '../../core/types';
import { GAME_CONFIG } from '../../core/config/GameConfig';
describe('World Utilities', () => {
const createTestWorld = (width: number, height: number, tiles: Tile[]): World => ({
@@ -44,9 +46,10 @@ describe('World Utilities', () => {
describe('isWall', () => {
it('should return true for wall tiles', () => {
const tiles: Tile[] = new Array(100).fill(0);
tiles[0] = 1; // wall at 0,0
tiles[55] = 1; // wall at 5,5
const tiles: Tile[] = new Array(100).fill(GAME_CONFIG.terrain.empty);
tiles[0] = GAME_CONFIG.terrain.wall; // wall at 0,0
tiles[55] = GAME_CONFIG.terrain.wall; // wall at 5,5
const world = createTestWorld(10, 10, tiles);
@@ -55,11 +58,12 @@ describe('World Utilities', () => {
});
it('should return false for floor tiles', () => {
const tiles: Tile[] = new Array(100).fill(0);
const tiles: Tile[] = new Array(100).fill(GAME_CONFIG.terrain.empty);
const world = createTestWorld(10, 10, tiles);
expect(isWall(world, 3, 3)).toBe(false);
expect(isWall(world, 7, 7)).toBe(false);
});
it('should return false for out of bounds coordinates', () => {
@@ -72,8 +76,9 @@ describe('World Utilities', () => {
describe('isBlocked', () => {
it('should return true for walls', () => {
const tiles: Tile[] = new Array(100).fill(0);
tiles[55] = 1; // wall at 5,5
const tiles: Tile[] = new Array(100).fill(GAME_CONFIG.terrain.empty);
tiles[55] = GAME_CONFIG.terrain.wall; // wall at 5,5
const world = createTestWorld(10, 10, tiles);