public static RobotTemplate CreateFromRecord(int id, string name, string descGenXY, string note) { Dictionary <string, object> dict = GenxyConverter.Deserialize(descGenXY); RobotTemplate botTemp = RobotTemplate.GetRobotTemplateFromXY(dict); botTemp.recordNote = note; botTemp.recordID = id; botTemp.recordName = name; botTemp.recordDescription = descGenXY; return(botTemp); }
private IRequest CreateRequest(string data) { var args = data.Split(':'); if (args.Length < 3) { throw new PerpetuumException(ErrorCodes.TooManyOrTooFewArguments); } var commandText = args[0]; var command = _commandFactory(commandText); if (command == null) { throw PerpetuumException.Create(ErrorCodes.NoSuchCommand).SetData("command", commandText); } if (!_accessLevel.HasFlag(command.AccessLevel)) { throw PerpetuumException.Create(ErrorCodes.InsufficientPrivileges) .SetData("command", command.Text) .SetData("accessLevel", (int)_accessLevel); } var targetPlugin = args[1]; var dictionary = GenxyConverter.Deserialize(args[2]); command.CheckArguments(dictionary); var request = new Request { Command = command, Session = this, Target = _globalConfiguration.RelayName, Data = dictionary, }; if (!targetPlugin.StartsWith("zone_")) { return(request); } request.Target = targetPlugin; var zoneID = int.Parse(targetPlugin.Remove(0, 5)); var zr = new ZoneRequest(request) { Zone = _zoneManager.GetZone(zoneID) }; return(zr); }
private static Dictionary <string, object> CreateCharacterWizardData(IExtensionReader extensionReader) { var extensions = extensionReader.GetExtensions(); var corpProfiles = Db.Query().CommandText("select eid,publicprofile from corporations where defaultcorp = 1") .Execute() .ToDictionary(r => r.GetValue("eid"), r => GenxyConverter.Deserialize(r.GetValue <string>("publicprofile"))); Dictionary <string, object> LoadCwData(string name, string idName, Action <IDataRecord, Dictionary <string, object> > action = null) { var cw = Db.Query().CommandText($"select * from {name}").Execute(); var ex = Db.Query().CommandText($"select * from {name}_extension") .Execute() .Where(r => extensions.ContainsKey(r.GetValue <int>("extensionid"))).ToLookup(r => r.GetValue(idName)); return(cw.ToDictionary("w", r => { var id = r.GetValue(idName); var dd = new Dictionary <string, object> { ["ID"] = id, ["name"] = r.GetValue("name"), ["description"] = r.GetValue("descriptiontoken"), ["extension"] = ex.GetOrEmpty(id).ToDictionary("e", x => { return new Dictionary <string, object> { { k.extensionID, x.GetValue("extensionid") }, { k.add, x.GetValue("levelincrement") } }; }) }; action?.Invoke(r, dd); return dd; })); } var result = new Dictionary <string, object> { ["race"] = LoadCwData("cw_race", "raceid"), ["spark"] = LoadCwData("cw_spark", "sparkid"), ["school"] = LoadCwData("cw_school", "schoolid", (r, d) => { d["raceID"] = r.GetValue("raceid"); }), ["major"] = LoadCwData("cw_major", "majorid", (r, d) => { d["schoolID"] = r.GetValue("schoolid"); }), ["corporation"] = LoadCwData("cw_corporation", "corporationEID", (r, d) => { d["baseEID"] = r.GetValue("baseEID"); d["schoolID"] = r.GetValue("schoolid"); d["publicProfile"] = corpProfiles[r.GetValue <long>("corporationEID")]; }) }; return(result); }
public static Message Parse(string s) { var x = s.Split(':'); var command = Commands.GetCommandByText(x[0]) ?? new Command(x[0]); var sender = x[1]; var data = GenxyConverter.Deserialize(x[2]); return(new Message(command, data) { Sender = sender }); }
private static EntityEnvironmentDescription ConvertFromString(string descriptionString) { var nativeDescription = new EntityEnvironmentDescription(); var descriptionObjects = GenxyConverter.Deserialize(descriptionString); if (descriptionObjects.ContainsKey(k.blocks)) { var tileDict = (Dictionary <string, object>)descriptionObjects[k.blocks]; nativeDescription.blocksTiles = ConvertTilesToList(tileDict); } return(nativeDescription); }
private static RobotTemplate CreateRobotTemplateFromRecord(IDataRecord record) { var id = record.GetValue <int>("id"); var name = record.GetValue <string>("name"); var description = record.GetValue <string>("description"); var dictionary = GenxyConverter.Deserialize(description); var template = RobotTemplate.CreateFromDictionary(name, dictionary); if (template == null) { return(null); } template.ID = id; return(template); }
public IDictionary <string, object> LoadSettingsFromFile(string path) { if (!_fileSystem.Exists(path)) { Logger.Warning($"ini file not found: {path}"); return(new Dictionary <string, object>()); } var lines = _fileSystem.ReadAllText(path).GetLines().Select(l => l.RemoveComment()).Where(line => line.Length > 0).ToArray(); var strSettings = new StringBuilder(); foreach (var line in lines) { strSettings.Append(line); strSettings.Append('#'); } var result = GenxyConverter.Deserialize(strSettings.ToString()); return(result); }
public void HandleRequest(IRequest request) { var character = request.Session.Character; var dataStr = Db.Query().CommandText("select settingsstring from charactersettings where characterid=@characterID") .SetParameter("@characterID", character.Id) .ExecuteScalar <string>(); var result = GenxyConverter.Deserialize(dataStr); if (result.Count == 0) { Message.Builder.FromRequest(request).WithData(new Dictionary <string, object>(1) { { k.state, k.empty } }).Send(); } else { Message.Builder.FromRequest(request).WithData(new Dictionary <string, object>(1) { { k.result, result } }).Send(); } }