public Items.Iitem RemoveInventoryItem(Items.Iitem item, Equipment equipment) { Items.Iitem result = null; result = inventory.Where(i => i.Id == item.Id).SingleOrDefault(); inventory.RemoveWhere(i => i.Id == item.Id); if (result == null) { //so if it wasn't in the inventory we need to check what is equipped foreach (KeyValuePair<Items.Wearable, Items.Iitem> slot in equipment.equipped) { if (slot.Value == item) { result = (Items.Iitem)slot.Value; equipment.equipped.Remove(slot.Key); break; } } } return result; }
public Character() { Class = CharacterClass.Explorer; Race = CharacterRace.Human; Gender = Genders.Female; SkinColor = SkinColors.Fair; SkinType = Interfaces.SkinType.Flesh; HairColor = HairColors.Black; EyeColor = EyeColors.Brown; Build = BodyBuild.Medium; _koCount = new Tuple<int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = Languages.Common; KnownLanguages = new HashSet<Languages>(); KnownLanguages.Add(_primaryLanguage); FirstName = ""; LastName = ""; Description = ""; Age = 17; //Do we want an age? And are we going to advance it every in game year? We'll need a birthdate for this. Weight = 180; //pounds or kilos? Height = 70; //inches or centimeters? Location = "A1000"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = false; Leveled = false; MainHand = "WIELD_RIGHT"; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; Inventory = new Inventory(); Equipment = new Equipment(); Bonuses = new Dictionary<BonusTypes, Bonus>(); StatBonus = new StatBonuses(); StatBonus.Bonuses = Bonuses; Attributes = new List<Attribute>(); Attributes.Add(new Attribute(150, "Hitpoints", 150, 0.1, 1)); Attributes.Add(new Attribute(10, "Dexterity", 5, 0, 1)); Attributes.Add(new Attribute(10, "Strength", 5, 0, 1)); Attributes.Add(new Attribute(10, "Intelligence", 5, 0, 1)); Attributes.Add(new Attribute(10, "Endurance", 5, 0, 1)); Attributes.Add(new Attribute(10, "Charisma", 5, 0, 1)); SubAttributes = new Dictionary<string, double>(); SubAttributes.Add("Agility", 1); SubAttributes.Add("Toughness", 1); SubAttributes.Add("Cunning", 1); SubAttributes.Add("Wisdom", 1); SubAttributes.Add("Leadership", 1); }
public Character(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build) { Class = characterClass; Race = race; Gender = gender; SkinColor = skinColor; SkinType = skinType; HairColor = hairColor; EyeColor = eyeColor; Build = build; _koCount = new Tuple<int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = language; KnownLanguages = new HashSet<Languages>(); KnownLanguages.Add(_primaryLanguage); FirstName = ""; LastName = ""; Description = ""; Age = 17; //Do we want an age? And are we going to advance it every in game year? Weight = 180.0d; //pounds or kilos? Height = 70.0d; //inches or centimeters? Location = "A1000"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = false; Leveled = false; MainHand = "WIELD_RIGHT"; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; Inventory = new Inventory(); Equipment = new Equipment(); Bonuses = new Dictionary<BonusTypes, Bonus>(); StatBonus = new StatBonuses(); StatBonus.Bonuses = Bonuses; Inventory.playerID = Id; Equipment.playerID = Id; Attributes = new List<Attribute>(); Attributes.Add(new Attribute(150, "Hitpoints", 150, 0.1, 1)); Attributes.Add(new Attribute(10, "Dexterity", 5, 0, 1)); Attributes.Add(new Attribute(10, "Strength", 5, 0, 1)); Attributes.Add(new Attribute(10, "Intelligence", 5, 0, 1)); Attributes.Add( new Attribute(10, "Endurance", 5, 0, 1)); Attributes.Add(new Attribute(10, "Charisma", 5, 0, 1)); SubAttributes = new Dictionary<string, double>(); SubAttributes.Add("Agility", 1); SubAttributes.Add("Toughness", 1); SubAttributes.Add("Cunning", 1); SubAttributes.Add("Wisdom", 1); SubAttributes.Add("Leadership", 1); }
public Monk() { SetName("Monk"); HitDie = "1d8"; /////////////////// // PROFICIENCIES // /////////////////// SetProficiencyBonus(2); var Proficiencies = new Dictionary <string, List <string> >() { { "Armor", new List <string>() { } }, { "Weapons", new List <string>() { "Simple Weapons", "Shortswords" } }, { "Tools", new List <string>() }, { "Saving Throws", new List <string>() { "Strength", "Dexterity" } }, { "Skills", new List <string>() { } } }; // Monks can select either one musical instrument or one artisan tool to be proficient in switch (Tools.GetRandomNumberInRange(0, 1)) { default: throw new System.Exception("number not in range"); case 0: var toolList = new Equipment().ReturnArtisansToolList().artisansTools; toolList = Tools.ShuffleList(toolList); Proficiencies["Tools"].Add(toolList[0].Name); break; case 1: var instrumentList = new Equipment().MusicalInstrument().MusicalInstruments; instrumentList = Tools.ShuffleList(instrumentList); Proficiencies["Tools"].Add(instrumentList[0].Name); break; } // Monks can select two skills from the following list var fighterSkillProfs = new List <string>() { "Acrobatics", "Athletics", "History", "Insight", "Religion", "Stealth" }; // Shuffle list and add the top two fighterSkillProfs = Tools.ShuffleList(fighterSkillProfs); Proficiencies["Skills"].Add(fighterSkillProfs[0]); Proficiencies["Skills"].Add(fighterSkillProfs[1]); SetProficiencies(Proficiencies); /////////////// // EQUIPMENT // /////////////// // Monks get either a shortsword or any simple weapon switch (Tools.GetRandomNumberInRange(0, 1)) { default: throw new System.Exception("number not in range"); case 0: PrimaryWeapon = GetWeapons().Where(w => w.Name == "Shortsword").ToList()[0]; break; case 1: var simpleWeapons = GetWeapons().Where(w => w.WeaponType == "Simple Melee").ToList(); PrimaryWeapon = Tools.ShuffleList(simpleWeapons).ToList()[0]; break; } // They also get a dungeoneer’s pack or an explorer’s pack switch (Tools.GetRandomNumberInRange(0, 1)) { default: throw new System.Exception("number not in range"); case 0: EquipmentPack = GetPacks().Where(p => p.Name == "Dungeoneer's Pack").ToList()[0]; break; case 1: EquipmentPack = GetPacks().Where(p => p.Name == "Explorer's Pack").ToList()[0]; break; } // And 10 darts // This is a bit shit, perhaps darts should be treated as ammo? for (int i = 0; i <= 10; i++) { AdditionalWeapons.Add(GetWeapons().Where(w => w.Name == "Dart").ToList()[0]); } ////////////// // FEATURES // ////////////// Features.Add(new Feature("Unarmored Defense", "", 1)); Features.Add(new Feature("Martial Arts", "", 1)); }
public NPC(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build) { Messages = new Queue <string>(); Fsm = AI.FSM.GetInstance(); Fsm.state = Fsm.GetStateFromName("Wander"); _class = characterClass; _race = race; _gender = gender; _skinColor = skinColor; _skinType = skinType; _hairColor = hairColor; _eyeColor = eyeColor; _build = build; _koCount = new Tuple <int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = language; KnownLanguages = new HashSet <Languages>(); KnownLanguages.Add(_primaryLanguage); Inventory = new Inventory(); damageTracker = new Dictionary <string, double>(); Triggers = new List <ITrigger>(); Bonuses = new StatBonuses(); FirstName = ""; LastName = ""; Description = ""; Age = 17; //Do we want an age? And are we going to advance it every in game year? Players could be 400+ years old rather quick. Weight = 180.0d; //pounds or kilos? Height = 70.0d; //inches or centimeters? Location = "A0"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = true; Leveled = false; MainHand = "WIELD_RIGHT"; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; IsMob = false; Inventory = new Inventory(); Equipment = new Equipment(); Inventory.playerID = this.ID; Equipment.playerID = this.ID; Attributes = new Dictionary <string, Attribute>(); Attributes.Add("Hitpoints", new Attribute(200.0d, "Hitpoints", 200.0d, 0.2d, 1)); Attributes.Add("Dexterity", new Attribute(10.0d, "Dexterity", 10.0d, 0.0d, 1)); Attributes.Add("Strength", new Attribute(10.0d, "Strength", 10.0d, 0.0d, 1)); Attributes.Add("Intelligence", new Attribute(10.0d, "Intelligence", 10.0d, 0.0d, 1)); Attributes.Add("Endurance", new Attribute(10.0d, "Endurance", 10.0d, 0.0d, 1)); Attributes.Add("Charisma", new Attribute(10.0d, "Charisma", 10.0d, 0.0d, 1)); SubAttributes = new Dictionary <string, double>(); SubAttributes.Add("Agility", 10.0d); SubAttributes.Add("Toughness", 10.0d); SubAttributes.Add("Cunning", 10.0d); SubAttributes.Add("Wisdom", 10.0d); SubAttributes.Add("Leadership", 10.0d); }
public Bard() { SetName("Bard"); HitDie = "1d8"; /////////////////// // PROFICIENCIES // /////////////////// SetProficiencyBonus(2); var Proficiencies = new Dictionary <string, List <string> >() { { "Armor", new List <string>() { "Light Armor" } }, { "Weapons", new List <string>() { "Simple Weapons", "Hand Crossbows", "Longswords", "Rapiers", "Shortswords" } }, { "Tools", new List <string>() }, { "Saving Throws", new List <string>() { "Dexterity", "Charisma" } }, { "Skills", new List <string>() { } } }; // Get 3 random instrument profs var instrumentList = new Equipment().MusicalInstrument().MusicalInstruments; instrumentList = Tools.ShuffleList(instrumentList); Proficiencies["Tools"].Add(instrumentList[0].Name); Proficiencies["Tools"].Add(instrumentList[1].Name); Proficiencies["Tools"].Add(instrumentList[2].Name); var bardSkillProfs = new List <string>() { "athletics", "acrobatics", "sleightOfHand", "arcana", "stealth", "history", "nature", "religion", "animalHandling", "insight", "medicine", "perception", "survival", "deception", "intimidation", "investigation", "performance", "persuasion" }; // Get 3 ransom skill profs bardSkillProfs = Tools.ShuffleList(bardSkillProfs); Proficiencies["Skills"].Add(bardSkillProfs[0]); Proficiencies["Skills"].Add(bardSkillProfs[1]); Proficiencies["Skills"].Add(bardSkillProfs[2]); SetProficiencies(Proficiencies); /////////////// // EQUIPMENT // /////////////// // Bards get either a Lute or a random musical instrument // My implimentation only adds a lute if we're proficient // If not, then add a random instrument we are proficient in if (Proficiencies["Tools"].Contains("Lute")) { var lute = new Equipment().MusicalInstrument().MusicalInstruments.Where(i => i.Name == "Lute").ToList()[0]; MusicalInstruments.Add(lute); } else { // Get a random instrument we are proficient in as a string var proficientInstrument = Tools.ShuffleList(Proficiencies["Tools"]).ToList()[0]; // Reterive the instrument object var instrument = new Equipment().MusicalInstrument().MusicalInstruments.Where(i => i.Name == proficientInstrument).ToList()[0]; MusicalInstruments.Add(instrument); } // All bards get a dagger and leather armor var dagger = GetWeapons().Where(w => w.Name == "Dagger").ToList()[0]; AdditionalWeapons.Add(dagger); Armor = GetArmor().Where(a => a.Name == "Leather Armor").ToList()[0]; // They also get either a Diplomat's pack or and entertainer's pack switch (Tools.GetRandomNumberInRange(0, 1)) { default: throw new Exception("Option no valid"); case 0: EquipmentPack = GetPacks().Where(p => p.Name == "Diplomat's Pack").ToList()[0]; break; case 1: EquipmentPack = GetPacks().Where(p => p.Name == "Entertainer's Pack").ToList()[0]; break; } // They also get either a Rapier, Longsword or a any simple weapon switch (Tools.GetRandomNumberInRange(0, 2)) { default: throw new Exception("Option no valid"); case 0: PrimaryWeapon = GetWeapons().Where(w => w.Name == "Rapier").ToList()[0]; break; case 1: PrimaryWeapon = GetWeapons().Where(w => w.Name == "Longsword").ToList()[0]; break; case 2: var randomSimpleWeapon = GetWeapons().Where(w => w.WeaponType == "Simple Melee").ToList(); randomSimpleWeapon = Tools.ShuffleList(randomSimpleWeapon); PrimaryWeapon = randomSimpleWeapon[0]; break; } ////////////// // SPELLS // ////////////// // At level 1 bards get // 2 x Cantrips // 2 x 1st level spells SpellSlots = 2; List <string> bardCantrips = new List <string>() { "Dancing Lights", "Light", "Mage Hand", "Mending", "Message", "Minor Illusion", "Prestidigitation", "True Strike" }; Cantrips = Tools.ReturnXSpellsFromList(bardCantrips, 2); List <string> bardLevel1Spells = new List <string>() { "Bane", "Charm Person", "Comprehend Languages", "Cure Wounds", "Detect Magic", "Disguise Self", "Faerie Fire", "Feather Fall", "Healing Word", "Heroism", "Hideous Laughter", "Identify", "Illusory Script", "Longstrider", "Silent Image", "Sleep", "Speak with Animals", "Thunderwave", "Unseen Servant" }; Level1Spells = Tools.ReturnXSpellsFromList(bardLevel1Spells, SpellSlots); ////////////// // FEATURES // ////////////// // Add Bard Features Features.Add(new Feature("Spellcasting", "", 1)); Features.Add(new Feature("Bardic Inspiration (d6)", "", 1)); }
public NPC(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build) { Messages = new Queue<string>(); Fsm = AI.FSM.GetInstance(); Fsm.state = Fsm.GetStateFromName("Wander"); _class = characterClass; _race = race; _gender = gender; _skinColor = skinColor; _skinType = skinType; _hairColor = hairColor; _eyeColor = eyeColor; _build = build; _koCount = new Tuple<int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = language; KnownLanguages = new HashSet<Languages>(); KnownLanguages.Add(_primaryLanguage); Inventory = new Inventory(); damageTracker = new Dictionary<string, double>(); Triggers = new List<ITrigger>(); Bonuses = new StatBonuses(); FirstName = ""; LastName = ""; Description = ""; Age = 17; //Do we want an age? And are we going to advance it every in game year? Players could be 400+ years old rather quick. Weight = 180.0d; //pounds or kilos? Height = 70.0d; //inches or centimeters? Location = "A0"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = true; Leveled = false; MainHand = "WIELD_RIGHT"; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; IsMob = false; Inventory = new Inventory(); Equipment = new Equipment(); Inventory.playerID = this.ID; Equipment.playerID = this.ID; Attributes = new Dictionary<string, Attribute>(); Attributes.Add("Hitpoints", new Attribute(200.0d, "Hitpoints", 200.0d, 0.2d, 1)); Attributes.Add("Dexterity", new Attribute(10.0d, "Dexterity", 10.0d, 0.0d, 1)); Attributes.Add("Strength", new Attribute(10.0d, "Strength", 10.0d, 0.0d, 1)); Attributes.Add("Intelligence", new Attribute(10.0d, "Intelligence", 10.0d, 0.0d, 1)); Attributes.Add("Endurance", new Attribute(10.0d, "Endurance", 10.0d, 0.0d, 1)); Attributes.Add("Charisma", new Attribute(10.0d, "Charisma", 10.0d, 0.0d, 1)); SubAttributes = new Dictionary<string, double>(); SubAttributes.Add("Agility", 10.0d); SubAttributes.Add("Toughness", 10.0d); SubAttributes.Add("Cunning", 10.0d); SubAttributes.Add("Wisdom", 10.0d); SubAttributes.Add("Leadership", 10.0d); }
public void Load(string id) { MongoUtils.MongoData.ConnectToDatabase(); MongoDatabase characterDB = MongoUtils.MongoData.GetDatabase("Characters"); MongoCollection characterCollection = characterDB.GetCollection <BsonDocument>("PlayerCharacter"); IMongoQuery query = Query.EQ("_id", ObjectId.Parse(id)); BsonDocument found = characterCollection.FindOneAs <BsonDocument>(query); ID = found["_id"].AsObjectId.ToString(); FirstName = found["FirstName"].AsString.CamelCaseWord(); LastName = found["LastName"].AsString.CamelCaseWord(); _class = (CharacterClass)Enum.Parse(typeof(CharacterClass), found["Class"].AsString.CamelCaseWord()); _race = (CharacterRace)Enum.Parse(typeof(CharacterRace), found["Race"].AsString.CamelCaseWord()); _gender = (Genders)Enum.Parse(typeof(Genders), found["Gender"].AsString.CamelCaseWord()); _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord()); _skinColor = (SkinColors)Enum.Parse(typeof(SkinColors), found["SkinColor"].AsString.CamelCaseWord()); _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord()); _hairColor = (HairColors)Enum.Parse(typeof(HairColors), found["HairColor"].AsString.CamelCaseWord()); _eyeColor = (EyeColors)Enum.Parse(typeof(EyeColors), found["EyeColor"].AsString.CamelCaseWord()); Height = found["Height"].AsDouble; Weight = found["Weight"].AsDouble; _stanceState = (CharacterStanceState)Enum.Parse(typeof(CharacterStanceState), found["StanceState"].AsString.CamelCaseWord()); _actionState = (CharacterActionState)Enum.Parse(typeof(CharacterActionState), found["ActionState"].AsString.CamelCaseWord()); Description = found["Description"].AsString; Location = found["Location"].AsString; Password = found["Password"].AsString; IsNPC = found["IsNPC"].AsBoolean; Experience = found["Experience"].AsInt64; NextLevelExperience = found["NextLevelExperience"].AsInt64; Level = found["Level"].AsInt32; Leveled = found["Leveled"].AsBoolean; PointsToSpend = found["PointsToSpend"].AsInt32; MainHand = found["MainHand"].AsString != "" ? found["MainHand"].AsString : null; Title = found.Contains("Title") ? found["Title"].AsString : ""; KillerID = found.Contains("KillerID") ? found["KillerID"].AsString : ""; BsonArray playerAttributes = found["Attributes"].AsBsonArray; BsonArray inventoryList = found["Inventory"].AsBsonArray; BsonArray equipmentList = found["Equipment"].AsBsonArray; BsonArray bonusesList = found["Bonuses"].AsBsonArray; if (playerAttributes != null) { foreach (BsonDocument attrib in playerAttributes) { if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) { Attribute tempAttrib = new Attribute(); tempAttrib.Name = attrib["Name"].ToString(); tempAttrib.Value = attrib["Value"].AsDouble; tempAttrib.Max = attrib["Max"].AsDouble; tempAttrib.RegenRate = attrib["RegenRate"].AsDouble; tempAttrib.Rank = attrib["Rank"].AsInt32; this.Attributes.Add(tempAttrib.Name, tempAttrib); } else { this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble; this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble; this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble; this.Attributes[attrib["Name"].ToString()].Rank = attrib["Rank"].AsInt32; } } } if (inventoryList.Count > 0) { foreach (BsonDocument item in inventoryList) { Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString()); if (!Inventory.inventory.Contains(fullItem)) { Inventory.AddItemToInventory(fullItem); } } } if (equipmentList.Count > 0) { foreach (BsonDocument item in equipmentList) { Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString()); if (!Equipment.equipped.ContainsKey(fullItem.WornOn)) { Equipment.EquipItem(fullItem, this.Inventory); } } } if (bonusesList.Count > 0) { Bonuses.LoadFromBson(bonusesList); } }