2017 © Pedro Peláez
 

project super-score

Mobile game leaderboards, currency log, and user data storage in PHP.

image

gnat/super-score

Mobile game leaderboards, currency log, and user data storage in PHP.

  • Wednesday, September 14, 2016
  • by geenat
  • Repository
  • 2 Watchers
  • 6 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Super Score, (*1)

Build Status, (*2)

Game leaderboards, in-game currency logging, and player data storage., (*3)

Written by Nathaniel Sabanski., (*4)

Features

  • Unlimited score leaderboards with offset querying.
  • In-game currency transaction logging with secure hash system.
  • Storage of miscellaneous User data.
  • Tiny codebase which can be easily added to and security audited.
  • Test suite.

Requirements

  • PHP 7+ or 5.3+.
  • Apache 2+ (mod_rewrite enabled) or nginx.

Optional

  • Redis and APCu may be installed for a high performance tiered cache.
  • PHPUnit may be installed to run the tests.

Installation Notes

  1. Development and production configurations can be set in src/config/Config.php, (*5)

  2. Set up your database tables using install.sql. You can use mysql -uUser -pPassword -e "create database superscore; use superscore; source install.sql;" or by importing the SQL file manually using any database management software., (*6)

  3. If using nginx, enable routing by using a server rule to route to index.php. This is achieved in Apache using mod_rewrite and the .htaccess file., (*7)

  4. Remember to switch your Config() from 'development' to 'production' in index.php before going live!, (*8)

REST API Usage

Any error will contain the following JSON response., (*9)

{ "Error" : "Reason for failure." }, (*10)

Current Time, (*11)

Retrieve the current unix timestamp on this server., (*12)

Endpoint http://{hostname}/timestamp
Input None
Output { "Timestamp" : <int> }
File src/Controller/Timestamp.php

Leaderboard Score Recording, (*13)

Accepts and records scores posted for a User and calculates their current rank in the specified Leaderboard. Returns the User and Leaderboard passed in with the Users highest score for the given Leaderboard., (*14)

Endpoint http://{hostname}/score/save
Input { "UserId" : <int>, "LeaderboardId" : <int>, "Score" : <int> }
Output { "UserId" : <int>, "LeaderboardId" : <int>, "Score" : <int>, "Rank" : <int> }
File src/Controller/Score.php

Leaderboard Score Query, (*15)

Returns a range of entries from the specified Leaderboard in order of rank, along with the score and rank of the specified User. Higher score is better, ranks start at 1., (*16)

Endpoint http://{hostname}/score/load
Input { "UserId" : <int>, "LeaderboardId" : <int>, "Offset" : <int>, "Limit" : <int>}
Output { "UserId" : <int>, "LeaderboardId" : <int>, "Score" : <int>, "Rank" : <int>, "Entries" : [ {"UserID" : <int>, "Score" : <int>, "Rank" : <int>}, ... ] }
File src/Controller/Score.php

Game Currency Transaction Recording, (*17)

Record simple user transactions involving game currency with hash verification. Duplicate transactions will respond with an error., (*18)

The Verifier parameter is a SHA-1 hash of the following values concatenated together: SecretKey+TransactionId+UserId+CurrencyAmount, (*19)

Endpoint http://{hostname}/transaction/save
Input { "TransactionId" : <int>, "UserId" : <int>, "CurrencyAmount" : <int>, "Verifier" : <string> }
Output { "Success" : true }
File src/Controller/Transaction.php

Game Currency Transaction Query, (*20)

Returns basic details of transactions recorded for the User specified., (*21)

Endpoint http://{hostname}/transaction/load
Input { "UserId" : <int> }
Output { "UserId" : <int>, "TransactionCount" : <int>, "CurrencySum" : <int> }
File src/Controller/Transaction.php

User Data Save, (*22)

Storage for arbitrary JSON data for User. If any key inside storage already exists for the User, the value will be overridden by the passed up value; otherwise the data will be assumed to be unchanged., (*23)

Endpoint http://{hostname}/user/save
Input { "UserId" : <int>, "Data" : { <JSON> } }
Output { "Success" : true }
File src/Controller/User.php

User Data Load, (*24)

Returns an aggregation of all previous data stored for User., (*25)

Endpoint http://{hostname}/user/load
Input { "UserId" : <int> }
Output { <JSON> }
File src/Controller/User.php

Using Composer

Install Composer and use:, (*26)

composer create-project -s dev --prefer-dist gnat/super-score ., (*27)

License

This project is licensed under the MIT License. This means you can use and modify it for free in private or commercial projects., (*28)

The Versions

14/09 2016

dev-master

9999999-dev https://github.com/gnat/super-score

Mobile game leaderboards, currency log, and user data storage in PHP.

  Sources   Download

MIT

The Requires

  • php ^5.3.0 || ^7.0
  • ext-apcu *
  • ext-pdo *
  • ext-mysql *

 

The Development Requires

currency game transaction users user data score leaderboard credits high scores user storage