示例#1
0
    public override string Execute()
    {
        string heroName  = InputArgs.ElementAt(1);
        IHero  heroFound = container.Heroes.FirstOrDefault(x => x.Name == heroName);

        if (heroFound is null)
        {
            throw new ArgumentException(string.Format(Constants.HeroUnfoundNameError, heroName));
        }

        string itemName          = InputArgs.ElementAt(0);
        var    strengthBonus     = long.Parse(InputArgs.ElementAt(2));
        var    agilityBonus      = long.Parse(InputArgs.ElementAt(3));
        var    intelligenceBonus = long.Parse(InputArgs.ElementAt(4));
        var    hitpointsBonus    = long.Parse(InputArgs.ElementAt(5));
        var    damageBonus       = long.Parse(InputArgs.ElementAt(6));

        IItem newItem = new CommonItem(itemName, strengthBonus, agilityBonus, intelligenceBonus, hitpointsBonus, damageBonus);

        heroFound.AddCommonItem(newItem);

        string resultMessage = string.Format(Constants.ItemCreateMessage, itemName, heroName);

        return(resultMessage);
    }
    public override string Execute()
    {
        string heroName  = InputArgs.ElementAt(1);
        IHero  heroFound = container.Heroes.FirstOrDefault(x => x.Name == heroName);

        if (heroFound is null)
        {
            throw new ArgumentException(string.Format(Constants.HeroUnfoundNameError, heroName));
        }

        string recipeName        = InputArgs.ElementAt(0);
        var    strengthBonus     = long.Parse(InputArgs.ElementAt(2));
        var    agilityBonus      = long.Parse(InputArgs.ElementAt(3));
        var    intelligenceBonus = long.Parse(InputArgs.ElementAt(4));
        var    hitpointsBonus    = long.Parse(InputArgs.ElementAt(5));
        var    damageBonus       = long.Parse(InputArgs.ElementAt(6));

        string[] itemsRequiredNames = InputArgs.Skip(7).ToArray();

        IRecipe newRecipe = new Recipe(recipeName, strengthBonus, agilityBonus, intelligenceBonus, hitpointsBonus, damageBonus, itemsRequiredNames);

        heroFound.AddRecipe(newRecipe);
        string resultMessage = string.Format(Constants.RecipeCreatedMessage, recipeName, heroName);

        return(resultMessage);
    }
示例#3
0
    public override string Execute()
    {
        string heroName = InputArgs.ElementAt(0);
        string heroType = InputArgs.ElementAt(1);
        IHero  newHero  = container.heroFactory.CreateHero(heroName, heroType);

        container.Heroes.Add(newHero);
        string resultMessage = string.Format(Constants.HeroCreateMessage, heroType, heroName);

        return(resultMessage);
    }
    public override string Execute()
    {
        string heroName  = InputArgs.ElementAt(0);
        IHero  heroFound = container.Heroes.FirstOrDefault(x => x.Name == heroName);


        if (heroFound is null)
        {
            throw new ArgumentException(string.Format(Constants.HeroUnfoundNameError, heroName));
        }

        string result = Constants.GenerateHeroReport(heroFound);

        return(result);
    }