This guide helps you migrate from the previous module versions to the enhanced versions with improved verbose handling, cross-module communication, and proper entity management.
❌ Old (will cause errors):
Initialize-EventSystem -GamePath "." -Verbose
Register-GameEvent -EventType "test" -ScriptBlock { } -Verbose
Send-GameEvent -EventType "test" -Data @{} -Verbose
Initialize-CommandRegistry -Configuration @{} -Verbose✅ New (correct approach):
# Option 1: Global verbose preference
$VerbosePreference = 'Continue'
Initialize-EventSystem -GamePath "."
Register-GameEvent -EventType "test" -ScriptBlock { }
Send-GameEvent -EventType "test" -Data @{}
Initialize-CommandRegistry -Configuration @{}
# Option 2: Scoped verbose preference
& {
$VerbosePreference = 'Continue'
Initialize-EventSystem -GamePath "."
Register-GameEvent -EventType "test" -ScriptBlock { }
}
# Option 3: Module-specific verbose
$oldVerbose = $VerbosePreference
$VerbosePreference = 'Continue'
Initialize-EventSystem -GamePath "."
$VerbosePreference = $oldVerbose❌ Old (will cause errors):
# Direct hashtable registration - NO LONGER SUPPORTED
Register-Entity -Entity @{
id = "player1"
type = "player"
data = @{ name = "John" }
}✅ New (required approach):
# Must import DataModels and create proper entities
Import-Module .\Modules\CoreGame\DataModels.psm1
$entity = New-GameEntity @{
id = "player1"
type = "player"
data = @{ name = "John" }
}
Register-Entity -Entity $entity❌ Old (might cause issues):
$cmd = New-CommandDefinition -Name "test" -Module "test" -Handler { }
$cmd.AddParameter($param) # Might fail if $cmd is an array✅ New (explicit handling):
$cmd = New-CommandDefinition -Name "test" -Module "test" -Handler { }
$cmd = @($cmd)[0] # Force single object if returned as array
$param = New-CommandParameter -Name "TestParam" -Type "String"
$param = @($param)[0] # Force single object if returned as array
$cmd.AddParameter($param)# Enhanced logging with structured data
Write-GameLog -Message "Player action" -Level Info -Module "PlayerSystem" -Data @{
PlayerId = "player1"
Action = "move"
Position = @{ X = 10; Y = 20 }
Timestamp = Get-Date
}# Prevent duplicate events
Send-GameEvent -EventType "player.status" -Data @{ HP = 100 } -Deduplicate
Send-GameEvent -EventType "player.status" -Data @{ HP = 100 } -Deduplicate # Ignored# High priority for critical events
Send-GameEvent -EventType "error.critical" -Data @{ Error = "Database down" } -Priority High
# Normal priority for standard events
Send-GameEvent -EventType "player.action" -Data @{ Action = "move" } -Priority Normal# Set up cross-module event handling
Register-GameEvent -EventType "command.*" -ScriptBlock {
param($Data, $Event)
Write-GameLog -Message "Command event: $($Event.EventType)" -Level Debug -Module "CommandTracker"
}
# Commands automatically trigger events
Invoke-GameCommand -CommandName "player.heal" -Parameters @{ Amount = 50 }- ✅ No function signature changes - fully backward compatible
- ✅ Enhanced: Multi-output support (console, file, events)
- ✅ Enhanced: Structured data logging with
-Dataparameter - ✅ Enhanced: VerbosePreference support
⚠️ Changed: Removed-Verboseparameters from all functions- ✅ Enhanced: Event deduplication with
-Deduplicate - ✅ Enhanced: Priority events with
-Priority - ✅ Enhanced: JavaScript communication bridge
⚠️ Changed: Removed-Verboseparameters from all functions⚠️ Changed: Helper functions may return arrays requiring explicit handling- ✅ Enhanced: Built-in documentation commands
- ✅ Enhanced: Performance monitoring and statistics
⚠️ Breaking: Now requires GameEntity objects (useNew-GameEntity)⚠️ Breaking: Must import DataModels module- ✅ Enhanced: Improved entity persistence and loading
- ✅ Enhanced: Better error handling and validation
# Test basic functionality after migration
try {
# Test verbose handling
$VerbosePreference = 'Continue'
Import-Module .\Modules\CoreGame\EventSystem.psm1 -Force
Initialize-EventSystem -GamePath "."
# Test entity creation
Import-Module .\Modules\CoreGame\DataModels.psm1 -Force
$entity = New-GameEntity @{ id = "test"; type = "test"; data = @{} }
# Test logging
Import-Module .\Modules\CoreGame\GameLogging.psm1 -Force
Write-GameLog -Message "Migration test" -Level Info -Module "Test" -Data @{ Test = $true }
Write-Host "✅ Migration successful!" -ForegroundColor Green
} catch {
Write-Host "❌ Migration issue: $($_.Exception.Message)" -ForegroundColor Red
Write-Host "Check the migration guide for fixes." -ForegroundColor Yellow
}# Comprehensive testing
& .\Test-EnhancedModules.ps1Error: A parameter cannot be found that matches parameter name 'Verbose'
Fix: Remove -Verbose parameters and use $VerbosePreference = 'Continue'
Error: Cannot process argument transformation on parameter 'Entity'
Fix: Import DataModels and use New-GameEntity instead of hashtables
Error: When calling AddParameter on command definition
Fix: Force single object: $cmd = @($cmd)[0]
Error: The specified module 'DataModels' was not loaded
Fix: Import required modules: Import-Module .\Modules\CoreGame\DataModels.psm1
- Full Documentation:
Modules\CoreGame\README.md - Architecture Guide:
Docs\EnhancedModulesGuide.md - Test Examples:
Test-EnhancedModules.ps1 - PowerShell Help:
Get-Help <FunctionName> -Full
- High Priority: Fix verbose parameter calls (breaks functionality)
- High Priority: Update StateManager entity creation (breaks persistence)
- Medium Priority: Handle helper function arrays (improves reliability)
- Low Priority: Leverage new features (enhances capabilities)
Need Help?
- Check error messages against common issues above
- Run the test script to validate changes
- Review the full test suite for working examples