cmd: delete ship type

This commit is contained in:
Ilia Denisov
2025-10-01 00:29:25 +03:00
parent 6f29288096
commit bcab29a47f
8 changed files with 100 additions and 15 deletions
+12 -2
View File
@@ -9,13 +9,17 @@ const (
ErrStorageFailure int = 1000
ErrGameStateInvalid int = 2000
ErrDeleteShipTypeExistingGroup = 5000
ErrDeleteShipTypePlanetProduction = 5001
)
const (
ErrInputUnknownHostRace int = 3000 + iota
ErrInputUnknownOpponentRace
ErrInputEntityTypeNameInvalid
ErrInputEntityTypeNameExists
ErrInputEntityTypeNameDuplicate
ErrInputEntityTypeNameNotExists
ErrInputShipTypeDriveValue
ErrInputShipTypeWeaponsValue
ErrInputShipTypeShieldsValue
@@ -39,8 +43,10 @@ func GenericErrorText(code int) string {
return "Opponent race name is unknown to this game"
case ErrInputEntityTypeNameInvalid:
return "Name has invalid length or symbols"
case ErrInputEntityTypeNameExists:
case ErrInputEntityTypeNameDuplicate:
return "Name already exists"
case ErrInputEntityTypeNameNotExists:
return "Name not exists"
case ErrInputShipTypeDriveValue:
return "Invalid Drive value"
case ErrInputShipTypeWeaponsValue:
@@ -55,6 +61,10 @@ func GenericErrorText(code int) string {
return "Invalid Armament or Weapons value"
case ErrInputShipTypeZeroValues:
return "Ship type values cannot be all zeros"
case ErrDeleteShipTypeExistingGroup:
return "Ship type exists in a Group"
case ErrDeleteShipTypePlanetProduction:
return "Ship type in production on the Planet"
default:
return fmt.Sprintf("Undescribed error with code %d", code)
}
+6 -2
View File
@@ -12,8 +12,12 @@ func NewEntityTypeNameValidationError(arg ...any) error {
return newGenericError(ErrInputEntityTypeNameInvalid, arg...)
}
func NewEntityTypeNameExistsError(arg ...any) error {
return newGenericError(ErrInputEntityTypeNameExists, arg...)
func NewEntityTypeNameDuplicateError(arg ...any) error {
return newGenericError(ErrInputEntityTypeNameDuplicate, arg...)
}
func NewEntityTypeNameNotExistsError(arg ...any) error {
return newGenericError(ErrInputEntityTypeNameNotExists, arg...)
}
func NewShipTypeDriveValueError(arg ...any) error {
+8
View File
@@ -3,3 +3,11 @@ package error
func NewGameStateError(arg ...any) error {
return newGenericError(ErrGameStateInvalid, arg...)
}
func NewDeleteShipTypeExistingGroupError(arg ...any) error {
return newGenericError(ErrDeleteShipTypeExistingGroup, arg...)
}
func NewDeleteShipTypePlanetProductionError(arg ...any) error {
return newGenericError(ErrDeleteShipTypePlanetProduction, arg...)
}