diff --git a/domain/dialog.go b/domain/dialog.go index 189dd9c..b58935c 100644 --- a/domain/dialog.go +++ b/domain/dialog.go @@ -30,6 +30,10 @@ func (d *Domain) InitDialog() { } } +func (d *Domain) GetDialogMap() entity.DialogMap { + return d.DialogMap +} + func (d *Domain) GetDialog(name string) entity.Dialog { value, _ := d.DialogMap[name] return value diff --git a/domain/level.go b/domain/level.go index 26cfeee..242b3c7 100644 --- a/domain/level.go +++ b/domain/level.go @@ -34,6 +34,10 @@ func (d *Domain) InitLevel() { } } +func (d *Domain) GetLevels() []entity.Level { + return d.Levels +} + func (d *Domain) GetLevel(index int) entity.Level { return d.Levels[index] } diff --git a/domain/menu.go b/domain/menu.go index 777c9a5..3d74691 100644 --- a/domain/menu.go +++ b/domain/menu.go @@ -63,6 +63,10 @@ func (d *Domain) InitMenu() { } } +func (d *Domain) GetMenuMap() entity.MenuMap { + return d.MenuMap +} + func (d *Domain) GetMenu(name string) entity.Menu { value, _ := d.MenuMap[name] return value diff --git a/konstructor/engine/engine.go b/konstructor/engine/engine.go index 1c858fd..5d04ddc 100644 --- a/konstructor/engine/engine.go +++ b/konstructor/engine/engine.go @@ -18,32 +18,28 @@ func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) { return e.Settings.Screen.Width, e.Settings.Screen.Height } -func (e *Engine) ScreenTypeIs(name string) bool { - return e.KContext.Screen.Type == name -} - func (e *Engine) Update(screen *ebiten.Image) error { e.WatchKeyPress() - if e.ScreenTypeIs("menu") { + if e.KContext.ScreenTypeIs("menu") { e.MenuUpdate() } - if e.ScreenTypeIs("dialog") { + if e.KContext.ScreenTypeIs("dialog") { e.DialogUpdate() } - if e.ScreenTypeIs("playground") { + if e.KContext.ScreenTypeIs("playground") { e.PlaygroundUpdate() } return nil } func (e *Engine) Draw(screen *ebiten.Image) { - if e.ScreenTypeIs("menu") { + if e.KContext.ScreenTypeIs("menu") { e.MenuDraw(screen) } - if e.ScreenTypeIs("dialog") { + if e.KContext.ScreenTypeIs("dialog") { e.DialogDraw(screen) } - if e.ScreenTypeIs("playground") { + if e.KContext.ScreenTypeIs("playground") { e.PlaygroundDraw(screen) } if e.Action3Pressed() { diff --git a/konstructor/engine/screen.dialog.go b/konstructor/engine/screen.dialog.go index a128eff..240f29d 100644 --- a/konstructor/engine/screen.dialog.go +++ b/konstructor/engine/screen.dialog.go @@ -6,7 +6,7 @@ import ( ) func (e *Engine) DialogDraw(screen *ebiten.Image) { - dialog := e.Domain.GetDialog(e.KContext.Screen.Value) + dialog := e.Domain.GetDialog(e.KContext.ScreenValue) face := GetFontFace(dialog.Layout.ChoiceFont) @@ -17,7 +17,7 @@ func (e *Engine) DialogDraw(screen *ebiten.Image) { } func (e *Engine) DialogUpdate() { - dialog := e.Domain.GetDialog(e.KContext.Screen.Value) + dialog := e.Domain.GetDialog(e.KContext.ScreenValue) if e.UpPressed() && dialog.CurrentSelected != 0 { dialog.CurrentSelected-- @@ -30,5 +30,5 @@ func (e *Engine) DialogUpdate() { if e.Action0Pressed() { dialog.Choices[dialog.CurrentSelected].Handler() } - e.Domain.SetDialog(e.KContext.Screen.Value, dialog) + e.Domain.SetDialog(e.KContext.ScreenValue, dialog) } diff --git a/konstructor/engine/screen.menu.go b/konstructor/engine/screen.menu.go index f19034f..4bb93c3 100644 --- a/konstructor/engine/screen.menu.go +++ b/konstructor/engine/screen.menu.go @@ -6,7 +6,7 @@ import ( ) func (e *Engine) MenuDraw(screen *ebiten.Image) { - menu := e.Domain.GetMenu(e.KContext.Screen.Value) + menu := e.Domain.GetMenu(e.KContext.ScreenValue) face := GetFontFace(menu.Layout.MenuItemFont) for i, menu_item := range menu.MenuItems { @@ -17,7 +17,7 @@ func (e *Engine) MenuDraw(screen *ebiten.Image) { } func (e *Engine) MenuUpdate() { - menu := e.Domain.GetMenu(e.KContext.Screen.Value) + menu := e.Domain.GetMenu(e.KContext.ScreenValue) if e.UpPressed() && menu.CurrentSelected != 0 { menu.CurrentSelected-- @@ -31,5 +31,5 @@ func (e *Engine) MenuUpdate() { menu.MenuItems[menu.CurrentSelected].Handler() } - e.Domain.SetMenu(e.KContext.Screen.Value, menu) + e.Domain.SetMenu(e.KContext.ScreenValue, menu) } diff --git a/konstructor/entity/entity.domain.go b/konstructor/entity/entity.domain.go index 6b2522e..a1679d7 100644 --- a/konstructor/entity/entity.domain.go +++ b/konstructor/entity/entity.domain.go @@ -2,11 +2,18 @@ package entity type DomainInterface interface { Init() + + GetMenuMap() MenuMap GetMenu(name string) Menu SetMenu(name string, menu Menu) + + GetDialogMap() DialogMap GetDialog(name string) Dialog SetDialog(name string, menu Dialog) + + GetLevels() []Level GetLevel(index int) Level + AddToInventory(item *Item) bool RemoveFromInventory(item *Item) bool UseInventoryItem(item *Item) bool diff --git a/konstructor/entity/entity.kcontext.go b/konstructor/entity/entity.kcontext.go index ddf6a1c..dec2c25 100644 --- a/konstructor/entity/entity.kcontext.go +++ b/konstructor/entity/entity.kcontext.go @@ -1,11 +1,16 @@ package entity -type KContextScreen struct { - Type string - Value string +type KContext struct { + ScreenType string + ScreenValue string + CurrentLevel int + Players []Player } -type KContext struct { - Screen KContextScreen - CurrentLevel int +func (c *KContext) getPrimaryPlayer() Player { + return c.Players[0] +} + +func (c *KContext) ScreenTypeIs(name string) bool { + return c.ScreenType == name } diff --git a/main.go b/main.go index b2f900f..6b49c9a 100644 --- a/main.go +++ b/main.go @@ -23,10 +23,8 @@ func main() { }, }, KContext: &entity.KContext{ - Screen: entity.KContextScreen{ - Type: "menu", - Value: "MainMenu", - }, + ScreenType: "menu", + ScreenValue: "MainMenu", CurrentLevel: 0, }, Settings: entity.Settings{