}
<?php
//Case Battle Fairness | Round Validation
$serverSeed = 'cef7544d66f612a41121f506a2903135'; // Server seed
$eosBlockSeed = '1a869e974688d612eae6886a5813c2d67da069f3be2b3bf23d381cf2705c9dab'; // EOS Block Seed
// Update this to true if you are validating a tiebreaker result.
$isTiebreaker = false;
/*
* Case Ticket's Quantity, by default it's 100,000
* We only change this if there's a case that has different ticket distribution.
* Right now, all cases use 100,000 by default.
* IMPORTANT: If it's the tiebreaker round, this will be number of players participating on the tiebreaker.
* For example, if two players are participating on a tiebreaker the ticketQuantity is 2.
*/
$ticketQuantity = 100000;
/* ------------------ */
if ($serverSeed == '' || $eosBlockSeed == '') {
echo "Fill in details";
return;
}
define('MAX_HEX_SEGMENTS', 6);
define('HEX_SEGMENT_SIZE', 2);
define('BASE_FOR_HEX_CONVERSION', 256);
define('HASH_TYPE', 'sha256');
if (!function_exists('calculateDecimalValue')) {
function calculateDecimalValue(string $preResult): float
{
$decimalValue = 0;
for ($i = 0; $i < MAX_HEX_SEGMENTS; $i++) {
$hexValue = substr($preResult, HEX_SEGMENT_SIZE * $i, HEX_SEGMENT_SIZE);
$decimalValue += hexdec($hexValue) / pow(BASE_FOR_HEX_CONVERSION, $i + 1);
}
return $decimalValue;
}
}
if (!function_exists('getProvablyFairResult')) {
function getProvablyFairResult(string $init, string $serverSeed, int $qty): array
{
$preResult = hash_hmac(HASH_TYPE, $init, $serverSeed);
$decimalValue = calculateDecimalValue($preResult);
$result = (int) ($decimalValue * $qty) + 1;
return [
'preResult' => $preResult,
'result' => $result,
];
}
}
$serverSeed = preg_replace("/\r|\n/", "", $serverSeed);
$eosBlockSeed = preg_replace("/\r|\n/", "", $eosBlockSeed);
// Print header
echo "Case Battle Fairness Validation Results\n";
echo "=====================================\n";
echo "Server Seed: " . substr($serverSeed, 0, 16) . "...\n";
echo "EOS Block Seed: " . substr($eosBlockSeed, 0, 32) . "...\n";
echo "Ticket Quantity: " . number_format($ticketQuantity) . "\n\n";
// Create table header
echo str_pad("Round", 7) . " | ";
for ($player = 1; $player <= 4; $player++) {
echo str_pad("Player $player", 12) . " | ";
}
echo "\n";
echo str_repeat("-", 7) . " | " . str_repeat(str_repeat("-", 12) . " | ", 4) . "\n";
// Calculate and display results for all rounds and players
for ($roundNumber = 1; $roundNumber <= 50; $roundNumber++) {
echo str_pad($roundNumber, 7, " ", STR_PAD_LEFT) . " | ";
for ($playerPosition = 1; $playerPosition <= 4; $playerPosition++) {
if ($isTiebreaker) {
$stringToHash = "$eosBlockSeed-$roundNumber";
} else {
$stringToHash = "$eosBlockSeed-$roundNumber-$playerPosition";
}
$result = getProvablyFairResult($stringToHash, $serverSeed, $ticketQuantity);
echo str_pad(number_format($result['result']), 12, " ", STR_PAD_LEFT) . " | ";
}
echo "\n";
// Add a separator line every 10 rounds for better readability
if ($roundNumber % 10 == 0 && $roundNumber < 50) {
echo str_repeat("-", 7) . " | " . str_repeat(str_repeat("-", 12) . " | ", 4) . "\n";
}
}
echo "\n\nNote: Each result represents the ticket number (1 to " . number_format($ticketQuantity) . ") that won for that player in that round.\n";
// Optional: Show example of hash calculation for verification
echo "\n\nExample Verification (Round 1, Player 1):\n";
echo "==========================================\n";
$exampleString = "$eosBlockSeed-1-1";
$exampleResult = getProvablyFairResult($exampleString, $serverSeed, $ticketQuantity);
echo "Input String: " . substr($exampleString, 0, 50) . "...\n";
echo "HMAC-SHA256 Hash: " . $exampleResult['preResult'] . "\n";
echo "Result: " . number_format($exampleResult['result']) . "\n";
?>
- Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.23, 8.4.1 - 8.4.10
- }
Case Battle Fairness Validation Results
=====================================
Server Seed: cef7544d66f612a4...
EOS Block Seed: 1a869e974688d612eae6886a5813c2d6...
Ticket Quantity: 100,000
Round | Player 1 | Player 2 | Player 3 | Player 4 |
------- | ------------ | ------------ | ------------ | ------------ |
1 | 98,396 | 11,805 | 7,810 | 84,261 |
2 | 76,486 | 27,902 | 9,855 | 33,158 |
3 | 73,300 | 84,632 | 17,589 | 57,789 |
4 | 13,804 | 95,410 | 41,268 | 73,001 |
5 | 47,971 | 61,655 | 15,045 | 18,377 |
6 | 29,246 | 69,312 | 57,949 | 66,498 |
7 | 68,551 | 54,049 | 39,567 | 78,210 |
8 | 8,003 | 49,271 | 83,411 | 38 |
9 | 61,125 | 87,178 | 719 | 47,186 |
10 | 1,103 | 6,406 | 17,643 | 10,400 |
------- | ------------ | ------------ | ------------ | ------------ |
11 | 91,545 | 39,513 | 45,614 | 51,851 |
12 | 68,301 | 29,895 | 43,482 | 74,457 |
13 | 33,422 | 83,191 | 82,258 | 8,390 |
14 | 16,095 | 97,462 | 33,440 | 92,293 |
15 | 61,949 | 60,197 | 22,518 | 35,341 |
16 | 85,712 | 65,892 | 33,597 | 14,462 |
17 | 32,989 | 74,821 | 51,122 | 46,099 |
18 | 4,794 | 99,024 | 34,274 | 80,869 |
19 | 44,300 | 32,756 | 46,198 | 91,350 |
20 | 9,107 | 44,945 | 80,408 | 75,077 |
------- | ------------ | ------------ | ------------ | ------------ |
21 | 95,737 | 48,826 | 26,163 | 24,291 |
22 | 43,618 | 85,287 | 24,189 | 44,691 |
23 | 733 | 85,282 | 40,915 | 30,989 |
24 | 7,851 | 41,775 | 82,830 | 5,245 |
25 | 28,295 | 32,140 | 6,793 | 4,608 |
26 | 50,796 | 2,870 | 70,534 | 58,739 |
27 | 83,769 | 97,267 | 43,437 | 29,329 |
28 | 64,752 | 11,486 | 63,822 | 26,463 |
29 | 92,468 | 32,766 | 63,036 | 47,982 |
30 | 29,386 | 31,781 | 80,984 | 65,540 |
------- | ------------ | ------------ | ------------ | ------------ |
31 | 62,967 | 79,207 | 9,076 | 9,482 |
32 | 6,062 | 86,106 | 93,764 | 85,328 |
33 | 69,605 | 13,116 | 64,188 | 5,442 |
34 | 20,175 | 53,963 | 20,821 | 3,822 |
35 | 95,331 | 66,338 | 84,871 | 1,472 |
36 | 27,561 | 65,546 | 88,388 | 54,857 |
37 | 54,423 | 3,903 | 53,142 | 28,463 |
38 | 64,232 | 62,221 | 67,626 | 62,790 |
39 | 5,514 | 61,989 | 16,478 | 30,749 |
40 | 87,895 | 39,413 | 18,126 | 28,612 |
------- | ------------ | ------------ | ------------ | ------------ |
41 | 15,476 | 37,915 | 57,806 | 87,483 |
42 | 84,048 | 62,768 | 30,635 | 97,616 |
43 | 29,822 | 26,032 | 35,164 | 61,083 |
44 | 92,228 | 21,916 | 27,646 | 79,192 |
45 | 99,264 | 54,553 | 37,249 | 69,889 |
46 | 69,113 | 27,213 | 87,702 | 23,577 |
47 | 11,398 | 62,546 | 90,824 | 66,899 |
48 | 71,773 | 39,022 | 99,815 | 47,859 |
49 | 17,727 | 62,514 | 9,059 | 69,087 |
50 | 70,762 | 85,777 | 16,327 | 90,884 |
Note: Each result represents the ticket number (1 to 100,000) that won for that player in that round.
Example Verification (Round 1, Player 1):
==========================================
Input String: 1a869e974688d612eae6886a5813c2d67da069f3be2b3bf23d...
HMAC-SHA256 Hash: fbe44434428c9a311493d308e1ae50bc10bfcd4be894cdc9ce53b59270f62c9e
Result: 98,396
preferences:
54.59 ms | 426 KiB | 5 Q