public OffenceTracker() { String[] Names = Enum.GetNames(typeof(OffenceType)); foreach (String Name in Names) { OffenceValue Value = (OffenceValue)Enum.Parse(typeof(OffenceValue), Name, true); OffenceType Offence = (OffenceType)Enum.Parse(typeof(OffenceType), Name, true); OffenceValues.Add(Offence, Value); } }
private void AddOffence(OffenceType offence, OffenceValue value) { if (TotalOffenceValue() >= ServerConstants.MaxOffenceValue) { //Todo add ban/kick or whatever ServerConsole.Warning("Client found with high offence values: " + Enum.GetName(typeof(OffenceType), offence)); } if (OffenceList.ContainsKey(offence)) { OffenceList[offence] += (int)value; } else { OffenceList.Add(offence, (int)value); } }
public readonly float lowerMoveTime, upperMoveTime; //length of time it takes to perform the move public MoveData(string textToParse) { string textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Name: "); name = textFromFile; textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Description: "); description = textFromFile; textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Stamina Cost: "); switch (textFromFile.ToUpper()) { case "VERY LOW": staminaCost = StaminaCost.VERY_LOW; break; case "LOW": staminaCost = StaminaCost.LOW; break; case "NORMAL": staminaCost = StaminaCost.NORMAL; break; case "HIGH": staminaCost = StaminaCost.HIGH; break; case "VERY HIGH": staminaCost = StaminaCost.VERY_HIGH; break; } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Offence Type: "); switch (textFromFile.ToUpper()) { case "GRAPPLE": offenceType = OffenceType.GRAPPLE; break; case "STRIKE": offenceType = OffenceType.STRIKE; break; case "DIVE": offenceType = OffenceType.FLYING; break; case "RUNNING": offenceType = OffenceType.RUNNING; break; } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Required Position: "); requiredPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Required Opponent Position: "); requiredOpponentPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Finished Position: "); finishedPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Reversal Position: "); reversalPosition = StringToPosition(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Damaged Body Parts: "); string[] bodyParts = textFromFile.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); damagedBodyParts = new BodyPart[bodyParts.Length]; for (byte i = 0; i < bodyParts.Length; i++) { switch (bodyParts [i].ToUpper()) { case "HEAD": damagedBodyParts [i] = BodyPart.HEAD; break; case "TORSO": damagedBodyParts [i] = BodyPart.TORSO; break; case "ARMS": damagedBodyParts [i] = BodyPart.ARMS; break; case "LEGS": damagedBodyParts [i] = BodyPart.LEGS; break; default: throw new Exception("Not a valid body part."); } } textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Lower Move Time: "); lowerMoveTime = float.Parse(textFromFile); textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Upper Move Time: "); upperMoveTime = float.Parse(textFromFile); }
public void AddOffence(OffenceType offence) { AddOffence(offence, OffenceValues[offence]); }
/// <summary> /// Loads an account from the mysql database using the given character details. /// </summary> /// <param name="details">The details used to load the account.</param> /// <returns>Returns the account load result.</returns> public AccountLoadResult Load(Details details, LoginConnectionType loginType) { AccountLoadResult result = new AccountLoadResult(); if (GameEngine.World.SystemUpdate) { result.Character = new Character(details, 0); result.ReturnCode = LoginReturnCode.SystemUpdate; } try { DataRow data = null; using (SqlDatabaseClient client = GameServer.Database.GetClient()) { /* * Checks if the character exists in the database. It also * checks if the given password matches the stored password. */ client.AddParameter("username", details.Username); client.AddParameter("password", details.Password); data = client.ReadDataRow("SELECT * FROM characters LEFT JOIN (character_preferences) ON (characters.id = character_preferences.master_id) WHERE username = @username AND password = @password LIMIT 1;"); } if (data != null) // Meaning the character exists, and the password is correct. { result.Character = new Character(details, (uint)data[0]); // If a character is offensive, set the proper penalties. OffenceType offence = (OffenceType)GameEngine.World.OffenseManager.GetOffence(result.Character.MasterId); if (offence == OffenceType.Banned) // If the character is banned, flag and end this request. { result.ReturnCode = LoginReturnCode.AccountDisabled; } if (offence == OffenceType.Muted) // If the character is muted, we will mute this character. { result.Character.Muted = true; } /* * Only check if it's a new connection, as reconnections try * connnecting to the server before the older session is removed, * so we must ignore whether or not the character is online. */ if (loginType != LoginConnectionType.Reconnection && (bool)data[5]) { result.ReturnCode = LoginReturnCode.AlreadyOnline; } /* * We only want to assign the character details loaded from * the database if the player has passed though security. */ if (result.ReturnCode == LoginReturnCode.Successful) { // Core info. result.Character.ClientRights = (ClientRights)data[3]; result.Character.ServerRights = (ServerRights)data[4]; result.Active = (bool)data[6]; // Appearance. result.Character.Appearance.Gender = (Gender)data[14]; result.Character.Appearance.Head = (short)data[15]; result.Character.Appearance.Torso = (short)data[16]; result.Character.Appearance.Arms = (short)data[17]; result.Character.Appearance.Wrist = (short)data[18]; result.Character.Appearance.Legs = (short)data[19]; result.Character.Appearance.Feet = (short)data[20]; result.Character.Appearance.Beard = (short)data[21]; result.Character.Appearance.HairColor = (byte)data[22]; result.Character.Appearance.TorsoColor = (byte)data[23]; result.Character.Appearance.LegColor = (byte)data[24]; result.Character.Appearance.FeetColor = (byte)data[25]; result.Character.Appearance.SkinColor = (byte)data[26]; // Location. result.Character.Location = Location.Create((short)data[27], (short)data[28], (byte)data[29]); // Energy. result.Character.WalkingQueue.RunEnergy = (byte)data[30]; // Containers. if (data[31] is string) { result.Character.Inventory.Deserialize((string)data[31]); } if (data[32] is string) { result.Character.Equipment.Deserialize((string)data[32]); } if (data[33] is string) { result.Character.Bank.Deserialize((string)data[33]); } // Friends and ignores if (data[34] is string) { string friends = (string)data[34]; if (friends != string.Empty) { result.Character.Contacts.DeserializeFriends(friends); } } if (data[35] is string) { string ignores = (string)data[35]; if (ignores != string.Empty) { result.Character.Contacts.DeserializeIgnores((string)data[35]); } } // Preferences. result.Character.Preferences.SingleMouse = (bool)data[37]; result.Character.Preferences.DisableChatEffects = (bool)data[38]; result.Character.Preferences.SplitChat = (bool)data[39]; result.Character.Preferences.AcceptAid = (bool)data[40]; } } else // User doesn't exist or password is wrong. { result.Character = new Character(details, 0); result.ReturnCode = LoginReturnCode.WrongPassword; } } catch (Exception ex) { Program.Logger.WriteException(ex); result.Character = new Character(details, 0); result.ReturnCode = LoginReturnCode.BadSession; } return(result); }