Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class Replay

  1. Object
  2. Replay

Plays a recorded run against a level and reports what happened, which is how a server verifies a score instead of trusting it.

import com.codename1.gaming.platformer.*;

// levelJson, seed, upload and claimedTicks arrive with the player's claim
String levelJson = "{\"tileSize\":16,\"tiles\":[\"....\",\"####\"]}";
long seed = 1;
String upload = new InputLog().encode();
int claimedTicks = 0;
Replay.Result r = Replay.run(LevelData.parse(levelJson), seed, InputLog.decode(upload, 60 * 60 * 15));
if (r.isComplete() && r.getTicks() == claimedTicks) {
    // the time is real
}

Nested types

class Replay.ResultThe outcome of a replay.

Methods

public static Replay.Result run(LevelData level, long seed, InputLog log)Replays a log, stopping at the tick the goal is reached.

Inherited methods

Method details

run

public static Replay.Result run(LevelData level, long seed, InputLog log)
Replays a log, stopping at the tick the goal is reached.

Parameters

level LevelData
the level
seed long
the seed the run used
log InputLog
the recorded input

Returns

the outcome