Exemplo n.º 1
0
        //public bool FixCharacterExpGain(Guid characterId)
        //{
        //    var character = gameData.GetCharacter(characterId);
        //    if (character == null) return false;
        //    var playerSkills = gameData.GetSkills(character.SkillsId);
        //    if (playerSkills == null) return false;

        //    var skills = playerSkills.GetSkills();
        //    foreach (var skill in skills)
        //    {
        //        var level = skill.Level;
        //        var cappedLevel = level > 170 ? 170 : level;
        //        var expBase = GameMath.OLD_ExperienceToLevel(cappedLevel);

        //        var newLevelDiff = level - cappedLevel;
        //        var totalGainedExp = 0m;
        //        for (var i = 1; i <= newLevelDiff; ++i)
        //        {
        //            totalGainedExp += GameMath.ExperienceForLevel(level + i);
        //        }
        //        skill.Experience
        //    }
        //}

        public bool AddCoins(string query, string identifier)
        {
            var character = itemResolver.ResolveCharacter(query, identifier);

            if (character == null)
            {
                return(false);
            }
            var amount = query.Split(' ').LastOrDefault();

            if (long.TryParse(amount, out var amountValue))
            {
                var resx = gameData.GetResourcesByCharacterId(character.Id);
                if (resx == null)
                {
                    resx = new DataModels.Resources
                    {
                        Id    = Guid.NewGuid(),
                        Coins = amountValue
                    };
                    character.ResourcesId = resx.Id;
                    gameData.Add(resx);
                    return(true);
                }

                resx.Coins += amountValue;
                return(true);
            }

            return(false);
        }