Răsfoiți Sursa

linting + solving linting

Sacha Ligthert 1 an în urmă
părinte
comite
e8d5ecc772
2 a modificat fișierele cu 21 adăugiri și 17 ștergeri
  1. 3 0
      Taskfile.dist.yaml
  2. 18 17
      robots/render.go

+ 3 - 0
Taskfile.dist.yaml

@@ -10,3 +10,6 @@ tasks:
       - rm builds/* || true
       - go tool dist list | grep -v android | grep -v ios | grep -v wasip1 | awk -F '/' '{printf "echo Compiling %s/%s; env CGO_ENABLED=1 GOOS=%s GOARCH=%s go build -o builds/rowboz.%s-%s\n",$1,$2,$1,$2,$1,$2 }' | sh
       - for i in `ls builds/*windows*`; do mv -v $i $i.exe; done
+  lint:
+    cmds:
+      - golangci-lint run

+ 18 - 17
robots/render.go

@@ -1,7 +1,6 @@
 package robots
 
 import (
-	"runtime"
 	"strconv"
 )
 
@@ -42,26 +41,28 @@ func (game *Game) drawBox() {
 }
 
 // drawCoords Print the coordinates of the player
-func (game *Game) drawCoords() {
-	var x, y int = 25, 24
-	for _, r := range []rune("[ x:" + strconv.FormatInt(int64(game.player.position.x), 10) + " y:" + strconv.FormatInt(int64(game.player.position.y), 10) + " ]") {
-		game.screen.SetContent(x, y-1, r, nil, game.style)
-		x++
-	}
-}
+// func (game *Game) drawCoords() {
+// 	var x, y int = 25, 24
+// 	for _, r := range []rune("[ x:" + strconv.FormatInt(int64(game.player.position.x), 10) + " y:" + strconv.FormatInt(int64(game.player.position.y), 10) + " ]") {
+// 		game.screen.SetContent(x, y-1, r, nil, game.style)
+// 		x++
+// 	}
+// }
 
-func (game *Game) drawDebug() {
-	var x, y int = 40, 24
-	for _, r := range []rune("[ NumGoRoutine: " + strconv.FormatInt(int64(runtime.NumGoroutine()), 10) + " Bots: " + strconv.FormatInt(int64(len(game.robots)), 10) + " ]") {
-		game.screen.SetContent(x, y-1, r, nil, game.style)
-		x++
-	}
-}
+// func (game *Game) drawDebug() {
+// 	var x, y int = 40, 24
+// 	for _, r := range []rune("[ NumGoRoutine: " + strconv.FormatInt(int64(runtime.NumGoroutine()), 10) + " Bots: " + strconv.FormatInt(int64(len(game.robots)), 10) + " ]") {
+// 		game.screen.SetContent(x, y-1, r, nil, game.style)
+// 		x++
+// 	}
+// }
 
 func (game *Game) drawScore() {
 	var x, y int = 5, 24
-	for _, r := range []rune("[ Score: " + strconv.FormatInt(int64(game.player.score), 10) + " Level: " + strconv.FormatInt(int64(game.level), 10) + " ]") {
-		game.screen.SetContent(x, y-1, r, nil, game.style)
+	content := "[ Score: " + strconv.FormatInt(int64(game.player.score), 10) + " Level: " + strconv.FormatInt(int64(game.level), 10) + " ]"
+
+	for i := 0; i < len(content); i++ {
+		game.screen.SetContent(x, y-1, rune(content[i]), nil, game.style)
 		x++
 	}
 }