Begin refactoring GameScene

This commit is contained in:
Peter Stockings
2026-01-26 15:30:14 +11:00
parent 1d7be54fd9
commit ef7d85750f
46 changed files with 2459 additions and 1291 deletions

View File

@@ -1,3 +1,4 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
// Mock Phaser
@@ -18,6 +19,10 @@ vi.mock('phaser', () => {
return {
default: {
GameObjects: {
Sprite: vi.fn(() => mockSprite),
Graphics: vi.fn(() => mockGraphics),
},
Scene: class {
add = {
graphics: vi.fn(() => mockGraphics),
@@ -37,11 +42,11 @@ vi.mock('../../../engine/gameplay/CombatLogic', () => ({
import { TargetingSystem } from '../TargetingSystem';
import { traceProjectile, getClosestVisibleEnemy } from '../../../engine/gameplay/CombatLogic';
import { TILE_SIZE } from '../../../core/constants';
import type { EntityId } from '../../../core/types';
describe('TargetingSystem', () => {
let targetingSystem: TargetingSystem;
let mockWorld: any;
let mockEntityManager: any;
let mockScene: any;
let mockGraphics: any;
let mockSprite: any;
@@ -72,7 +77,6 @@ describe('TargetingSystem', () => {
targetingSystem = new TargetingSystem(mockScene);
mockWorld = { width: 10, height: 10 };
mockEntityManager = {};
// Default return for traceProjectile
(traceProjectile as any).mockReturnValue({
@@ -97,8 +101,8 @@ describe('TargetingSystem', () => {
'item-1',
playerPos,
mockWorld,
mockEntityManager!,
1 as any,
{} as any, // accessor
1 as EntityId, // playerId
new Uint8Array(100),
10
);
@@ -118,8 +122,8 @@ describe('TargetingSystem', () => {
'item-1',
playerPos,
mockWorld,
mockEntityManager!,
1 as any,
{} as any, // accessor
1 as EntityId, // playerId
new Uint8Array(100),
10,
mousePos
@@ -144,8 +148,8 @@ describe('TargetingSystem', () => {
'item-1',
playerPos,
mockWorld,
mockEntityManager!,
1 as any,
{} as any, // accessor
1 as EntityId,
new Uint8Array(100),
10,
targetPos