Example #1
0
        /// <summary>
        /// Buy water and development rights for a particular parcel
        /// </summary>
        /// <param name="rawBuyPointId"></param>
        /// <param name="rawPlayerId"></param>
        public void BuyLandRights(string rawBuyPointId, string rawPlayerId)
        {
            UUID playerId = WaterWarsUtils.ParseRawId(rawPlayerId);

            Player buyer = GetPlayer(playerId);

            UUID buyPointId = WaterWarsUtils.ParseRawId(rawBuyPointId);

            BuyPoint bp = GetBuyPoint(buyPointId);

            if (buyer.Money < bp.CombinedPrice)
            {
                // A messy abstraction breaking hack to alert the player that they can't go ahead.
                m_controller.HudManager.m_playerIdToHud[buyer.Uuid].m_statusButton.SendAlert(
                    buyer.Uuid,
                    string.Format(
                        "Can't buy rights because they cost {0}{1} and you only have {2}{3}",
                        WaterWarsConstants.MONEY_UNIT, bp.CombinedPrice,
                        WaterWarsConstants.MONEY_UNIT, buyer.Money));
            }
            else
            {
                m_controller.State.BuyLandRights(bp, buyer);
            }
        }
Example #2
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);
            }
        }
Example #3
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));
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
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));
        }
Example #7
0
        /// <summary>
        /// Buy a game asset.
        /// </summary>
        /// This is called by code which only has the ids available.
        /// <param name="rawBuyPointId"></param>
        /// <param name="rawFieldId"></param>
        /// <param name="level"></param>
        public AbstractGameAsset BuildGameAsset(string rawBuyPointId, string rawFieldId, int level)
        {
            UUID buyPointId = WaterWarsUtils.ParseRawId(rawBuyPointId);
            UUID fieldId    = WaterWarsUtils.ParseRawId(rawFieldId);

            BuyPoint bp = GetBuyPoint(buyPointId);
            Field    f  = GetField(bp, fieldId);
            Player   p  = bp.DevelopmentRightsOwner;

            return(BuildGameAsset(f, p.Role.AllowedAssets[0], level));
        }
Example #8
0
        /// <summary>
        /// Add a player
        /// </summary>
        /// <param name="rawPlayerId"></param>
        /// <param name="roleType"></param>
        /// <returns>Player added</returns>
        public Player AddPlayer(string rawPlayerId, RoleType roleType)
        {
            IRole role = null;

            switch (roleType)
            {
            case RoleType.Developer:
                role = Developer.Singleton;
                break;

            case RoleType.Farmer:
                role = Farmer.Singleton;
                break;

            case RoleType.Manufacturer:
                role = Manufacturer.Singleton;
                break;

            case RoleType.WaterMaster:
                role = WaterMaster.Singleton;
                break;
            }

            UUID playerId = WaterWarsUtils.ParseRawId(rawPlayerId);

            ScenePresence scenePresence = null;

            // Look for the presence in every scene.  If this kind of thing becomes common we will need to refactor the
            // code
            foreach (Scene scene in m_controller.Scenes)
            {
                ScenePresence sp = scene.GetScenePresence(playerId);
                if (sp != null)
                {
                    scenePresence = sp;
                    break;
                }
            }

            if (null == scenePresence)
            {
                throw new Exception(
                          string.Format(
                              "ScenePresence unexpectedly null for player {0} registering for role {1}", playerId, roleType));
            }

            Player newPlayer = m_controller.ModelFactory.CreatePlayer(scenePresence.UUID, scenePresence.Name, role);

            m_controller.State.AddPlayer(newPlayer);

            return(newPlayer);
        }
Example #9
0
 public Field GetField(BuyPoint bp, string rawUuid)
 {
     return(GetField(bp, WaterWarsUtils.ParseRawId(rawUuid)));
 }
Example #10
0
 public AbstractGameAsset GetAsset(BuyPoint bp, string rawUuid)
 {
     return(GetAsset(bp, WaterWarsUtils.ParseRawId(rawUuid)));
 }
Example #11
0
 public Player GetPlayer(string rawUuid)
 {
     return(GetPlayer(WaterWarsUtils.ParseRawId(rawUuid)));
 }
Example #12
0
 public BuyPoint GetBuyPoint(string rawUuid)
 {
     return(GetBuyPoint(WaterWarsUtils.ParseRawId(rawUuid)));
 }