Exemple #1
0
 /**
  * Parse <race>.race_stats packed sheets
  *
  * @return string
  */
 private function genRaceStats()
 {
     $raceStats = new RaceDefaultsModel();
     $raceStats->clear();
     $races = array('fyros', 'matis', 'tryker', 'zorai');
     foreach ($races as $race) {
         $sheet = $race . '.race_stats';
         echo "-- {$sheet}\n";
         $id = $this->sheetIds->getSheetId($sheet);
         /** @var $stats RaceStatsSheet */
         $stats = $this->sheets->findById($id);
         foreach ($stats->GenderInfos as $gender => $genderInfos) {
             $result = array();
             foreach ($genderInfos->Items as $sheetName) {
                 $slot = $this->findSheetSlot($sheetName);
                 $result[$slot] = $sheetName;
             }
             $raceStats->setRaceItems($stats->People, $gender, $result);
         }
     }
     return $raceStats->save();
 }
 /**
  * Parse input for character data
  *
  * @param array $args
  *
  * @return \Rrs\Character
  */
 public function create(array $args)
 {
     if (empty($this->raceStats)) {
         // automatically load from Resources directory if needed
         $this->loadResources(__DIR__ . '/Resources');
     }
     if (isset($args['vpa']) && isset($args['vpb']) && isset($args['vpc'])) {
         // decode vpx values into $args
         $args = $this->decodeVisualProps($args);
     }
     $args = array_merge(['race' => 'fy', 'gender' => 'f', 'age' => 0, 'dir' => 0, 'zoom' => 'body', 'tattoo' => 0, 'eyes' => 0, 'morph' => '3,3,3,3,3', 'gabarit' => '7,7,7,7,7'], $args);
     $char = new Character();
     $race = $this->normalizeRace($args['race']);
     $char->setRace($race);
     $age = max(0, min(2, $args['age']));
     $char->setAge($age);
     // allow character rotation on 45degree increments
     $dir = (int) $args['dir'];
     $char->setDirection(floor($dir / 45) * 45);
     $char->setAngle(0);
     $isPortrait = $args['zoom'] === 'portrait';
     $isHeadShot = $args['zoom'] === 'face' || $isPortrait;
     $char->setFaceShot($isHeadShot, !$isPortrait);
     // FIXME: allow to set background?
     //$bgColor = isset($args['bg']) ? $args['bg'] : false;
     $char->setBackground(0, 0, 0, 0);
     $gender = EGender::fromValue($args['gender']);
     if ($gender === false) {
         $gender = EGender::FEMALE;
     }
     $char->setGender($gender);
     // setup race default armor / haircut
     $defaults = $this->raceStats->getRaceItems($race, $gender);
     foreach ($defaults as $slot => $sheetid) {
         $index = ryzom_vs_index($slot, $sheetid);
         $char->setSlot($slot, $index);
     }
     $tattoo = (int) $args['tattoo'];
     $eyes = (int) $args['eyes'];
     $char->setSlot(EVisualSlot::FACE_SLOT, $tattoo, $eyes);
     $morph = explode(',', $args['morph']);
     $char->setMorph($morph);
     $gabarit = explode(',', $args['gabarit']);
     $char->setGabarit($gabarit);
     // armor, process haircut first, so that helmet can override it
     $keys = array('hair' => EVisualSlot::HEAD_SLOT, 'arms' => EVisualSlot::ARMS_SLOT, 'legs' => EVisualSlot::LEGS_SLOT, 'hands' => EVisualSlot::HANDS_SLOT, 'feet' => EVisualSlot::FEET_SLOT, 'chest' => EVisualSlot::CHEST_SLOT, 'head' => EVisualSlot::HEAD_SLOT, 'handr' => EVisualSlot::RIGHT_HAND_SLOT, 'handl' => EVisualSlot::LEFT_HAND_SLOT);
     foreach ($keys as $k => $slot) {
         if (!isset($args[$k])) {
             continue;
         }
         // <sheet>/<color>
         $pairs = explode('/', $args[$k]);
         if (!isset($pairs[1])) {
             // FIXME: 1 == beige ?
             $pairs[1] = 1;
         } else {
             $pairs[1] = (int) $pairs[1];
         }
         if ($k == 'hair') {
             $index = $this->verifyHaircutSlotIndex($race, $gender, $pairs[0]);
         } else {
             $index = $this->lookupItemSlotIndex($slot, $pairs[0]);
         }
         if ($index !== false) {
             // item lookup was success
             $char->setSlot($slot, $index, $pairs[1]);
         }
     }
     return $char;
 }