public function __construct()
 {
     if (self::$gamification != null) {
         return;
     }
     // Creation of gamification engine
     $gamification = new PHPGamification();
     $gamification->setDAO(new DAO(GM_HOST, GM_DBNAME, GM_USERNAME, GM_PASSWORD));
     self::$gamification = $gamification;
 }
Ejemplo n.º 2
0
namespace TiagoGouvea\PHPGamification;

// Set enviroment
use Exception;
use TiagoGouvea\PHPGamification;
use TiagoGouvea\PHPGamification\Model;
use TiagoGouvea\PHPGamification\Model\Event;
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 'On');
// PHP Gamification require
require_once '../PHPGamification.class.php';
// Some other class used to callback sample
require_once 'MyOtherClass.php';
// Creation of gamification engine and DAO
$gamification = new PHPGamification();
$gamification->setDAO(new DAO('localhost', 'eventos_wp', 'rut', ''));
// Reser all data (be careful, only to test purpose)
$truncateDatabaseFull = true;
// Will truncate "levels" and "badges" tables, and ALL data (config+user data)
$truncateDatabaseUsers = false;
// Will truncate just logs, events and user related data (user data)
if ($truncateDatabaseFull) {
    /**
     * Rules setup
     */
    $gamification->truncateDatabase(true);
    /** Badges definitions */
    $gamification->addBadge('breath', 'You breath', 'Happy to you are live', 'img/badge0.png');
    $gamification->addBadge('newbee', 'Newbee', 'You logged in, congratulations!', 'img/badge1.png');
    $gamification->addBadge('addict', 'Addict', 'You have logged in 10 times', 'img/badge1.png');
    $gamification->addBadge('king_of_chat', 'King of the Chat', 'You posted 20 messages to the chat', 'img/badge2.png');