set up VReplayChecks for Dedimania records in Laps mode (#187)
This commit is contained in:
parent
0ab36b6fd3
commit
56b361fff9
@ -66,6 +66,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
private $recordWidget = null;
|
private $recordWidget = null;
|
||||||
|
|
||||||
private $checkpoints = array();
|
private $checkpoints = array();
|
||||||
|
private $allCheckpoints = array();
|
||||||
|
|
||||||
/** @var \MCTeam\Dedimania\DedimaniaWebHandler $webHandler */
|
/** @var \MCTeam\Dedimania\DedimaniaWebHandler $webHandler */
|
||||||
private $webHandler = null;
|
private $webHandler = null;
|
||||||
@ -249,6 +250,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
*/
|
*/
|
||||||
public function handleBeginMap() {
|
public function handleBeginMap() {
|
||||||
$this->checkpoints = null;
|
$this->checkpoints = null;
|
||||||
|
$this->allCheckpoints = null;
|
||||||
$this->webHandler->getDedimaniaData()->unsetRecords();
|
$this->webHandler->getDedimaniaData()->unsetRecords();
|
||||||
$this->webHandler->maniaLinkUpdateNeeded();
|
$this->webHandler->maniaLinkUpdateNeeded();
|
||||||
$this->webHandler->fetchDedimaniaRecords(true);
|
$this->webHandler->fetchDedimaniaRecords(true);
|
||||||
@ -278,7 +280,12 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
if (!isset($this->checkpoints[$login])) {
|
if (!isset($this->checkpoints[$login])) {
|
||||||
$this->checkpoints[$login] = array();
|
$this->checkpoints[$login] = array();
|
||||||
}
|
}
|
||||||
|
if (!isset($this->allCheckpoints[$login])) {
|
||||||
|
$this->allCheckpoints[$login] = array();
|
||||||
|
}
|
||||||
|
|
||||||
$this->checkpoints[$login][$structure->getCheckPointInLap()] = $structure->getLapTime();
|
$this->checkpoints[$login][$structure->getCheckPointInLap()] = $structure->getLapTime();
|
||||||
|
$this->allCheckpoints[$login][$structure->getCheckPointInRace()] = $structure->getRaceTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -304,15 +311,18 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
|
|
||||||
$player = $structure->getPlayer();
|
$player = $structure->getPlayer();
|
||||||
|
|
||||||
|
$this->checkpoints[$player->login][$structure->getCheckPointInLap()] = $structure->getLapTime();
|
||||||
|
$this->allCheckpoints[$player->login][$structure->getCheckPointInRace()] = $structure->getRaceTime();
|
||||||
|
|
||||||
$oldRecord = $this->getDedimaniaRecord($player->login);
|
$oldRecord = $this->getDedimaniaRecord($player->login);
|
||||||
if ($oldRecord->nullRecord || $oldRecord && $oldRecord->best > $structure->getLapTime()) {
|
if ($oldRecord->nullRecord || $oldRecord && $oldRecord->best > $structure->getLapTime()) {
|
||||||
// Save time
|
// Save time
|
||||||
$newRecord = new RecordData(null);
|
$newRecord = new RecordData(null);
|
||||||
|
|
||||||
$checkPoints = $this->getCheckpoints($player->login);
|
$checkPoints = $this->getCheckpoints($player->login);
|
||||||
$checkPoints = $checkPoints . "," . $structure->getLapTime();
|
$allCPs = $this->getAllCheckpoints($player->login);
|
||||||
|
|
||||||
$newRecord->constructNewRecord($player->login, $player->nickname, $structure->getLapTime(), $checkPoints, true);
|
$newRecord->constructNewRecord($player->login, $player->nickname, $structure->getLapTime(), $checkPoints, true, $allCPs);
|
||||||
|
|
||||||
if ($this->insertDedimaniaRecord($newRecord, $oldRecord)) {
|
if ($this->insertDedimaniaRecord($newRecord, $oldRecord)) {
|
||||||
// Get newly saved record
|
// Get newly saved record
|
||||||
@ -400,6 +410,27 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get total checkpoint string for dedimania record
|
||||||
|
*
|
||||||
|
* @param string $login
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getAllCheckpoints($login) {
|
||||||
|
if (!$login || !isset($this->allCheckpoints[$login])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$string = '';
|
||||||
|
$count = count($this->allCheckpoints[$login]);
|
||||||
|
foreach ($this->allCheckpoints[$login] as $index => $check) {
|
||||||
|
$string .= strval($check);
|
||||||
|
if ($index < $count - 1) {
|
||||||
|
$string .= ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts the given new Dedimania record at the proper position
|
* Inserts the given new Dedimania record at the proper position
|
||||||
*
|
*
|
||||||
|
@ -183,8 +183,7 @@ class DedimaniaWebHandler implements TimerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($replays['VReplayChecks'])) {
|
if (!isset($replays['VReplayChecks'])) {
|
||||||
$replays['VReplayChecks'] = '';
|
$replays['VReplayChecks'] = $record->allCheckpoints;
|
||||||
// TODO: VReplayChecks
|
|
||||||
}
|
}
|
||||||
if (!isset($replays['Top1GReplay'])) {
|
if (!isset($replays['Top1GReplay'])) {
|
||||||
$replays['Top1GReplay'] = $record->top1GReplay;
|
$replays['Top1GReplay'] = $record->top1GReplay;
|
||||||
@ -192,6 +191,7 @@ class DedimaniaWebHandler implements TimerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xmlrpc_set_type($replays['VReplay'], 'base64');
|
xmlrpc_set_type($replays['VReplay'], 'base64');
|
||||||
|
xmlrpc_set_type($replays['VReplayChecks'], 'base64');
|
||||||
xmlrpc_set_type($replays['Top1GReplay'], 'base64');
|
xmlrpc_set_type($replays['Top1GReplay'], 'base64');
|
||||||
|
|
||||||
$data = array($this->dedimaniaData->sessionId, $this->getMapInfo(), $gameMode, $times, $replays);
|
$data = array($this->dedimaniaData->sessionId, $this->getMapInfo(), $gameMode, $times, $replays);
|
||||||
|
@ -25,6 +25,7 @@ class RecordData {
|
|||||||
public $newRecord = false;
|
public $newRecord = false;
|
||||||
public $vReplay = '';
|
public $vReplay = '';
|
||||||
public $top1GReplay = '';
|
public $top1GReplay = '';
|
||||||
|
public $allCheckpoints = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a Record by a given Record Array
|
* Construct a Record by a given Record Array
|
||||||
@ -54,12 +55,13 @@ class RecordData {
|
|||||||
* @param int $checkpoints
|
* @param int $checkpoints
|
||||||
* @param bool $newRecord
|
* @param bool $newRecord
|
||||||
*/
|
*/
|
||||||
public function constructNewRecord($login, $nickname, $best, $checkpoints, $newRecord = false) {
|
public function constructNewRecord($login, $nickname, $best, $checkpoints, $newRecord = false, $allCPs = '') {
|
||||||
$this->nullRecord = false;
|
$this->nullRecord = false;
|
||||||
$this->login = $login;
|
$this->login = $login;
|
||||||
$this->nickname = $nickname;
|
$this->nickname = $nickname;
|
||||||
$this->best = $best;
|
$this->best = $best;
|
||||||
$this->checkpoints = $checkpoints;
|
$this->checkpoints = $checkpoints;
|
||||||
$this->newRecord = $newRecord;
|
$this->newRecord = $newRecord;
|
||||||
|
$this->allCheckpoints = $allCPs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user