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));
        }
Пример #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"));
        }
Пример #3
0
        public ActionResult CharacterDetails(int?characterId)
        {
            if (characterId == null)
            {
                return(RedirectToAction("Ranking"));
            }

            return(View(CharacterDAO.GetAllInformations(characterId)));
        }
Пример #4
0
        public ActionResult Index()
        {
            int  userId = Convert.ToInt32(SessionManager.GetUserId());
            User user   = UserDAO.Get(userId);

            if (user.Character == null)
            {
                return(View("GenerateCharacter"));
            }
            Character character = CharacterDAO.GetAllInformations(user.Character.CharacterId);

            return(View(character));
        }
        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));
        }