var ms = new MemoryStream();
var bytes = VarInt.GetBytes((ulong)value);
ms.Write(bytes, 0, bytes.Length);
function countCards($num,$cards){
$count = 0;
foreach($cards as $card){
if($card[1]==$num){
$count++;
}
}
return $count;
}
function countAllCards($cards){
return count($cards);
}
$deck = [
'cards' => [[1, 3], [2, 3], [3, 3], [4, 3]],
'heroes' => 7,
'format' => 1,
];
$code = '';
$code .= pack('i', 0);
$code .= pack('i', 1);
$code .= pack('i', $deck['format']);
$code .= pack('i', 1);
$code .= pack('i', $deck['heroes']);
$all = countAllCards($deck['cards']);
$one = countCards(1,$deck['cards']);
$code .= pack('i', $one);
foreach($deck['cards'] as $cards){
if($cards[1]==1){
$code .= pack('i', $cards[0]);
}
}
$double = countCards(2,$deck['cards']);
$code .= pack('i', $double);
foreach($deck['cards'] as $cards){
if($cards[1]==2){
$code .= pack('i', $cards[0]);
}
}
$code .= pack('i', ($all-$one-$double));
foreach($deck['cards'] as $cards){
if($cards[1]>2){
$code .= pack('i', $cards[0]);
}
}
echo base64_encode($code);
$code = '';
$code .= pack('i', 0);
$code .= pack('i', 1);
$code .= pack('i', $somevar);
echo base64_encode($code);
Трансформировал скрипт в следующее:
В результате выдается ACCCOAAICGEGGGIG