remove controller layer

This commit is contained in:
2023-06-28 15:41:06 +02:00
parent b688fb85d3
commit 17b2aab4fa
6 changed files with 25 additions and 34 deletions

6
Makefile Normal file
View File

@@ -0,0 +1,6 @@
dev:
go run main.go
build:
echo "install"
install:
echo "install"

View File

@@ -1,11 +0,0 @@
package controller
import "game/domain"
type Controller struct {
Context domain.Context
}
func (c Controller) Init() {
}

View File

@@ -13,12 +13,21 @@ type GameField struct {
LevelSection LevelSection LevelSection LevelSection
} }
type Position struct {
X int
Y int
}
type Context struct { type Context struct {
Player Player Player Player
User User User User
GameField GameField CurrentGameField GameField
CurrentPosition Position
} }
func CreateContext() Context { func CreateContext() Context {
return Context{} return Context{
Player: Player{},
User: User{},
}
} }

View File

@@ -1,21 +1,15 @@
package domain package domain
type ControllerInterface interface {
Init()
}
type PresenterInterface interface { type PresenterInterface interface {
Init() Init()
} }
type Domain struct { type Domain struct {
Context Context Context Context
Controller ControllerInterface Presenter PresenterInterface
Presenter PresenterInterface
} }
func (d Domain) Init() { func (d Domain) Init() {
d.Controller.Init()
d.Presenter.Init() d.Presenter.Init()
menu_manager := MenuManager{} menu_manager := MenuManager{}
menu_manager.Init() menu_manager.Init()

View File

@@ -1,7 +1,6 @@
package domain package domain
type Screen struct { type Screen struct {
Controller ControllerInterface
} }
type ScreenManager struct { type ScreenManager struct {

14
main.go
View File

@@ -1,7 +1,6 @@
package main package main
import ( import (
"game/controller"
"game/domain" "game/domain"
"game/presenter" "game/presenter"
) )
@@ -9,16 +8,11 @@ import (
func main() { func main() {
context := domain.CreateContext() context := domain.CreateContext()
controller := controller.Controller{
Context: context,
}
presenter := presenter.Presenter{
Context: context,
}
domain := domain.Domain{ domain := domain.Domain{
Context: context, Context: context,
Controller: controller, Presenter: presenter.Presenter{
Presenter: presenter, Context: context,
},
} }
domain.Init() domain.Init()
} }