예제 #1
0
        /// <summary>
        /// Sells all the sessions plants
        /// </summary>
        public static int SellPlants(GameClient Session)
        {
            if (Session == null || Session.GetRoleplay() == null || Session.GetRoleplay().FarmingStats == null)
            {
                return(0);
            }

            var Satchel = Session.GetRoleplay().FarmingStats.PlantSatchel;
            int Amount  = 0;

            #region Plumerias
            if (Satchel.YellowPlumerias > 0)
            {
                FarmingItem Item = GetFarmingItem(1);
                if (Item != null)
                {
                    Amount += (Satchel.YellowPlumerias * Item.SellPrice);
                    Satchel.YellowPlumerias = 0;
                }
            }

            if (Satchel.BluePlumerias > 0)
            {
                FarmingItem Item = GetFarmingItem(2);
                if (Item != null)
                {
                    Amount += (Satchel.BluePlumerias * Item.SellPrice);
                    Satchel.BluePlumerias = 0;
                }
            }

            if (Satchel.PinkPlumerias > 0)
            {
                FarmingItem Item = GetFarmingItem(3);
                if (Item != null)
                {
                    Amount += (Satchel.PinkPlumerias * Item.SellPrice);
                    Satchel.PinkPlumerias = 0;
                }
            }
            #endregion

            #region Primroses
            if (Satchel.YellowPrimroses > 0)
            {
                FarmingItem Item = GetFarmingItem(4);
                if (Item != null)
                {
                    Amount += (Satchel.YellowPrimroses * Item.SellPrice);
                    Satchel.YellowPrimroses = 0;
                }
            }

            if (Satchel.BluePrimroses > 0)
            {
                FarmingItem Item = GetFarmingItem(5);
                if (Item != null)
                {
                    Amount += (Satchel.BluePrimroses * Item.SellPrice);
                    Satchel.BluePrimroses = 0;
                }
            }

            if (Satchel.PinkPrimroses > 0)
            {
                FarmingItem Item = GetFarmingItem(6);
                if (Item != null)
                {
                    Amount += (Satchel.PinkPrimroses * Item.SellPrice);
                    Satchel.PinkPrimroses = 0;
                }
            }
            #endregion

            #region Dahlias
            if (Satchel.YellowDahlias > 0)
            {
                FarmingItem Item = GetFarmingItem(7);
                if (Item != null)
                {
                    Amount += (Satchel.YellowDahlias * Item.SellPrice);
                    Satchel.YellowDahlias = 0;
                }
            }

            if (Satchel.BlueDahlias > 0)
            {
                FarmingItem Item = GetFarmingItem(8);
                if (Item != null)
                {
                    Amount += (Satchel.BlueDahlias * Item.SellPrice);
                    Satchel.BlueDahlias = 0;
                }
            }

            if (Satchel.PinkDahlias > 0)
            {
                FarmingItem Item = GetFarmingItem(9);
                if (Item != null)
                {
                    Amount += (Satchel.PinkDahlias * Item.SellPrice);
                    Satchel.PinkDahlias = 0;
                }
            }
            #endregion

            #region Starflowers
            if (Satchel.YellowStarflowers > 0)
            {
                FarmingItem Item = GetFarmingItem(10);
                if (Item != null)
                {
                    Amount += (Satchel.YellowStarflowers * Item.SellPrice);
                    Satchel.YellowStarflowers = 0;
                }
            }

            if (Satchel.BlueStarflowers > 0)
            {
                FarmingItem Item = GetFarmingItem(11);
                if (Item != null)
                {
                    Amount += (Satchel.BlueStarflowers * Item.SellPrice);
                    Satchel.BlueStarflowers = 0;
                }
            }

            if (Satchel.RedStarflowers > 0)
            {
                FarmingItem Item = GetFarmingItem(12);
                if (Item != null)
                {
                    Amount += (Satchel.RedStarflowers * Item.SellPrice);
                    Satchel.RedStarflowers = 0;
                }
            }
            #endregion

            return(Amount);
        }
예제 #2
0
        /// <summary>
        /// Generates the FarmingItems dictionary based on database
        /// </summary>
        public static void Initialize()
        {
            #region Farming Items
            FarmingItems.Clear();

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `rp_farming`");
                DataTable Table = dbClient.getTable();

                if (Table != null)
                {
                    foreach (DataRow Row in Table.Rows)
                    {
                        int    Id            = Convert.ToInt32(Row["id"]);
                        string BaseItem      = Row["base_item"].ToString().ToLower();
                        int    LevelRequired = Convert.ToInt32(Row["level_required"]);
                        int    MinExp        = Convert.ToInt32(Row["min_exp"]);
                        int    MaxExp        = Convert.ToInt32(Row["max_exp"]);
                        int    SellPrice     = Convert.ToInt32(Row["sell_price"]);
                        int    BuyPrice      = Convert.ToInt32(Row["buy_price"]);

                        FarmingItem FarmingItem = new FarmingItem(Id, BaseItem, LevelRequired, MinExp, MaxExp, SellPrice, BuyPrice);

                        if (!FarmingItems.ContainsKey(BaseItem))
                        {
                            FarmingItems.TryAdd(BaseItem, FarmingItem);
                        }
                    }
                }
            }
            //log.Info("Carregado " + FarmingItems.Count + " itens agrícolas.");
            #endregion

            #region Farming Spaces

            #region Remove all existing farming spaces
            if (FarmingSpaces.Count > 0)
            {
                foreach (var Space in FarmingSpaces.Values)
                {
                    if (Space.Item == null)
                    {
                        continue;
                    }

                    if (Space.Item.GetRoom() == null || Space.Item.GetRoom().GetRoomItemHandler() == null)
                    {
                        continue;
                    }

                    Space.Item.GetRoom().GetRoomItemHandler().RemoveFurniture(null, Space.Item.Id);

                    using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE `rp_farming_spaces` SET `expiration` = @expiration, `owner_id` = @owner WHERE `id` = @id");
                        dbClient.AddParameter("owner", Space.OwnerId);
                        dbClient.AddParameter("expiration", Space.Expiration);
                        dbClient.AddParameter("id", Space.Id);
                        dbClient.RunQuery();
                    }
                }
            }
            #endregion

            FarmingSpaces.Clear();

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `rp_farming_spaces`");
                DataTable Table = dbClient.getTable();

                if (Table != null)
                {
                    foreach (DataRow Row in Table.Rows)
                    {
                        int    Id         = Convert.ToInt32(Row["id"]);
                        int    ItemId     = Convert.ToInt32(Row["item_id"]);
                        int    RoomId     = Convert.ToInt32(Row["room_id"]);
                        int    Cost       = Convert.ToInt32(Row["cost"]);
                        int    X          = Convert.ToInt32(Row["x"]);
                        int    Y          = Convert.ToInt32(Row["y"]);
                        double Z          = Convert.ToDouble(Row["z"]);
                        int    OwnerId    = Convert.ToInt32(Row["owner_id"]);
                        int    Expiration = Convert.ToInt32(Row["expiration"]);

                        FarmingSpace FarmingSpace = new FarmingSpace(Id, ItemId, RoomId, Cost, X, Y, Z, OwnerId, Expiration);

                        if (!FarmingSpaces.ContainsKey(Id))
                        {
                            FarmingSpaces.TryAdd(Id, FarmingSpace);
                            FarmingSpace.SpawnSign();
                        }
                    }
                }
            }
            //log.Info("Carregado " + FarmingSpaces.Count + " espaços agrícolas.");
            #endregion
        }
예제 #3
0
        /// <summary>
        /// Increases the sessions satchel based on the amount and plant bool (false = seed satchel)
        /// </summary>
        public static void IncreaseSatchelCount(GameClient Session, FarmingItem Item, int Amount, bool Plant)
        {
            if (Session == null || Item == null || Session.GetRoleplay() == null || Session.GetRoleplay().FarmingStats == null)
            {
                return;
            }

            #region Plant Satchel
            if (Plant)
            {
                switch (Item.Id)
                {
                case 1:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.YellowPlumerias += Amount;
                    break;

                case 2:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.BluePlumerias += Amount;
                    break;

                case 3:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.PinkPlumerias += Amount;
                    break;

                case 4:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.YellowPrimroses += Amount;
                    break;

                case 5:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.BluePrimroses += Amount;
                    break;

                case 6:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.PinkPrimroses += Amount;
                    break;

                case 7:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.YellowDahlias += Amount;
                    break;

                case 8:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.BlueDahlias += Amount;
                    break;

                case 9:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.PinkDahlias += Amount;
                    break;

                case 10:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.YellowStarflowers += Amount;
                    break;

                case 11:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.BlueStarflowers += Amount;
                    break;

                case 12:
                    Session.GetRoleplay().FarmingStats.PlantSatchel.RedStarflowers += Amount;
                    break;
                }
            }
            #endregion

            #region Seed Satchel
            else
            {
                switch (Item.Id)
                {
                case 1:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.YellowPlumeriaSeeds += Amount;
                    break;

                case 2:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.BluePlumeriaSeeds += Amount;
                    break;

                case 3:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.PinkPlumeriaSeeds += Amount;
                    break;

                case 4:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.YellowPrimroseSeeds += Amount;
                    break;

                case 5:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.BluePrimroseSeeds += Amount;
                    break;

                case 6:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.PinkPrimroseSeeds += Amount;
                    break;

                case 7:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.YellowDahliaSeeds += Amount;
                    break;

                case 8:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.BlueDahliaSeeds += Amount;
                    break;

                case 9:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.PinkDahliaSeeds += Amount;
                    break;

                case 10:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.YellowStarflowerSeeds += Amount;
                    break;

                case 11:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.BlueStarflowerSeeds += Amount;
                    break;

                case 12:
                    Session.GetRoleplay().FarmingStats.SeedSatchel.RedStarflowerSeeds += Amount;
                    break;
                }
            }
            #endregion
        }