Esempio n. 1
0
        public string Forecast(Game game)
        {
            double forecast;

            if (game.CurrentRound <= Deviations.Count - 1)
                forecast = Deviations[game.CurrentRound];
            else
                forecast = 1;

            string humanForecast;
            if (forecast >= 1)
                humanForecast = "Normal";
            else if (forecast >= 0.65)
                humanForecast = "Below Normal";
            else
                humanForecast = "Drought";

            return humanForecast;
        }
        public int Generate(Game game)
        {
            double totalEntitlement = 0;

            foreach (Player p in game.Players.Values)
                totalEntitlement += p.WaterEntitlement;

            foreach (BuyPoint bp in game.BuyPoints.Values)
                if (!bp.HasAnyOwner)
                    totalEntitlement += bp.InitialWaterRights;

            double generationRatio;

            if (game.CurrentRound <= Deviations.Count - 1)
                generationRatio = Deviations[game.CurrentRound];
            else
                generationRatio = 1;

            return (int)Math.Ceiling(totalEntitlement * generationRatio);
        }
Esempio n. 3
0
        public Game CreateGame(UUID uuid, string name)
        {
            Game game = new Game(UUID.Random(), "Game1", GameStateType.None);

            // This must be done after the constructor is called, since creating the player will require a valid
            // game object and we can't use the one on the controller since it hasn't been returned yet.
            UserAccount economyAccount = m_controller.EconomyUserAccount;
            game.Economy = CreatePlayer(economyAccount.PrincipalID, economyAccount.Name, Economy.Singleton, game);
            game.Roles.Add(Developer.Singleton);
            game.Roles.Add(Economy.Singleton);
            game.Roles.Add(Farmer.Singleton);
            game.Roles.Add(Manufacturer.Singleton);
            game.Roles.Add(WaterMaster.Singleton);

            return game;
        }
Esempio n. 4
0
 protected Player CreatePlayer(UUID uuid, string name, IRole role, Game game)
 {
     //            System.Console.WriteLine("Player {0} created with game [{1}]", name, game.Name);
     return new Player(name, uuid) { Game = game, Role = role };
 }
        public int Generate(Game game)
        {
            int water = game.BuyPoints.Count * WaterPerParcel;

            return water;
        }
        public IDictionary<AbstractGameAssetType, double[]> Generate(Game game)
        {
            IDictionary<AbstractGameAssetType, double[]> activityByAgat
                = new Dictionary<AbstractGameAssetType, double[]>();

            int[] agatValues = (int[])Enum.GetValues(typeof(AbstractGameAssetType));
            foreach (int agatValue in agatValues)
            {
                AbstractGameAssetType type = (AbstractGameAssetType)agatValue;
                double[] levelValues = new double[4];

                if (Deviations.ContainsKey(type))
                {
                    double[][] levelDeviations = Deviations[type];

                    for (int i = 1; i < levelDeviations.Length; i++)
                    {
            //                        m_log.InfoFormat(
            //                            "[WATER WARS]: Fetching deviation for {0} at level [{1}], round [{2}]",
            //                            type, i, game.CurrentRound);

                        if (levelDeviations[i] == null)
                            levelValues[i] = 1;
                        else if (levelDeviations[i].Length - 1 >= game.CurrentRound)
                            levelValues[i] = levelDeviations[i][game.CurrentRound];
                        else
                            levelValues[i] = 1;
                    }
                }
                else
                {
                    for (int i = 1; i <= 3; i++)
                        levelValues[i] = 1;
                }

                activityByAgat[type] = levelValues;
            }

            return activityByAgat;
        }