public Game(Player player) { this.player = player; this.worldMap = new WorldMap(); }
public string enemyTurn(Player opponent) { string returnThis = "error"; List<string> actions = new List<string>(); actions.Add("Attack"); if (this.shield != null) actions.Add("Defend"); if (this.health < this.maxHealth) actions.Add("Run Away"); Random rand = new Random(); int chosenAction = rand.Next(0, actions.Count - 1); if (actions[chosenAction] == "Attack") { this.shielding = false; Console.WriteLine("The creature lunges at you with a " + this.weapon.name); int dexterity = Utility.rollDice(this.dexterity); int opponentSpeed = Utility.rollDice(opponent.speed); Tuple<int, int, string> result = this.getReducedDamageAgainstArmor(Utility.rollDice(1 + this.strength) + this.getWeaponDamage(), opponent.dexterity); if (result.Item3 != "Miss") { Console.WriteLine("The weapon strikes your " + result.Item3 + " and does " + result.Item1 + " points of damage to you!"); if (result.Item2 > 0) Console.WriteLine("Your armor absorbed " + result.Item2 + " damage."); Console.WriteLine("You take " + (result.Item1 - result.Item2) + " points of damage."); opponent.applyDamage(result.Item1 - result.Item2); returnThis = "damageHit"; } else { Console.WriteLine("You manage to dodge the creature and turn to face it!"); returnThis = "damageDodge"; } } else if (actions[chosenAction] == "Defend") { Console.WriteLine("The creature brings it's shield up into a defensive stance"); this.shielding = true; returnThis = "defend"; } else if (actions[chosenAction] == "Run Away") { int speed = Utility.rollDice(1 + this.speed); int opponentSpeed = Utility.rollDice(1 + opponent.speed); if (speed > opponentSpeed) { Console.WriteLine("The creature starts to run away, you follow but loose it after a little bit!"); returnThis = "escapeSuccess"; } else { Console.WriteLine("The creature tries to run away, but you catch up and block it's path!"); returnThis = "escapeFail"; } } Console.WriteLine("..."); Console.ReadKey(); return returnThis; }