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
- Object
- 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.Result | The 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
levelLevelData- the level
seedlong- the seed the run used
logInputLog- the recorded input
Returns
the outcome