Ejemplo n.º 1
0
        public override void UndoUseWater(AbstractGameAsset a)
        {
            if (!a.CanBeAllocatedWater)
            {
                throw new WaterWarsGameLogicException(
                          string.Format(
                              "Attempt made to undo allocate water on asset {0} but this asset type does not allow water allocation",
                              a.Name));
            }

            if (!a.IsBuilt)
            {
                throw new WaterWarsGameLogicException(
                          "{0} tried to undo allocate water on asset {1} but it is only partially built",
                          a.OwnerName, a.Name);
            }

            Player   p  = a.Field.BuyPoint.DevelopmentRightsOwner;
            BuyPoint bp = a.Field.BuyPoint;

            m_log.InfoFormat(
                "[WATER WARS]: {0} undoing use of {1} on {2} at {3} in {4}",
                p.Name, WaterWarsUtils.GetWaterUnitsText(a.WaterAllocated), a.Name, bp.Name, bp.Location.RegionName);

            m_controller.WaterAllocator.ChangeAllocation(a, p, 0);
            m_controller.EventManager.TriggerWaterUsed(a, p, 0);
            a.TriggerChanged();
            bp.TriggerChanged();
            p.TriggerChanged();

            UpdateHudStatus(p);
        }
Ejemplo n.º 2
0
 public void TriggerGameAssetBuildCompleted(AbstractGameAsset ga)
 {
     if (OnGameAssetBuildCompleted != null)
     {
         OnGameAssetBuildCompleted(ga);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a game asset view
        /// </summary>
        /// <param name="asset"></param>
        /// <returns>A view that doesn't have a link to the model.  The caller needs to link this subsequently</returns>
        public GameAssetView CreateGameAssetView(AbstractGameAsset asset)
        {
            GameAssetView v   = null;
            FieldView     fv  = m_fieldViews[asset.Field.Uuid];
            Vector3       pos = fv.RootPart.AbsolutePosition;

            if (asset.Type == AbstractGameAssetType.Factory)
            {
                v = new FactoryView(m_controller, m_scene, asset, m_itemStoreView);
            }
            else if (asset.Type == AbstractGameAssetType.Houses)
            {
                v = new HousesView(m_controller, m_scene, asset, m_itemStoreView);
            }
            else if (asset.Type == AbstractGameAssetType.Crops)
            {
                v = new CropsView(m_controller, m_scene, asset, m_itemStoreView);
            }
            else
            {
                throw new Exception(string.Format("Unrecognized asset type {0} at position {1}", asset.Type, pos));
            }

            fv.Close();
            m_fieldViews.Remove(asset.Field.Uuid);

            v.Initialize(pos);

            return(v);
        }
Ejemplo n.º 4
0
 public void TriggerGameAssetRemoved(AbstractGameAsset ga)
 {
     if (OnGameAssetRemoved != null)
     {
         OnGameAssetRemoved(ga);
     }
 }
Ejemplo n.º 5
0
 public void TriggerGameAssetSoldToEconomy(AbstractGameAsset ga, Player p, int price)
 {
     if (OnGameAssetSoldToEconomy != null)
     {
         OnGameAssetSoldToEconomy(ga, p, price);
     }
 }
Ejemplo n.º 6
0
 public void TriggerGameAssetUpgraded(AbstractGameAsset ga, int oldLevel)
 {
     if (OnGameAssetUpgraded != null)
     {
         OnGameAssetUpgraded(ga, oldLevel);
     }
 }
Ejemplo n.º 7
0
 protected void RecordGameAsset(AbstractGameAsset ga)
 {
     m_xtw.WriteStartElement(AssetElement);
     RecordAttributes(ga);
     m_xtw.WriteElementString("Level", ga.Level.ToString());
     m_xtw.WriteElementString("MinLevel", ga.MinLevel.ToString());
     m_xtw.WriteElementString("MaxLevel", ga.MaxLevel.ToString());
     m_xtw.WriteElementString(PriceElement, ga.ConstructionCost.ToString());
     m_xtw.WriteElementString("PricePerBuildStep", ga.ConstructionCostPerBuildStep.ToString());
     m_xtw.WriteElementString("StepsBuilt", ga.StepsBuilt.ToString());
     m_xtw.WriteElementString("StepsRequired", ga.StepsToBuild.ToString());
     m_xtw.WriteElementString("StepBuiltThisTurn", ga.StepBuiltThisTurn.ToString());
     m_xtw.WriteElementString("IsMultiStepBuild", ga.IsMultiStepBuild.ToString());
     m_xtw.WriteElementString("IsBuilt", ga.IsBuilt.ToString());
     m_xtw.WriteElementString("IsDependentOnWaterToExist", ga.IsDependentOnWaterToExist.ToString());
     m_xtw.WriteElementString("IsSoldToEconomy", ga.IsSoldToEconomy.ToString());
     m_xtw.WriteElementString("MarketPrice", ga.MarketPrice.ToString());
     m_xtw.WriteElementString("NormalOperatingRevenue", ga.NormalRevenue.ToString());
     m_xtw.WriteElementString("OperatingRevenue", ga.ProjectedRevenue.ToString());
     m_xtw.WriteElementString("NominalMaximumProfitThisTurn", ga.NominalMaximumProfitThisTurn.ToString());
     m_xtw.WriteElementString("Profit", ga.Profit.ToString());
     m_xtw.WriteElementString("WaterUsage", ga.WaterUsage.ToString());
     m_xtw.WriteElementString("WaterAllocated", ga.WaterAllocated.ToString());
     m_xtw.WriteElementString("MaintenanceCost", ga.MaintenanceCost.ToString());
     m_xtw.WriteElementString("AccruedMaintenanceCost", ga.AccruedMaintenanceCost.ToString());
     m_xtw.WriteElementString("TimeToLive", ga.TimeToLive.ToString());
     m_xtw.WriteElementString("CanBeAllocatedWater", ga.CanBeAllocatedWater.ToString());
     m_xtw.WriteElementString("CanBePartiallyAllocatedWater", ga.CanPartiallyAllocateWater.ToString());
     m_xtw.WriteElementString("CanBeSoldToEconomy", ga.CanBeSoldToEconomy.ToString());
     m_xtw.WriteElementString("CanUpgradeInPrinciple", ga.CanUpgradeInPrinciple.ToString());
     m_xtw.WriteElementString("CanUpgrade", ga.CanUpgrade.ToString());
     m_xtw.WriteEndElement();
 }
Ejemplo n.º 8
0
        public void TestWaterDependentCropBehaviour()
        {
            TestHelpers.InMethod();

            AddBuyPoints();
            AddPlayers(Farmer.Singleton);
            StartGame();

            m_controller.State.BuyLandRights(bp1, p1);
            m_controller.State.BuyLandRights(bp2, p1);
            AbstractGameAsset c1
                = m_controller.State.BuildGameAsset(bp1.Fields.Values.ToList()[0], Crops.Template, (int)CropType.Grapes);

            EndTurns();

            m_controller.State.UseWater(c1, p1, c1.WaterUsage);

            EndTurns();

            Assert.That(bp1.Cropss.Count, Is.EqualTo(1));

            // Switch from build to water and back again
            EndTurns(2);

            // Without watering, the crops should have died
            Assert.That(bp1.Cropss.Count, Is.EqualTo(0));
        }
Ejemplo n.º 9
0
 public void TriggerWaterUsed(AbstractGameAsset ga, Player user, int amount)
 {
     if (OnWaterUsed != null)
     {
         OnWaterUsed(ga, user, amount);
     }
 }
Ejemplo n.º 10
0
        public void TestSalesRevenue()
        {
            TestHelpers.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            AddBuyPoints();
            AddPlayers(Farmer.Singleton);
            StartGame();

            m_controller.State.BuyLandRights(bp1, p1);
            m_controller.State.BuyLandRights(bp2, p1);
            AbstractGameAsset c1 = m_controller.State.BuildGameAsset(bp1.Fields.Values.ToList()[0], Crops.Template, 1);

            EndTurns(1);

            m_controller.State.UseWater(c1, p1, c1.WaterUsage);
            EndTurns(1);

            Assert.That(p1.History[1].BuildRevenueThisTurn, Is.EqualTo(0));
            Assert.That(p1.History[1].WaterRevenueThisTurn, Is.EqualTo(0));
            Assert.That(p1.History[1].BuildCostsThisTurn, Is.EqualTo(c1.ConstructionCost));
            Assert.That(p1.History[1].WaterCostsThisTurn, Is.EqualTo(0));
            Assert.That(p1.History[1].CostOfLiving, Is.EqualTo(p1.CostOfLiving));
            Assert.That(p1.History[1].ProjectedRevenueFromProducts, Is.EqualTo(c1.ProjectedRevenue));
            Assert.That(p1.History[1].Profit, Is.EqualTo(c1.ProjectedRevenue - c1.ConstructionCost - p1.CostOfLiving));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Use available water on a particular asset on a particular parcel
        /// </summary>
        /// <param name="rawBuyPointId"></param>
        /// <param name="rawAssetId"></param>
        /// <param name="rawPlayerId">Temporarily, this can be UUID.Zero if no player id was supplied in the request</param>
        /// <param name="amount">
        /// Amount of water to use.  If this is zero and there already is some water allocated then this signals undo
        /// </param>
        public void UseWater(string rawBuyPointId, string rawAssetId, string rawPlayerId, int amount)
        {
            UUID buyPointId = WaterWarsUtils.ParseRawId(rawBuyPointId);
            UUID assetId    = WaterWarsUtils.ParseRawId(rawAssetId);
            UUID playerId   = WaterWarsUtils.ParseRawId(rawPlayerId);

            BuyPoint          bp = GetBuyPoint(buyPointId);
            AbstractGameAsset a  = GetAsset(bp, assetId);

            if (0 == amount)
            {
                m_controller.State.UndoUseWater(a);
            }
            else
            {
                Player p = null;

                if (playerId != UUID.Zero)
                {
                    p = GetPlayer(playerId);
                }
                else
                {
                    p = bp.DevelopmentRightsOwner;
                }

                m_controller.State.UseWater(a, p, amount);
            }
        }
Ejemplo n.º 12
0
        public void ChangeAllocation(AbstractGameAsset a, Player p, int allocation)
        {
            int adjustment = allocation - a.WaterAllocated;

            if (adjustment > p.Water)
            {
                throw new WaterWarsGameLogicException(
                          string.Format(
                              "Player {0} only has {1} water, not enough to satisfy allocation adjustment of {2}",
                              p.Name, p.Water, adjustment));
            }

            if (adjustment == 0)
            {
                return;
            }
            else if (adjustment > 0)
            {
                TakeWater(a, p, adjustment);
            }
            else
            {
                GiveBackWater(a, p, -adjustment);
            }
        }
Ejemplo n.º 13
0
        public override AbstractGameAsset BuildGameAsset(Field f, AbstractGameAsset templateAsset, int level)
        {
            BuyPoint bp = f.BuyPoint;
            Player   p  = bp.DevelopmentRightsOwner;

            if (!p.Role.AllowedAssets.Contains(templateAsset))
            {
                throw new WaterWarsGameLogicException(
                          "[WATER WARS]: Player {0} tried to buy a {1} on {2} but this is not one of their allowed assets",
                          p.Name, templateAsset.Type, bp.Name);
            }

            AbstractGameAsset ga
                = m_controller.ModelFactory.CreateGameAsset(f, templateAsset, Vector3.Zero, level);

            int price = ga.ConstructionCostPerBuildStep;

            if (p.Money < price)
            {
                // TODO: Signal this to the player in-world in some way
                throw new WaterWarsGameLogicException(
                          "[WATER WARS]: Player {0} has {1}, not enough to starting building a {2} costing {3}",
                          p, p.Money, templateAsset.Type, price);
            }

            m_log.InfoFormat(
                "[WATER WARS]: Player {0} building a {1} on {2} in {3} for {4} (approx {5} each turn)",
                p.Name, ga.Type, bp.Name, bp.Location.RegionName, ga.ConstructionCost, price);

            p.Money -= price;
            p.BuildCostsThisTurn += price;
            ga.StepsBuilt++;
            ga.StepBuiltThisTurn = true;

            // We have to remove the field from the buy point - it is now attached to the game asset if we want it back
            // later on.  This is pretty nasty - fields and game assets should probably occupy specific slots on the
            // BuyPoint now.
            // NO!  The buy point has to be kept here since this is actually the only way that the game asset can
            // retrieve the field.
//            f.BuyPoint = null;

            bp.AddGameAsset(ga);

            m_controller.EventManager.TriggerGameAssetBuildStarted(ga);
            if (ga.IsBuilt)
            {
                m_controller.EventManager.TriggerGameAssetBuildCompleted(ga);
            }

            p.TriggerChanged();
            bp.TriggerChanged();

            // Don't trigger this change since we are deleting the field view
            //f.TriggerChanged();

            UpdateHudStatus(p);

            return(ga);
        }
Ejemplo n.º 14
0
 public CropsView(WaterWarsController controller, Scene scene, AbstractGameAsset asset, AbstractView itemStoreView)
     : base(controller, scene, asset, itemStoreView)
 {
     m_veSceneObjectNames       = new string[4, 1];
     m_veSceneObjectNames[1, 0] = string.Format("{0}_Alfalfa", IN_WORLD_NAME);
     m_veSceneObjectNames[2, 0] = string.Format("{0}_Chillis", IN_WORLD_NAME);
     m_veSceneObjectNames[3, 0] = string.Format("{0}_Grapes", IN_WORLD_NAME);
 }
Ejemplo n.º 15
0
 public WaterAllocationDecorator(
     WaterWarsController controller, Scene scene, AbstractGameAsset asset, AbstractView itemStoreView, Vector3 positionToDisplay)
     : base(controller, scene, itemStoreView, IN_WORLD_NAME, positionToDisplay)
 {
     GameAsset = asset;
     Update();
     GameAsset.OnChange += GameAssetChanged;
 }
Ejemplo n.º 16
0
            protected void OnGameAssetBuildStarted(AbstractGameAsset ga)
            {
                if (ga != m_gav.GameAsset)
                {
                    return;
                }

                LabelBehaviour.Text = GetGameAssetStatusMessage();
            }
Ejemplo n.º 17
0
            protected void OnGameAssetUpgraded(AbstractGameAsset ga, int oldLevel)
            {
                if (ga != m_gav.GameAsset)
                {
                    return;
                }

                LabelBehaviour.Text = GetGameAssetStatusMessage();
            }
Ejemplo n.º 18
0
        /// <summary>
        /// Remove a particular game asset on a parcel
        /// </summary>
        /// <param name="buyPointId"></param>
        /// <param name="rawGameAssetId">
        public Field RemoveGameAsset(string rawBuyPointId, string rawGameAssetId)
        {
            UUID buyPointId  = WaterWarsUtils.ParseRawId(rawBuyPointId);
            UUID gameAssetId = WaterWarsUtils.ParseRawId(rawGameAssetId);

            BuyPoint          bp = GetBuyPoint(buyPointId);
            AbstractGameAsset ga = GetAsset(bp, gameAssetId);

            return(m_controller.State.RemoveGameAsset(ga));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Upgrade a game asset.
        /// </summary>
        /// This is called by code which only has the ids available.
        /// <param name="rawBuyPointId"></param>
        /// <param name="rawPlayerId"></param>
        /// <param name="level"></param>
        public void UpgradeGameAsset(string rawBuyPointId, string rawAssetId, int level)
        {
            UUID     buyPointId = WaterWarsUtils.ParseRawId(rawBuyPointId);
            BuyPoint bp         = GetBuyPoint(buyPointId);

            UUID assetId            = WaterWarsUtils.ParseRawId(rawAssetId);
            AbstractGameAsset asset = GetAsset(bp, assetId);

            m_controller.State.UpgradeGameAsset(bp.DevelopmentRightsOwner, asset, level);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Buy a game asset.
        /// </summary>
        /// <param name="rawBuyPointId"></param>
        /// <param name="rawAssetId"></param>
        public AbstractGameAsset ContinueBuildingGameAsset(string rawBuyPointId, string rawAssetId)
        {
            UUID     buyPointId = WaterWarsUtils.ParseRawId(rawBuyPointId);
            BuyPoint bp         = GetBuyPoint(buyPointId);

            UUID assetId            = WaterWarsUtils.ParseRawId(rawAssetId);
            AbstractGameAsset asset = GetAsset(bp, assetId);

            return(m_controller.State.ContinueBuildingGameAsset(asset));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Sell a game asset to the economy
        /// </summary>
        /// <param name="rawBuyPointId"></param>
        /// <param name="rawGameAssetId"></param>
        public void SellGameAssetToEconomy(string rawBuyPointId, string rawGameAssetId)
        {
            UUID buyPointId  = WaterWarsUtils.ParseRawId(rawBuyPointId);
            UUID gameAssetId = WaterWarsUtils.ParseRawId(rawGameAssetId);

            BuyPoint          bp = GetBuyPoint(buyPointId);
            AbstractGameAsset ga = GetAsset(bp, gameAssetId);

            m_controller.State.SellGameAssetToEconomy(ga);
        }
Ejemplo n.º 22
0
        public override void UpgradeGameAsset(Player p, AbstractGameAsset ga, int newLevel)
        {
            BuyPoint bp = ga.Field.BuyPoint;

            if (!ga.IsBuilt)
            {
                throw new WaterWarsGameLogicException(
                          "{0} tried to upgrade {1} at {2} in {3} but the asset is only partially built",
                          p.Name, ga.Name, bp.Name, bp.Location.RegionName);
            }

            if (newLevel <= ga.Level)
            {
                throw new WaterWarsGameLogicException(
                          "{0} tried to upgrade {1} to level {2} but asset is already at level {3}",
                          p, ga, newLevel, ga.Level);
            }

            if (newLevel > ga.MaxLevel)
            {
                throw new WaterWarsGameLogicException(
                          "{0} tried to upgrade {1} to level {2} but max level of asset is {3}",
                          p, ga, newLevel, ga.MaxLevel);
            }

            int price = ga.ConstructionCosts[newLevel] - ga.ConstructionCosts[ga.Level];

            if (p.Money < price)
            {
                throw new WaterWarsGameLogicException(
                          "{0} has {1}, not enough to upgrade {2} to level {3} which costs {4}",
                          p, p.Money, ga, newLevel, price);
            }

            m_log.InfoFormat(
                "[WATER WARS]: {0} upgrading {1} on {2} in {3} to level {4}",
                p.Name, ga.Name, bp.Name, bp.Location.RegionName, newLevel);

            // Perform the transaction
            p.Money -= price;
            int oldLevel = ga.Level;

            ga.Level           = newLevel;
            ga.Name            = string.Format("{0} ({1})", ga.InitialNames[ga.Level], ga.Field.Name);
            ga.RevenueThisTurn = m_controller.EconomicDistributor.Allocate(ga.Game.EconomicActivity, ga);

            m_controller.EventManager.TriggerGameAssetUpgraded(ga, oldLevel);

            bp.TriggerChanged();
            p.TriggerChanged();
            ga.TriggerChanged();

            UpdateHudStatus(p);
        }
Ejemplo n.º 23
0
        protected void CreateGameAssetView(AbstractGameAsset asset)
        {
            lock (m_buyPointViews)
            {
                GameAssetView gav = GetBuyPointView(asset.BuyPointUuid).CreateGameAssetView(asset);
                asset.Position = gav.RootPart.AbsolutePosition;

                lock (m_gameAssetViews)
                    m_gameAssetViews.Add(gav.Uuid, gav);
            }
        }
Ejemplo n.º 24
0
 public HousesView(WaterWarsController controller, Scene scene, AbstractGameAsset asset, AbstractView itemStoreView)
     : base(controller, scene, asset, itemStoreView)
 {
     m_veSceneObjectNames       = new string[4, 2];
     m_veSceneObjectNames[1, 0] = string.Format("{0}_Level-1-under-construction", IN_WORLD_NAME);
     m_veSceneObjectNames[2, 0] = string.Format("{0}_Level-2-under-construction", IN_WORLD_NAME);
     m_veSceneObjectNames[3, 0] = string.Format("{0}_Level-3-under-construction", IN_WORLD_NAME);
     m_veSceneObjectNames[1, 1] = string.Format("{0}_Level-1", IN_WORLD_NAME);
     m_veSceneObjectNames[2, 1] = string.Format("{0}_Level-2", IN_WORLD_NAME);
     m_veSceneObjectNames[3, 1] = string.Format("{0}_Level-3", IN_WORLD_NAME);
 }
Ejemplo n.º 25
0
        protected void TakeWater(AbstractGameAsset a, Player p, int waterRequired)
        {
            m_log.InfoFormat(
                "[WATER WARS]: Allocating {0} water to {1} owned by {2}",
                waterRequired, a.Name, a.Field.BuyPoint.DevelopmentRightsOwner);

            int totalWaterTaken = 0;

            if (a.Field.BuyPoint.WaterRightsOwner == p)
            {
                int waterTaken = Math.Min(a.Field.BuyPoint.WaterAvailable, waterRequired);
                a.Field.BuyPoint.WaterAvailable -= waterTaken;
                waterRequired   -= waterTaken;
                totalWaterTaken += waterTaken;
            }

            // We need to pull in water from other places.
            if (waterRequired > 0)
            {
                lock (p.WaterRightsOwned)
                {
                    Dictionary <UUID, BuyPoint> otherRights = new Dictionary <UUID, BuyPoint>(p.WaterRightsOwned);
                    otherRights.Remove(a.Field.BuyPoint.Uuid);

                    while (waterRequired > 0)
                    {
                        BuyPoint waterMaxBp = BuyPoint.None;

                        foreach (BuyPoint bp in otherRights.Values)
                        {
                            if (bp.WaterAvailable > waterMaxBp.WaterAvailable)
                            {
                                waterMaxBp = bp;
                            }
                        }

                        m_log.InfoFormat(
                            "[WATER WARS]: ParcelOrientedAllocator determined buy point {0} has max water of {1}",
                            waterMaxBp.Name, waterMaxBp.WaterAvailable);

                        int waterTaken = Math.Min(waterMaxBp.WaterAvailable, waterRequired);
                        waterMaxBp.WaterAvailable -= waterTaken;
                        waterRequired             -= waterTaken;
                        totalWaterTaken           += waterTaken;
                    }
                }
            }

            a.WaterAllocated += totalWaterTaken;
            //p.Water -= a.WaterUsage;
            a.TriggerChanged();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Load a set of values for a given configurable parameter of a game asset (e.g. costs)
        /// </summary>
        /// <param name="config"></param>
        /// <param name="keyNames"></param>
        /// <param name="keyPostFix"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        protected int[] LoadValues(
            IConfig config, List <string> keyNames, string keyPostFix, AbstractGameAsset template)
        {
            int[] values = new int[keyNames.Count];
            for (int i = template.MinLevel; i <= template.MaxLevel; i++)
            {
                string keyName
                          = string.Format(ConfigurationParser.GAME_ASSET_KEY_FORMAT, keyNames[i].ToLower(), keyPostFix);
                values[i] = config.GetInt(keyName);
            }

            return(values);
        }
Ejemplo n.º 27
0
            protected void OnGameAssetSoldToEconomy(AbstractGameAsset ga, Player owner, int price)
            {
                if (ga != m_gav.GameAsset)
                {
                    return;
                }

                Color4 soldColour = new Color4(32, 44, 66, 255);

                Part.ParentGroup.OwnerID = m_controller.Game.Economy.Uuid;
                ChangeTextureColor(soldColour);
                Part.ParentGroup.ScheduleGroupForFullUpdate();
            }
Ejemplo n.º 28
0
        protected void OnGameAssetUpgraded(AbstractGameAsset ga, int oldLevel)
        {
            if (ga != GameAsset)
            {
                return;
            }

            int lastPhaseIndex = m_veSceneObjectNames.GetLength(1) - 1;

            ReplaceSceneObjectFromInventoryItem(
                m_veSceneObjectNames[GameAsset.Level, lastPhaseIndex], GameAsset, GameAsset.OwnerUuid);

            m_button.ResetButtonPrims(m_rootPart);
        }
Ejemplo n.º 29
0
            protected void OnGameAssetBuildCompleted(AbstractGameAsset ga)
            {
                if (ga != m_gav.GameAsset)
                {
                    return;
                }

                Color4 neutralColour = new Color4(255, 255, 255, 255);

                ChangeTextureColor(neutralColour);
                Part.ParentGroup.ScheduleGroupForFullUpdate();

                LabelBehaviour.Text = GetGameAssetStatusMessage();
            }
Ejemplo n.º 30
0
//        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public void ChangeAllocation(AbstractGameAsset a, Player p, int allocation)
        {
            int adjustment = allocation - a.WaterAllocated;

            if (adjustment > p.Water)
            {
                throw new WaterWarsGameLogicException(
                          string.Format(
                              "Player {0} only has {1} water, not enough to satisfy allocation adjustment of {2}",
                              p.Name, p.Water, adjustment));
            }

            a.WaterAllocated += adjustment;
            p.Water          -= adjustment;
        }