PHP code example of hypejunction / hypegamemechanics

1. Go to this page and download the library: Download hypejunction/hypegamemechanics library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hypejunction / hypegamemechanics example snippets


$rules = array(
	'events' => array(
		// Adding a blog post
		'create:object:blog' => array(
			'title' => elgg_echo('mechanics:create:object:blog'),
			'description' => '',
			// Events, to which this rule applies
			'events' => array(
				'publish::object'
			),
			// Positive or negative number of points to apply
			// Rule will be skipped if this value is 0
			// The option to set the score will also appear in plugin settings
			'score' => 0,
			// Entity attribute that should be used to determine the object
			'object_guid_attr' => 'guid',
			// Entity attribute that should be used to determine the user
			// who should receive points
			'subject_guid_attr' => 'owner_guid',
			// Attributes to validate
			// name => value pairs, where name is an attribute or metadata,
			// and value is a value or an array of values
			'attributes' => array(
				'type' => 'object',
				'subtype' => 'blog',
			),
			// A list of callback functions to trigger to validate the
			// applicability of this event
			// Callback functions will receive Rule object as parameter
			'callbacks' => array(
			),
			// override global settings for this rule
			'settings' => array(
				'daily_max' => 0,
				'daily_action_max' => 0,
				'alltime_action_max' => 0,
				'daily_recur_max' => 0,
				'alltime_recur_max' => 0,
				'object_recur_max' => 1,
				'daily_object_max' => 0,
				'alltime_object_max' => 0,
				'action_object_max' => 0,
				'allow_negative_total' => true,
			),
		)
	)
);

$rules['events']['profileupdate:user:location'] = array(
	'title' => elgg_echo('mechanics:profileupdate:user:location'),
	'events' => array(
		'profileupdate::user'
	),
	'attributes' => array(
		'location' => Rule::NOT_EMPTY
	),
	'settings' => array(
		'object_recur_max' => 1
	)
);