public ActionResult BuyItem(int itemId)
        {
            int       characterId = Convert.ToInt32(SessionManager.GetCharacterId());
            Character character   = CharacterDAO.GetAllInformations(characterId);

            Item itemToBuy = ItemDAO.Get(itemId);

            if (character.Coins < itemToBuy.Price || character.Level < itemToBuy.RequiredLevel)
            {
                FlashMessage.Danger("Erro: ", "Você não possuí moedas suficientes para realizar a compra ou não tem level suficiente para adquirir o item");
                return(RedirectToAction("Market", "Home", null));
            }

            foreach (var itemInBag in character.Bag.ItemsInBag)
            {
                if (itemInBag.Item == null)
                {
                    character.Coins -= itemToBuy.Price;
                    itemInBag.Item   = itemToBuy;
                    CharacterDAO.Update(character);
                    return(RedirectToAction("Index", "Home", null));
                }
            }
            FlashMessage.Danger("Erro: ", "Você não possuí slots vazios na mochila para armazenar o item");
            return(RedirectToAction("Market", "Home", null));
        }
Ejemplo n.º 2
0
        public ActionResult AttackCharacter(int?characterId)
        {
            if (characterId == null || characterId == Convert.ToInt32(SessionManager.GetCharacterId()))
            {
                FlashMessage.Danger("Erro: ", "Você não não pode atacar o seu próprio personagem!!!");
                return(RedirectToAction("Ranking", "Home"));
            }


            Character challenger = CharacterDAO.GetAllInformations(Convert.ToInt32(SessionManager.GetCharacterId()));
            Character challenged = CharacterDAO.GetAllInformations(characterId);


            Character winner = MakeCombat(challenger, challenged);

            GiveBonusFromCombat(winner);

            CharacterDAO.Update(GiveBonusFromCombat(winner));

            if (winner.CharacterId != Convert.ToInt32(SessionManager.GetCharacterId()))
            {
                FlashMessage.Danger(":/ ", "Você perdeu o combate, tente bater em alguém mais noob!!!");
                return(RedirectToAction("Ranking", "Home"));
            }

            return(RedirectToAction("IsCharacterEnvolved", "Characters"));
        }
        public ActionResult SellItem(int characterId, int itemInBagId)
        {
            Character character = CharacterDAO.GetAllInformations(characterId);
            ItemInBag itemInBag = ItemInBagDAO.Get(itemInBagId);

            character.Coins += itemInBag.Item.Price;
            CharacterDAO.Update(character);

            itemInBag.Equipped = false;
            itemInBag.Item     = null;

            ItemInBagDAO.Update(itemInBag);

            return(RedirectToAction("Index", "Home", null));
        }
        public ActionResult AddAttributePointToAnCharacter(int characterId, int attributeInCharacterId)
        {
            Character character = CharacterDAO.Get(characterId);

            if (character.AttributePoints > 0)
            {
                AttributeInCharacter attributeInCharacter = AttributeInCharacterDAO.Get(attributeInCharacterId);

                attributeInCharacter.ProficiencyPoints++;
                character.AttributePoints--;

                CharacterDAO.Update(character);
                AttributeInCharacterDAO.Update(attributeInCharacter);
            }
            return(RedirectToAction("Index", "Home", null));
        }
        public ActionResult IsCharacterEnvolved()
        {
            Character character = CharacterDAO.Get(Convert.ToInt32(SessionManager.GetCharacterId()));

            if (character.Experience >= character.Level * 10)
            {
                character.Level           += 1;
                character.Experience       = 0;
                character.Coins           += 10;
                character.LifePoints      += 5;
                character.AttributePoints += 1;
                CharacterDAO.Update(character);
                FlashMessage.Confirmation("Evolução ", "Parabéns, você passou de level!!!");
                return(RedirectToAction("Index", "Home"));
            }

            FlashMessage.Confirmation(":) ", "Parabéns, você ganhou esse duelo!!!");
            return(RedirectToAction("Ranking", "Home"));
        }