Example #1
0
        public static Database.Records.WorldItemRecord GenerateItem(World.Network.WorldClient client, int templateID, bool canGenerateMount = true)
        {
            try
            {
                Database.Records.ItemRecord template = Database.Cache.ItemCache.Cache.First(x => x.ID == templateID);
                Database.Records.WorldItemRecord item = new Database.Records.WorldItemRecord();
                item.Template = templateID;
                item.Engine.Effects = template.Engine.GetRandomEffect();
                item.Owner = client.Character.ID;
                item.Effects = item.Engine.StringEffect();
                item.Position = -1;
                item.Quantity = 1;

                item.SaveAndFlush();

                if (canGenerateMount)
                {
                    Database.Records.MountTemplateRecord mount = Helper.MountHelper.GetMountTemplateByScrool(item.Template);
                    if (mount != null)
                    {
                        Database.Records.WorldMountRecord newWMount = Game.Mounts.MountFactory.CreateMount(mount, item.ID, client.Character.ID);
                    }
                }

                return item;
            }
            catch (Exception e)
            {
                Utilities.ConsoleStyle.Error("Cant generate items : " + e.ToString());
                return null;
            }
        }
Example #2
0
 public void RemoveItem(Database.Records.WorldItemRecord item, int quantity, bool removeFromDB = true)
 {
     if (_character != null)
     {
         if (_character.Player != null)
         {
             if (item.Quantity - quantity < 1)
             {
                 _character.Player.Send("OR" + item.ID);
                 item.Owner = -1;
                 item.SaveAndFlush();
                 if (removeFromDB)
                 {
                     item.DeleteAndFlush();
                 }
                 Items.Remove(item);
             }
             else
             {
                 item.Quantity -= quantity;
                 RefreshQuantity(item);
             }
             _character.Player.Action.RefreshPods();
         }
     }
 }
Example #3
0
        public static Database.Records.WorldItemRecord GenerateItem(World.Network.WorldClient client, int templateID, bool canGenerateMount = true)
        {
            try
            {
                Database.Records.ItemRecord      template = Database.Cache.ItemCache.Cache.First(x => x.ID == templateID);
                Database.Records.WorldItemRecord item     = new Database.Records.WorldItemRecord();
                item.Template       = templateID;
                item.Engine.Effects = template.Engine.GetRandomEffect();
                item.Owner          = client.Character.ID;
                item.Effects        = item.Engine.StringEffect();
                item.Position       = -1;
                item.Quantity       = 1;

                item.SaveAndFlush();

                if (canGenerateMount)
                {
                    Database.Records.MountTemplateRecord mount = Helper.MountHelper.GetMountTemplateByScrool(item.Template);
                    if (mount != null)
                    {
                        Database.Records.WorldMountRecord newWMount = Game.Mounts.MountFactory.CreateMount(mount, item.ID, client.Character.ID);
                    }
                }

                return(item);
            }
            catch (Exception e)
            {
                Utilities.ConsoleStyle.Error("Cant generate items : " + e.ToString());
                return(null);
            }
        }
Example #4
0
 public Database.Records.WorldItemRecord AddItem(Database.Records.WorldItemRecord item, bool newStack = false, int quantity = 1)
 {
     if (item.Position == -1)
     {
         try
         {
             dontHaveItem :;
             if (!HaveItemWithSameEffects(item.Effects, -1, item.Template) || newStack)
             {
                 item.Quantity = quantity;
                 item.SaveAndFlush();
                 Items.Add(item);
                 if (_character != null)
                 {
                     if (_character.Player != null)
                     {
                         _character.Player.Send("OAKO" + item.DisplayItem);
                         _character.Player.Action.RefreshPods();
                     }
                 }
                 return(item);
             }
             else
             {
                 Database.Records.WorldItemRecord existItem = GetItemWithSameEffects(item.Effects, item.Template);
                 if (existItem != null)
                 {
                     item.DeleteAndFlush();
                     existItem.Quantity += quantity;
                     RefreshQuantity(existItem);
                     return(existItem);
                 }
                 else
                 {
                     newStack = true;
                     goto dontHaveItem;
                 }
             }
         }
         catch (Exception e)
         {
             Utilities.ConsoleStyle.Error("Cant add item : " + e.ToString());
         }
         return(null);
     }
     else
     {
         if (_character != null)
         {
             if (_character.Player != null)
             {
                 _character.Player.Send("OAKO" + item.DisplayItem);
                 _character.Player.Action.RefreshPods();
             }
         }
         Items.Add(item);
         return(item);
     }
 }
Example #5
0
 public Database.Records.WorldItemRecord DuplicateItem(Database.Records.WorldItemRecord item, int pos, bool send = true)
 {
     Database.Records.WorldItemRecord newItem = new Database.Records.WorldItemRecord();
     newItem.Effects  = item.Effects;
     newItem.Template = item.Template;
     newItem.Position = pos;
     newItem.Quantity = 1;
     newItem.Owner    = item.Owner;
     newItem.Engine.Load(newItem.Effects, item.GetTemplate.WeaponInfo);
     newItem.SaveAndFlush();
     if (send)
     {
         Items.Add(newItem);
         _character.Player.Send("OAKO" + newItem.DisplayItem);
         _character.Player.Action.RefreshPods();
     }
     return(newItem);
 }
Example #6
0
        public void ProcessExchange()
        {
            #region Item Process

            foreach (var item in this.ItemsStack1)
            {
                if (item.Quantity == item.WItem.Quantity)
                {
                    Requester.Character.Items.RemoveItem(item.WItem, item.Quantity, false);
                    Requested.Character.Items.AddItem(item.WItem, false, item.Quantity);
                    item.WItem.Owner = Requested.Character.ID;
                }
                else
                {
                    var newItem = new Database.Records.WorldItemRecord()
                    {
                        Owner    = Requested.Character.ID,
                        Template = item.WItem.Template,
                        Quantity = item.Quantity,
                        Position = -1,
                        Effects  = item.WItem.Effects,
                    };
                    Requester.Character.Items.RemoveItem(item.WItem, item.Quantity);
                    newItem.Engine.Load(newItem.Effects, newItem.GetTemplate.WeaponInfo);
                    Requested.Character.Items.AddItem(newItem);
                    newItem.SaveAndFlush();
                }
                item.WItem.SaveAndFlush();
            }

            foreach (var item in this.ItemsStack2)
            {
                if (item.Quantity == item.WItem.Quantity)
                {
                    Requested.Character.Items.RemoveItem(item.WItem, item.Quantity, false);
                    Requester.Character.Items.AddItem(item.WItem, false, item.Quantity);
                    item.WItem.Owner = Requester.Character.ID;
                }
                else
                {
                    var newItem = new Database.Records.WorldItemRecord()
                    {
                        Owner    = Requester.Character.ID,
                        Template = item.WItem.Template,
                        Quantity = item.Quantity,
                        Position = -1,
                        Effects  = item.WItem.Effects,
                    };
                    Requested.Character.Items.RemoveItem(item.WItem, item.Quantity);
                    newItem.Engine.Load(newItem.Effects, newItem.GetTemplate.WeaponInfo);
                    Requester.Character.Items.AddItem(newItem);
                    newItem.SaveAndFlush();
                }
                item.WItem.SaveAndFlush();
            }

            #endregion

            #region Kamas Process

            Requester.Character.Kamas -= Requester.Action.KamasExchangeStack;
            Requested.Character.Kamas += Requester.Action.KamasExchangeStack;

            Requested.Character.Kamas -= Requested.Action.KamasExchangeStack;
            Requester.Character.Kamas += Requested.Action.KamasExchangeStack;

            #endregion

            this.Requester.Send("EVa");
            this.Requested.Send("EVa");
            this.Exit(false);

            this.Requester.Action.SaveContents();
            this.Requested.Action.SaveContents();

            this.Requester.Character.Stats.RefreshStats();
            this.Requested.Character.Stats.RefreshStats();
        }
Example #7
0
        public void ProcessExchange()
        {
            #region Item Process

            foreach (var item in this.ItemsStack1)
            {
                if (item.Quantity == item.WItem.Quantity)
                {
                    Requester.Character.Items.RemoveItem(item.WItem, item.Quantity, false);
                    Requested.Character.Items.AddItem(item.WItem, false, item.Quantity);
                    item.WItem.Owner = Requested.Character.ID;
                }
                else
                {
                    var newItem = new Database.Records.WorldItemRecord()
                    {
                        Owner = Requested.Character.ID,
                        Template = item.WItem.Template,
                        Quantity = item.Quantity,
                        Position = -1,
                        Effects = item.WItem.Effects,
                    };
                    Requester.Character.Items.RemoveItem(item.WItem, item.Quantity);
                    newItem.Engine.Load(newItem.Effects, newItem.GetTemplate.WeaponInfo);
                    Requested.Character.Items.AddItem(newItem);
                    newItem.SaveAndFlush();
                }
                item.WItem.SaveAndFlush();
            }

            foreach (var item in this.ItemsStack2)
            {
                if (item.Quantity == item.WItem.Quantity)
                {
                    Requested.Character.Items.RemoveItem(item.WItem, item.Quantity, false);
                    Requester.Character.Items.AddItem(item.WItem, false, item.Quantity);
                    item.WItem.Owner = Requester.Character.ID;
                }
                else
                {
                    var newItem = new Database.Records.WorldItemRecord()
                    {
                        Owner = Requester.Character.ID,
                        Template = item.WItem.Template,
                        Quantity = item.Quantity,
                        Position = -1,
                        Effects = item.WItem.Effects,
                    };
                    Requested.Character.Items.RemoveItem(item.WItem, item.Quantity);
                    newItem.Engine.Load(newItem.Effects, newItem.GetTemplate.WeaponInfo);
                    Requester.Character.Items.AddItem(newItem);
                    newItem.SaveAndFlush();
                }
                item.WItem.SaveAndFlush();
            }

            #endregion

            #region Kamas Process

            Requester.Character.Kamas -= Requester.Action.KamasExchangeStack;
            Requested.Character.Kamas += Requester.Action.KamasExchangeStack;

            Requested.Character.Kamas -= Requested.Action.KamasExchangeStack;
            Requester.Character.Kamas += Requested.Action.KamasExchangeStack;

            #endregion

            this.Requester.Send("EVa");
            this.Requested.Send("EVa");
            this.Exit(false);

            this.Requester.Action.SaveContents();
            this.Requested.Action.SaveContents();

            this.Requester.Character.Stats.RefreshStats();
            this.Requested.Character.Stats.RefreshStats();
        }
Example #8
0
 public Database.Records.WorldItemRecord DuplicateItem(Database.Records.WorldItemRecord item, int pos, bool send = true)
 {
     Database.Records.WorldItemRecord newItem = new Database.Records.WorldItemRecord();
     newItem.Effects = item.Effects;
     newItem.Template = item.Template;
     newItem.Position = pos;
     newItem.Quantity = 1;
     newItem.Owner = item.Owner;
     newItem.Engine.Load(newItem.Effects, item.GetTemplate.WeaponInfo);
     newItem.SaveAndFlush();
     if (send)
     {
         Items.Add(newItem);
         _character.Player.Send("OAKO" + newItem.DisplayItem);
         _character.Player.Action.RefreshPods();
     }
     return newItem;
 }