1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-20 15:37:31 -05:00
OpenDiablo2/d2core/d2systems/game_config_test.go
gravestench 8b1b6b9adc more work on ecs implementation
* removed d2common/d2scene, was not the right way to go.
* added components for animation, scale, main viewport, viewport filter
* added interface for scenes, which are extensions of akara.System
* BootStrap is now AppBootstrap, common to game clients and headless
server
* added generic BasicScene struct for common scene functionality
* added game object factory as a system, with single sprite factory
* added update counter system, shows how many times the world updates
per second
* integration test is now the game client test
2020-12-07 12:44:11 -08:00

52 lines
1.3 KiB
Go

package d2systems
import (
"testing"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2components"
"github.com/gravestench/akara"
)
func Test_GameConfigSystem_Bootstrap(t *testing.T) {
cfg := akara.NewWorldConfig()
typeSys := NewFileTypeResolver()
handleSys := NewFileHandleResolver()
srcSys := NewFileSourceResolver()
cfgSys := NewGameConfigSystem()
cfg.With(typeSys).
With(srcSys).
With(handleSys).
With(cfgSys)
world := akara.NewWorld(cfg)
// for the purpose of this test, we want to add the testdata directory, so that
// when the game looks for the config file it gets pulled from there
filePathsAbstract, err := world.GetMap(d2components.FilePath)
if err != nil {
t.Error("file path component map not found")
return
}
filePaths := filePathsAbstract.(*d2components.FilePathMap)
cfgDir := filePaths.AddFilePath(world.NewEntity())
cfgDir.Path = "./testdata/"
cfgFile := filePaths.AddFilePath(world.NewEntity())
cfgFile.Path = "config.json"
// at this point the world has initialized the systems. when the world
// updates it should process the config dir to a source and then
// use the source to resolve a file handle, and finally the config file
// will get loaded by the config system.
_ = world.Update(0)
if len(cfgSys.gameConfigs.GetEntities()) < 1 {
t.Error("no game configs were loaded")
}
}