cmd: giveaway group
This commit is contained in:
@@ -104,19 +104,20 @@ func (g Game) CreateShipType(raceName, typeName string, d, w, s, c float64, a in
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return g.createShipTypeInternal(ri, typeName, d, w, s, c, a)
|
||||
_, err = g.createShipTypeInternal(ri, typeName, d, w, s, c, a)
|
||||
return err
|
||||
}
|
||||
|
||||
func (g Game) createShipTypeInternal(ri int, name string, d, w, s, c float64, a int) error {
|
||||
func (g Game) createShipTypeInternal(ri int, name string, d, w, s, c float64, a int) (int, error) {
|
||||
if err := checkShipTypeValues(d, w, s, c, a); err != nil {
|
||||
return err
|
||||
return -1, err
|
||||
}
|
||||
n, ok := validateTypeName(name)
|
||||
if !ok {
|
||||
return e.NewEntityTypeNameValidationError("%q", n)
|
||||
return -1, e.NewEntityTypeNameValidationError("%q", n)
|
||||
}
|
||||
if st := slices.IndexFunc(g.Race[ri].ShipTypes, func(st ShipType) bool { return st.Name == name }); st >= 0 {
|
||||
return e.NewEntityTypeNameDuplicateError("ship type %w", g.Race[ri].ShipTypes[st].Name)
|
||||
return -1, e.NewEntityTypeNameDuplicateError("ship type %w", g.Race[ri].ShipTypes[st].Name)
|
||||
}
|
||||
g.Race[ri].ShipTypes = append(g.Race[ri].ShipTypes, ShipType{
|
||||
ID: uuid.New(),
|
||||
@@ -129,7 +130,7 @@ func (g Game) createShipTypeInternal(ri int, name string, d, w, s, c float64, a
|
||||
Armament: uint(a),
|
||||
},
|
||||
})
|
||||
return nil
|
||||
return len(g.Race[ri].ShipTypes) - 1, nil
|
||||
}
|
||||
|
||||
func (g Game) MergeShipType(race, name, targetName string) error {
|
||||
|
||||
Reference in New Issue
Block a user