public function processRecord($login, $score, $checkpoints)
    {
        if ($this->enabled->get() == false) {
            return false;
        }

        if ($this->isDisabled()) {
            return false;
        }

        $tempRecords = $this->recordsByLogin;
        $tempPositions = $this->ranksByLogin;

        if (isset($this->recordsByLogin[$login])) {
            $record = $this->recordsByLogin[$login];
        } else {
            $record = new DedimaniaRecord($login);
            $pla = $this->playerStorage->getPlayerInfo($login);
            $record->nickName = $pla->getNickName();
        }

        $tempRecords[$login] = clone $record;
        $oldRecord = clone $record;

        // if better time
        if ($score < $oldRecord->best || $oldRecord->best == -1) {
            $record->best = $score;
            $record->checks = implode(",", $checkpoints);
            $tempRecords[$login] = $record;

            // sort and update new rank
            uasort($tempRecords, [$this, "compare"]);

            if (!isset($this->players[$login])) {
                echo "player $login not connected\n";

                return false;
            }

            $player = $this->players[$login];

            // recalculate ranks for records
            $rank = 1;
            $newRecord = false;
            foreach ($tempRecords as $key => $tempRecord) {
                $tempRecords[$key]->rank = $rank;
                $tempPositions[$key] = $rank;

                if ($tempRecord->login == $login && ($rank <= $this->serverMaxRank || $rank <= $player->maxRank) && $rank < 100) {
                    $newRecord = $tempRecords[$login];
                }

                $rank++;
            }


            $tempRecords = array_slice($tempRecords, 0, 100, true);
            $tempPositions = array_slice($tempPositions, 0, 100, true);

            if ($newRecord) {
                $this->recordsByLogin = $tempRecords;
                $outRecords = usort($tempRecords, [$this, 'compare']);

                $this->ranksByLogin = $tempPositions;
                $params = [
                    $newRecord,
                    $oldRecord,
                    $outRecords,
                    $newRecord->rank,
                    $oldRecord->rank,
                ];

                $this->dispatcher->dispatch("expansion.dedimania.records.update", [$params]);

                return $newRecord;
            }
        }

        return false;
    }
public function processRecord($login, $score, $checkpoints)
    {
        if ($this->enabled->get() == false) {
            return false;
        }

        if ($this->isDisabled()) {
            return false;
        }

        $tempRecords = $this->recordsByLogin;
        $tempPositions = $this->ranksByLogin;

        if (isset($this->recordsByLogin[$login])) {
            $record = $this->recordsByLogin[$login];
        } else {
            $record = new DedimaniaRecord($login);
            $pla = $this->playerStorage->getPlayerInfo($login);
            $record->nickName = $pla->getNickName();
        }

        $tempRecords[$login] = clone $record;
        $oldRecord = clone $record;

        // if better time
        if ($score < $oldRecord->best || $oldRecord->best == -1) {
            $record->best = $score;
            $record->checks = implode(",", $checkpoints);
            $tempRecords[$login] = $record;

            // sort and update new rank
            uasort($tempRecords, [$this, "compare"]);

            if (!isset($this->players[$login])) {
                echo "player $login not connected\n";

                return false;
            }

            $player = $this->players[$login];

            // recalculate ranks for records
            $rank = 1;
            $newRecord = false;
            foreach ($tempRecords as $key => $tempRecord) {
                $tempRecords[$key]->rank = $rank;
                $tempPositions[$key] = $rank;

                if ($tempRecord->login == $login && ($rank <= $this->serverMaxRank || $rank <= $player->maxRank) && $rank < 100) {
                    $newRecord = $tempRecords[$login];
                }

                $rank++;
            }


            $tempRecords = array_slice($tempRecords, 0, 100, true);
            $tempPositions = array_slice($tempPositions, 0, 100, true);

            if ($newRecord) {
                $this->recordsByLogin = $tempRecords;
                $outRecords = usort($tempRecords, [$this, 'compare']);

                $this->ranksByLogin = $tempPositions;
                $params = [
                    $newRecord,
                    $oldRecord,
                    $outRecords,
                    $newRecord->rank,
                    $oldRecord->rank,
                ];

                $this->dispatcher->dispatch("expansion.dedimania.records.update", [$params]);

                return $newRecord;
            }
        }

        return false;
    }
public function processRecord ( $ login , $ score , $ checkpoints ) { if ( $ this -> enabled -> get ( ) == false ) { return false ; } if ( $ this -> isDisabled ( ) ) { return false ; } $ tempRecords = $ this -> recordsByLogin ; $ tempPositions = $ this -> ranksByLogin ; if ( isset ( $ this -> recordsByLogin [ $ login ] ) ) { $ record = $ this -> recordsByLogin [ $ login ] ; } else { $ record = new DedimaniaRecord ( $ login ) ; $ pla = $ this -> playerStorage -> getPlayerInfo ( $ login ) ; $ record -> nickName = $ pla -> getNickName ( ) ; } $ tempRecords [ $ login ] = clone $ record ; $ oldRecord = clone $ record ; // if better time if ( $ score < $ oldRecord -> best || $ oldRecord -> best == - 1 ) { $ record -> best = $ score ; $ record -> checks = implode ( "," , $ checkpoints ) ; $ tempRecords [ $ login ] = $ record ; // sort and update new rank uasort ( $ tempRecords , [ $ this , "compare" ] ) ; if ( ! isset ( $ this -> players [ $ login ] ) ) { echo "player $login not connected\n" ; return false ; } $ player = $ this -> players [ $ login ] ; // recalculate ranks for records $ rank = 1 ; $ newRecord = false ; foreach ( $ tempRecords as $ key => $ tempRecord ) { $ tempRecords [ $ key ] -> rank = $ rank ; $ tempPositions [ $ key ] = $ rank ; if ( $ tempRecord -> login == $ login && ( $ rank <= $ this -> serverMaxRank || $ rank <= $ player -> maxRank ) && $ rank < 100 ) { $ newRecord = $ tempRecords [ $ login ] ; } $ rank ++ ; } $ tempRecords = array_slice ( $ tempRecords , 0 , 100 , true ) ; $ tempPositions = array_slice ( $ tempPositions , 0 , 100 , true ) ; if ( $ newRecord ) { $ this -> recordsByLogin = $ tempRecords ; $ outRecords = usort ( $ tempRecords , [ $ this , 'compare' ] ) ; $ this -> ranksByLogin = $ tempPositions ; $ params = [ $ newRecord , $ oldRecord , $ outRecords , $ newRecord -> rank , $ oldRecord -> rank , ] ; $ this -> dispatcher -> dispatch ( "expansion.dedimania.records.update" , [ $ params ] ) ; return $ newRecord ; } } return false ; }
Check and Add a new record, if needed

@param string $login
@param int    $score
@param int[]  $checkpoints

@return DedimaniaRecord|false
Check and Add a new record if needed