public static List <RoomModifier> GetModifiers(string roomId) { List <RoomModifier> roomModifierList = new List <RoomModifier>(); BsonDocument roomFound = MongoUtils.MongoData.GetCollection("Rooms", GetZoneCode(roomId)).FindOneAs <BsonDocument>(Query.EQ("_id", roomId)); BsonArray modifiers = roomFound["Modifiers"].AsBsonArray; MongoDatabase worldDB = MongoUtils.MongoData.GetDatabase("World"); MongoCollection modifierCollection = worldDB.GetCollection("RoomModifiers"); foreach (BsonDocument mod in modifiers.Where(m => m.AsBsonDocument.Count() > 0)) { IMongoQuery modifierQuery = Query.EQ("_id", mod["id"]); BsonDocument modifier = modifierCollection.FindOneAs <BsonDocument>(modifierQuery); if (modifier != null) //just in case you never know what stupid thing a builder might have done { RoomModifier roomMod = new RoomModifier(); roomMod.TimeInterval = modifier["Timer"].AsInt32; //get the hints for the modifier BsonArray hintArray = modifier["Hints"].AsBsonArray; foreach (BsonDocument hint in hintArray.Where(h => h.AsBsonDocument.Count() > 0)) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Attribute", hint["Attribute"].AsString); dic.Add("ValueToPass", hint["ValueToPass"].AsInt32.ToString()); dic.Add("Display", hint["Display"].AsString); roomMod.Hints.Add(dic); } BsonArray affectArray = modifier["Affects"].AsBsonArray; foreach (BsonDocument affect in affectArray.Where(a => a.AsBsonDocument.Count() > 0)) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Name", affect["Name"].AsString); dic.Add("Value", affect["Value"].AsDouble.ToString()); dic.Add("DescriptionSelf", affect["DescriptionSelf"].AsString); dic.Add("DescriptionOthers", affect["DescriptionOthers"].AsString); roomMod.Affects.Add(dic); } roomModifierList.Add(roomMod); } } return(roomModifierList); }
public static List<RoomModifier> GetModifiers(string roomId) { List<RoomModifier> roomModifierList = new List<RoomModifier>(); BsonDocument roomFound = MongoUtils.MongoData.GetCollection("Rooms", GetZoneCode(roomId)).FindOneAs<BsonDocument>(Query.EQ("_id", roomId)); BsonArray modifiers = roomFound["Modifiers"].AsBsonArray; MongoDatabase worldDB = MongoUtils.MongoData.GetDatabase("World"); MongoCollection modifierCollection = worldDB.GetCollection("RoomModifiers"); foreach (BsonDocument mod in modifiers.Where(m => m.AsBsonDocument.Count() > 0)) { IMongoQuery modifierQuery = Query.EQ("_id", mod["id"]); BsonDocument modifier = modifierCollection.FindOneAs<BsonDocument>(modifierQuery); if (modifier != null) { //just in case you never know what stupid thing a builder might have done RoomModifier roomMod = new RoomModifier(); roomMod.TimeInterval = modifier["Timer"].AsInt32; //get the hints for the modifier BsonArray hintArray = modifier["Hints"].AsBsonArray; foreach (BsonDocument hint in hintArray.Where(h => h.AsBsonDocument.Count() > 0)) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("Attribute", hint["Attribute"].AsString); dic.Add("ValueToPass", hint["ValueToPass"].AsInt32.ToString()); dic.Add("Display", hint["Display"].AsString); roomMod.Hints.Add(dic); } BsonArray affectArray = modifier["Affects"].AsBsonArray; foreach (BsonDocument affect in affectArray.Where(a => a.AsBsonDocument.Count() > 0)) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("Name", affect["Name"].AsString); dic.Add("Value", affect["Value"].AsDouble.ToString()); dic.Add("DescriptionSelf", affect["DescriptionSelf"].AsString); dic.Add("DescriptionOthers", affect["DescriptionOthers"].AsString); roomMod.Affects.Add(dic); } roomModifierList.Add(roomMod); } } return roomModifierList; }