Example #1
0
    public static Vocation CreateVocation(VocationType type)
    {
        switch (type)
        {
        case VocationType.Mage:
        {
            return(new Mage());

            break;
        }
        }
        throw new Exception($"You did not implement type '{type}'.");
    }
Example #2
0
        public async Task <ActionResult> GetHighscores(string world, HighScoreType type, VocationType vocation)
        {
            var response = new Response <AllHighScoresDTO>
            {
                Succeed = false
            };

            if (string.IsNullOrEmpty(world))
            {
                response.Message = "The world name must be provided";
                return(BadRequest(response));
            }
            var forbiddenVocations = new VocationType[]
            {
                VocationType.ELDER_DRUID,
                VocationType.MASTER_SORCERER,
                VocationType.ELITE_KNIGHT,
                VocationType.ROYAL_PALADIN
            };

            if (forbiddenVocations.Contains(vocation))
            {
                response.Message = "The provided vocation type is not valid";
                return(BadRequest(response));
            }

            try
            {
                var r = await _highScoresService.GetAllHighScores(
                    world,
                    type.GetHighScore(),
                    vocation.GetVocation().ToLowerInvariant());

                response.Result  = _mapper.Map <AllHighScoresDTO>(r.Response);
                response.Succeed = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, response));
            }
            return(Ok(response));
        }
Example #3
0
        public static string GetVocation(this VocationType vocationType)
        {
            switch (vocationType)
            {
            case VocationType.SORCERER:
                return("Sorcerer");

            case VocationType.MASTER_SORCERER:
                return("Master Sorcerer");

            case VocationType.DRUID:
                return("Druid");

            case VocationType.ELDER_DRUID:
                return("Elder Druid");

            case VocationType.KNIGHT:
                return("Knight");

            case VocationType.ELITE_KNIGHT:
                return("Elite Knight");

            case VocationType.PALADIN:
                return("Paladin");

            case VocationType.ROYAL_PALADIN:
                return("Royal Paladin");

            case VocationType.ALL:
                return("All");

            case VocationType.NONE:
                return("None");

            default:
                throw new ArgumentOutOfRangeException(nameof(vocationType), vocationType, "Couldnt find the vocation string value");
            }
        }