Ejemplo n.º 1
0
        public int NewUserCharacter(CharacterTransition character, int userID)
        {
            // Get data from the class of the character to use in calculations
            ClassDO _class = dataContext.GetClassDOByClassName(character.Class);

            // Calculate hit points for the new personal character
            int hp = (character.ClassLevel * _class.ClassDiceValue);

            // Adjust the stats for the new personal character based on character level
            int StatMod(int stat)
            {
                if (character.ClassLevel >= 15)
                {
                    stat = stat + 2;
                    if (stat <= 25)
                    {
                        return(stat);
                    }
                    return(25);
                }
                else if (character.ClassLevel >= 10)
                {
                    stat = stat + 1;
                    if (stat <= 25)
                    {
                        return(stat);
                    }
                    return(25);
                }
                return(stat);
            }

            // Add the new personal character to the database and retrieve the id in order to display the new character
            var rv = dataContext.AddUserCharacter(character.Name, character.Class, character.ClassLevel, hp, character.AC, StatMod(character.Strength), StatMod(character.Dexterity), StatMod(character.Constitution), StatMod(character.Intelligence), StatMod(character.Wisdom), StatMod(character.Charisma), character.Description, character.SeriesID_FK, userID);

            return(rv);
        }