Exemplo n.º 1
0
        public void ReturnInt_MageAttack(int baseDamage, int expectedDamage)
        {
            Player player = new Mage();
            int    result = player.Attack(baseDamage);

            result.Should().Be(expectedDamage);
        }
        static void Main()
        {
            Character mage    = new Mage(); // The punisher
            Character warrior = new Warrior();
            Priest    priest  = new Priest();

            PrintInfo(mage, warrior, priest);
            Console.WriteLine("Mage attacks the Warrior; Priest heals the Mage.");

            mage.Attack(warrior);
            priest.Heal(mage);
            PrintInfo(mage, warrior, priest);
            Console.WriteLine("Warrior attacks the Mage");

            warrior.Attack(mage);
            PrintInfo(mage, warrior, priest);
            Console.WriteLine("Priest heals the Warrior (he betrays the Mage).");

            priest.Heal(warrior);
            PrintInfo(mage, warrior, priest);
            Console.WriteLine("Mage attacks the Warrior; Priest heals the Warrior.");

            mage.Attack(warrior);
            priest.Heal(warrior);
            PrintInfo(mage, warrior, priest);
            Console.WriteLine("Mage attacks the Warrior; Warrior attacks the Mage.");

            mage.Attack(warrior);
            warrior.Attack(mage);
            PrintInfo(mage, warrior, priest);
            Console.WriteLine("Mage punishes the Warrior and the Priest by one-shoting them.");

            mage.Attack(warrior);
            mage.Attack(priest);
            PrintInfo(mage, warrior, priest);
        }
Exemplo n.º 3
0
        public IActionResult PlayersTurn(int attk)
        {
            int        PlayerId  = (int)HttpContext.Session.GetInt32("PlayerId");
            Player     Player1   = _context.player.SingleOrDefault(p => p.PlayerId == PlayerId);
            int?       enconId   = HttpContext.Session.GetInt32("EncounterId");
            Encounters encounter = _context.encounters.SingleOrDefault(e => e.EncountersId == enconId);
            Enemies    monster   = _context.enemies.Where(m => m.EncountersId == enconId && m.life == true).First();
            Story      newStory  = new Story();
            Story      newStory2 = new Story();

            if (Player1.Class == "mage")
            {
                Mage Player = _context.mage.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Heal();
                    newStory.storyBook = "You used heal";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Fireball(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.FrostBolt(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "hunter")
            {
                Hunter Player = _context.hunter.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Mend();
                    newStory.storyBook = "You were mended fight on Hunter.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Snipe(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Silencing_Shot(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "samurai")
            {
                Samurai Player = _context.samurai.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Meditate();
                    newStory.storyBook = "You used meditate.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Smash(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Death_Blow(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "ninja")
            {
                Ninja Player = _context.ninja.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Hide();
                    newStory.storyBook = "You hide from the enemies.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Backstab(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Rend(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "priest")
            {
                Priest Player = _context.priest.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Holy_Heal();
                    newStory.storyBook = "You healed yourself";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Holy_Light(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Smight(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            _context.Add(newStory);
            _context.SaveChanges();
            if (monster.health <= 0)
            {
                monster.health      = 0;
                monster.life        = false;
                newStory2.storyBook = "You killed a " + monster.name;
                SetTemp(-10);
                newStory2.created_at = DateTime.Now;
                newStory2.PlayerId   = PlayerId;
                newStory2.flag       = 2;
                _context.Add(newStory2);
                _context.SaveChanges();
            }
            List <Enemies> enemyCount = _context.enemies.Where(m => m.EncountersId == enconId && m.life == true).ToList();

            if (enemyCount.Count() > 0)
            {
                return(RedirectToAction("EnemiesTurn"));
            }
            int level = (int)HttpContext.Session.GetInt32("Level");

            level++;
            HttpContext.Session.SetInt32("Level", level);
            return(RedirectToAction("firstEncounter"));
        }
Exemplo n.º 4
0
    public void doAction(string cardTitle, float percentHit)
    {
        Debug.Log("Doing action: " + cardTitle);
        Debug.Log("Percent hit: " + percentHit);

        switch (cardTitle)
        {
        case "Attack":
            warrior.Attack(10.0f, percentHit);
            animationManager.WarriorAttack();
            break;

        case "Defend":
            //dont give buff if they suck
            if (percentHit > 0.5)
            {
                animationManager.Defend();
                warrior.Defend(5.0f, percentHit);
            }
            break;

        case "Provoke":
            warrior.Provoke();
            animationManager.Provoke();
            break;

        case "Lightning":
            animationManager.Lightning();
            mage.Attack(8.0f, percentHit);
            if (percentHit > 0.5)
            {
                mage.DebuffAttack(8.0f, percentHit);
            }
            break;

        case "Gust":
            animationManager.Gust();
            mage.Attack(8.0f, percentHit);
            if (percentHit > 0.5)
            {
                mage.DebuffDefense(8.0f, percentHit);
            }
            break;

        case "Explosion":
            mage.Attack(14.0f, percentHit);
            animationManager.Explosion();
            break;

        case "Heal":
            healer.Heal(20.0f, percentHit);
            break;

        case "Healing Ballad":
            healer.GroupHeal(15.0f, percentHit);
            break;

        case "Power Up":
            if (percentHit > 0.5)
            {
                animationManager.PowerUp();
                healer.BuffAttack(6.0f, percentHit);
            }
            break;
        }

        Boss.Instance.ChooseTarget();
        Boss.Instance.Attack(10.0f, 1.0f);

        Warrior.Instance.TakeTurn();
        Mage.Instance.TakeTurn();
        Healer.Instance.TakeTurn();
        Boss.Instance.TakeTurn();



        //let the player select cards once action is done.
        cardManager.gameObject.SetActive(true);
    }