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


PHP Participant::setPitstops方法代码示例

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


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

示例1: getParticipants

 /**
  * Get participants sorted by ending position
  *
  * @return  array
  */
 protected function getParticipants()
 {
     // Drivers already read
     if ($this->participants !== null) {
         // Return already read participants
         return $this->participants;
     }
     // Init drivers array
     $participants = array();
     // Remember all lap positions to detect corruption later
     $lap_positions = array();
     // Remeber all lap instances per lap number so we fix position
     // corruption on them
     $all_laps_by_lap_number = array();
     // Loop each driver (if any)
     /* @var $driver_xml \DOMNode */
     foreach ($this->dom->getElementsByTagName('Driver') as $driver_xml) {
         // Create new driver
         $main_driver = new Driver();
         // Get position
         $position = (int) $this->dom_value('Position', $driver_xml);
         // Set driver values
         $main_driver->setName($this->dom_value('Name', $driver_xml))->setHuman((bool) $this->dom_value('isPlayer', $driver_xml));
         // Create new vehicle
         $vehicle = new Vehicle();
         // Set vehicle values
         $vehicle->setName($this->dom_value('VehName', $driver_xml))->setType($this->dom_value('CarType', $driver_xml))->setClass($this->dom_value('CarClass', $driver_xml))->setNumber((int) $this->dom_value('CarNumber', $driver_xml));
         // Create participant
         $participant = new Participant();
         // Set participant values
         $participant->setTeam($this->dom_value('TeamName', $driver_xml))->setPosition((int) $this->dom_value('Position', $driver_xml))->setClassPosition((int) $this->dom_value('ClassPosition', $driver_xml))->setGridPosition((int) $this->dom_value('GridPos', $driver_xml))->setClassGridPosition((int) $this->dom_value('ClassGridPos', $driver_xml))->setPitstops((int) $this->dom_value('Pitstops', $driver_xml));
         // Has finish time
         if ($finish_time = (double) $this->dom_value('FinishTime', $driver_xml)) {
             // Overwrite total time, because rfactor results tend to be
             // corrupted at times
             $participant->setTotalTime($finish_time);
         }
         // Get finish status value
         $finish_status = strtolower($this->dom_value('FinishStatus', $driver_xml));
         // Has finished
         if ($finish_status === 'finished normally') {
             // Set finish status
             $participant->setFinishStatus(Participant::FINISH_NORMAL);
         } elseif ($finish_status === 'dq') {
             // Set disqualified status
             $participant->setFinishStatus(Participant::FINISH_DQ);
         } elseif ($finish_status === 'dnf') {
             // Set did not finish status
             $participant->setFinishStatus(Participant::FINISH_DNF);
             // Set finish comment (if any)
             if ($finish_status = $this->dom_value('DNFReason', $driver_xml)) {
                 $participant->setFinishComment($finish_status);
             }
         } else {
             // Set no finish status
             $participant->setFinishStatus(Participant::FINISH_NONE);
         }
         // Get the driver swaps
         $swaps_xml = $driver_xml->getElementsByTagName('Swap');
         // Init drivers array, a participant can have multiple
         $drivers = array();
         // Remember the drivers per laps
         $drivers_per_laps = array();
         // Remember drivers by name so we can re-use them
         $drivers_by_name = array();
         // Remember the number of swaps (always -1 of number of swap
         // elements in XML, because first driver starts on grid, which is
         // actually not really a swap)
         $number_of_swaps = 0;
         // Loop each swap
         $first_swap = true;
         // First swap reminder, can't use $swap_xml_key
         // to detect because it is bugged in hhvm!
         foreach ($swaps_xml as $swap_xml_key => $swap_xml) {
             // Empty driver name
             if (!($driver_name = $swap_xml->nodeValue)) {
                 // Skip this swap
                 continue;
             }
             // Driver already processed
             if (array_key_exists($driver_name, $drivers_by_name)) {
                 // Use existing found driver instance
                 $swap_driver = $drivers_by_name[$driver_name];
             } else {
                 // Create new driver
                 $swap_driver = new Driver();
                 // Set name
                 $swap_driver->setName($driver_name);
                 // Use human state the same of main driver within XML
                 $swap_driver->setHuman($main_driver->isHuman());
                 // Add swap driver to drivers array
                 $drivers[] = $swap_driver;
                 // Remember swap driver by name
                 $drivers_by_name[$driver_name] = $swap_driver;
             }
//.........这里部分代码省略.........
开发者ID:bighome,项目名称:simresults,代码行数:101,代码来源:Rfactor2.php


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