Aura.Channel.Skills.Life.Tailoring.CalculateQuality C# (CSharp) Метод

CalculateQuality() приватный Метод

Calculates quality, based on the stitches made by the player.
Calculates the distances between the points and the stitches made by the player and calculates the quality based on the total of all distances. Unofficial, but seems to work rather well. Except for 100 quality, which is practically impossible with this atm.
private CalculateQuality ( List stitches, int offsetX, int offsetY ) : int
stitches List
offsetX int
offsetY int
Результат int
		private int CalculateQuality(List<Point> stitches, int offsetX, int offsetY)
		{
			var points = new List<Point>();

			points.Add(new Point(100 - offsetX, 100 + (int)(offsetY * 2.5f))); // Lower Left
			points.Add(new Point(100 + offsetX, 100 + (int)(offsetY * 1.5f))); // Lower Right
			points.Add(new Point(100 - offsetX, 100 + (int)(offsetY * 0.5f))); // Mid Left
			points.Add(new Point(100 + offsetX, 100 - (int)(offsetY * 0.5f))); // Mid Right
			points.Add(new Point(100 - offsetX, 100 - (int)(offsetY * 1.5f))); // Upper Left
			points.Add(new Point(100 + offsetX, 100 - (int)(offsetY * 2.5f))); // Upper Right

			var total = 0.0;
			for (int i = 0; i < stitches.Count; ++i)
			{
				var p1 = points[i];
				var p2 = stitches[i];

				// Calculate distance between point and stitch made by the player
				total += Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
			}

			// Quality = 100 - (Total Distance * 2)
			// Min = -100
			// Max = 100 (increasing the max would increase the chance for 100 quality)
			return Math.Max(-100, 100 - (int)(total * 2));
		}