Example #1
0
        Character CharacterByName(string name)
        {
            if (!characters.ContainsKey(name))
            {
                characters[name] = new Character {
                    Name = name, Created = DateTime.Now
                }
            }
            ;
            return(characters[name]);
        }

        Character ReadCharacterData(GameInfo gameInfo)
        {
            Character character = CharacterByName(gameInfo.PlayerData.PlayerName);

            character.UpdateMode((D2Data.Mode)gameInfo.Player.eMode);
            character.IsHardcore  = gameInfo.Client.IsHardcore();
            character.IsExpansion = gameInfo.Client.IsExpansion();

            // Don't update stats and items while dead.
            if (!character.IsDead)
            {
                character.ParseStats(unitReader, gameInfo);
                character.InventoryItemIds = ReadInventoryItemIds(gameInfo.Player);
                character.Items            = ItemInfo.GetItemsByItems(this, GetEquippedItems(gameInfo.Player));
            }

            return(character);
        }
        Character ProcessCharacterData(D2GameInfo gameInfo)
        {
            string    playerName = gameInfo.PlayerData.PlayerName;
            Character character  = CharacterByNameCached(playerName);

            if (wasInTitleScreen)
            {
                // A brand new character has been started.
                // The extra wasInTitleScreen check prevents DI from splitting
                // when it was started AFTER Diablo 2, but the char is still a new char
                if (IsNewChar())
                {
                    ActiveCharacterTimestamp = DateTime.Now;
                    ActiveCharacter          = character;
                    OnCharacterCreated(new CharacterCreatedEventArgs(character));
                }

                // Not in title screen anymore.
                wasInTitleScreen = false;
            }

            character.UpdateMode((D2Data.Mode)gameInfo.Player.eMode);

            // Don't update stats while dead.
            if (!character.IsDead)
            {
                character.ParseStats(unitReader, gameInfo);
            }
            return(character);
        }
Example #3
0
        void ProcessCharacterData(D2GameInfo gameInfo)
        {
            character = GetCurrentCharacter(gameInfo);
            character.UpdateMode((D2Data.Mode)gameInfo.Player.eMode);

            Dictionary <StatIdentifier, D2Stat> playerStats = unitReader.GetStatsMap(gameInfo.Player);
            Dictionary <StatIdentifier, D2Stat> itemStats   = unitReader.GetItemStatsMap(gameInfo.Player);

            character.ParseStats(playerStats, itemStats, gameInfo);
        }
Example #4
0
        Character CharacterByName(string name)
        {
            if (!characters.ContainsKey(name))
            {
                characters[name] = new Character {
                    Name = name, Created = DateTime.Now
                }
            }
            ;
            return(characters[name]);
        }

        Character ReadCharacterData(D2GameInfo gameInfo)
        {
            Character character = CharacterByName(gameInfo.PlayerData.PlayerName);

            if (wasInTitleScreen)
            {
                // A brand new character has been started.
                // The extra wasInTitleScreen check prevents DI from splitting
                // when it was started AFTER Diablo 2, but the char is still a new char
                if (Character.IsNewChar(gameInfo.Player, unitReader, inventoryReader, skillReader))
                {
                    // disable IsAutosplitChar from the other chars created so far
                    foreach (var pair in characters)
                    {
                        pair.Value.IsAutosplitChar = false;
                    }

                    Logger.Info($"A new chararacter was created: {character.Name}");
                    charCount++;
                    character.Deaths          = 0;
                    character.IsAutosplitChar = true;
                    ActiveCharacter           = character;
                    OnCharacterCreated(new CharacterCreatedEventArgs(character));
                }

                // Not in title screen anymore.
                wasInTitleScreen = false;
            }

            character.UpdateMode((D2Data.Mode)gameInfo.Player.eMode);
            character.IsHardcore  = gameInfo.Client.IsHardcore();
            character.IsExpansion = gameInfo.Client.IsExpansion();

            // Don't update stats and items while dead.
            if (!character.IsDead)
            {
                character.ParseStats(unitReader, gameInfo);
                character.EquippedItemStrings = ReadEquippedItemStrings(gameInfo.Player);
                character.InventoryItemIds    = ReadInventoryItemIds(gameInfo.Player);
            }

            return(character);
        }
Example #5
0
        Character ReadCharacterData(GameInfo gameInfo, bool isNewChar)
        {
            var name = gameInfo.PlayerData.PlayerName;

            if (isNewChar)
            {
                // disable IsNewChar from the other chars created so far
                foreach (var pair in characters)
                {
                    pair.Value.IsNewChar = false;
                }
            }

            if (isNewChar || !characters.ContainsKey(name))
            {
                characters[name] = new Character {
                    Name      = name,
                    Created   = DateTime.Now,
                    Guid      = Guid.NewGuid().ToString(),
                    IsNewChar = isNewChar,
                };
            }

            Character character = characters[name];

            character.UpdateMode((D2Data.PlayerMode)gameInfo.Player.eMode);
            character.IsHardcore  = gameInfo.Client.IsHardcore();
            character.IsExpansion = gameInfo.Client.IsExpansion();

            // Don't update stats and items while dead.
            if (!character.IsDead)
            {
                character.Parse(unitReader, gameInfo);
                character.InventoryItemIds = ReadInventoryItemIds(gameInfo.Player);
                character.Items            = GetItemInfosByItems(inventoryReader.GetAllItems(gameInfo.Player), gameInfo.Player);
                character.Skills           = ReadSkillInfos(gameInfo.Player, skillReader);
            }

            return(character);
        }