fix logger

This commit is contained in:
2020-09-25 00:45:45 +03:00
parent d2b22f4760
commit 9f3eaafa3f
21 changed files with 115 additions and 79 deletions

View File

@ -1,7 +1,6 @@
package gamemap
import (
"context"
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
"lab.zaar.be/thefish/alchemyst-go/util/appctx"
@ -14,7 +13,6 @@ var mapHeight = 90
type Level struct {
types.Rect
ctx context.Context
Name string
Branch string
Depth int
@ -66,23 +64,22 @@ func (l *Level) MakePassByXY (x,y int, tile *Tile) {
func (l *Level) Put (x, y int, tileFunc interface{}) {
tile := tileFunc.(func() *Tile)()
if tile == nil {
appctx.Logger(l.ctx).Fatal().Msgf("Got non-tile type to put into level: %v", tile)
appctx.Logger().Fatal().Msgf("Got non-tile type to put into level: %v", tile)
}
if l.InBounds(types.Coords{x, y}) {
l.Tiles[y*l.W+x] = tile
}
}
func NewLevel(ctx context.Context, branch string, depth int) *Level {
func NewLevel(branch string, depth int) *Level {
l := &Level{
ctx: ctx,
Name: branch + string(depth),
Depth: depth,
Rect: types.NewRect(0,0, mapWidth, mapHeight),
}
l.Tiles = make([]*Tile, l.W*l.H)
appctx.Logger(ctx).Debug().Msgf("Generating level of branch %s depth %d", branch, depth)
appctx.Logger().Debug().Msgf("Generating level of branch %s depth %d", branch, depth)
return l
}