예제 #1
0
        public void UpdateDreamTeamComponents(int driverIndex, int qPosition, int rPosition)
        {
            float points   = Constants.qualificationPositionToPointsMap[qPosition] + Constants.racePositionToPointsMap[rPosition];
            float newPrice = Constants.PRICING_PRICE_COEFFICIENT * Drivers.ElementAt(driverIndex).Price + Constants.PRICING_POINTS_COEFFICIENT * points;

            newPrice = newPrice >= 0.5 ? newPrice : 0.5F;
            float priceChange = newPrice - Drivers.ElementAt(driverIndex).Price;

            priceChange = RoundFloat.round(priceChange);
            Drivers.ElementAt(driverIndex).Points          = points;
            Drivers.ElementAt(driverIndex).PriceChange     = priceChange;
            Form.DriverPointsLabels[driverIndex].Text      = points != 0 ? points.ToString() : "";
            Form.DriverPriceChangeLabels[driverIndex].Text = priceChange.ToString();
            Form.ColorLabels(Form.DriverPriceChangeLabels[driverIndex], priceChange);

            for (int i = 0; i < Constants.NUMBER_OF_TEAMS; i++)
            {
                Team team = Teams.ElementAt(i);
                team.UpdatePoints();
                team.UpdatePriceChange();
                Form.TeamPointsLabels[i].Text      = team.Points != 0 ? team.Points.ToString() : "";
                Form.TeamPriceChangeLabels[i].Text = team.PriceChange.ToString();
                Form.ColorLabels(Form.TeamPriceChangeLabels[i], team.PriceChange);
            }
            for (int i = 0; i < Constants.NUMBER_OF_ENGINES; i++)
            {
                Engine engine = Engines.ElementAt(i);
                engine.UpdatePoints();
                engine.UpdatePriceChange();
                Form.EnginePointsLabels[i].Text      = engine.Points != 0 ? engine.Points.ToString() : "";
                Form.EnginePriceChangeLabels[i].Text = engine.PriceChange.ToString();
                Form.ColorLabels(Form.EnginePriceChangeLabels[i], engine.PriceChange);
            }
        }
예제 #2
0
 private void initializePriceChangeValues()
 {
     for (int i = 0; i < Constants.NUMBER_OF_DRIVERS; i++)
     {
         Driver driver          = Drivers.ElementAt(i);
         float  initialNewPrice = Constants.PRICING_PRICE_COEFFICIENT * driver.Price;
         initialNewPrice = initialNewPrice >= 0.5 ? initialNewPrice : 0.5F;
         float initialPriceChange = initialNewPrice - driver.Price;
         initialPriceChange = RoundFloat.round(initialPriceChange);
         Drivers.ElementAt(i).PriceChange     = initialPriceChange;
         Form.DriverPriceChangeLabels[i].Text = initialPriceChange.ToString();
         Form.ColorLabels(Form.DriverPriceChangeLabels[i], initialPriceChange);
     }
     for (int i = 0; i < Constants.NUMBER_OF_TEAMS; i++)
     {
         Team team = Teams.ElementAt(i);
         team.UpdatePriceChange();
         Form.TeamPriceChangeLabels[i].Text = team.PriceChange.ToString();
         Form.ColorLabels(Form.TeamPriceChangeLabels[i], team.PriceChange);
     }
     for (int i = 0; i < Constants.NUMBER_OF_ENGINES; i++)
     {
         Engine engine = Engines.ElementAt(i);
         engine.UpdatePriceChange();
         Form.EnginePriceChangeLabels[i].Text = engine.PriceChange.ToString();
         Form.ColorLabels(Form.EnginePriceChangeLabels[i], engine.PriceChange);
     }
 }