mirror of
https://github.com/fluencelabs/assemblyscript-dice
synced 2025-04-24 15:42:13 +00:00
fix array initialization
This commit is contained in:
parent
2b40ad2d59
commit
6aec6d050f
@ -12,7 +12,7 @@ const DICE_LINE_COUNT: u8 = 6;
|
||||
export class GameManager {
|
||||
|
||||
registeredPlayers: u64 = 0;
|
||||
playerIds: u64[] = new Array(PLAYERS_MAX_COUNT);
|
||||
playerIds: u64[] = new Array();
|
||||
playerBalance: Map<u64, u64> = new Map<u64, u64>();
|
||||
encoder: JSONEncoder = new JSONEncoder();
|
||||
|
||||
@ -33,7 +33,7 @@ export class GameManager {
|
||||
|
||||
let response = new JoinResponse(this.registeredPlayers);
|
||||
|
||||
this.registeredPlayers += 1;
|
||||
this.registeredPlayers = this.registeredPlayers + 1;
|
||||
|
||||
return response.serialize();
|
||||
}
|
||||
@ -53,7 +53,7 @@ export class GameManager {
|
||||
let balance: u64 = this.playerBalance.get(playerId);
|
||||
|
||||
if (betSize > balance) {
|
||||
let error = new ErrorResponse(`Player hasn't enough money: player's current balance is ${balance.toString()} while the bet is ${betSize.toString()}`);
|
||||
let error = new ErrorResponse("Player hasn't enough money: player's current balance is " + balance.toString() + " while the bet is " + betSize.toString());
|
||||
return error.serialize();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "allocator/tlsf";
|
||||
//import "allocator/buddy";
|
||||
//import "allocator/arena";
|
||||
// import "allocator/tlsf";
|
||||
import "allocator/buddy";
|
||||
// import "allocator/arena";
|
||||
|
||||
import {handler} from "./game_handler";
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import "allocator/arena";
|
||||
import "allocator/buddy";
|
||||
|
||||
import { invoke } from "../../assembly/index";
|
||||
|
||||
@ -26,15 +26,11 @@ export class SomeTest {
|
||||
|
||||
for (let i = 3; i >= 0; i--) {
|
||||
let b = load<u8>(resultPtr + i) as i32;
|
||||
logF64(b);
|
||||
resultLength = resultLength + b << i * 8;
|
||||
}
|
||||
|
||||
logF64(resultLength);
|
||||
logStr("result: " + String.fromUTF8(resultPtr + 4, resultLength));
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export async function setup(testFileName: string): Promise<ExportedEntries> {
|
||||
if (!WebAssembly.validate(file)) {
|
||||
throw new Error(`WebAssembly binary "${ pathName }" file not valid!`);
|
||||
}
|
||||
const imports = buildImports(`${ testFileName }.spec.as`, new WebAssembly.Memory({ initial: 2 }));
|
||||
const imports = buildImports(`${ testFileName }.spec.as`, new WebAssembly.Memory({ initial: 200, maximum: 1000 }));
|
||||
const result = await WebAssembly.instantiate(file, imports);
|
||||
return demangle<ExportedEntries>(result.instance.exports);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user