newGame static method
Initialize a new game from the given seed
Implementation
static GameRef newGame(List<int> seed) {
ffi.Pointer<ffi.Uint8> seedData = ffi.nullptr;
if (seed.isNotEmpty) {
seedData = malloc.allocate(ffi.sizeOf<ffi.Uint8>() * seed.length + 1);
for (final (i, n) in seed.indexed) {
seedData[i] = n;
}
seedData[seed.length] = 0; // Null termination
}
GameRef g = malloc.allocate(ffi.sizeOf<GameRef>());
g.value = _core.new_game(seedData);
malloc.free(seedData);
return g;
}