All pastes #25439 Raw Edit

tobz

public text v1 · immutable
#25439 ·published 2005-10-14 00:42 UTC
rendered paste body
protected static readonly long[] REALMPOINTS_FOR_LEVEL =
		{
			0,			// 1L1
			1,			// 1L1
			25,			// 1L2
			125,		// 1L3
			350,		// 1L4
			750,		// 1L5
			1375,		// 1L6
			2275,		// 1L7
			3500,		// 1L8
			5100,		// 1L9
			7125,		// 2L0
			9625,		// 2L1
			12650,		// 2L2
			16250,		// 2L3
			20475,		// 2L4
			25375,		// 2L5
			31000,		// 2L6
			37400,		// 2L7
			44625,		// 2L8
			52725,		// 2L9
			61750,		// 3L0
			71750,		// 3L1
			82775,		// 3L2
			94875,		// 3L3
			108100,		// 3L4
			122500,		// 3L5
			138125,		// 3L6
			155025,		// 3L7
			173250,		// 3L8
			192850,		// 3L9
			213875,		// 4L0
			236375,		// 4L1
			260400,		// 4L2
			286000,		// 4L3
			313225,		// 4L4
			342125,		// 4L5
			372750,		// 4L6
			405150,		// 4L7
			439375,		// 4L8
			475475,		// 4L9
			513500,		// 5L0
			553500,		// 5L1
			595525,		// 5L2
			639625,		// 5L3
			685850,		// 5L4
			734250,		// 5L5
			784875,		// 5L6
			837775,		// 5L7
			893000,		// 5L8
			950600,		// 5L9
			1010625,	// 6L0
			1073125,	// 6L1
			1138150,	// 6L2
			1205750,	// 6L3
			1275975,	// 6L4
			1348875,	// 6L5
			1424500,	// 6L6
			1502900,	// 6L7
			1584125,	// 6L8
			1668225,	// 6L9
			1755250,	// 7L0
			1845250,	// 7L1
			1938275,	// 7L2
			2034375,	// 7L3
			2133600,	// 7L4
			2236000,	// 7L5
			2341625,	// 7L6
			2450525,	// 7L7
			2562750,	// 7L8
			2678350,	// 7L9
			2797375,	// 8L0
			2919875,	// 8L1
			3045900,	// 8L2
			3175500,	// 8L3
			3308725,	// 8L4
			3445625,	// 8L5
			3586250,	// 8L6
			3730650,	// 8L7
			3878875,	// 8L8
			4030975,	// 8L9
			4187000,	// 9L0
			4347000,	// 9L1
			4511025,	// 9L2
			4679125,	// 9L3
			4851350,	// 9L4
			5027750,	// 9L5
			5208375,	// 9L6
			5393275,	// 9L7
			5582500,	// 9L8
			5776100,	// 9L9
			5974125,	// 10L0
			6176625,	// 10L1
			6383650,	// 10L2
			6595250,	// 10L3
			6811475,	// 10L4
			7032375,	// 10L5
			7258000,	// 10L6
			7488400,	// 10L7
			7723625,	// 10L8
			7963725,	// 10L9
			8208750,	// 11L0
			9111713,    // 11L1
			10114001,   // 11L2
			11226541,   // 11L3
			12461460,   // 11L4
			13832221,   // 11L5
			15353765,   // 11L6
			17042680,   // 11L7
			18917374,   // 11L8
			20998286,   // 11L9
			23308097    // 12L0
		};

	protected virtual int CalculateRealmLevelFromRPs(long realmPoints)
	{
		if (realmPoints == 0)
			return 0;

		int i = REALMPOINTS_FOR_LEVEL.Length - 1;
		for (; i > 0; i--)
		{
			if (REALMPOINTS_FOR_LEVEL[i] <= realmPoints)
				break;
		}

		if (i > 111)
			return 111;
		return i;
	}

	public string GetRealmTitle(long realmPoints, int realm)
	{
		if (realm >= REALM_RANK_NAMES.Length)
			return "unknown realm";

		string[] rankNames = REALM_RANK_NAMES[realm];

		int rank = CalculateRealmLevelFromRPs(realmPoints) / 10;

		if (rank >= rankNames.Length)
			rank = rankNames.Length - 1;

		return rankNames[rank];
	}

	public string GetRealmRankTitle(long realmPoints)
	{
		int rank = CalculateRealmLevelFromRPs(realmPoints);

		int firstPart = rank / 10;

		int secondPart = rank - (firstPart * 10);

		return firstPart.ToString() + "L" + secondPart.ToString();
	}