public static string MonsterAttacksPlayer(TRPG_core _gameState, Buff _buffs, Monster _monster, int _seed) { Random RNG = new Random(_seed); Buff finalBuff = _buffs; finalBuff.Clamp(); Buff monsterBuffs = _monster.Buffs; monsterBuffs.Clamp(); string result = ""; result += "The " + _monster.GetFullName() + " attacks you.\n"; //Check to see if the monster actually hit if (RNG.Next(100) <= (_monster.Accuracy + monsterBuffs.Dexterity)) { int dmgDone = (_monster.Damage + monsterBuffs.Strength) - (RNG.Next(Math.Max(1, _buffs.Intelligence)) + RNG.Next(Math.Max(1, _buffs.Wisdom))); if (dmgDone < 0) { dmgDone = 0; } _gameState.player.Health -= dmgDone; result += "The " + _monster.Name + " hits you and deals " + dmgDone + " damage.\n"; result += "Your health is now " + _gameState.player.Health + ".\n"; } else { result += "Fortunately, it misses and does no damage.\n"; } return result; }
/// <summary> /// Carries out a player's attack with a specified weapon against a specified monster /// </summary> /// <param name="_gameState">Main TRPG_core instance containing entire game state</param> /// <param name="_weapon">Weapon object to be used in the attack</param> /// <param name="_buffs">Sum of all buffs currently effecting the player</param> /// <param name="_monster">Monster object to be attacked</param> /// <returns>Returns a string describing the event</returns> public static string PlayerAttacksMonster(TRPG_core _gameState, Weapon _weapon, Buff _buffs, Monster _monster, int _seed) { Random RNG = new Random(_seed); Buff finalBuff = _buffs + _weapon.Buffs; finalBuff.Clamp(); string result = ""; result += "You attack the " + _monster.Name + " with your " + _weapon.Name + ".\n"; //Check to see if the player actually hit if (RNG.Next(100) <= (_weapon.Accuracy + finalBuff.Dexterity)) { int dmgDone = (_weapon.Damage + finalBuff.Strength) - (RNG.Next(Math.Max(1, _monster.Defense + _monster.Buffs.Intelligence)) + RNG.Next(Math.Max(1, _monster.Defense + _monster.Buffs.Wisdom))); if (dmgDone < 0) { dmgDone = 0; } _monster.Health -= dmgDone; if (dmgDone > (_weapon.Damage / 2))//If it is a good hit { result += "You hit the " + _monster.Name + " and deal " + dmgDone + " damage.\n"; } else { result += "You hit the " + _monster.Name + ", but only deal " + dmgDone + " damage.\n"; } result += "The " + _monster.Name + "'s health is now " + _monster.Health + ". "; } else { result += "Unfortunately, you miss and do no damage. "; if (finalBuff.Intelligence < finalBuff.Strength && RNG.Next(100) < 25) { result += "Worse yet, you lose your footing and hit yourself instead.\n"; int dmgDone = RNG.Next(Math.Max(1, _weapon.Damage / 2)); _gameState.player.Health -= dmgDone; result += "You lose " + dmgDone + " health! "; } } if (_monster.Health <= 0) { result += "The " + _monster.Name + " is killed! "; for (int i = 0; i < _gameState.dungeon.CurrentRoom.Contents.Count; i++) { if (_gameState.dungeon.CurrentRoom.Contents[i] is Monster) { if (_gameState.dungeon.CurrentRoom.Contents[i] == _monster) { _gameState.dungeon.CurrentRoom.Contents.RemoveAt(i); } } } } return result + "\n"; }
/// <summary> /// Load all the items from file. /// Hardcoded items until file loading is added. /// </summary> private void LoadItems() { ItemsMaster = new List<Item>(); WeaponsMaster = new List<Weapon>(); MonstersMaster = new List<Monster>(); List<Adjective> Adjectives = new List<Adjective>(); Adjectives.Add(new Adjective("large", 1.0f, 0.5f, 1.0f, 1.0f, 1.0f, 1.5f, 1.75f, 1.5f, 1.0f, 1.1f, 0.9f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("small", 1.0f, 1.5f, 1.0f, 1.0f, 1.0f, 0.75f, 0.75f, 0.75f, 1.0f, 0.9f, 1.25f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("sharp", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.5f, 1.0f, 1.75f, 2.0f, 1.0f, 1.5f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("dull", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 0.75f, 1.0f, 0.9f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("polished", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 3.0f, 1.1f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("dirty", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 1.0f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)); Random RNG = new Random(); Monster tempMonster; tempMonster = new Monster("Grue", "M_00", 10, 75); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Wraith", "M_01", 5, 150); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Wendigo", "M_02", 20, 50); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Vampire", "M_03", 10, 50); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Horta", "M_04", 15, 35); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Zombie", "M_05", 5, 25); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Skeleton", "M_06", 50, 50); MonstersMaster.Add(tempMonster); for (int i = 0; i < 10; i++) { Weapon tempWeapon; tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "sword", "W_00", 10, 10); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "knife", "W_01", 20, 2); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "club", "W_02", 7, 25); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "dagger", "W_03", 25, 5); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "saber", "W_04", 15, 7); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "stick", "W_05", 7, 1); WeaponsMaster.Add(tempWeapon); } Item tempItem; tempItem = new Item("Gold", "I_00", 1, 0); ItemsMaster.Add(tempItem); tempItem = new Item("Amulet", "I_01", 200, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Rock", "I_02", 0, 5); ItemsMaster.Add(tempItem); tempItem = new Item("Bone", "I_03", 0, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Skull", "I_04", 5, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Potion", "I_05", 10, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Poison", "I_06", 10, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Gem", "I_07", 100, 1); ItemsMaster.Add(tempItem); DataPack datapack = new DataPack(Directory.GetCurrentDirectory()); datapack.AdjectivesMaster = Adjectives; datapack.ItemsMaster = ItemsMaster; datapack.MonstersMaster = MonstersMaster; datapack.WeaponsMaster = WeaponsMaster; datapack.Save(); }
public new Monster Copy() { Monster result = new Monster(); result.Name = Name; result.Lore = Lore; result.Weight = Weight; result.Value = Value; result.Adjectives = Adjectives; result.Buffs = Buffs; result.Damage = Damage; result.Defense = Defense; result.Accuracy = Accuracy; result.Health = Health; result.Uses = Uses; result.Experience = Experience; result.Contents = Contents; result.ID = ID + "_1"; return result; }
/// <summary> /// Load all the items from file. /// Hardcoded items until file loading is added. /// </summary> private void LoadItems() { ItemsMaster = new List <Item>(); WeaponsMaster = new List <Weapon>(); MonstersMaster = new List <Monster>(); List <Adjective> Adjectives = new List <Adjective>(); Adjectives.Add(new Adjective("large", 1.0f, 0.5f, 1.0f, 1.0f, 1.0f, 1.5f, 1.75f, 1.5f, 1.0f, 1.1f, 0.9f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("small", 1.0f, 1.5f, 1.0f, 1.0f, 1.0f, 0.75f, 0.75f, 0.75f, 1.0f, 0.9f, 1.25f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("sharp", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.5f, 1.0f, 1.75f, 2.0f, 1.0f, 1.5f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("dull", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 0.75f, 1.0f, 0.9f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("polished", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 3.0f, 1.1f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)); Adjectives.Add(new Adjective("dirty", 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 1.0f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)); Random RNG = new Random(); Monster tempMonster; tempMonster = new Monster("Grue", "M_00", 10, 75); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Wraith", "M_01", 5, 150); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Wendigo", "M_02", 20, 50); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Vampire", "M_03", 10, 50); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Horta", "M_04", 15, 35); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Zombie", "M_05", 5, 25); MonstersMaster.Add(tempMonster); tempMonster = new Monster("Skeleton", "M_06", 50, 50); MonstersMaster.Add(tempMonster); for (int i = 0; i < 10; i++) { Weapon tempWeapon; tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "sword", "W_00", 10, 10); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "knife", "W_01", 20, 2); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "club", "W_02", 7, 25); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "dagger", "W_03", 25, 5); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "saber", "W_04", 15, 7); WeaponsMaster.Add(tempWeapon); tempWeapon = new Weapon(Adjectives[RNG.Next(Adjectives.Count)], "stick", "W_05", 7, 1); WeaponsMaster.Add(tempWeapon); } Item tempItem; tempItem = new Item("Gold", "I_00", 1, 0); ItemsMaster.Add(tempItem); tempItem = new Item("Amulet", "I_01", 200, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Rock", "I_02", 0, 5); ItemsMaster.Add(tempItem); tempItem = new Item("Bone", "I_03", 0, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Skull", "I_04", 5, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Potion", "I_05", 10, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Poison", "I_06", 10, 1); ItemsMaster.Add(tempItem); tempItem = new Item("Gem", "I_07", 100, 1); ItemsMaster.Add(tempItem); DataPack datapack = new DataPack(Directory.GetCurrentDirectory()); datapack.AdjectivesMaster = Adjectives; datapack.ItemsMaster = ItemsMaster; datapack.MonstersMaster = MonstersMaster; datapack.WeaponsMaster = WeaponsMaster; datapack.Save(); }