race quit, transfer state, refactor
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"iter"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
@@ -12,14 +11,6 @@ import (
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
)
|
||||
|
||||
func (c *Controller) RenamePlanet(raceName string, planetNumber int, typeName string) error {
|
||||
ri, err := c.Cache.raceIndex(raceName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.Cache.RenamePlanet(ri, planetNumber, typeName)
|
||||
}
|
||||
|
||||
func (c *Cache) RenamePlanet(ri int, number int, name string) error {
|
||||
n, ok := util.ValidateTypeName(name)
|
||||
if !ok {
|
||||
@@ -39,35 +30,6 @@ func (c *Cache) RenamePlanet(ri int, number int, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) PlanetProduction(raceName string, planetNumber int, prodType, subject string) error {
|
||||
ri, err := c.Cache.raceIndex(raceName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var prod game.ProductionType
|
||||
switch game.ProductionType(strings.ToUpper(prodType)) {
|
||||
case game.ProductionMaterial:
|
||||
prod = game.ProductionMaterial
|
||||
case game.ProductionCapital:
|
||||
prod = game.ProductionCapital
|
||||
case game.ResearchDrive:
|
||||
prod = game.ResearchDrive
|
||||
case game.ResearchWeapons:
|
||||
prod = game.ResearchWeapons
|
||||
case game.ResearchShields:
|
||||
prod = game.ResearchShields
|
||||
case game.ResearchCargo:
|
||||
prod = game.ResearchCargo
|
||||
case game.ResearchScience:
|
||||
prod = game.ResearchScience
|
||||
case game.ProductionShip:
|
||||
prod = game.ProductionShip
|
||||
default:
|
||||
return e.NewProductionInvalidError(prodType)
|
||||
}
|
||||
return c.Cache.PlanetProduction(ri, planetNumber, prod, subject)
|
||||
}
|
||||
|
||||
func (c *Cache) PlanetProduction(ri int, number int, prod game.ProductionType, subj string) error {
|
||||
c.validateRaceIndex(ri)
|
||||
if number < 0 {
|
||||
|
||||
Reference in New Issue
Block a user