public static void SwapSortcut(int characterid, sbyte firstslot, sbyte secondslot)
        {
            var shortcut1 = GetShorcut(characterid, firstslot);
            var shortcut2 = GetShorcut(characterid, secondslot);

            if (!shortcut1.IsNull() && !shortcut2.IsNull())
            {
                if (shortcut1.SlotId == firstslot)
                {
                    shortcut1.SlotId = secondslot;
                }
                else
                {
                    shortcut1.SlotId = firstslot;
                }

                if (shortcut2.SlotId == firstslot)
                {
                    shortcut2.SlotId = secondslot;
                }
                else
                {
                    shortcut2.SlotId = firstslot;
                }
                SaveTask.UpdateElement(shortcut2);
            }
            else if (shortcut1 != null)
            {
                shortcut1.SlotId = secondslot;
            }
            SaveTask.UpdateElement(shortcut1);
        }
Esempio n. 2
0
        public void RemoveItem(uint id, uint quantity, bool refresh = true)
        {
            var item = GetItem(id);

            if (item == null)
            {
                Character.NotificationError("Impossible de retirer l'item, il n'éxiste pas...");
                return;
            }

            if (quantity == item.Quantity)
            {
                Items.Remove(item);
                SaveTask.RemoveElement(item);
                CharacterItemRecord.CharactersItems.Remove(item);
                Character.Client.Send(new ObjectDeletedMessage(item.UID));
            }
            else if (quantity < item.Quantity)
            {
                item.Quantity -= (uint)quantity;
                SaveTask.UpdateElement(item);
            }
            if (refresh)
            {
                Refresh();
            }
            Character.RefreshShortcuts();
        }
Esempio n. 3
0
        public void UnequipItem(CharacterItemRecord item, byte newposition, ItemRecord template, uint quantity)
        {
            var existing = Items.ExistingItem(item);

            if (existing == null)
            {
                item.Position = newposition;
                SaveTask.UpdateElement(item);
                ItemEffectsProvider.RemoveEffects(Character.Client, item.GetEffects());
                RemoveItemSkin(item, template);
            }
            else
            {
                if (item.UID != existing.UID)
                {
                    existing.Quantity += quantity;
                    RemoveItem(item.UID, item.Quantity);
                    ItemEffectsProvider.RemoveEffects(Character.Client, item.GetEffects());
                    RemoveItemSkin(item, template);
                }
                else
                {
                    Character.NotificationError("Spamming ItemMove!");
                }
            }
            Character.RefreshGroupInformations();
        }
Esempio n. 4
0
        public void AddJobXp(sbyte jobid, ulong amount)
        {
            var job = CharacterJobRecord.GetJob(Id, jobid);

            if (job.JobLevel == 200)
            {
                return;
            }
            var exp = ExperienceRecord.GetExperienceForLevel((uint)(job.JobLevel + 1));

            if (job.JobExp + amount >= exp)
            {
                job.JobLevel++;
                Client.Send(new JobLevelUpMessage(job.JobLevel, job.GetJobDescription()));
                if (job.JobLevel == 200)
                {
                    job.JobExp = exp;
                    RefreshJobs();
                    return;
                }
                AddJobXp(jobid, amount);
            }
            else
            {
                job.JobExp += amount;
            }
            SaveTask.UpdateElement(job);
            RefreshJobs();
        }
Esempio n. 5
0
 public void Dispose()
 {
     if (Map != null)
     {
         Map.Instance.RemoveClient(Client);
     }
     if (SearchingArena)
     {
         ArenaProvider.Instance.OnClientDisconnected(Client);
     }
     if (IsFighting)
     {
         FighterInstance.OnDisconnect();
     }
     if (PlayerTradeInstance != null)
     {
         PlayerTradeInstance.Abort();
     }
     if (PartyMember != null)
     {
         PartyMember.Party.QuitParty(Client);
     }
     if (DungeonPartyProvider.Instance.GetDPCByCharacterId(this.Id) != null)
     {
         DungeonPartyProvider.Instance.RemoveCharacter(this);
     }
     Client.Character.Look.UnsetAura();
     Record.Look = Look.ConvertToString();
     SaveTask.UpdateElement(Record);
     SaveTask.UpdateElement(StatsRecord);
     Inventory.InitializeForSaveTask();
 }
 public void RemoveItemFromPanel(BankItemRecord obj, int quantity)
 {
     if (obj.IsNull())
     {
         return;
     }
     if (obj.Quantity == (uint)-quantity)
     {
         SaveTask.RemoveElement(obj);
         var existing = Client.Character.Inventory.Items.ExistingItem(obj);
         if (existing != null)
         {
             existing.Quantity += (uint)-quantity;
             SaveTask.UpdateElement(existing);
             Client.Character.Inventory.Refresh();
         }
         else
         {
             Client.Character.Inventory.Add(obj);
         }
         Client.Send(new StorageObjectRemoveMessage(obj.UID));
     }
     else
     {
         obj.Quantity = (uint)(obj.Quantity + quantity);
         SaveTask.UpdateElement(obj);
         Client.Character.Inventory.Add(obj, (uint)-quantity);
         Client.Send(new StorageObjectUpdateMessage(obj.GetObjectItem()));
     }
 }
Esempio n. 7
0
        public void ChangeParameters(WorldClient changer, ushort rank, sbyte experienceGivenPercent, uint rights)
        {
            GuildRecord guild = changer.Character.GetGuild();

            if (guild == null || guild.Id != this.GuildId)
            {
                return;
            }
            CharacterGuildRecord modifier = CharacterGuildRecord.GetCharacterGuild(changer.Character.Id);

            if (modifier != this)
            {
                if (modifier.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_XP_CONTRIBUTION))
                {
                    this.ExperienceGivenPercent = experienceGivenPercent;
                }
            }
            else
            {
                if (this.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_MY_XP_CONTRIBUTION))
                {
                    this.ExperienceGivenPercent = experienceGivenPercent;
                }
            }
            if (modifier.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_RANKS))
            {
                this.Rank = rank;
            }
            if (modifier.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_RIGHTS))
            {
                this.Rights = rights;
            }
            SaveTask.UpdateElement(modifier);
        }
        public ItemCut(CharacterItemRecord item, uint quantity, byte newItempos)
        {
            newItem       = item.CloneAndGetNewUID();
            item.Position = newItempos;
            item.Quantity = quantity;

            newItem.Quantity -= quantity;
            BaseItem          = item;
            SaveTask.UpdateElement(BaseItem);
        }
Esempio n. 9
0
        public static void BeforeSave()
        {
            var online = WorldServer.Instance.GetAllClientsOnline();

            foreach (var client in online)
            {
                client.Character.Look.UnsetAura();
                client.Character.Record.Look = client.Character.Look.ConvertToString();
                SaveTask.UpdateElement(client.Character.Record);
                SaveTask.UpdateElement(client.Character.StatsRecord);
            }
        }
 public void MoveKamas(int amount)
 {
     Client.Account.Informations.BankKamas += (uint)amount;
     Client.Send(new StorageKamasUpdateMessage((int)Client.Account.Informations.BankKamas));
     if (amount < 0)
     {
         Client.Character.AddKamas(-amount);
     }
     else
     {
         Client.Character.RemoveKamas(amount);
     }
     SaveTask.UpdateElement(Client.Account.Informations);
 }
 public override void AddItemToPanel(CharacterItemRecord obj, uint quantity)
 {
     if (obj.IsNull())  // il ajoute a son propre panel
     {
         return;
     }
     if (quantity == obj.Quantity)
     {
         var existing = BankItems.ExistingItem(obj);
         if (!existing.IsNull())
         {
             existing.Quantity += quantity;
             SaveTask.UpdateElement(existing);
             Client.Character.Inventory.RemoveItem(obj.UID, obj.Quantity);
             Client.Send(new StorageObjectUpdateMessage(existing.GetObjectItem()));
             return;
         }
         else
         {
             var newBankItem = obj.GetBankItem(Client.Account.Id);
             Client.Send(new StorageObjectUpdateMessage(newBankItem.GetObjectItem()));
             SaveTask.AddElement(newBankItem);
             Client.Character.Inventory.RemoveItem(obj.UID, obj.Quantity);
             return;
         }
     }
     else
     {
         var existing = BankItems.ExistingItem(obj);
         if (existing != null)
         {
             existing.Quantity += (uint)quantity;
             Client.Send(new StorageObjectUpdateMessage(existing.GetObjectItem()));
             Client.Character.Inventory.RemoveItem(obj.UID, quantity);
             SaveTask.UpdateElement(existing);
             return;
         }
         else
         {
             var addedItem = obj.CloneWithUID(); // fonctionne
             addedItem.Quantity = (uint)quantity;
             Client.Send(new StorageObjectUpdateMessage(addedItem.GetObjectItem()));
             SaveTask.AddElement(addedItem.GetBankItem(Client.Account.Id));
             Client.Character.Inventory.RemoveItem(obj.UID, quantity);
             return;
         }
     }
 }
Esempio n. 12
0
        public void Add(CharacterItemRecord item, bool refresh = true)
        {
            var existingItem = Items.ExistingItem(item);

            if (existingItem == null)
            {
                Items.Add(item);
                if (!CharacterItemRecord.CharactersItems.Contains(item))
                {
                    SaveTask.AddElement(item);
                }
            }
            else
            {
                existingItem.Quantity += item.Quantity;
                SaveTask.UpdateElement(existingItem);
            }
            if (refresh)
            {
                Refresh();
                Character.RefreshShortcuts();
            }
        }
Esempio n. 13
0
 public void RemoveAllEffects()
 {
     m_realEffect.Clear();
     this.Effects = string.Empty;
     SaveTask.UpdateElement(this);
 }
Esempio n. 14
0
 public void InitializeForSaveTask()
 {
     Items.ForEach(x => SaveTask.UpdateElement(x));
 }
Esempio n. 15
0
 /// <summary>
 /// Using SaveTask.cs
 /// </summary>
 /// <param name="table"></param>
 /// <param name="addtolist"></param>
 public static void UpdateElement(this ITable table)
 {
     SaveTask.UpdateElement(table);
 }
Esempio n. 16
0
 public void SetEffects(List <ObjectEffect> effects)
 {
     this.m_realEffect = effects;
     this.Effects      = EffectsToString(m_realEffect);
     SaveTask.UpdateElement(this);
 }
Esempio n. 17
0
        public void EquipItem(CharacterItemRecord item, ItemRecord template, byte newposition, uint quantity)
        {
            if (!ConditionProvider.ParseAndEvaluate(Character.Client, template.Criteria))
            {
                Character.Reply("Vous n'avez pas les critères nessessaire pour équiper cet objet");
                return;
            }
            if (CheckRingStacks(item, newposition))
            {
                Character.Reply("Vous avez déja équipé cet anneau!");
                return;
            }
            if (CheckDofusStacks(item, newposition))
            {
                Character.Reply("Vous avez déja équipé ce dofus");
                return;
            }
            if (DOFUS_POSITIONS.Contains((CharacterInventoryPositionEnum)item.Position) && DOFUS_POSITIONS.Contains((CharacterInventoryPositionEnum)newposition))
            {
                return;
            }
            if ((CharacterInventoryPositionEnum)newposition == CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD)
            {
                var weapon = GetEquipedWeapon();
                if (weapon != null)
                {
                    if (WeaponRecord.GetWeapon(weapon.GID).TwoHanded)
                    {
                        Character.Reply("Vous devez deséquiper votre arme pour équiper le bouclier.");
                        return;
                    }
                }
            }
            if ((CharacterInventoryPositionEnum)newposition == CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON)
            {
                var shield = GetItemByPosition(CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD);
                if (WeaponRecord.GetWeapon(item.GID).TwoHanded)
                {
                    Character.Reply("Vous devez enlevé votre bouclier pour équiper votre arme.");
                    return;
                }
            }
            var equiped = EquipedItem(newposition);

            if (equiped != null)
            {
                UnequipItem(equiped, 63, equiped.GetTemplate(), quantity);
                SaveTask.UpdateElement(equiped);
            }
            if (item.Quantity == 1)
            {
                item.Position = newposition;
                SaveTask.UpdateElement(item);
                AddItemSkin(item, template);
                ItemEffectsProvider.AddEffects(Character.Client, item.GetEffects());
            }
            else
            {
                var items = ItemCut.Cut(item, quantity, newposition);
                Add(items.newItem);
                ItemEffectsProvider.AddEffects(Character.Client, items.BaseItem.GetEffects());
                AddItemSkin(item, template);
            }
            Character.RefreshGroupInformations();
        }
Esempio n. 18
0
 public void AddEffects(List <ObjectEffect> effects)
 {
     this.m_realEffect.AddRange(effects);
     this.Effects = EffectsToString(m_realEffect);
     SaveTask.UpdateElement(this);
 }
Esempio n. 19
0
 public void RemoveAllEffect(EffectsEnum effect)
 {
     this.m_realEffect.RemoveAll(x => x.actionId == (ushort)effect);
     this.Effects = EffectsToString(m_realEffect);
     SaveTask.UpdateElement(this);
 }