Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function serializedSize(\Protobuf\ComputeSizeContext $context)
 {
     $calculator = $context->getSizeCalculator();
     $size = 0;
     if ($this->item_id !== null) {
         $size += 1;
         $size += $calculator->computeStringSize($this->item_id);
     }
     if ($this->is_iap !== null) {
         $size += 1;
         $size += 1;
     }
     if ($this->currency_to_buy !== null) {
         $innerSize = $this->currency_to_buy->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->yields_currency !== null) {
         $innerSize = $this->yields_currency->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->yields_item !== null) {
         $innerSize = $this->yields_item->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->tags !== null) {
         foreach ($this->tags as $val) {
             $innerSize = $val->serializedSize($context);
             $size += 1;
             $size += $innerSize;
             $size += $calculator->computeVarintSize($innerSize);
         }
     }
     if ($this->unknown7 !== null) {
         $size += 1;
         $size += $calculator->computeVarintSize($this->unknown7);
     }
     if ($this->extensions !== null) {
         $size += $this->extensions->serializedSize($context);
     }
     return $size;
 }
Exemplo n.º 2
0
 /**
  * Item constructor.
  * @param ItemData $itemData
  */
 function __construct(ItemData $itemData)
 {
     $this->itemData = $itemData;
     $this->count = $itemData->getCount();
 }
 /**
  * {@inheritdoc}
  */
 public function serializedSize(\Protobuf\ComputeSizeContext $context)
 {
     $calculator = $context->getSizeCalculator();
     $size = 0;
     if ($this->pokemon_data !== null) {
         $innerSize = $this->pokemon_data->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->item !== null) {
         $innerSize = $this->item->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->pokedex_entry !== null) {
         $innerSize = $this->pokedex_entry->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->player_stats !== null) {
         $innerSize = $this->player_stats->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->player_currency !== null) {
         $innerSize = $this->player_currency->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->player_camera !== null) {
         $innerSize = $this->player_camera->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->inventory_upgrades !== null) {
         $innerSize = $this->inventory_upgrades->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->applied_items !== null) {
         $innerSize = $this->applied_items->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->egg_incubators !== null) {
         $innerSize = $this->egg_incubators->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->candy !== null) {
         $innerSize = $this->candy->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->quest !== null) {
         $innerSize = $this->quest->serializedSize($context);
         $size += 1;
         $size += $innerSize;
         $size += $calculator->computeVarintSize($innerSize);
     }
     if ($this->extensions !== null) {
         $size += $this->extensions->serializedSize($context);
     }
     return $size;
 }
Exemplo n.º 4
0
 /**
  * Function for return the selected item by pass the item id
  *
  * @param $id
  * @return Item
  * @throws \Exception
  */
 public function getItem($id)
 {
     if ($id == ItemId::ITEM_UNKNOWN) {
         throw new \Exception("You cannot get item for UNRECOGNIZED");
     }
     if (!array_key_exists($id, $this->items)) {
         $itemData = new ItemData();
         $itemData->setCount(0);
         $itemData->setItemId($id);
         return new Item($itemData);
     }
     return $this->items[$id];
 }