dev-master
9999999-dev https://bitbucket.org/cay89/achieveAchive is an achievement implementation and manager library for PHP.
LGPL-3.0-or-later
The Development Requires
by cay89
Achive is an achievement implementation and manager library for PHP.
Achive is an achievement implementation and manager library based on Dovyski/Achieve's (https://github.com/Dovyski/Achieve) idea. To understanding the principle of operation please see the fallowing article: https://gamedevelopment.tutsplus.com/tutorials/how-to-code-unlockable-achievements-for-your-game-a-simple-approach--gamedev-6012, (*1)
composer require cay89/achieve
Because of flexibility and support application specific behaviours, I used interfaces and traits to implements business logic of the library. So just implement my interfaces and use my traits in your own class and override them if you need it., (*2)
use cay89\Achieve\PropertyInterface; use cay89\Achieve\PropertyTrait; class Property implements PropertyInterface { use PropertyTrait; // Database, application-specific operations etc. }
use cay89\Achieve\AchievementInterface; use cay89\Achieve\AchievementTrait; class Achievement implements AchievementInterface { use AchievementTrait; // Database, application-specific operations etc. }
$property = new Property('Greater then 10', function($params) { return ($params['value'] > 10); }, ['value' => 25], ['level1']);
$achievement1 = new Achievement('Achievement 1', [$property1, $property2]);
Instantiate the Achieve class with Achievement objects and call check() method to verify the requirements of the achievements. It returns the unlocked ones., (*3)
$achieve = new Achieve([$achievement1, $achievement2]); $achieve->check();
Please see the following path for more examples: example/example.php, (*4)
Achive is an achievement implementation and manager library for PHP.
LGPL-3.0-or-later