package calc

import (
	e "galaxy/error"
)

func ValidateShipTypeValues(d float64, a int, w, s, c float64) error {
	if !CheckShipTypeValueDWSC(d) {
		return e.NewDriveValueError(d)
	}
	if !CheckShipTypeValueDWSC(w) {
		return e.NewWeaponsValueError(w)
	}
	if !CheckShipTypeValueDWSC(s) {
		return e.NewShieldsValueError(s)
	}
	if !CheckShipTypeValueDWSC(c) {
		return e.NewCargoValueError(s)
	}
	if a < 0 {
		return e.NewShipTypeArmamentValueError(a)
	}
	if (w == 0 && a > 0) || (a == 0 && w > 0) {
		return e.NewShipTypeArmamentAndWeaponsValueError("A=%d W=%.0f", a, w)
	}
	if d == 0 && w == 0 && s == 0 && c == 0 && a == 0 {
		return e.NewShipTypeShipTypeZeroValuesError()
	}
	return nil
}

func CheckShipTypeValueDWSC(v float64) bool {
	return v == 0 || v >= 1
}
