Release Template files
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// include database and object files
|
||||
include_once '../config/init.php'; // contains $db
|
||||
include_once '../config/error.php';
|
||||
include_once '../objects/db_participates.php';
|
||||
//include_once './score_algo1.php';
|
||||
|
||||
// prepare user object
|
||||
$participation = new UserInGameSession($db);
|
||||
|
||||
// ensure sessionId and userId are passed in $_POST parameters
|
||||
if (isset($_POST['sessionId']))
|
||||
$participation->sessionId = $_POST['sessionId'];
|
||||
else trigger_error( missing_parameter_error("sessionId") );
|
||||
|
||||
if (isset($_POST['userId']))
|
||||
$participation->userId = $_POST['userId'];
|
||||
else trigger_error( missing_parameter_error("userId") );
|
||||
|
||||
// calculate user score in session
|
||||
if ($participation->updateUserScores())
|
||||
{
|
||||
$participation_arr= $participation->getResultArray(true,"Score_Updated_OK");
|
||||
print_r(json_encode($participation_arr)); // OK
|
||||
}
|
||||
else trigger_error("User_Score_Not_Updated");
|
||||
?>
|
||||
23
version/proserve-ReleaseTemplate/_api/score/score_algo1.php
Normal file
23
version/proserve-ReleaseTemplate/_api/score/score_algo1.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
function calculate_v1 ($precisionOnEnemies, $nbCivils)
|
||||
{
|
||||
$pointsPerEnemy = 100;
|
||||
$penaltyPerCivil = 200;
|
||||
|
||||
return $precisionOnEnemies*$pointsPerEnemy - $nbCivils*$penaltyPerCivil;
|
||||
}
|
||||
|
||||
function calculate_firerange_v1 ($precision)
|
||||
{
|
||||
$pointsPerShot = 10;
|
||||
|
||||
return $precision*$pointsPerShot;
|
||||
}
|
||||
|
||||
function is_success_v1 ($score)
|
||||
{
|
||||
$targetScore = 70;
|
||||
|
||||
return $score >= $targetScore;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user