// -------------------------------------------------------------------------------------------------------------------- // Constructors // -------------------------------------------------------------------------------------------------------------------- public Player(Enum template, string name, int maxHP, Gender gender, Faction faction, Race race, Location location, Enum weaponTemplate = null, Enum armorTemplate = null) { if (name == null) { throw new ArgumentNullException("Error: Player constructor null name error"); } if (name.Length == 0) { throw new ArgumentException("Error: Player constructor empty name error"); } if (maxHP <= 0) { throw new ArgumentOutOfRangeException("Error: Player constructor maxHP must be > 0"); } if (weaponTemplate == null) { weaponTemplate = ItemType.Unarmed; } if (armorTemplate == null) { armorTemplate = ItemType.Unarmored; } this.UnitType = template; this.Name = name; this.MaxHP = maxHP; this.HP = MaxHP; this.Gender = gender; this.Faction = faction; this.Race = race; this.Location = location; TimeToAct = GameEngine.WorldTime + (ulong)rng.Next(GameEngine.MSTimePerPCAction); if (!weaponTemplate.Equals(ItemType.Unarmed)) { this.weapon = (Weapon)Prefabs.NewItem(weaponTemplate); } if (!armorTemplate.Equals(ItemType.Unarmored)) { this.armor = (Armor)Prefabs.NewItem(armorTemplate); } this.Flags = new List <Enum>(); PersonalEffects = new List <StatusEffect>(); actions = new List <ActionOption <Player, MenuOptionType> >(); notifications = new List <TimeText>(); HatedUnits = new Dictionary <Player, int>(); causeOfDeath = ""; }
private static void DoProdWater(Player player, Location location) { if (player == null) { throw new ArgumentNullException($"Error: LocationAction DoProdWater null player."); } if (location == null) { throw new ArgumentNullException($"Error: LocationAction DoProdWater null location."); } if (player.IsAlive && player.Location == location && player.HasItem(ItemType.Stick)) { GameEngine.SayToLocation(location, $"{player.Name} prods the water with a crook..."); if (!player.HasFlag(QuestFlags.ProddedCloths)) { player.AddFlag(QuestFlags.ProddedCloths); player.Notify(" * GET! You found yourself some new clothes!"); GameEngine.SayToLocation(location, $"{player.Name} picks up bits of clothing from the putrid water."); Armor newArmor = (Armor)Prefabs.NewItem(ItemType.Cloth); newArmor.AddSocket(); player.AddItem(newArmor); } else if (!player.HasFlag(QuestFlags.ProddedRustSword)) { player.AddFlag(QuestFlags.ProddedRustSword); player.Notify(" * GET! You found yourself a rusty sword!"); GameEngine.SayToLocation(location, $"{player.Name} picks up a broken, rusty sword from the putrid water."); Weapon newWeapon = (Weapon)Prefabs.NewItem(ItemType.RustySword); newWeapon.AddSocket(); player.AddItem(newWeapon); } else { GameEngine.SayToLocation(location, $"...but gets distracted by {player.Genderize("his handsome", "her beautiful", "its mesmerizing")} reflection."); } } else { GameEngine.SayToLocation(player.Location, $"{player.Name} was about to prod the water with a stick but didn't succeed..."); } }
public void AddItem(Enum itemType) { Items.Add(Prefabs.NewItem(itemType)); }
public void AddItem(ItemType itemType) { AddItem(Prefabs.NewItem(itemType)); }