gj

package module
v0.0.0-...-01948d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2018 License: Zlib Imports: 6 Imported by: 1

README

GoGameJolt

GameJolt for the Go Language (WIP)

NOTICE!

This code is not yet complete, and at the current time not tested. Feel free to use it if you please, but keep in mind that bugs and other undesirable behavior can still exist!

Testing / Example

A test program which can also be used as "example code" can be found in this repository.

Documentation

Overview

Provides the Game Jolt API support as object gj

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultError

func DefaultError()

Set the errorhanding back to default

func FetchScore

func FetchScore(gameid, limit, table_id, privatekey string) map[string]string

Fetches scores in general Note: The first score will just come with the fieldnames alone, and all next ones will have a number suffixed to it 1, 2, 3, etc...

func RegError

func RegError(verf *Erf)

By default the GJ API will just print the error onto the output with a simple fmt.Print kind of command. However if you have a full graphic game or GUI based application, you may not want to go down that road. Here you can register an alternate function to throw the error to the user. Please note, the API will NOT crash anything. It will only display the error and then resume the program like nothing happened.

func SubmitGuestScore

func SubmitGuestScore(guestname, gameid, privatekey, score, sort, table_id string) bool

Submit score as a guest

Types

type Erf

type Erf struct {
	// This field must contain the function in question
	EFUN func(reportedby, errmessage string)
}

Used to store the registered error function

func CurrentError

func CurrentError() *Erf

Returns the current error routine

type GJUser

type GJUser struct {

	// contains 'true' if succesfully logged in.
	LoggedIn bool
	// contains filtered or unexported fields
}

This type is used to log in a user, and also contains the methods to send all the data a user can send or receive from Game Jolt through this API.

func Login

func Login(gameid, privatekey, username, token string) *GJUser

Logs a user into a game and returns the user record

func (*GJUser) AwardTrophy

func (me *GJUser) AwardTrophy(id string) bool

Awards a trophy and returns "true" if succesful!

func (*GJUser) CloseSession

func (me *GJUser) CloseSession()

func (*GJUser) FetchScore

func (me *GJUser) FetchScore(limit, table_id string) map[string]string

Fetches the score for a user Only use this if you want to fetch the scores for that specific user! Note: The first score will just come with the fieldnames alone, and all next ones will have a number suffixed to it 1, 2, 3, etc...

func (*GJUser) OpenSession

func (me *GJUser) OpenSession()

Opens a game session for a particular user. Allows you to tell Game Jolt that a user is playing your game. You must ping the session to keep it active and you must close it when you're done with it. Note that you can only have one open session at a time. If you try to open a new session while one is running, the system will close out your current one before opening a new one.

func (*GJUser) Ping

func (me *GJUser) Ping()

Pings to the GJ server It is adviced to do this every 30 seconds Please note that it might be possible this is brought under a "go" sequence in future versions, and by that time this will be an empty function to prevent errors. This is however not a promise ;)

func (*GJUser) StartSession

func (me *GJUser) StartSession()

Same as OpenSession :P

func (*GJUser) SubmitScore

func (me *GJUser) SubmitScore(score, sort, table_id string) bool

Submits a score as a user. If you give up an empty string for table_id, Game Jolt will use the "primary" table. The only reason why you MUST at least put in something even if it's an empty string is because Go does not support optional parameters, and the dev crew also showed no interest to implement the feature (for reasons that are downright stupid if you ask me).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL