hypejunction/hypegamemechanics

此包已被废弃且不再维护。未建议替代包。

Elgg 的游戏化

安装: 61

依赖项: 0

建议者: 0

安全: 0

星标: 9

关注者: 5

分支: 6

类型:elgg-plugin

5.0.1 2019-10-10 16:26 UTC

This package is auto-updated.

Last update: 2020-03-10 17:17:20 UTC


README

Elgg 3.0

Elgg 的用户积分和游戏机制

特性

hypeGameMechanics 允许您的用户

  • 通过在网站上执行特定操作/活动来积极获得积分
  • 通过接收他们内容项的互动(例如评分、评论、点赞)来被动获得积分
  • 当满足一组定义的准则时,可以领取徽章

简介

此插件受一组 规则 控制 - 描述事件的(操作)条件。每个规则都有一个唯一的名称,并定义了应满足的条件,以授予或扣除积分。

规则定义

可以通过 'get_rules','gm_score' 钩子扩展/修改一组规则。

每个规则定义接受以下参数

$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,
			),
		)
	)
);

节流

全局设置在插件设置中公开,但您也可以为单个规则覆盖这些设置。

  • daily_max - 每天所有规则下用户可以积累的最大积分
  • daily_action_max - 每天给定规则下用户可以积累的最大积分
  • alltime_action_max - 给定规则下用户可以积累的最大积分
  • daily_recur_max - 每天使用给定规则收集积分的最大次数
  • alltime_recur_max - 使用给定规则收集积分的最大次数
  • object_recur_max - 使用给定规则对单个对象收集积分的最大次数。这可以帮助节流适用于多个事件(如 'create','object''publish','object')的规则。另一个例子是仅对一个对象应用一次的点赞
  • daily_object_max - 每天通过在单个对象上执行操作可以收集的最大积分
  • alltime_object_max - 通过在单个对象上执行操作可以收集的最大积分
  • action_object_max - 在单个对象上使用给定规则可以收集的最大积分。例如,您可以限制对对象评论的最大积分

徽章

徽章是在满足预定义条件后授予用户的奖励。每个徽章可以用 4 个准则进行条件限制

  • 用户应拥有的最低积分数
  • 最多 10 个规则定义,每个规则有重复次数
  • 用户应花费的积分来揭露徽章
  • 在领取徽章之前所需的其它徽章

有 3 种类型的徽章

  • status - 状态徽章将定义当前用户在网站上的状态
  • experience - 经验徽章将在用户个人资料上显示,以象征成就/贡献
  • surprise - 惊喜徽章不会在徽章画廊中可见

备注

  • 管理员免于遵守积分规则

示例

要了解规则定义,请查阅 setup_scoring_rules() 中的预设规则

以下是一些额外的示例

  1. 当用户更新其带有位置的资料时,授予积分
$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
	)
);

屏幕截图

alt text alt text alt text alt text alt text alt text alt text alt text