Example #1
0
 /**
  * @covers Character::setVpa
  */
 public function testSetVpa()
 {
     // properties are all set to 1
     $vpa = '2310911766417117699';
     $this->character->setVpa($vpa);
     $this->assertEquals(1, $this->character->getGender());
     $this->assertEquals([1, 1], $this->character->getSlot(EVisualSlot::CHEST_SLOT));
     $this->assertEquals([1, 1], $this->character->getSlot(EVisualSlot::LEGS_SLOT));
     $this->assertEquals([1, 1], $this->character->getSlot(EVisualSlot::ARMS_SLOT));
     $this->assertEquals([1, 1], $this->character->getSlot(EVisualSlot::HEAD_SLOT));
     $this->assertEquals([1], $this->character->getSlot(EVisualSlot::RIGHT_HAND_SLOT));
     $this->assertEquals([1], $this->character->getSlot(EVisualSlot::LEFT_HAND_SLOT));
 }
Example #2
0
 private function doFaceShot(Character $char, $img)
 {
     switch ($char->getRace()) {
         case TPeople::FYROS:
             $crop = [0 => [143, 157], 1 => [149, 180]];
             break;
         case TPeople::TRYKER:
             $crop = [0 => [143, 191], 1 => [148, 207]];
             break;
         case TPeople::MATIS:
             $crop = [0 => [144, 138], 1 => [148, 170]];
             break;
         case TPeople::ZORAI:
             $crop = [0 => [143, 109], 1 => [149, 122]];
             break;
         default:
             // should not reach here
             return $img;
     }
     $gender = $char->getGender();
     list($cx, $cy) = $crop[$gender];
     $x = $cx - 50;
     $y = $cy - 50;
     $w = 100;
     $h = 100;
     if ($char->isCropFaceShot()) {
         // WxW box
         $out = imagecreatetruecolor($this->width, $this->width);
         $dstw = $this->width;
         $dsth = $this->width;
     } else {
         // portrait
         $out = imagecreatetruecolor($this->width, $this->height);
         $dstw = $this->width;
         $dsth = $this->height;
         $y -= $h / 2;
         $h += $h;
     }
     $bg = imagecolorallocatealpha($out, 0, 0, 0, 127);
     imagefill($out, 0, 0, $bg);
     imagesavealpha($out, true);
     imagecopyresampled($out, $img, 0, 0, $x, $y, $dstw, $dsth, $w, $h);
     imagedestroy($img);
     return $out;
 }