I’m been going through the Typescript guide and testing out Nakama, so far so good!
I’ve run into a problem with tournaments, however. They seem to create ok, but I can’t seem register hook to handle when it ends. I get the following error in the log:
{"level":"info","ts":"2022-09-12T15:38:31.171Z","caller":"server/core_tournament.go:59","msg":"Tournament created","id":"dailyChallenge"}
{"level":"error","ts":"2022-09-12T15:38:31.175Z","caller":"server/runtime_javascript_logger.go:94","msg":"Error creating tournament%!(EXTRA map[string]interface {}=map[value:js registerTournamentEnd function key could not be extracted: not found])"}
Here’s a snipped of my server code:
const distributeTournamentRewards: nkruntime.TournamentEndFunction = function (
ctx: nkruntime.Context,
logger: nkruntime.Logger,
nk: nkruntime.Nakama,
tournament: nkruntime.Tournament,
end: number,
reset: number
) {
// I commented everything out here...
};
const InitModule: nkruntime.InitModule = function (
ctx: nkruntime.Context,
logger: nkruntime.Logger,
nk: nkruntime.Nakama,
initializer: nkruntime.Initializer
) {
// ...
// Create tournament
{
const id = "dailyChallenge";
const authoritative = false;
const sortOrder = nkruntime.SortOrder.DESCENDING;
const operator = nkruntime.Operator.BEST;
const resetSchedule = "*/10 * * * *"; // Every 10 minutes
const duration = 1000; // Until reset
const metadata = {
weatherConditions: "rain",
};
const metadata = {};
const title = "Daily Challenge";
const description = "The top score for today's challenge";
try {
nk.tournamentCreate(
id,
authoritative,
sortOrder,
operator,
duration,
resetSchedule,
metadata,
title,
description
);
initializer.registerTournamentEnd(distributeTournamentRewards);
logger.info("Tournament created");
} catch (error) {
logger.error("Error creating tournament", error);
}
}
};
- Versions: Nakama 3.13 on Docker
- Server Framework Runtime language: TS
Any help would be appreciated. Thanks!