Esempio n. 1
0
 public CharacterEngine(CharacterRecord record, GameClient client)
 {
     Record = record;
     Client = client;
     Stats  = new StatEngine(this);
     Spells = CharacterSpellRecord.ReturnCharacterSpells(Id);
 }
        public CharacterSpell LearnSpell(SpellTemplate template)
        {
            CharacterSpellRecord record = Singleton <SpellManager> .Instance.CreateSpellRecord(this.Owner.Record, template);

            CharacterSpell characterSpell = new CharacterSpell(record);

            this.m_spells.Add(characterSpell.Id, characterSpell);
            InventoryHandler.SendSpellUpgradeSuccessMessage(this.Owner.Client, characterSpell);
            return(characterSpell);
        }
Esempio n. 3
0
        public void BoostSpell(ushort spellid, sbyte level)
        {
            SpellItem actualSpell = GetSpell(spellid);
            sbyte     cost        = GetBoostCost(actualSpell.spellLevel, level);

            Record.SpellPoints    -= (ushort)cost;
            actualSpell.spellLevel = level;
            CharacterSpellRecord.UpdateSpellLevel(actualSpell);
            Client.Send(new SpellUpgradeSuccessMessage(spellid, level));
            RefreshStats();
        }
Esempio n. 4
0
        public static void HandleSpellUpgradeRequestMessage(Client client, SpellUpgradeRequestMessage message)
        {
            CharacterSpellRecord spellRecord = client.Character.Spells.FirstOrDefault(spell => spell.SpellId == message.spellId);

            if (spellRecord != null && client.Character.SpellsPoints > 0)
            {
                client.Character.SpellsPoints--;
                client.Send(new SpellUpgradeSuccessMessage(spellRecord.SpellId, spellRecord.Level++));
                CharacterHandler.SendCharacterStatsListMessage(client);
                InventoryHandler.SendSpellListMessage(client);
            }
            else
            {
                client.Send(new SpellUpgradeFailureMessage());
            }
        }
        public static void HandleCharacterDeletion(CharacterDeletionRequestMessage message, WorldClient client) // finish this
        {
            CharacterRecord deletedCharacter = CharacterRecord.GetCharacterRecordById(message.characterId);

            if (deletedCharacter == null)
            {
                return;
            }
            StatsRecord.GetStatsRecord(message.characterId).RemoveElement();
            CharacterRecord.Characters.Remove(deletedCharacter);
            client.Characters.Remove(deletedCharacter);
            deletedCharacter.RemoveElement();
            CharacterItemRecord.RemoveAll(message.characterId);
            GeneralShortcutRecord.RemoveAll(message.characterId);
            CharacterSpellRecord.RemoveAll(message.characterId);
            CharacterJobRecord.RemoveAll(message.characterId);
            BidShopGainRecord.RemoveAll(message.characterId);
            CharacterGuildRecord.RemoveAll(message.characterId); // Si il est meneur de guilde?
            BidShopItemRecord.RemoveAll(message.characterId);
            Logger.Log("Character " + deletedCharacter.Name + " deleted");

            client.Send(new CharactersListMessage(client.Characters.ConvertAll <CharacterBaseInformations>(x => x.GetBaseInformation()), false));
        }
Esempio n. 6
0
        public static void HandleSpellMoveMessage(Client client, SpellMoveMessage message)
        {
            CharacterSpellRecord spellRecord = client.Character.Spells.FirstOrDefault(spell => spell.SpellId == message.spellId);

            if (spellRecord != null)
            {
                byte oldPosition = spellRecord.Position;
                byte newPosition = message.position;
                CharacterSpellRecord spell2Record = client.Character.Spells.FirstOrDefault(x => x.Position == newPosition);
                if (spell2Record != null)
                {
                    spellRecord.Position  = newPosition;
                    spell2Record.Position = oldPosition;
                    client.Send(new SpellMovementMessage((short)spellRecord.SpellId, newPosition));
                    client.Send(new SpellMovementMessage((short)spell2Record.SpellId, oldPosition));
                }
                else
                {
                    spellRecord.Position = newPosition;
                    client.Send(new SpellMovementMessage((short)spellRecord.SpellId, newPosition));
                }
            }
        }
        public void Save()
        {
            lock (this.m_locker)
            {
                Stump.ORM.Database database = ServerBase <WorldServer> .Instance.DBAccessor.Database;
                using (System.Collections.Generic.Dictionary <int, CharacterSpell> .Enumerator enumerator = this.m_spells.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        System.Collections.Generic.KeyValuePair <int, CharacterSpell> current = enumerator.Current;
                        database.Save(current.Value.Record);
                    }
                    goto IL_79;
                }
IL_65:
                CharacterSpellRecord poco = this.m_spellsToDelete.Dequeue();
                database.Delete(poco);
IL_79:
                if (this.m_spellsToDelete.Count > 0)
                {
                    goto IL_65;
                }
            }
        }
Esempio n. 8
0
 public bool CanBoostSpell(CharacterSpellRecord spell)
 {
     //Need to add a check if the character is fighting when fight will be done.
     return(SpellsPoints >= 0 && spell != null && spell.Level < 6 && SpellsPoints >= spell.Level && Spells.Contains(spell));
 }
Esempio n. 9
0
 public CharacterSpell(CharacterSpellRecord record)
     : base(record)
 {
     Record = record;
 }