Exemplo n.º 1
0
        public Monster CreateWhiteMonster(GameContext gameContext)
        {
            PlayerAttackCalculator.CalculatePlayerAttack(gameContext);

            Monster whiteMonster01 = new Monster
            {
                Name             = "White Monster",
                Level            = gameContext.Player.Level,
                Attack           = gameContext.Player.BaseAttack - (gameContext.Player.BaseAttack / 2),
                HitPointsCurrent = gameContext.Player.HitPointsTotal - (gameContext.Player.HitPointsTotal / 2),
                HitPointsTotal   = gameContext.Player.HitPointsTotal - (gameContext.Player.HitPointsTotal / 2),
            };

            return(whiteMonster01);
        }
Exemplo n.º 2
0
        public Monster CreateRedMonster(GameContext gameContext)
        {
            PlayerAttackCalculator.CalculatePlayerAttack(gameContext);

            Monster redMonster01 = new Monster
            {
                Name             = "Red Monster",
                Level            = gameContext.Player.Level,
                Attack           = gameContext.Player.Attack - (gameContext.Player.Attack / 2),
                HitPointsCurrent = gameContext.Player.HitPointsTotal + (gameContext.Player.HitPointsTotal / 2),
                HitPointsTotal   = gameContext.Player.HitPointsTotal + (gameContext.Player.HitPointsTotal / 2),
            };

            return(redMonster01);
        }
Exemplo n.º 3
0
        public void ChooseWeaponToAttackWith(Character attacker, GameContext gameContext)
        {
            gameContext.PlayerInventory.EunumerateWeapons(gameContext);
            Console.WriteLine("Choose which weapon to attack with (enter the number) ");
            int chosenWeaponToAttackWith;
            var tempUserInput = Console.ReadLine();

            chosenWeaponToAttackWith = new InteractionService().GetUserInputForNumberedOptionMenu(tempUserInput, gameContext.List.WeaponList.Count);

            gameContext.Player.WeaponDamageCurrent = gameContext.List.WeaponList[chosenWeaponToAttackWith].Attack;

            PlayerAttackCalculator.CalculatePlayerAttack(gameContext);

            gameContext.List.WeaponList[chosenWeaponToAttackWith].DurabilityCurrent -= 1;
        }
Exemplo n.º 4
0
        public void DoFight(GameContext gameContext)
        {
            PlayerAttackCalculator.CalculatePlayerAttack(gameContext);

            var       fightOver = false;
            Character winner    = gameContext.Player;
            Character looser    = gameContext.Player;

            PreBattleRoll(gameContext, out Character attacker, out Character defender);

            while (fightOver == false)
            {
                // Choose Spell or Weapon
                if (attacker == gameContext.Player)
                {
                    this.ChooseSpellOrWeapon(gameContext, attacker, defender);
                }

                // Computer's attack turn
                else
                {
                    // Rolling
                    attacker.Roll = gameContext.Roller.GetRandomNumber(1, 12);
                    Console.WriteLine("attacker's roll " + attacker.Roll + "\n");

                    // Calculate Damage
                    var damage = (attacker.Roll / 10) * attacker.Attack;
                    Console.WriteLine("Damage " + (damage) + "\n");

                    // Apply damage to defender
                    defender.HitPointsCurrent = defender.HitPointsCurrent - damage;
                    Console.WriteLine("Defender's HP  " + defender.HitPointsCurrent + "\n");
                    StandardMessages.ReturnToContinue();
                }

                // End fight and declare winner or switch roles
                if (defender.HitPointsCurrent <= 0)
                {
                    // End the fight
                    fightOver = true;
                    winner    = attacker;
                    looser    = defender;
                }
                else
                {
                    // Switch roles
                    var temporaryCharacter = attacker;
                    attacker = defender;
                    defender = temporaryCharacter;

                    Console.WriteLine("the Attacker is now " + attacker.Name + "\n");
                }
            }

            // Post battle stuff.
            if (winner.Name == gameContext.Player.Name)
            {
                gameContext.Player     = (Player)winner;
                gameContext.Player.XP += looser.HitPointsTotal / 2;
                gameContext.Player.HitPointsCurrent = gameContext.Player.HitPointsTotal;

                Console.WriteLine("YOU ARE A WINNER");
                Console.WriteLine("You received " + looser.HitPointsTotal + " Experience Points.");
                gameContext.PlayerStats.PrintPlayerStats(gameContext);
            }
            else
            {
                gameContext.Player = (Player)looser;

                Console.WriteLine("YOU ARE A LOOSER!");
            }
        }