public List <EngineEnum> GetEnums() { var results = new List <EngineEnum>(); if (Items != null) { var enumObj = Items["enum"] ?? null; if (enumObj != null) { var engineEnum = new EngineEnum() { Name = Name }; Type = Name; var childen = enumObj.Children(); foreach (var child in childen) { var name = child.ToObject <string>(); var shotEnumValues = Items["enumShort"] ?? null; var shotName = engineEnum.GetShotEnumName(name, shotEnumValues); engineEnum.Values.Add(new EngineEnumValue() { Name = name, ShotValue = shotName }); } results.Add(engineEnum); } } return(results); }
public ParseState Parse(XmlElement element, ParseState parseState) { string name = element.Attributes["name"].InnerText; string docs = element.Attributes["docs"].InnerText; EngineEnum engineEnum = new EngineEnum(name) { Docs = docs, Scope = parseState.Scope }; foreach (XmlElement childNode in element.ChildNodes[0].ChildNodes) { engineEnum.Add(new EngineEnum.Field() { Name = childNode.Attributes["name"].InnerText, Value = int.Parse(childNode.Attributes["value"].InnerText), Docs = childNode.Attributes["docs"].InnerText }); } parseState.Enums.Add(engineEnum); return(parseState); }
private string GetFormatedEnumBlock(EngineEnum enumObject) { //enumObject.RenameValues(); var builder = new StringBuilder(); builder.Append(QlikApiUtils.Indented($"public enum {enumObject.Name}\r\n", 1)); builder.AppendLine(QlikApiUtils.Indented("{", 1)); foreach (var enumValue in enumObject.Values) { if (enumValue.Value.HasValue) { var numValue = $" = {enumValue.Value}"; builder.AppendLine(QlikApiUtils.Indented($"{enumValue.Name}{numValue},", 2)); } else { builder.AppendLine(QlikApiUtils.Indented($"{enumValue.Name},", 2)); } if (!String.IsNullOrEmpty(enumValue.ShotValue)) { var shotValue = $"{enumValue.ShotValue} = "; builder.AppendLine(QlikApiUtils.Indented($"{shotValue}{enumValue.Name},", 2)); } } builder.AppendLine(QlikApiUtils.Indented("}", 1)); return(builder.ToString().TrimEnd(',').TrimEnd()); }
public bool Equals(EngineEnum obj) { if ((object)obj == null) { return(false); } return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value)); }
public ErrorMessage(EngineEnum.HeadersEnum.Send.TM_SC_RESULT msg_error_id, Engine.Network.mmoClient mmo_socket = null, Engine.Network.Client client_socket = null, Engine.Network.lobbyClient lobby_socket = null, Engine.Network.msgClient msg_socket = null) { msgerrorid = msg_error_id; clientsocket = client_socket; mmosocket = mmo_socket; msgsocket = msg_socket; lobbysocket = lobby_socket; }
public PlayerCharacterList(Engine.Network.mmoClient mmo_client = null, Engine.Network.lobbyClient lobby_client = null, string char_name = "", EngineEnum.PlayerEnum.CharactersType char_type = 0, bool last_login = true) { mmoclient = mmo_client; lobbyclient = lobby_client; charname = char_name; chartype = char_type; lastlogin = last_login; }
public StockfishEngine(IEngineProcess engineProcess) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) throw new NotImplementedException("Stockfish not supported."); this.engineProcess = engineProcess; EngineId = EngineEnum.Stockfish12; }
private Engine GetEngine(EngineEnum e) { switch (e) { case EngineEnum.Ada: return(Engine.Ada); case EngineEnum.Babbage: return(Engine.Babbage); case EngineEnum.Curie: return(Engine.Curie); case EngineEnum.Davinci: return(Engine.Davinci); } return(Engine.Default); }
private EngineEnum EnumExists(EngineEnum engineEnum) { var results = EngineObjects.Where(o => o.EngType == engineEnum.EngType && o.Name.StartsWith(engineEnum.Name)).ToList(); if (results.Count == 0) { return(null); } var hitCount = 0; EngineEnum currentEnum = null; foreach (EngineEnum item in results) { currentEnum = item; foreach (var enumValue in engineEnum.Values) { var hit = item.Values.FirstOrDefault(v => v.Name == enumValue.Name); if (hit != null) { hitCount++; if (!String.IsNullOrEmpty(enumValue.ShotValue)) { hit.ShotValue = enumValue.ShotValue; } } } } if (hitCount == engineEnum.Values.Count) { return(currentEnum); } return(null); }
/// <summary> /// Big ass messy code to load inventory stuff of each character. /// </summary> /// <param name="packet"></param> /// <param name="D"></param> /// <param name="char_type"></param> /// <param name="char_item_list"></param> /// <param name="char_list_inventory_size"></param> public static void LoadItemList(byte[] packet, EngineEnum.WorldEnum.CharactersType char_type) { // Initializing basic stuff SByte unknow_number = 0x0A; // Still not sure about this Int32 item_number = 0; // To tell the loop where to stop // Initializing items list List<int> rookieItemList = new List<int>(); List<int> lunaItemList = new List<int>(); List<int> rushItemList = new List<int>(); List<int> tippyItemList = new List<int>(); // Initializing inventory enums EngineEnum.IventoryEnum.ROOKIE_ITEM_LIST[] rookie_items = (EngineEnum.IventoryEnum.ROOKIE_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.ROOKIE_ITEM_LIST)); EngineEnum.IventoryEnum.LUNA_ITEM_LIST[] luna_items = (EngineEnum.IventoryEnum.LUNA_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.LUNA_ITEM_LIST)); EngineEnum.IventoryEnum.RUSH_ITEM_LIST[] rush_items = (EngineEnum.IventoryEnum.RUSH_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.RUSH_ITEM_LIST)); EngineEnum.IventoryEnum.TIPPY_ITEM_LIST[] tippy_items = (EngineEnum.IventoryEnum.TIPPY_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.TIPPY_ITEM_LIST)); // Initializing the packet writer PacketWriter PW = new PacketWriter(packet); switch(char_type) { case EngineEnum.WorldEnum.CharactersType.CHARACTER_ROOKIE: item_number = 150; foreach (var itemId in rookie_items) rookieItemList.Add((int)itemId); for (int pItem = 0x24, feItem = 0; pItem < (item_number * 0x1D) && feItem < item_number; pItem += 0x1D, feItem++) PW.WriteInt16(pItem, (Int16)rookieItemList[feItem]); break; // Load rookie items case EngineEnum.WorldEnum.CharactersType.CHARACTER_LUNA: item_number = 150; foreach (var itemId in luna_items) lunaItemList.Add((int)itemId); for (int pItem = 0x24, feItem = 0; pItem < (item_number * 0x1D) && feItem < item_number; pItem += 0x1D, feItem++) PW.WriteInt16(pItem, (Int16)lunaItemList[feItem]); break; // Load luna items case EngineEnum.WorldEnum.CharactersType.CHARACTER_RUSH: item_number = 100; foreach (var itemId in rush_items) rushItemList.Add((int)itemId); for (int pItem = 0x24, feItem = 0; pItem < (item_number * 0x1D) && feItem < item_number; pItem += 0x1D, feItem++) PW.WriteInt16(pItem, (Int16)rushItemList[feItem]); break; // Load rush items case EngineEnum.WorldEnum.CharactersType.CHARACTER_TIPPY: item_number = 124; foreach (var itemId in tippy_items) tippyItemList.Add((int)itemId); for (int pItem = 0x24, feItem = 0; pItem < (item_number * 0x1D) && feItem < item_number; pItem += 0x1D, feItem++) PW.WriteInt16(pItem, (Int16)tippyItemList[feItem]); break; // Load tippy items case EngineEnum.WorldEnum.CharactersType.CHARACTER_KLAUS: // There is still no avaiable items for klaus case EngineEnum.WorldEnum.CharactersType.CHARACTER_KARA: // There is still no avaiable items for kara break; } PW.WriteInt32(30, item_number); // I'm not sure if the packet really need this // Write the rank of each items (1,2,3,4, etc..) for (int pUnk = 0x2E; pUnk < (item_number * 0x1D); pUnk += 0x1D) PW.WriteSByte(pUnk, unknow_number); for (int nItem = 0x20, j = 0; nItem < (item_number * 0x1D) && j < (item_number * 0x1D); nItem += 0x1D, j++) PW.WriteInt16(nItem, (Int16)j); }
public InventoryItems(Engine.Network.mmoClient mmo_client = null, Engine.Network.lobbyClient lobby_client = null, EngineEnum.PlayerEnum.CharactersType char_type = 0) { mmoclient = mmo_client; lobbyclient = lobby_client; chartype = char_type; }
/// <summary> /// Create the selected character type items list /// </summary> /// <param name="data"></param> /// <param name="char_type"></param> public void CreateItemList(byte[] data, EngineEnum.PlayerEnum.CharactersType char_type) { // Initializing the packet writer PacketWriter PW = new PacketWriter(data); // Initializing basic stuff SByte unknow_number = 0x0A; Int32 item_number = 0; // Initializing items list List<int> rookieItemList = new List<int>(); List<int> lunaItemList = new List<int>(); List<int> rushItemList = new List<int>(); List<int> tippyItemList = new List<int>(); // Initializing inventory enums EngineEnum.IventoryEnum.ROOKIE_ITEM_LIST[] rookie_items = (EngineEnum.IventoryEnum.ROOKIE_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.ROOKIE_ITEM_LIST)); EngineEnum.IventoryEnum.LUNA_ITEM_LIST[] luna_items = (EngineEnum.IventoryEnum.LUNA_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.LUNA_ITEM_LIST)); EngineEnum.IventoryEnum.RUSH_ITEM_LIST[] rush_items = (EngineEnum.IventoryEnum.RUSH_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.RUSH_ITEM_LIST)); EngineEnum.IventoryEnum.TIPPY_ITEM_LIST[] tippy_items = (EngineEnum.IventoryEnum.TIPPY_ITEM_LIST[])Enum.GetValues(typeof(EngineEnum.IventoryEnum.TIPPY_ITEM_LIST)); switch (char_type) { case EngineEnum.PlayerEnum.CharactersType.CHARACTER_ROOKIE: item_number = rookie_items.Count(); for (int i = 0x24, j = 0; i < (item_number * 0x1D) && j < item_number; i += 0x1D, j++) { PW.WriteInt16(i, (Int16)rookie_items[j]); } break; // Load rookie items case EngineEnum.PlayerEnum.CharactersType.CHARACTER_LUNA: item_number = luna_items.Count(); for (int i = 0x24, j = 0; i < (item_number * 0x1D) && j < item_number; i += 0x1D, j++) { PW.WriteInt16(i, (Int16)luna_items[j]); } break; // Load luna items case EngineEnum.PlayerEnum.CharactersType.CHARACTER_RUSH: item_number = rush_items.Count(); for (int i = 0x24, j = 0; i < (item_number * 0x1D) && j < item_number; i += 0x1D, j++) { PW.WriteInt16(i, (Int16)rush_items[j]); } break; // Load rush items case EngineEnum.PlayerEnum.CharactersType.CHARACTER_TIPPY: item_number = tippy_items.Count(); for (int i = 0x24, j = 0; i < (item_number * 0x1D) && j < item_number; i += 0x1D, j++) { PW.WriteInt16(i, (Int16)tippy_items[j]); } break; // Load tippy items case EngineEnum.PlayerEnum.CharactersType.CHARACTER_KLAUS: // There is still no avaiable items for klaus case EngineEnum.PlayerEnum.CharactersType.CHARACTER_KARA: // There is still no avaiable items for kara break; } PW.WriteInt32(30, item_number); // Write some unknow number for now (each items) maybe something to do with duration? for (int i = 0x2E; i < (item_number * 0x1D); i += 0x1D) { PW.WriteSByte(i, unknow_number); } // Write the position of each items for (int i = 0x20, j = 0; i < (item_number * 0x1D) && j < (item_number * 0x1D); i += 0x1D, j++) { PW.WriteInt16(i, (Int16)j); } }
public SelectServer(Engine.Network.Client client_socket, EngineEnum.LoginEnum.SelectServerStatus status) { clientsocket = client_socket; _status = status; }
/// <summary> /// Load inventory items. /// </summary> /// <param name="type"></param> /// <returns></returns> public static byte[] Inventory_Buff(EngineEnum.WorldEnum.CharactersType type) { byte[] block = new byte[0x118F]; // Create the packet's data base byte[] c_block = EngineUtils.PacketUtils.calcPacket(0x118F, 0x833); // Calc the packet's header // Initializing the packet writer PacketWriter PW = new PacketWriter(block); // Write the packet's header PW.WriteByteArray(0, c_block); // Write the packet's data PW.WriteString(5, EngineEnum.PacketEnum.PacketCommand.success_0); switch(type) { case EngineEnum.WorldEnum.CharactersType.CHARACTER_ROOKIE: LoadItemList(block, EngineEnum.WorldEnum.CharactersType.CHARACTER_ROOKIE); break; case EngineEnum.WorldEnum.CharactersType.CHARACTER_LUNA: LoadItemList(block, EngineEnum.WorldEnum.CharactersType.CHARACTER_LUNA); break; case EngineEnum.WorldEnum.CharactersType.CHARACTER_RUSH: LoadItemList(block, EngineEnum.WorldEnum.CharactersType.CHARACTER_RUSH); break; case EngineEnum.WorldEnum.CharactersType.CHARACTER_TIPPY: LoadItemList(block, EngineEnum.WorldEnum.CharactersType.CHARACTER_TIPPY); break; case EngineEnum.WorldEnum.CharactersType.CHARACTER_KLAUS: // There is still no avaiable items for klaus case EngineEnum.WorldEnum.CharactersType.CHARACTER_KARA: // There is still no avaiable items for kara break; } return block; }
/// <summary> /// Create a player character list. /// </summary> /// <param name="isFirstTime"></param> /// <param name="char_type"></param> /// <param name="char_name"></param> /// <returns></returns> public static byte[] PlayerCharacterList_Buff(bool isFirstTime, EngineEnum.WorldEnum.CharactersType char_type, string char_name) { byte[] block = new byte[0x120]; // Create the packet's data base byte[] c_block = EngineUtils.PacketUtils.calcPacket(0x120, 0x90E); // Calc the packet's header // Initializing the packet writer PacketWriter PW = new PacketWriter(block); // Write the packet's header PW.WriteByteArray(0, c_block); // Write the packet's data PW.WriteString(5, EngineEnum.PacketEnum.PacketCommand.success_0); PW.WriteString(30, char_name); // Write the character's name, you can use some html code like: <#ff0000> or <glow> PW.WriteInt32(73, isFirstTime ? 1 : 0); // Create a character/or no PW.WriteUInt32(75, 0); // I don't know what is it PW.WriteUInt32(79, (UInt32)char_type); // Choose the desired character (luna, etc..) PW.WriteUInt32(83, 0); // I don't know what is it return block; }
private void AddDefinitions(JObject mergeObject) { try { var definitions = mergeObject["definitions"] as JObject; foreach (var child in definitions.Children()) { var jProperty = child as JProperty; foreach (var subChild in child.Children()) { logger.Debug($"Object name: {jProperty.Name}"); dynamic jObject = subChild as JObject; var export = jObject?.export?.ToObject <bool>() ?? true; if (!export) { continue; } var objectType = jObject?.type?.ToString() ?? null; EngineClass engineClass = null; switch (objectType) { case "object": engineClass = jObject.ToObject <EngineClass>(); engineClass.Name = jProperty.Name; //special case for .NET JObject - JsonObject is ignored if (engineClass.Name == "JsonObject") { logger.Info("The class \"JsonObject\" is ignored because \"JObject\" already exists in the namespace Newtonsoft."); continue; } engineClass.SeeAlso = GetValueFromProperty <List <string> >(jObject, "x-qlik-see-also"); var properties = ReadProperties(jObject, "properties", engineClass.Name); if (properties.Count == 0) { logger.Info($"The Class \"{engineClass.Name}\" has no properties."); } engineClass.Properties.AddRange(properties); EngineObjects.Add(engineClass); //Special for ObjectInterface => Add IObjectInterface if (engineClass.Name == Config.BaseObjectInterfaceClassName) { var baseInterface = new EngineInterface() { Name = Config.BaseObjectInterfaceName, Description = "Generated Interface", }; baseInterface.Properties.AddRange(engineClass.Properties); EngineObjects.Add(baseInterface); } break; case "array": engineClass = jObject.ToObject <EngineClass>(); engineClass.Name = jProperty.Name; engineClass.SeeAlso = GetValueFromProperty <List <string> >(jObject, "x-qlik-see-also"); var arrays = ReadProperties(jObject, "items", engineClass.Name); engineClass.Properties.AddRange(arrays); EngineObjects.Add(engineClass); break; case "enum": EngineEnum engineEnum = jObject.ToObject <EngineEnum>(); engineEnum.Name = jProperty.Name; var enums = GetEnumValues(jObject); engineEnum.Values = enums; if (EnumExists(engineEnum) == null) { EngineObjects.Add(engineEnum); } break; default: logger.Error($"Unknown object type {objectType}"); break; } } } } catch (Exception ex) { logger.Error(ex, "The definitions could not be added."); } }
private List <EngineProperty> ReadProperties(JObject jObject, string tokenName, string className) { var results = new List <EngineProperty>(); try { var properties = GetValueFromProperty <JToken>(jObject, tokenName); if (properties == null) { return(results); } foreach (var property in properties) { var jprop = property as JProperty; logger.Debug($"Property name: {jprop.Name}"); var engineProperty = new EngineProperty(); dynamic propObject = null; if (property.First.Type == JTokenType.Object) { propObject = property.First as JObject; engineProperty = propObject.ToObject <EngineProperty>(); engineProperty.EnumShot = (propObject as JObject)["enumShort"] as JToken ?? null; } engineProperty.Name = jprop.Name; if (engineProperty.Description != null && engineProperty.Description.Contains("The default value is")) { if (!String.IsNullOrEmpty(engineProperty.Default)) { engineProperty.DefaultValueFromDescription = engineProperty.Default; } else { logger.Warn($"The default value was not found for the property: \"{engineProperty.Name}\" class: \"{className}\""); } } var refValue = GetValueFromProperty <string>(propObject, "$ref"); if (!String.IsNullOrEmpty(refValue)) { engineProperty.Ref = refValue; } if (jprop.Name == "$ref") { var refLink = jprop?.Value?.ToObject <string>() ?? null; logger.Debug($"Items Ref: {refLink}"); engineProperty.Ref = refLink; } if (engineProperty.Type == "array") { refValue = GetValueFromProperty <string>(propObject.items, "$ref"); if (String.IsNullOrEmpty(refValue)) { refValue = propObject.items.type.ToObject <string>(); } engineProperty.Ref = refValue; } if (engineProperty.Enum != null) { engineProperty.Type = GenerateEnumType(engineProperty.Name); engineProperty.IsEnumType = true; var engineEnum = new EngineEnum() { Name = engineProperty.Name, }; foreach (var enumValue in engineProperty.Enum) { var shotName = engineEnum.GetShotEnumName(enumValue, engineProperty.EnumShot); engineEnum.Values.Add(new EngineEnumValue() { Name = enumValue, ShotValue = shotName }); } var enumResult = EnumExists(engineEnum); if (enumResult == null) { EngineObjects.Add(engineEnum); engineEnum.Name = engineProperty.Type; } else { engineProperty.Type = enumResult.Name; } } results.Add(engineProperty); } return(results); } catch (Exception ex) { logger.Error(ex, $"The method {nameof(ReadProperties)} failed."); return(results); } }
public Engine(EngineEnum id) { Id = id; Name = id.ToString(); Description = id.GetEnumDescription(); }
/// <summary> /// Select the server created. /// </summary> /// <param name="status"></param> /// <returns></returns> public static byte[] SelectServer_Buff(EngineEnum.LoginEnum.SelectServerStatus status) { byte[] block = new byte[0x12]; // Create the packet's data base byte[] c_block = EngineUtils.PacketUtils.calcPacket(0x12, 0x3EF); // Calc the packet's header // Initializing the packet writer PacketWriter PW = new PacketWriter(block); // Write the packet's header PW.WriteByteArray(0, c_block); // Write the packet's data PW.WriteInt32(5, (int)status); return block; }
public Engine(EngineEnum engine) { EngineProperty = engine; }
/// <summary> /// Send an error message to the client. /// </summary> /// <param name="request_msg_id"></param> /// <returns></returns> public static byte[] Error_Buff(EngineEnum.HeadersEnum.Send.TM_SC_RESULT request_msg_id) { byte[] block = new byte[0x09]; // Create the packet's data base byte[] c_block = EngineUtils.PacketUtils.calcPacket(0x09, 1001); // Calc the packet header // Initialize the packet writer PacketWriter PW = new PacketWriter(block); // Write the packet's header PW.WriteByteArray(0, c_block); // Write the packet's data PW.WriteInt16(7, (Int16)request_msg_id); // Desired error message return block; }