cmd: create ship type

This commit is contained in:
Ilia Denisov
2025-09-30 23:40:50 +03:00
parent c6ccc2df9f
commit 6f29288096
8 changed files with 280 additions and 10 deletions
+13
View File
@@ -2,6 +2,7 @@ package game
import (
"encoding/json"
"strings"
"github.com/google/uuid"
e "github.com/iliadenisov/galaxy/pkg/error"
@@ -111,6 +112,18 @@ func (g Game) relationInternal(hostID, opponentID uuid.UUID) (RaceRelation, erro
return RaceRelation{}, e.NewGameStateError("Relation: host %v not found", hostID)
}
// -----------------------------------------------------------------------------
// validateTypeName always return v without leading and trailing spaces
func validateTypeName(v string) (string, bool) {
s := strings.TrimSpace(v)
if len(s) > 0 {
return s, true
}
// TODO: special symbols
return s, false
}
func (g Game) MarshalBinary() (data []byte, err error) {
return json.Marshal(&g)
}