mirror of
https://github.com/fluencelabs/assemblyscript-dice
synced 2025-04-28 09:22:15 +00:00
fixe arrays
This commit is contained in:
parent
73ef5f8754
commit
deeecf2290
@ -12,14 +12,10 @@ const DICE_LINE_COUNT: u8 = 6;
|
|||||||
export class GameManager {
|
export class GameManager {
|
||||||
|
|
||||||
registeredPlayers: u64 = 0;
|
registeredPlayers: u64 = 0;
|
||||||
playerIds: u64[] = [];
|
playerIds: u64[] = new Array(PLAYERS_MAX_COUNT);
|
||||||
playerBalance: Map<u64, u64> = new Map<u64, u64>();
|
playerBalance: Map<u64, u64> = new Map<u64, u64>();
|
||||||
encoder: JSONEncoder = new JSONEncoder();
|
encoder: JSONEncoder = new JSONEncoder();
|
||||||
|
|
||||||
constructor() {
|
|
||||||
NativeMath.seedRandom(SEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
join(): string {
|
join(): string {
|
||||||
// delete the oldest player, if maximum players reach
|
// delete the oldest player, if maximum players reach
|
||||||
if (this.playerIds.length >= PLAYERS_MAX_COUNT) {
|
if (this.playerIds.length >= PLAYERS_MAX_COUNT) {
|
||||||
@ -28,6 +24,7 @@ export class GameManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.playerIds.push(this.registeredPlayers);
|
this.playerIds.push(this.registeredPlayers);
|
||||||
|
|
||||||
this.playerBalance.set(this.registeredPlayers, INIT_ACCOUNT_BALANCE);
|
this.playerBalance.set(this.registeredPlayers, INIT_ACCOUNT_BALANCE);
|
||||||
|
|
||||||
let response = new JoinResponse(this.registeredPlayers);
|
let response = new JoinResponse(this.registeredPlayers);
|
||||||
@ -56,7 +53,7 @@ export class GameManager {
|
|||||||
return error.serialize();
|
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;
|
let newBalance: u64 = 0;
|
||||||
|
|
||||||
|
@ -23,6 +23,6 @@ export function handler(requestBytes: Uint8Array): string {
|
|||||||
return error.serialize();
|
return error.serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = new ErrorResponse("Unereachable.");
|
let response = new ErrorResponse("Unreachable.");
|
||||||
return response.serialize();
|
return response.serialize();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// import "allocator/tlsf";
|
import "allocator/tlsf";
|
||||||
//import "allocator/buddy";
|
//import "allocator/buddy";
|
||||||
//import "allocator/arena";
|
//import "allocator/arena";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user