fixe arrays

This commit is contained in:
DieMyst 2019-03-15 19:01:55 +03:00
parent 73ef5f8754
commit deeecf2290
3 changed files with 5 additions and 8 deletions

View File

@ -12,14 +12,10 @@ const DICE_LINE_COUNT: u8 = 6;
export class GameManager {
registeredPlayers: u64 = 0;
playerIds: u64[] = [];
playerIds: u64[] = new Array(PLAYERS_MAX_COUNT);
playerBalance: Map<u64, u64> = new Map<u64, u64>();
encoder: JSONEncoder = new JSONEncoder();
constructor() {
NativeMath.seedRandom(SEED);
}
join(): string {
// delete the oldest player, if maximum players reach
if (this.playerIds.length >= PLAYERS_MAX_COUNT) {
@ -28,6 +24,7 @@ export class GameManager {
}
this.playerIds.push(this.registeredPlayers);
this.playerBalance.set(this.registeredPlayers, INIT_ACCOUNT_BALANCE);
let response = new JoinResponse(this.registeredPlayers);
@ -56,7 +53,7 @@ export class GameManager {
return error.serialize();
}
let outcome = ((NativeMath.random() * 10000000) % DICE_LINE_COUNT + 1) as u8;
let outcome = ((Math.random() * 10000000) % DICE_LINE_COUNT + 1) as u8;
let newBalance: u64 = 0;

View File

@ -23,6 +23,6 @@ export function handler(requestBytes: Uint8Array): string {
return error.serialize();
}
let response = new ErrorResponse("Unereachable.");
let response = new ErrorResponse("Unreachable.");
return response.serialize();
}

View File

@ -1,4 +1,4 @@
// import "allocator/tlsf";
import "allocator/tlsf";
//import "allocator/buddy";
//import "allocator/arena";