public override void turn(Character enemy) { Random generator = new Random(); double choice = generator.NextDouble(); if (choice > .4) basicAttack(enemy); }
public override void useAbility(Character player, Character enemy) { Console.WriteLine(Name + " slashes " + enemy.Name + "!"); int attack = 2 * player.Strength * player.attackModifier(); enemy.Health -= attack; Console.WriteLine(enemy.Name + " took " + attack + " damage and now has " + enemy.Health + "."); }
public void useItem(Character player, Character enemy) { Console.WriteLine("Pick item to use: "); displayInventory(); int itemIndex = GameManager.getInputBetween(1, itemCount) - 1; Character target = pickTarget(player, enemy); bool removeItem = inventory[itemIndex].effect(target); if (removeItem) { totalWeight -= inventory[itemIndex].Weight; inventory.RemoveAt(itemIndex); } }
public override void turn(Character enemy) { Console.WriteLine(Name + "'s turn: "); Console.WriteLine("1. Basic attack"); Console.WriteLine("2. Special abilities"); Console.WriteLine("3. Inventory"); Console.WriteLine("4. Run"); int option = GameManager.getInputBetween(1, 4); if (option == 1) basicAttack(enemy); else if(option == 2) { SpecialAbility picked = abilities.getAbility(); picked.useAbility(this, enemy); } else if(option == 3) { inventory.useItem(this, enemy); } }
public override bool effect(Character target) { int healthDifference = target.MaxHealth - target.Health; if (healthDifference == 0) { Console.WriteLine("Nothing to heal. Not using health potion. Lose a turn."); return false; } else if (healthDifference >= 20) { target.Health += 20; Console.WriteLine(target.Name + " healed by 20 and now has " + target.Health + " health."); } else { target.Health += target.MaxHealth; Console.WriteLine(target.Name + " healed by " + healthDifference + " and now has " + target.Health + " health."); } return true; }
public abstract void useAbility(Character player, Character enemy);
public Event(Character thisPlayer, Character thisEnemy) { player = thisPlayer; enemy = thisEnemy; }
public Event(Character thisPlayer) { player = thisPlayer; enemy = null; }
public abstract void turn( Character enemy );
public void basicAttack( Character enemy ) { Console.WriteLine(Name + " is attacking " + enemy.Name + "."); int attack = strength * attackModifier(); enemy.health -= attack; Console.WriteLine(enemy.Name + " took " + attack + " damage and now has " + enemy.Health + "."); }
private Character pickTarget(Character him, Character her) { Console.WriteLine("Pick target for item: "); Console.WriteLine("1. " + him.Name); Console.WriteLine("2. " + her.Name); int option = GameManager.getInputBetween(1, 2); if (option == 1) return him; else return her; }
//chest? //enemy? //hidden treasure? public Area(Character thisPlayer) { player = thisPlayer; }
public World(Character thisPlayer) { player = thisPlayer; currentLocation = new Area(player); previousLocation = null; }
public Battle(Character thisPlayer, Character thisEnemy) { player = thisPlayer; enemy = thisEnemy; }
public abstract bool effect(Character target);