mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-09-08 10:15:13 -05:00
Trainer rankings works!!
This commit is contained in:
@@ -423,226 +423,20 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
|
||||
// Record record contains 4 bytes of category and 4 bytes of my score in the category.
|
||||
|
||||
// The response is biig and contains all the records for both this week and last week.
|
||||
// This week lacks numbers because they're still growing and to make it a surprise.
|
||||
// Including more than 3 RecordTypes in the response will give error 10609.
|
||||
|
||||
// Note: Although the game gives instructions that only
|
||||
// your first submission will apply, I think it's more
|
||||
// fun if we allow you to update your results by
|
||||
// submitting again. In this way, you can race against
|
||||
// competing teams to get the highest score.
|
||||
var submission = new TrainerRankingsSubmission(pid, data, 0x140);
|
||||
Database.Instance.TrainerRankingsSubmit(submission);
|
||||
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
|
||||
|
||||
/*
|
||||
response.WriteBytes(new byte[] {
|
||||
// Last week comes first:
|
||||
0x1c, 0x00, 0x00, 0x00, // 0x1c is a record type here.
|
||||
0x02, 0x07, 0x06, 0x00, 0x04, 0x01, 0x05, 0x03, // Then we have 16 bytes for trainer classes
|
||||
0x0c, 0x09, 0x0f, 0x0e, 0x0d, 0x08, 0x0a, 0x0b,
|
||||
0x89, 0xe9, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Then 16 longs for their scores
|
||||
0x8a, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x8f, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xb1, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x31, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xf5, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xa8, 0x9d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd6, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xc9, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x17, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xb2, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x58, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x20, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x99, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6b, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// The response is biig and contains all the records for both this week and last week.
|
||||
// This week lacks numbers because they're still growing and to make it a surprise.
|
||||
// Including more than 3 RecordTypes in the response will give error 10609.
|
||||
|
||||
0x01, 0x09, 0x05, 0x0c, 0x07, 0x04, 0x08, 0x0a, // Now the 12 months begin...
|
||||
0x02, 0x03, 0x06, 0x0b,
|
||||
0xd3, 0x16, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // And the 12 longs for their scores
|
||||
0xf0, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xa4, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x17, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x90, 0xcd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x86, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6e, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xdf, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xde, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7b, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x46, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x89, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x9d, 0x00, 0xc0, 0x01, 0xf9, 0x00, 0x5e, 0x01, // And 20 pokemon numbers.
|
||||
0xf8, 0x00, 0x06, 0x00, 0x95, 0x01, 0xa0, 0x00,
|
||||
0x97, 0x00, 0x95, 0x00, 0xbd, 0x01, 0x7f, 0x01,
|
||||
0x5f, 0x00, 0xd8, 0x01, 0x88, 0x01, 0x94, 0x00,
|
||||
0xed, 0x01, 0x19, 0x00, 0x93, 0x00, 0x96, 0x00,
|
||||
0xb6, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // And 20 longs for their scores
|
||||
0x95, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x61, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xb1, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0b, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd3, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xa4, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xee, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x22, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x1f, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3a, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6f, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x41, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x20, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x33, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xeb, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xdf, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x4c, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
// 0x2b is the second record category.
|
||||
0x2b, 0x00, 0x00, 0x00, 0x07, 0x03, 0x0f, 0x02,
|
||||
0x05, 0x0e, 0x04, 0x01, 0x09, 0x00, 0x0a, 0x0c,
|
||||
0x06, 0x0d, 0x0b, 0x08, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0c, 0x08, 0x0b, 0x09,
|
||||
0x01, 0x07, 0x03, 0x04, 0x06, 0x0a, 0x05, 0x02,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xf8, 0x00, 0xbd, 0x00, 0x8d, 0x00, 0x71, 0x01,
|
||||
0x8e, 0x01, 0x98, 0x00, 0xa2, 0x00, 0x7e, 0x00,
|
||||
0x42, 0x01, 0x55, 0x01, 0x48, 0x01, 0xa7, 0x01,
|
||||
0x53, 0x00, 0x4f, 0x01, 0xa6, 0x00, 0xd7, 0x00,
|
||||
0xcc, 0x01, 0x48, 0x00, 0xf3, 0x00, 0x94, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
// 0x4a is the last record category.
|
||||
0x4a, 0x00, 0x00, 0x00, 0x02, 0x06, 0x07, 0x05,
|
||||
0x00, 0x03, 0x04, 0x01, 0x08, 0x09, 0x0e, 0x0c,
|
||||
0x0d, 0x0a, 0x0b, 0x0f, 0x5e, 0x76, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x8f, 0x39, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x16, 0x28, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x8e, 0x1e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x4a, 0x13, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xb6, 0x0c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x33, 0x0b, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xaa, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x2b, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xb8, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x63, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x01, 0x09,
|
||||
0x0a, 0x05, 0x03, 0x0b, 0x07, 0x08, 0x0c, 0x06,
|
||||
0x64, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd7, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x24, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7a, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5a, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xfc, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xf3, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9f, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3a, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x82, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xbb, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xa6, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xf9, 0x00, 0x79, 0x00, 0x9d, 0x00, 0x80, 0x01,
|
||||
0xa0, 0x00, 0x9b, 0x01, 0x95, 0x01, 0x70, 0x01,
|
||||
0xc0, 0x01, 0xd0, 0x01, 0x7f, 0x01, 0x94, 0x01,
|
||||
0x95, 0x00, 0xbd, 0x01, 0x7d, 0x01, 0xe6, 0x01,
|
||||
0x94, 0x00, 0x92, 0x00, 0xd2, 0x01, 0x01, 0x00,
|
||||
0xf5, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xec, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x85, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x1d, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x38, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x1a, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xb7, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x87, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x87, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x67, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xb2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9d, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x97, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xcd, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xb4, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
// Current week begins:
|
||||
0x01, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x0f, // ** 0x01 **
|
||||
0x03, 0x05, 0x07, 0x00, 0x08, 0x09, 0x01, 0x0c, // 16 (trainer classes) + 12 (months) + 20 * 2 (pokemon) = 68 byte payload
|
||||
0x0e, 0x0b, 0x0d, 0x0a, 0x03, 0x06, 0x01, 0x04,
|
||||
0x0a, 0x05, 0x08, 0x0c, 0x09, 0x0b, 0x02, 0x07,
|
||||
0x8e, 0x00, 0x7c, 0x01, 0x75, 0x01, 0x8e, 0x01,
|
||||
0x9d, 0x00, 0xe4, 0x01, 0x04, 0x01, 0x80, 0x01,
|
||||
0xfe, 0x00, 0xaf, 0x00, 0xe3, 0x01, 0x88, 0x01,
|
||||
0xe7, 0x01, 0x82, 0x00, 0x5e, 0x01, 0xeb, 0x01,
|
||||
0xe5, 0x00, 0xe8, 0x01, 0x93, 0x00, 0x96, 0x00,
|
||||
0x28, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x0c, // ** 0x28 **
|
||||
0x04, 0x02, 0x05, 0x06, 0x0b, 0x01, 0x0f, 0x0d,
|
||||
0x08, 0x09, 0x0e, 0x0a, 0x0a, 0x07, 0x0c, 0x06,
|
||||
0x01, 0x02, 0x08, 0x03, 0x05, 0x09, 0x0b, 0x04,
|
||||
0x88, 0x01, 0x8f, 0x00, 0x7c, 0x01, 0x8e, 0x01,
|
||||
0xea, 0x00, 0x01, 0x01, 0xa4, 0x01, 0xe6, 0x01,
|
||||
0x5e, 0x01, 0xc0, 0x01, 0x8e, 0x00, 0x9a, 0x00,
|
||||
0xe7, 0x01, 0xbd, 0x01, 0xfe, 0x00, 0x82, 0x00,
|
||||
0xbb, 0x00, 0x04, 0x01, 0xb0, 0x00, 0x9d, 0x00,
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x04, // ** 0x43 **
|
||||
0x03, 0x08, 0x07, 0x05, 0x0f, 0x01, 0x0c, 0x09,
|
||||
0x0b, 0x0e, 0x0d, 0x0a, 0x0a, 0x05, 0x04, 0x07,
|
||||
0x01, 0x03, 0x0b, 0x0c, 0x09, 0x06, 0x08, 0x02,
|
||||
0x8e, 0x01, 0x75, 0x01, 0x82, 0x00, 0x80, 0x01,
|
||||
0xaf, 0x00, 0xeb, 0x01, 0xe7, 0x01, 0x5e, 0x01,
|
||||
0x9a, 0x00, 0x8f, 0x00, 0x9d, 0x00, 0xe8, 0x01,
|
||||
0x8e, 0x00, 0x7c, 0x01, 0x7d, 0x01, 0xe5, 0x00,
|
||||
0x88, 0x01, 0x1a, 0x00, 0xfe, 0x00, 0xf9, 0x00
|
||||
});*/
|
||||
|
||||
/*
|
||||
// fake replay data:
|
||||
@@ -665,14 +459,17 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
*/
|
||||
|
||||
TrainerRankingsReport thisWeek = Database.Instance.TrainerRankingsGetPendingReport();
|
||||
thisWeek.PadResults();
|
||||
TrainerRankingsReport lastWeek = Database.Instance.TrainerRankingsGetReport(DateTime.MinValue, thisWeek.StartDate.AddDays(-1), 1).FirstOrDefault();
|
||||
if (lastWeek == null) lastWeek = GenerateFakeReport(thisWeek.StartDate.AddDays(-7),
|
||||
new TrainerRankingsRecordTypes[]
|
||||
{
|
||||
TrainerRankingsRecordTypes.HallOfFameEntries,
|
||||
TrainerRankingsRecordTypes.CompletedGtsPokemonTrades,
|
||||
TrainerRankingsRecordTypes.FacilitiesChallengedAtTheBattleFrontier
|
||||
0, 0, 0
|
||||
});
|
||||
else
|
||||
{
|
||||
lastWeek.PadResults();
|
||||
}
|
||||
|
||||
// Last week:
|
||||
foreach (var lbg in lastWeek.Leaderboards)
|
||||
|
||||
@@ -2937,7 +2937,7 @@ namespace PkmnFoundations.Data
|
||||
"ON pkmncf_terminal_trainer_rankings_records.pid = pkmncf_terminal_trainer_rankings_teams.pid " +
|
||||
"WHERE pkmncf_terminal_trainer_rankings_records.LastUpdated >= @start_date " +
|
||||
"AND RecordType = @record_type " +
|
||||
"GROUP BY TrainerClass;",
|
||||
"GROUP BY Team",
|
||||
new MySqlParameter("@record_type", recordType),
|
||||
new MySqlParameter("@start_date", startDate));
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
<Compile Include="Support\AssertHelper.cs" />
|
||||
<Compile Include="Support\EncodedString4.cs" />
|
||||
<Compile Include="Support\EncodedString5.cs" />
|
||||
<Compile Include="Support\EnumerableExtender.cs" />
|
||||
<Compile Include="Support\GameSyncUtils.cs" />
|
||||
<Compile Include="Support\Indexer1d.cs" />
|
||||
<Compile Include="Support\LazyKeyValuePair.cs" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using PkmnFoundations.Support;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -19,6 +20,14 @@ namespace PkmnFoundations.Structures
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
public TrainerRankingsLeaderboardGroup[] Leaderboards { get; set; }
|
||||
|
||||
public void PadResults()
|
||||
{
|
||||
foreach (var group in Leaderboards)
|
||||
{
|
||||
group.PadResults(StartDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TrainerRankingsLeaderboardGroup
|
||||
@@ -37,6 +46,13 @@ namespace PkmnFoundations.Structures
|
||||
public TrainerRankingsLeaderboard LeaderboardTrainerClass { get; set; }
|
||||
public TrainerRankingsLeaderboard LeaderboardBirthMonth { get; set; }
|
||||
public TrainerRankingsLeaderboard LeaderboardFavouritePokemon { get; set; }
|
||||
|
||||
public void PadResults(DateTime startDate)
|
||||
{
|
||||
LeaderboardTrainerClass.PadResults(startDate, 16, 0, 16);
|
||||
LeaderboardBirthMonth.PadResults(startDate, 12, 1, 12);
|
||||
LeaderboardFavouritePokemon.PadResults(startDate, 20, 1, 493);
|
||||
}
|
||||
}
|
||||
|
||||
public class TrainerRankingsLeaderboard
|
||||
@@ -50,6 +66,24 @@ namespace PkmnFoundations.Structures
|
||||
public TrainerRankingsTeamCategories TeamCategory { get; set; }
|
||||
|
||||
public TrainerRankingsLeaderboardEntry[] Entries { get; set; }
|
||||
|
||||
public void PadResults(DateTime startDate, int entryCount, int minTeam, int teamCount)
|
||||
{
|
||||
IEnumerable<TrainerRankingsLeaderboardEntry> working = Entries;
|
||||
if (Entries.Length < teamCount)
|
||||
{
|
||||
var unusedValues = Enumerable.Range(minTeam, teamCount)
|
||||
.DrawWithoutReplacement(new Random((int)startDate.Ticks + 69420))
|
||||
.Take(entryCount)
|
||||
.Where(i => !Entries.Select(e => e.Team).Contains(i));
|
||||
|
||||
working = Entries.Concat(unusedValues.Select(i => new TrainerRankingsLeaderboardEntry(i, 0)));
|
||||
}
|
||||
|
||||
// todo: shuffle ties maybe...
|
||||
|
||||
Entries = working.Take(entryCount).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public class TrainerRankingsLeaderboardEntry
|
||||
@@ -72,16 +106,16 @@ namespace PkmnFoundations.Structures
|
||||
//Blank02 = 0x02,
|
||||
//Blank03 = 0x03,
|
||||
//Blank04 = 0x04,
|
||||
BattleTowerSingleBattleWinStreak = 0x05,
|
||||
//Blank06 = 0x06,
|
||||
BattleTowerDoubleBattleWinStreak = 0x07,
|
||||
//Blank08 = 0x08,
|
||||
BattleTowerMultiBattleWinStreak = 0x09,
|
||||
//Blank0a = 0x0a,
|
||||
BattleTowerPartneredMultiBattleWinStreak = 0x0b,
|
||||
//Blank0c = 0x0c,
|
||||
WiFiBattleTowerWinStreak = 0x0d,
|
||||
//Blank0e = 0x0e,
|
||||
//BattleTowerSingleBattleWinStreak = 0x05, // crashes when asked for
|
||||
//Blank06 = 0x06, // crashes when asked for
|
||||
//BattleTowerDoubleBattleWinStreak = 0x07, // crashes when asked for
|
||||
//Blank08 = 0x08, // crashes when asked for
|
||||
//BattleTowerMultiBattleWinStreak = 0x09, // crashes when asked for
|
||||
//Blank0a = 0x0a, // crashes when asked for
|
||||
//BattleTowerPartneredMultiBattleWinStreak = 0x0b, // crashes when asked for
|
||||
//Blank0c = 0x0c, // crashes when asked for
|
||||
//WiFiBattleTowerWinStreak = 0x0d, // crashes when asked for
|
||||
//Blank0e = 0x0e, // crashes when asked for
|
||||
ContestsEnteredAlone = 0x0f,
|
||||
ContestsEnteredWithFriends = 0x10,
|
||||
ContestsEnteredAloneAndWon = 0x11,
|
||||
@@ -102,7 +136,7 @@ namespace PkmnFoundations.Structures
|
||||
EggsHatched = 0x20,
|
||||
TimesOwnPokemonEvolved = 0x21,
|
||||
GameCornerSlotJackpots = 0x22,
|
||||
BattleFrontierChallenges = 0x23,
|
||||
BattleTowerChallenges = 0x23, // seems to say Frontier on Platinum but Tower on HGSS
|
||||
//Blank24 = 0x24,
|
||||
//Blank25 = 0x25,
|
||||
//Blank26 = 0x26,
|
||||
@@ -111,19 +145,19 @@ namespace PkmnFoundations.Structures
|
||||
BattlesWonOverNintendoWiFiConnection = 0x29,
|
||||
//Blank2a = 0x2a,
|
||||
BattlesTiedOverNintendoWiFiConnection = 0x2b,
|
||||
BattlesWonAtBattleTower = 0x2c,
|
||||
TotalMoneySpendShopping = 0x2d,
|
||||
PokemonLeftWithDayCare = 0x2e,
|
||||
BattlesWonAtTheBattleTower = 0x2c,
|
||||
TotalMoneySpentShopping = 0x2d,
|
||||
PokemonLeftWithTheDayCare = 0x2e,
|
||||
PokemonDefeated = 0x2f,
|
||||
PokemonOfferedOnGts = 0x30,
|
||||
TimesPokemonWereTradedWithFriendsAtWiFiClub = 0x31,
|
||||
TimesPokemonWereTradedWithFriendsAtTheWiFiClub = 0x31,
|
||||
TimesYouSignedYourTrainerCard = 0x32,
|
||||
PokemonExtractedFromFossils = 0x33,
|
||||
TimesFootprintsWereCheckedByDrFootstep = 0x34,
|
||||
TimesMailWasSent = 0x35,
|
||||
WildPokemonLuredUsingHoney = 0x36,
|
||||
TimesYouTalkedToSomeoneInWiFiPlaza = 0x37,
|
||||
SpheresBuriedInUnderground = 0x38,
|
||||
TimesYouTalkedToSomeoneInTheWiFiPlaza = 0x37,
|
||||
NumberOfSpheresBuriedInTheUnderground = 0x38,
|
||||
TimesWatchedTv = 0x39,
|
||||
TimesPokemonWereGivenNicknames = 0x3a,
|
||||
PremierBallsReceived = 0x3b,
|
||||
@@ -133,7 +167,7 @@ namespace PkmnFoundations.Structures
|
||||
PokemonDressUpDataPhotosTaken = 0x3f,
|
||||
BouldersPushedUsingTheHiddenMoveStrength = 0x40,
|
||||
TimesMiredInASwamp = 0x41,
|
||||
MatchesAgainstYourFrivalAndGymLeadersAtTheBattleground = 0x42,
|
||||
MatchesAgainstYourRivalAndGymLeadersAtTheBattleground = 0x42,
|
||||
FacilitiesChallengedAtTheBattleFrontier = 0x43,
|
||||
TimesYouMetTheFrontierBrains = 0x44,
|
||||
WinsAtTheBattleFactory = 0x45,
|
||||
@@ -148,16 +182,16 @@ namespace PkmnFoundations.Structures
|
||||
TotalBattlePointsSpent = 0x4e,
|
||||
WiFiPlazaGamesPlayed = 0x4f,
|
||||
EggsTradedUsingSpinTrade = 0x50,
|
||||
StarPiecesTradedAtFuegoIronworks = 0x51,
|
||||
//BattlePointsEarnedFromTheBattleArcadeGameBoard52 = 0x52,
|
||||
ItemsAndBerriesEarnedFromTheBattleArcadeGameBoard = 0x53,
|
||||
//TotalBattlePointsWon54 = 0x54,
|
||||
//TotalBattlePointsSpent55 = 0x55,
|
||||
WinsInWiFiPlazaGames = 0x56,
|
||||
//EggsTradedUsingSpinTrade57 = 0x57,
|
||||
//Blank58 = 0x58,
|
||||
//Blank59 = 0x59,
|
||||
//Blank5a = 0x5a,
|
||||
StarPiecesTradedAtTheFuegoIronworks = 0x51,
|
||||
//BattlePointsEarnedFromTheBattleArcadeGameBoard52 = 0x52, // crashes when asked for
|
||||
//ItemsAndBerriesEarnedFromTheBattleArcadeGameBoard53 = 0x53, // crashes when asked for
|
||||
//TotalBattlePointsWon54 = 0x54, // crashes when asked for
|
||||
//TotalBattlePointsSpent55 = 0x55, // crashes when asked for
|
||||
//WinsInWiFiPlazaGames = 0x56, // crashes when asked for
|
||||
//EggsTradedUsingSpinTrade57 = 0x57, // crashes when asked for
|
||||
//Blank58 = 0x58, // crashes when asked for
|
||||
//Blank59 = 0x59, // crashes when asked for
|
||||
//Blank5a = 0x5a, // crashes when asked for
|
||||
//BlueScreen = 0x5b
|
||||
}
|
||||
|
||||
|
||||
43
library/Support/EnumerableExtender.cs
Normal file
43
library/Support/EnumerableExtender.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PkmnFoundations.Support
|
||||
{
|
||||
public static class EnumerableExtender
|
||||
{
|
||||
public static IEnumerable<T> OrderByLambda<T>(this IEnumerable<T> arg, Func<T, T, int> comparer)
|
||||
{
|
||||
// xxx: Should be using Comparer<T>.Create but we need .NET 4.5 for it. and are still targeting 3.5.
|
||||
return arg.OrderBy(k => k, new LambdaComparer<T>(comparer));
|
||||
}
|
||||
|
||||
private class LambdaComparer<T> : IComparer<T>
|
||||
{
|
||||
public LambdaComparer(Func<T, T, int> comparer)
|
||||
{
|
||||
m_comparer = comparer;
|
||||
}
|
||||
|
||||
private readonly Func<T, T, int> m_comparer;
|
||||
|
||||
public int Compare(T first, T second)
|
||||
{
|
||||
return m_comparer(first, second);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<T> DrawWithoutReplacement<T>(this IEnumerable<T> source, Random rng)
|
||||
{
|
||||
var working = source.ToList();
|
||||
|
||||
for (int i = working.Count; i > 0; i--)
|
||||
{
|
||||
int rand = rng.Next(i);
|
||||
yield return working[rand];
|
||||
working[rand] = working[i - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
-- Host: 127.0.0.1
|
||||
-- Server version: 10.3.28-MariaDB - mariadb.org binary distribution
|
||||
-- Server OS: Win64
|
||||
-- HeidiSQL Version: 12.0.0.6468
|
||||
-- HeidiSQL Version: 12.0.0.6518
|
||||
-- --------------------------------------------------------
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
@@ -829,7 +829,7 @@ BEGIN
|
||||
GROUP BY TrainerClass;
|
||||
|
||||
INSERT INTO pkmncf_terminal_trainer_rankings_leaderboards_month
|
||||
SELECT @report_id AS report_id, TrainerClass, @record_type AS RecordType, SUM(Score) AS Score
|
||||
SELECT @report_id AS report_id, BirthMonth, @record_type AS RecordType, SUM(Score) AS Score
|
||||
FROM pkmncf_terminal_trainer_rankings_records
|
||||
INNER JOIN pkmncf_terminal_trainer_rankings_teams
|
||||
ON pkmncf_terminal_trainer_rankings_records.pid = pkmncf_terminal_trainer_rankings_teams.pid
|
||||
@@ -838,7 +838,7 @@ BEGIN
|
||||
GROUP BY BirthMonth;
|
||||
|
||||
INSERT INTO pkmncf_terminal_trainer_rankings_leaderboards_pokemon
|
||||
SELECT @report_id AS report_id, TrainerClass, @record_type AS RecordType, SUM(Score) AS Score
|
||||
SELECT @report_id AS report_id, FavouritePokemon, @record_type AS RecordType, SUM(Score) AS Score
|
||||
FROM pkmncf_terminal_trainer_rankings_records
|
||||
INNER JOIN pkmncf_terminal_trainer_rankings_teams
|
||||
ON pkmncf_terminal_trainer_rankings_records.pid = pkmncf_terminal_trainer_rankings_teams.pid
|
||||
@@ -898,7 +898,7 @@ CREATE TABLE IF NOT EXISTS `pkmncf_terminal_trainer_rankings_leaderboards_month`
|
||||
-- Dumping structure for table gts.pkmncf_terminal_trainer_rankings_leaderboards_pokemon
|
||||
CREATE TABLE IF NOT EXISTS `pkmncf_terminal_trainer_rankings_leaderboards_pokemon` (
|
||||
`report_id` int(11) NOT NULL,
|
||||
`pokemon_id` int(10) unsigned NOT NULL,
|
||||
`pokemon_id` int(11) NOT NULL,
|
||||
`RecordType` int(11) NOT NULL,
|
||||
`Score` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`report_id`,`pokemon_id`,`RecordType`) USING BTREE,
|
||||
|
||||
Reference in New Issue
Block a user