fix(reward): Updated reward system

Signed-off-by: Stuart McCulloch Anderson's avatarStuart McCulloch Anderson <stuart@nxfifteen.me.uk>
parent c077c33a
......@@ -2728,7 +2728,7 @@ class ApiBabel
}
/**
* @return bool|string
* @return bool|array
*/
private function pullNomieTrackers()
{
......@@ -3068,14 +3068,9 @@ class ApiBabel
// Check we have a valid user
if ($this->getAppClass()->isUser($user)) {
nxr(0, " Checking $user for minecraft reward support");
$minecraftUsername = $this->getAppClass()->getUserSetting($user, "minecraft_username");
if (is_null($minecraftUsername)) {
nxr(0, " Users is not a Minecraft player");
$this->RewardsSystem = null;
} else {
$this->RewardsSystem = new RewardsMinecraft($user);
nxr(0, " Reward system ready");
}
nxr(0, " Reward system ready");
$this->RewardsSystem = new RewardsMinecraft($user);
$userCoolDownTime = $this->getAppClass()->getUserCooldown($this->activeUser);
if (strtotime($userCoolDownTime) >= date("U")) {
......@@ -3316,7 +3311,7 @@ class ApiBabel
]);
}
//if (!is_null($this->RewardsSystem)) $this->RewardsSystem->check_rewards($user);
if (!is_null($this->RewardsSystem)) $this->RewardsSystem->actionRewards();
} else {
nxr(0, "User has not yet authenticated with Fitbit");
......
......@@ -220,6 +220,7 @@ class RewardsMinecraft {
"LINE" => __LINE__
] );
nxr( 4, "Awarding $cat / $event ($score) = " . print_r( $recordReward[ 'description' ], true ) );
nxr( 0, $this->getAppClass()->getDatabase()->last() );
} else {
nxr( 4, "Already awarded $cat / $event ($score) = " . print_r( $recordReward[ 'description' ],
true ) );
......@@ -446,12 +447,9 @@ class RewardsMinecraft {
"logType[!]" => 'auto_detected'
];
$minMaxAvg = [];
$minMaxAvg[ 'min' ] = ( $this->getAppClass()->getDatabase()->min( $db_prefix . "activity_log",
"activeDuration", [ "AND" => $sql_search ] ) / 1000 ) / 60;
$minMaxAvg[ 'avg' ] = ( $this->getAppClass()->getDatabase()->avg( $db_prefix . "activity_log",
"activeDuration", [ "AND" => $sql_search ] ) / 1000 ) / 60;
$minMaxAvg[ 'max' ] = ( $this->getAppClass()->getDatabase()->max( $db_prefix . "activity_log",
"activeDuration", [ "AND" => $sql_search ] ) / 1000 ) / 60;
$minMaxAvg[ 'min' ] = ( $this->getAppClass()->getDatabase()->min( $db_prefix . "activity_log", "activeDuration", [ "AND" => $sql_search ] ) / 1000 ) / 60;
$minMaxAvg[ 'avg' ] = ( $this->getAppClass()->getDatabase()->avg( $db_prefix . "activity_log", "activeDuration", [ "AND" => $sql_search ] ) / 1000 ) / 60;
$minMaxAvg[ 'max' ] = ( $this->getAppClass()->getDatabase()->max( $db_prefix . "activity_log", "activeDuration", [ "AND" => $sql_search ] ) / 1000 ) / 60;
$minMaxAvg[ 'min2avg' ] = ( ( $minMaxAvg[ 'avg' ] - $minMaxAvg[ 'min' ] ) / 2 ) + $minMaxAvg[ 'min' ];
$minMaxAvg[ 'avg2max' ] = ( ( $minMaxAvg[ 'max' ] - $minMaxAvg[ 'avg' ] ) / 2 ) + $minMaxAvg[ 'avg' ];
......@@ -640,4 +638,24 @@ class RewardsMinecraft {
public function eventTriggerStreak( $goal, $length ) {
$this->checkForAward( "streak", $goal, $length );
}
public function actionRewards()
{
$prefix = $this->getAppClass()->getSetting("db_prefix", null,false);
$dbRewards = $this->getAppClass()->getDatabase()->select($prefix . "reward_queue",
["[>]" . $prefix . "rewards" => ["reward" => "rid"]],
[
$prefix . 'reward_queue.date',
$prefix . 'reward_queue.state',
$prefix . 'rewards.system',
$prefix . 'rewards.reward'
],
[ "AND" => [ $prefix . "reward_queue.fuid" => $this->getUserID(), $prefix . "rewards.system" => "xp" ] ]);
$this->getAppClass()->getErrorRecording()->postDatabaseQuery($this->getAppClass()->getDatabase(), [
"METHOD" => __METHOD__,
"LINE" => __LINE__
]);
nxr( 2, print_r($dbRewards, true) );
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment