当前位置: 首页>>代码示例>>PHP>>正文


PHP Match::getTimestamp方法代码示例

本文整理汇总了PHP中Match::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Match::getTimestamp方法的具体用法?PHP Match::getTimestamp怎么用?PHP Match::getTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Match的用法示例。


在下文中一共展示了Match::getTimestamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * {@inheritdoc}
  *
  * @param \Match $match
  */
 public function update($form, $match)
 {
     if ($match->getDuration() != $form->get('duration')->getData() || $match->getTimestamp()->ne($form->get('time')->getData())) {
         // The timestamp of the match was changed, we might need to
         // recalculate its ELO
         $this->controller->recalculateNeeded = true;
     }
     $firstTeam = $form->get('first_team');
     $secondTeam = $form->get('second_team');
     $serverInfo = $this->getServerInfo($form->get('server_address'));
     $match->setTeamPlayers($this->getPlayerList($firstTeam), $this->getPlayerList($secondTeam));
     $match->setTeamPoints($firstTeam->get('score')->getData(), $secondTeam->get('score')->getData());
     $match->setDuration($form->get('duration')->getData())->setServerAddress($serverInfo[0], $serverInfo[1])->setTimestamp($form->get('time')->getData())->setMap($form->get('map')->getData()->getId());
     if (!$match->isEloCorrect()) {
         $this->controller->recalculateNeeded = true;
     }
 }
开发者ID:blast007,项目名称:bzion,代码行数:22,代码来源:MatchFormCreator.php

示例2: recalculate

 /**
  * Recalculates match history for all teams and matches
  *
  * Recalculation is done as follows:
  * 1. A match is chosen as a starting point - it's stored old team ELOs are
  *    considered correct
  * 2. Team ELOs are reset to their values at the starting point
  * 3. Each match that occurred since the first specified match has its ELO
  *    recalculated based on the current team values, and the new match data
  *    and team ELOs are stored in the database
  *
  * @param Match $match The first match
  */
 private function recalculate(Match $match)
 {
     try {
         // Commented out to prevent ridiculously large recalculations
         //set_time_limit(0);
         $query = Match::getQueryBuilder()->where('status')->notEquals('deleted')->where('type')->equals(Match::OFFICIAL)->where('time')->isAfter($match->getTimestamp(), $inclusive = true)->sortBy('time');
         /** @var Match[] $matches */
         $matches = $query->getModels($fast = true);
         // Send the total count to client-side javascript
         $this->log(count($matches) . "\n");
         // Start a transaction so tables are locked and we don't stay with
         // messed up data if something goes wrong
         Database::getInstance()->startTransaction();
         $teamsReset = [];
         // Reset match teams, in case the selected match is deleted and does
         // not show up in the list of matches to recalculate
         $match->getTeamA()->setElo($match->getTeamAEloOld());
         $match->getTeamB()->setElo($match->getTeamBEloOld());
         $teamsReset[$match->getTeamA()->getId()] = true;
         $teamsReset[$match->getTeamB()->getId()] = true;
         foreach ($matches as $i => $match) {
             // Reset teams' ELOs if they haven't been reset already
             if (!isset($teamsReset[$match->getTeamA()->getId()])) {
                 $teamsReset[$match->getTeamA()->getId()] = true;
                 $match->getTeamA()->setElo($match->getTeamAEloOld());
             }
             if (!isset($teamsReset[$match->getTeamB()->getId()])) {
                 $teamsReset[$match->getTeamB()->getId()] = true;
                 $match->getTeamB()->setElo($match->getTeamBEloOld());
             }
             $match->recalculateElo();
             // Send an update to the client-side javascript, so that a
             // progress bar can be updated
             $this->log("m");
         }
     } catch (Exception $e) {
         Database::getInstance()->rollback();
         Database::getInstance()->finishTransaction();
         throw $e;
     }
     Database::getInstance()->finishTransaction();
     $this->log("\n\nCalculation successful\n");
 }
开发者ID:allejo,项目名称:bzion,代码行数:56,代码来源:MatchController.php

示例3: hasBeenActive

 /**
  * Check whether or not a player been in a match or has logged on in the specified amount of time to be considered
  * active
  *
  * @return bool True if the player has been active
  */
 public function hasBeenActive()
 {
     $this->lazyLoad();
     $interval = Service::getParameter('bzion.miscellaneous.active_interval');
     $lastLogin = $this->last_login->copy()->modify($interval);
     $hasBeenActive = TimeDate::now() <= $lastLogin;
     if ($this->last_match->isValid()) {
         $lastMatch = $this->last_match->getTimestamp()->copy()->modify($interval);
         $hasBeenActive = $hasBeenActive || TimeDate::now() <= $lastMatch;
     }
     return $hasBeenActive;
 }
开发者ID:allejo,项目名称:bzion,代码行数:18,代码来源:Player.php


注:本文中的Match::getTimestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。