Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c05b62f
Refactor game data structure and enhance auto-loading functionality
PowerShellYoungTeam Nov 12, 2025
98b12e2
Refactor whitespace and formatting in app.js and Generate-GameData.ps…
PowerShellYoungTeam Nov 14, 2025
a9756a3
Refactor event management system for improved clarity and maintainabi…
PowerShellYoungTeam Nov 14, 2025
9327499
Implement pathfinding system and client-side integration
PowerShellYoungTeam Nov 14, 2025
bac4ae8
Refactor Pathfinding and State Management Modules for Improved Readab…
PowerShellYoungTeam Nov 14, 2025
a235438
Update Game Design Document with author details and enhance game conc…
PowerShellYoungTeam Nov 19, 2025
7ec287f
Refactor module imports and enhance logging initialization for improv…
PowerShellYoungTeam Nov 26, 2025
b4a33a2
Clean up whitespace and formatting in various modules for improved re…
PowerShellYoungTeam Nov 26, 2025
8fb8cdb
Phase 1: Fix CoreGame module loading and add CI/CD
PowerShellYoungTeam Jan 17, 2026
be7a6b6
Phase 2: Complete CharacterSystem implementation + test fixes
PowerShellYoungTeam Jan 17, 2026
e27aa5f
Phase 3: Complete WorldSystem implementation
PowerShellYoungTeam Jan 17, 2026
efb6102
Phase 4: Complete QuestSystem implementation
PowerShellYoungTeam Jan 17, 2026
2b33dba
Phase 5: Implement FactionSystem module with 7 faction types
PowerShellYoungTeam Jan 17, 2026
af2f917
Phase 6: Implement ShopSystem module with comprehensive trading
PowerShellYoungTeam Jan 18, 2026
88fccfa
Phase 7: Implement comprehensive TerminalSystem module
PowerShellYoungTeam Jan 18, 2026
2bf080f
Phase 8: Implement comprehensive DroneSystem (2038 lines, 108 tests)
PowerShellYoungTeam Jan 18, 2026
7df46d1
Phase 9: Add comprehensive integration tests (22 tests passing)
PowerShellYoungTeam Jan 18, 2026
0006aa3
Add integration and module tests for HTTP Bridge Server
PowerShellYoungTeam Jan 21, 2026
c59404f
Update Test-ModuleLoad.ps1
PowerShellYoungTeam Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 51 additions & 9 deletions .github/workflows/powershell-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,66 @@ name: PowerShell Tests

on:
push:
branches: [ main, 'feature/*', 'release/*' ]
branches: [ main, core-architecture, 'feature/*', 'release/*' ]
pull_request:
branches: [ main ]
branches: [ main, core-architecture ]

jobs:
test:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Validate Module Manifests
shell: pwsh
run: |
$manifests = Get-ChildItem -Path ./Modules -Filter "*.psd1" -Recurse
$failed = $false
foreach ($manifest in $manifests) {
Write-Host "Testing manifest: $($manifest.FullName)"
try {
Test-ModuleManifest -Path $manifest.FullName -ErrorAction Stop
Write-Host " ✓ Valid" -ForegroundColor Green
} catch {
Write-Host " ✗ Invalid: $_" -ForegroundColor Red
$failed = $true
}
}
if ($failed) { exit 1 }

- name: Run Pester tests
- name: Test Module Import
shell: pwsh
run: |
Install-Module Pester -Force -SkipPublisherCheck
Invoke-Pester -Path ./Tests -OutputFile test-results.xml -OutputFormat NUnitXml

- name: Upload test results
uses: actions/upload-artifact@v3
Write-Host "Importing CoreGame module..."
Import-Module ./Modules/CoreGame/CoreGame.psd1 -Force -DisableNameChecking -ErrorAction Stop
$exportedFunctions = (Get-Module CoreGame).ExportedFunctions.Count
Write-Host "CoreGame loaded with $exportedFunctions exported functions"
if ($exportedFunctions -lt 50) {
Write-Error "Expected at least 50 exported functions, got $exportedFunctions"
exit 1
}

- name: Install Pester
shell: pwsh
run: |
Install-Module Pester -Force -SkipPublisherCheck -MinimumVersion 5.0
Import-Module Pester

- name: Run Pester Tests
shell: pwsh
run: |
$config = New-PesterConfiguration
$config.Run.Path = "./Tests"
$config.Run.Exit = $true
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = "test-results.xml"
$config.TestResult.OutputFormat = "NUnitXml"
$config.Output.Verbosity = "Detailed"
Invoke-Pester -Configuration $config

- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results.xml
Expand Down
Empty file added Communication-Success-Report.md
Empty file.
1 change: 0 additions & 1 deletion Data/Backups/test-save_20250801_002044.json

This file was deleted.

1 change: 1 addition & 0 deletions Data/Backups/test-save_20251112_210425.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"AdditionalData":{},"Performance":{"LastActivity":"2025-08-01T00:37:39.038934+01:00","AverageLoadTime":0,"SaveCount":0,"SyncCount":0,"LoadCount":0,"AverageSaveTime":0,"TotalDataSize":0,"LastSaveSize":0,"ErrorCount":0},"Entities":{"test-entity-20250801-003739":{"IsDirty":false,"EntityType":"test","Changes":[],"LastModified":"2025-08-01T00:37:39.051054+01:00","State":{"Version":"1.0.0","Id":"test-entity-20250801-003739","OriginalValues":{},"Name":"","UpdatedAt":"2025-08-01T00:37:39.0506457+01:00","Type":"test","CreatedAt":"2025-08-01T00:37:39.0506235+01:00","Metadata":{},"Tags":{},"PropertyChanges":{},"Properties":{},"IsActive":true,"Description":"","IsTrackingChanges":true}}},"GameState":{},"Version":"1.0.0","Metadata":{"GameVersion":"1.0.0","TotalEntities":1,"PlayerCount":0,"SavedAt":"2025-08-01T00:37:39.0522007+01:00","Platform":"PowerShell"}}
2 changes: 1 addition & 1 deletion Data/Saves/test-save.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"AdditionalData":{},"Performance":{"LastActivity":"2025-08-01T00:37:39.038934+01:00","AverageLoadTime":0,"SaveCount":0,"SyncCount":0,"LoadCount":0,"AverageSaveTime":0,"TotalDataSize":0,"LastSaveSize":0,"ErrorCount":0},"Entities":{"test-entity-20250801-003739":{"IsDirty":false,"EntityType":"test","Changes":[],"LastModified":"2025-08-01T00:37:39.051054+01:00","State":{"Version":"1.0.0","Id":"test-entity-20250801-003739","OriginalValues":{},"Name":"","UpdatedAt":"2025-08-01T00:37:39.0506457+01:00","Type":"test","CreatedAt":"2025-08-01T00:37:39.0506235+01:00","Metadata":{},"Tags":{},"PropertyChanges":{},"Properties":{},"IsActive":true,"Description":"","IsTrackingChanges":true}}},"GameState":{},"Version":"1.0.0","Metadata":{"GameVersion":"1.0.0","TotalEntities":1,"PlayerCount":0,"SavedAt":"2025-08-01T00:37:39.0522007+01:00","Platform":"PowerShell"}}
{"AdditionalData":{},"Version":"1.0.0","Performance":{"LoadCount":0,"SaveCount":0,"AverageSaveTime":0,"LastActivity":"2025-11-12T21:04:25.1571824+00:00","AverageLoadTime":0,"TotalDataSize":0,"ErrorCount":0,"LastSaveSize":0,"SyncCount":0},"Entities":{"test-entity-20251112-210425":{"State":{"IsTrackingChanges":true,"OriginalValues":{},"IsActive":true,"UpdatedAt":"2025-11-12T21:04:25.2267045+00:00","Tags":{},"CreatedAt":"2025-11-12T21:04:25.2254424+00:00","Id":"test-entity-20251112-210425","Properties":{},"Type":"test","Metadata":{},"PropertyChanges":{},"Version":"1.0.0","Name":"","Description":""},"LastModified":"2025-11-12T21:04:25.2716066+00:00","IsDirty":false,"Changes":[],"EntityType":"test"}},"Metadata":{"SavedAt":"2025-11-12T21:04:25.2976467+00:00","GameVersion":"1.0.0","Platform":"PowerShell","PlayerCount":0,"TotalEntities":1},"GameState":{}}
Empty file added Demo-CommandRegistry.ps1
Empty file.
Empty file added Demo-CommunicationBridge.ps1
Empty file.
Empty file added Demo-CommunicationSystem.ps1
Empty file.
251 changes: 251 additions & 0 deletions Demo-PlayerMovement.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
# Demo-PlayerMovement.ps1
# Demo script for testing player movement with pathfinding

# Import the CoreGame module using the manifest (which handles all nested modules)
$script:PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$CoreGamePath = Join-Path $script:PSScriptRoot 'Modules\CoreGame'

$ErrorActionPreference = 'Stop'
try {
Write-Host "Loading CoreGame module..." -ForegroundColor Yellow

# Import CoreGame.psd1 - this loads all nested modules in the correct order
Import-Module (Join-Path $CoreGamePath "CoreGame.psd1") -Force -Global -ErrorAction Stop

Write-Host " ✓ CoreGame module loaded (all subsystems included)" -ForegroundColor Green
Write-Host ""
}
catch {
Write-Host "ERROR: Failed to load CoreGame module - $_" -ForegroundColor Red
Write-Host "Error Details: $($_.Exception.Message)" -ForegroundColor Red
if ($_.InvocationInfo) {
Write-Host "At: $($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber)" -ForegroundColor Red
}
exit 1
}

Write-Host "╔════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ Player Movement & Pathfinding Demo ║" -ForegroundColor Cyan
Write-Host "╚════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
Write-Host ""

# Initialize systems
Write-Host "Initializing game systems..." -ForegroundColor Yellow
try {
Initialize-GameLogging
Write-Host " ✓ GameLogging initialized" -ForegroundColor Green

Initialize-EventSystem
Write-Host " ✓ EventSystem initialized" -ForegroundColor Green

Initialize-StateManager | Out-Null
Write-Host " ✓ StateManager initialized" -ForegroundColor Green

Initialize-PathfindingSystem
Write-Host " ✓ PathfindingSystem initialized" -ForegroundColor Green

Initialize-CommunicationBridge
Write-Host " ✓ CommunicationBridge initialized" -ForegroundColor Green
Write-Host ""
}
catch {
Write-Host "`nERROR: Failed to initialize systems - $_" -ForegroundColor Red
Write-Host "Error Details: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

# Create player entity
Write-Host "Creating player entity..." -ForegroundColor Yellow
try {
$player = New-PlayerEntity -Name "TestPlayer"
$player.SetProperty('Position', @{ Lat = 40.7128; Lng = -74.0060 }) # NYC

# Register the player entity with StateManager
Register-GameEntity -EntityId $player.Id -EntityType 'Player' -InitialState @{
Name = $player.Name
Position = $player.Position
}

Write-Host "✓ Player created at position: [$($player.Position.Lat), $($player.Position.Lng)]" -ForegroundColor Green
Write-Host ""
}
catch {
Write-Host "ERROR: Failed to create player - $_" -ForegroundColor Red
Write-Host "Error Details: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

# Register event handlers
Write-Host "Setting up event handlers..." -ForegroundColor Yellow
try {
Register-GameEvent -EventType 'movement.started' -ScriptBlock {
param($Data)
Write-Host "`n[MOVEMENT] Player started moving to [$($Data.Destination.Lat), $($Data.Destination.Lng)]" -ForegroundColor Cyan
Write-Host " Travel mode: $($Data.TravelMode)" -ForegroundColor Gray
Write-Host " Pathfinding: $($Data.PathfindingType)" -ForegroundColor Gray
Write-Host " Distance: $([Math]::Round($Data.Distance, 2))m" -ForegroundColor Gray
} | Out-Null

Register-GameEvent -EventType 'unit.positionUpdated' -ScriptBlock {
param($Data)
Write-Host "[UPDATE] Position updated: [$($Data.NewPosition.Lat), $($Data.NewPosition.Lng)]" -ForegroundColor DarkCyan
} | Out-Null

Register-GameEvent -EventType 'movement.completed' -ScriptBlock {
param($Data)
Write-Host "[ARRIVAL] Player arrived at [$($Data.Position.Lat), $($Data.Position.Lng)]" -ForegroundColor Green
Write-Host ""
} | Out-Null

Register-GameEvent -EventType 'location.entered' -ScriptBlock {
param($Data)
Write-Host "[LOCATION] Player entered: $($Data.LocationName)" -ForegroundColor Magenta
} | Out-Null

Register-GameEvent -EventType 'encounter.random' -ScriptBlock {
param($Data)
Write-Host "[ENCOUNTER] Random encounter: $($Data.EncounterType)!" -ForegroundColor Yellow
} | Out-Null

Write-Host "✓ Event handlers registered" -ForegroundColor Green
Write-Host ""
}
catch {
Write-Host "ERROR: Failed to register event handlers - $_" -ForegroundColor Red
Write-Host "Error Details: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

# Start local server
Write-Host "Starting local web server on http://localhost:8080..." -ForegroundColor Yellow
Write-Host "Opening player-movement-demo.html..." -ForegroundColor Yellow
Write-Host ""

# Start simple HTTP server
$ServerJob = Start-Job -ScriptBlock {
param($RootPath)

$listener = New-Object System.Net.HttpListener
$listener.Prefixes.Add("http://localhost:8080/")
$listener.Start()

Write-Host "Server started on http://localhost:8080" -ForegroundColor Green

while ($listener.IsListening) {
$context = $listener.GetContext()
$request = $context.Request
$response = $context.Response

$path = $request.Url.LocalPath
if ($path -eq '/') { $path = '/player-movement-demo.html' }

$filePath = Join-Path $RootPath $path.TrimStart('/')

if (Test-Path $filePath) {
$content = [System.IO.File]::ReadAllBytes($filePath)

# Set content type
$ext = [System.IO.Path]::GetExtension($filePath)
$contentType = switch ($ext) {
'.html' { 'text/html' }
'.js' { 'application/javascript' }
'.css' { 'text/css' }
'.json' { 'application/json' }
default { 'application/octet-stream' }
}

$response.ContentType = $contentType
$response.StatusCode = 200
$response.OutputStream.Write($content, 0, $content.Length)
}
else {
$response.StatusCode = 404
$errorMsg = [System.Text.Encoding]::UTF8.GetBytes("404 - File not found: $path")
$response.OutputStream.Write($errorMsg, 0, $errorMsg.Length)
}

$response.Close()
}

$listener.Stop()
} -ArgumentList $PSScriptRoot

# Wait for server to start
Start-Sleep -Seconds 2

# Open browser
Start-Process "http://localhost:8080/player-movement-demo.html"

Write-Host "╔════════════════════════════════════════════════════════╗" -ForegroundColor Green
Write-Host "║ Demo is now running! ║" -ForegroundColor Green
Write-Host "╚════════════════════════════════════════════════════════╝" -ForegroundColor Green
Write-Host ""
Write-Host "Instructions:" -ForegroundColor Yellow
Write-Host " 1. Click anywhere on the map to move the player" -ForegroundColor White
Write-Host " 2. Select different travel modes (foot, car, etc.)" -ForegroundColor White
Write-Host " 3. Watch the path calculation and animation" -ForegroundColor White
Write-Host " 4. Check this console for event logs" -ForegroundColor White
Write-Host ""
Write-Host "Active Systems:" -ForegroundColor Yellow
Write-Host " ✓ PathfindingSystem - Handles movement logic" -ForegroundColor Green
Write-Host " ✓ EventSystem - Broadcasts movement events" -ForegroundColor Green
Write-Host " ✓ StateManager - Tracks player position" -ForegroundColor Green
Write-Host " ✓ CommunicationBridge - Frontend ↔ Backend sync" -ForegroundColor Green
Write-Host ""
Write-Host "Press Ctrl+C to stop the demo..." -ForegroundColor Cyan
Write-Host ""

# Keep script running and process commands from frontend
try {
while ($true) {
# Process bridge commands
$commands = Receive-BridgeCommands

foreach ($cmd in $commands) {
try {
switch ($cmd.Type) {
'StartMovement' {
Start-UnitMovement -UnitId $player.Id -Destination $cmd.Destination -TravelMode $cmd.TravelMode
}
'StopMovement' {
Stop-UnitMovement -UnitId $player.Id
}
'UpdatePosition' {
Update-UnitPosition -UnitId $player.Id -Position $cmd.Position
}
'CompleteMovement' {
Complete-UnitMovement -UnitId $player.Id -FinalPosition $cmd.FinalPosition
}
}
}
catch {
Write-Host "Error processing command: $_" -ForegroundColor Red
}
}

# Process game events
try {
$events = Get-GameEvent
foreach ($event in $events) {
# Events are already handled by registered handlers
}
}
catch {
# Silently continue if event processing fails
}

# Small delay to prevent CPU spinning
Start-Sleep -Milliseconds 100
}
}
finally {
# Cleanup
Write-Host "`nShutting down..." -ForegroundColor Yellow

if ($ServerJob) {
Stop-Job $ServerJob
Remove-Job $ServerJob
}

Write-Host "✓ Demo stopped" -ForegroundColor Green
}
36 changes: 36 additions & 0 deletions Docs/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,42 @@ Log Sources ──► GameLogging ──► Multiple Outputs
└─ Context Data ────┘
```

## Module Loading Architecture

The CoreGame module uses an **Import-Module approach** in the root module rather than `NestedModules` in the manifest. This design decision was made to properly handle function scoping across PowerShell versions.

### Load Order
```
CoreGame.psm1 (root)
├── Import GameLogging.psm1 (no dependencies)
├── Import DataModels.psm1 (no dependencies)
├── Import EventSystem.psm1 (depends on GameLogging)
├── Import StateManager.psm1 (depends on DataModels, EventSystem)
├── Import PathfindingSystem.psm1 (depends on GameLogging, EventSystem, StateManager, DataModels)
├── Import CommunicationBridge.psm1 (depends on GameLogging, EventSystem)
└── Import CommandRegistry.psm1 (depends on GameLogging, EventSystem)
```

### Usage Pattern
```powershell
# Single import loads all subsystems
Import-Module ./Modules/CoreGame/CoreGame.psd1 -Force

# Initialize all systems at once
Initialize-GameEngine -DebugMode

# Or initialize individually
Initialize-GameLogging
Initialize-EventSystem
Initialize-StateManager
```

### Function Export Strategy
The manifest (`CoreGame.psd1`) explicitly lists all exported functions from all submodules. This follows Microsoft best practices for:
- **Performance**: Explicit exports are faster than wildcards
- **Discoverability**: Clear documentation of public API
- **Maintainability**: Changes to exports are version-controlled

### Specialized Modules

#### Character System (Modules/CharacterSystem/)
Expand Down
Loading
Loading