Beispiel #1
0
        private static bool ShipMatterIsValid(ApiShipMatter shipMatter)
        {
            // note (sivukhin, 23.06.2020): to prevent integer overflow after calculation of total weight
            var maxComponentValueEstimation = Math.Max(BalanceConstants.MaxAttackerMatter, BalanceConstants.MaxDefenderMatter);

            if (shipMatter.Fuel < 0 || shipMatter.Fuel > maxComponentValueEstimation)
            {
                return(false);
            }

            if (shipMatter.Lasers < 0 || shipMatter.Lasers > maxComponentValueEstimation)
            {
                return(false);
            }

            if (shipMatter.Radiators < 0 || shipMatter.Radiators > maxComponentValueEstimation)
            {
                return(false);
            }

            if (shipMatter.Engines < 1 || shipMatter.Engines > maxComponentValueEstimation)
            {
                return(false);
            }

            return(true);
        }
 public static ShipMatter ToShipMatter(this ApiShipMatter shipMatter)
 {
     checked
     {
         return(new ShipMatter(
                    fuel: (int)shipMatter.Fuel,
                    engines: (int)shipMatter.Engines,
                    lasers: (int)shipMatter.Lasers,
                    radiators: (int)shipMatter.Radiators));
     }
 }