Beispiel #1
0
        public void Fight(Character Player, Character Enemy)
        {
            FightRound fightRound = new FightRound();

            while (Player.IsAlive && Enemy.IsAlive)
            {
                Random    rnd       = new Random();
                DiceRound diceRound = new DiceRound(Player.Strength + rnd.Next(1, 6), Enemy.Strength + rnd.Next(1, 6));
                MyDebugWriteStatusWriter(Player, Enemy, diceRound);
                fightRound.AddDiceRound(diceRound); //Logging
                if ((diceRound.PlayerDiceRoll) > (diceRound.EnemyDiceRoll))
                {
                    Enemy.Health -= 1;
                    if (Enemy.Health <= 0)
                    {
                        Enemy.IsAlive = false;
                    }
                }
                else
                {
                    Player.Health -= 1;
                    if (Player.Health <= 0)
                    {
                        Player.IsAlive = false;
                    }
                }
            }
            if (Player.IsAlive)
            {
                fightRound.SetWinner(Player);
                fightRound.SetLooser(Enemy);
            }
            else
            {
                fightRound.SetWinner(Enemy);
                fightRound.SetLooser(Player);
            }
            FightRounds.Add(fightRound); //Logging
        }
Beispiel #2
0
 public void MyDebugWriteStatusWriter(Character Player, Character Enemy, DiceRound diceRound)
 {
     Console.WriteLine($"Round: {Player.Name}  Str+Dice = {diceRound.PlayerDiceRoll} HP={Player.Health} _____VS_____ Enemy  Str+Dice= {diceRound.EnemyDiceRoll} HP={Enemy.Health}");
 }