-
Notifications
You must be signed in to change notification settings - Fork 2
/
GJScores.hx
43 lines (31 loc) · 1.32 KB
/
GJScores.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright (c) 2019 Charles Griffiths
*/
package gjCloud;
class GJScores
{
static var fetchDir:String = "/scores/";
static var tablesDir:String = "/scores/tables/";
static var addDir:String = "/scores/add/";
static var getrankDir:String = "/scores/get-rank/";
static public function fetch( ?tableID:Int=null, ?limit:Int=null, ?betterThan:Int=null, ?worseThan:Int=null ):GJTransaction
{
return new GJTransaction( fetchDir ).addGameID().addUserName().addUserToken()
.addTableID( tableID ).addLimit( limit, 10, 100 )
.addArg( "better_than", Std.string( betterThan )).addArg( "worse_than", Std.string( worseThan ));
}
static public function tables():GJTransaction
{
return new GJTransaction( tablesDir ).addGameID();
}
static public function add( score:Int, scoreString:String, ?tableID:Int=null, ?extra:String=null ):GJTransaction
{
return new GJTransaction( addDir ).addGameID().addUserName().addUserToken()
.addArg( "sort", Std.string( score )).addArg( "score", scoreString ).addTableID( tableID ).addArg( "extra_data", extra );
}
static public function getRank( score:Int, ?tableID:Int=null ):GJTransaction
{
return new GJTransaction( getrankDir ).addGameID()
.addArg( "sort", Std.string( score )).addTableID( tableID );
}
}