public TCPSocketClient(string tmpIP, int tmpPort) { this.basicLoger = new BasicLogger("TCPSocketClient.log"); this._ServerIP = IPAddress.Parse(tmpIP); this._ServerPort = tmpPort; this._ServerEndPoint = new IPEndPoint(_ServerIP, _ServerPort); this._client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); }
/// <summary> /// Creates the wrapper for the specified type. Current valid types are: /// /// "Entity" /// "Player Entity" /// "Generated Entity" /// /// /// Migrated type /// "Entity Template" - To EntityTemplateWrapper /// /// </summary> /// <param name="tmpType"></param> public EntityWrapper(string tmpType, List<Weapon> currentWeapons) { this._EntityEncrypter = new EncrypterDecrypter(); this._EntityEncrypter.setKey(this._key); if (tmpType == "Player Entity") { this.bLogger = new BasicLogger(this._ELog); this._ActivePath = this._PEPath; string encryptedEntities = this._EntityEncrypter.decryptFile(this._PEPath); if (encryptedEntities.Length > 0) { int TotalEntries = ParseItems.parseIntFrom(encryptedEntities, 4); encryptedEntities = encryptedEntities.Substring(4); int i = 0; while (i < TotalEntries) { int lengthOfEntity = ParseItems.parseIntFrom(encryptedEntities, 3); encryptedEntities = encryptedEntities.Substring(3); this.bLogger.Log("Attempting to decrypt: " + encryptedEntities.Substring(0, lengthOfEntity), debug); Entity newEntity = new Entity(encryptedEntities.Substring(0, lengthOfEntity), currentWeapons); encryptedEntities = encryptedEntities.Substring(lengthOfEntity); this._listOfEntities.Add(newEntity); this._usedIDs.Add(newEntity.id); i++; } } } else if (tmpType == "Generated Entity") { this.bLogger = new BasicLogger(this._ELog); this._ActivePath = this._GEPath; string encryptedEntities = this._EntityEncrypter.decryptFile(this._GEPath); if (encryptedEntities.Length > 0) { int TotalEntries = ParseItems.parseIntFrom(encryptedEntities, 4); encryptedEntities = encryptedEntities.Substring(4); int i = 0; while (i < TotalEntries) { int lengthOfEntity = ParseItems.parseIntFrom(encryptedEntities, 3); encryptedEntities = encryptedEntities.Substring(3); this.bLogger.Log("Attempting to decrypt: " + encryptedEntities.Substring(0, lengthOfEntity), debug); Entity newEntity = new Entity(encryptedEntities.Substring(0, lengthOfEntity), currentWeapons); encryptedEntities = encryptedEntities.Substring(lengthOfEntity); this._listOfEntities.Add(newEntity); this._usedIDs.Add(newEntity.id); i++; } } } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } }
public ItemWrapper(string tmpType) { this._WeaponPotionEncrypter = new EncrypterDecrypter(); this._WeaponPotionEncrypter.setKey(this._key); if (tmpType == "Weapon") { this.bLogger = new BasicLogger(this._WLog); this._ActivePath = this._WPath; string encryptedWeapons = this._WeaponPotionEncrypter.decryptFile(this._WPath); if (encryptedWeapons.Length > 0) { int TotalItems = ParseItems.parseIntFrom(encryptedWeapons, 4); encryptedWeapons = encryptedWeapons.Substring(4); int i = 0; while (i < TotalItems) { int lengthOfWeapon = ParseItems.parseIntFrom(encryptedWeapons, 3); encryptedWeapons = encryptedWeapons.Substring(3); this.bLogger.Log("Attempting to decrypt: " + encryptedWeapons.Substring(0, lengthOfWeapon), debug); Weapon newWeapon = new Weapon(encryptedWeapons.Substring(0, lengthOfWeapon)); encryptedWeapons = encryptedWeapons.Substring(lengthOfWeapon); this._listOfItems.Add(newWeapon); this._usedIDs.Add(newWeapon.itemID); i++; } } } else if (tmpType == "Potion") { this.bLogger = new BasicLogger(this._PLog); this._ActivePath = this._PPath; string encryptedPotions = this._WeaponPotionEncrypter.decryptFile(this._PPath); if (encryptedPotions.Length > 0) { int TotalItems = ParseItems.parseIntFrom(encryptedPotions, 4); encryptedPotions = encryptedPotions.Substring(4); int i = 0; while (i < TotalItems) { int lengthOfPotion = ParseItems.parseIntFrom(encryptedPotions, 3); encryptedPotions = encryptedPotions.Substring(3); Potion newPotion = new Potion(encryptedPotions.Substring(0, lengthOfPotion)); encryptedPotions = encryptedPotions.Substring(lengthOfPotion); this._listOfItems.Add(newPotion); this._usedIDs.Add(newPotion.itemID); i++; } } } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } }
public ItemWrapper(string tmpType) { type = tmpType; if (tmpType == "Weapon") { bLogger = new BasicLogger(_WLog); } else if (tmpType == "Potion") { bLogger = new BasicLogger(_PLog); } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } reload(); }
/// <summary> /// Constructs the wrapper(Opens/decryptes the effect data file and starts the logger) /// </summary> public EffectWrapper() { bLogger = new BasicLogger(elog); OdbcCommand effectQuery = new OdbcCommand("select * from Effect", dbConnection); dbConnection.ConnectionString = connectionString; dbConnection.Open(); OdbcDataReader reader = effectQuery.ExecuteReader(); while (reader.Read()) { int EffectID = (int)reader[0]; string EffectName = reader[1].ToString(); int ElementType = (int)reader[2]; int EffectType = (int)reader[3]; int EffectedStat = (int)reader[4]; int EffectedAmount = (int)reader[5]; int EffectedDuration = (int)reader[6]; _listOfEffects.Add(new Effect(EffectID, EffectName, ElementType, EffectType, EffectedStat,EffectedAmount, EffectedDuration)); _usedIDs.Add(EffectID); } dbConnection.Close(); }
public AbilityWrapper() { bLogger = new BasicLogger(alog); OdbcCommand AbilityQuery = new OdbcCommand("select * from Ability",dbConnection); dbConnection.ConnectionString = connectionString; dbConnection.Open(); OdbcDataReader reader = AbilityQuery.ExecuteReader(); while (reader.Read()) { int AbilityID = (int)reader[0]; string AbilityName = reader[1].ToString(); OdbcCommand AbilityEffectQuery = new OdbcCommand("select * from AbilityEffects where AbilityID="+AbilityID,dbConnection); OdbcDataReader abilityEffectsReader = AbilityEffectQuery.ExecuteReader(); List<int> effects = new List<int>(); while (abilityEffectsReader.Read()) { effects.Add((int)abilityEffectsReader[2]); } _listOfAbilities.Add(new Ability(AbilityID, AbilityName, effects)); _usedIDs.Add(AbilityID); } dbConnection.Close(); }
/// <summary> /// Constructs the wrapper(Opens/decryptes the effect data file and starts the logger) /// </summary> public EffectWrapper() { bLogger = new BasicLogger(elog); _effectEncrypter = new EncrypterDecrypter(_key); string decryptedResults = _effectEncrypter.decryptFile(epath); int numOfEffects = 0; if (decryptedResults.Length > 0) { numOfEffects = ParseItems.parseIntFrom(decryptedResults, 4); decryptedResults = decryptedResults.Substring(4); } int i = 0; while (i < numOfEffects) { int length = ParseItems.parseIntFrom(decryptedResults, 3); decryptedResults = decryptedResults.Substring(3); string currentEffect = ParseItems.parseStringFrom(decryptedResults, length); _listOfEffects.Add(new Effect(currentEffect)); _usedIDs.Add(_listOfEffects.Last().id); decryptedResults = decryptedResults.Substring(length); i++; } }
public AbilityWrapper() { bLogger = new BasicLogger(alog); _abilityEncrypter = new EncrypterDecrypter(_key); string decryptedResults = _abilityEncrypter.decryptFile(apath); int numOfAbilities = 0; if (decryptedResults.Length > 0) { numOfAbilities = ParseItems.parseIntFrom(decryptedResults, 4); decryptedResults = decryptedResults.Substring(4); } int i = 0; while (i < numOfAbilities) { int length = ParseItems.parseIntFrom(decryptedResults, 3); decryptedResults = decryptedResults.Substring(3); string currentAbility = ParseItems.parseStringFrom(decryptedResults, length); _listOfAbilities.Add(new Ability(currentAbility)); _usedIDs.Add(_listOfAbilities.Last().id); decryptedResults = decryptedResults.Substring(length); i++; } }
public ElementWrapper() { bLogger = new BasicLogger(logFile); reload(); }
public SpellWrapper() { bLogger = new BasicLogger(slog); reload(); }
public override void reload() { if (type == "Weapon") { OdbcCommand WeaponQuery = new OdbcCommand("select * from Weapon", dbConnection); dbConnection.ConnectionString = connectionString; dbConnection.Open(); OdbcDataReader reader = WeaponQuery.ExecuteReader(); while (reader.Read()) { int WeaponID = (int)reader[0]; string WeaponName = reader[1].ToString(); string tmpCanBuy = reader[2].ToString(); bool WeaponCanBuy; if (tmpCanBuy == "False") { WeaponCanBuy = false; } else { WeaponCanBuy = true; } int WeaponValue = (int)reader[3]; int WeaponPower = (int)reader[4]; int WeaponMagiPower = (int)reader[5]; List<int> WeaponEffects = new List<int>(); List<int> WeaponClasses = new List<int>(); OdbcCommand WeaponEffectsQuery = new OdbcCommand("select EffectID from WeaponEffects where WeaponID = " + WeaponID, dbConnection); OdbcDataReader WeaponEffectReader = WeaponEffectsQuery.ExecuteReader(); while (WeaponEffectReader.Read()) { WeaponEffects.Add((int)WeaponEffectReader[0]); } OdbcCommand WeaponClassesQuery = new OdbcCommand("select ClassID from WeaponClasses where WeaponID = " + WeaponID, dbConnection); OdbcDataReader WeaponClassesReader = WeaponClassesQuery.ExecuteReader(); while (WeaponClassesReader.Read()) { WeaponClasses.Add((int)WeaponClassesReader[0]); } _listOfItems.Add(new Weapon(WeaponID, WeaponName, WeaponValue, WeaponPower, WeaponMagiPower, WeaponCanBuy, WeaponEffects, WeaponClasses)); _usedIDs.Add(WeaponID); } dbConnection.Close(); } else if (type == "Potion") { } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } }
public CharacterClassWrapper() { bLogger = new BasicLogger(clog); reload(); }