# Copyright (c) 2016-2017 Anki, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the file LICENSE.txt or at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Autogenerated python message buffer code.
Source: clad/types/inventoryTypes.clad
Full command line: ../tools/message-buffers/emitters/Python_emitter.py -C ./src/ -I ../robot/clad/src/ ../coretech/vision/clad/src/ ../coretech/common/clad/src/ ../lib/util/source/anki/clad -o ../generated/cladPython// clad/types/inventoryTypes.clad
"""

from __future__ import absolute_import
from __future__ import print_function

def _modify_path():
  import inspect, os, sys
  search_paths = [
    '../..',
    '../../../../tools/message-buffers/support/python',
  ]
  currentpath = os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())))
  for search_path in search_paths:
    search_path = os.path.normpath(os.path.abspath(os.path.realpath(os.path.join(currentpath, search_path))))
    if search_path not in sys.path:
      sys.path.insert(0, search_path)
_modify_path()

import msgbuffers

Anki = msgbuffers.Namespace()
Anki.Cozmo = msgbuffers.Namespace()

class InventoryType(object):
  "Automatically-generated uint_32 enumeration."
  Invalid = 0
  Sparks  = 1

Anki.Cozmo.InventoryType = InventoryType
del InventoryType


class InventoryList(object):
  "Generated message-passing structure."

  __slots__ = (
    '_inventoryItemAmount', # int_32[64]
  )

  @property
  def inventoryItemAmount(self):
    "int_32[64] inventoryItemAmount struct property."
    return self._inventoryItemAmount

  @inventoryItemAmount.setter
  def inventoryItemAmount(self, value):
    self._inventoryItemAmount = msgbuffers.validate_farray(
      'InventoryList.inventoryItemAmount', value, 64,
      lambda name, value_inner: msgbuffers.validate_integer(
        name, value_inner, -2147483648, 2147483647))

  def __init__(self, inventoryItemAmount=(0,) * 64):
    self.inventoryItemAmount = inventoryItemAmount

  @classmethod
  def unpack(cls, buffer):
    "Reads a new InventoryList from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('InventoryList.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new InventoryList from the given BinaryReader."
    _inventoryItemAmount = reader.read_farray('i', 64)
    return cls(_inventoryItemAmount)

  def pack(self):
    "Writes the current InventoryList, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current InventoryList to the given BinaryWriter."
    writer.write_farray(self._inventoryItemAmount, 'i', 64)

  def __eq__(self, other):
    if type(self) is type(other):
      return self._inventoryItemAmount == other._inventoryItemAmount
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return (msgbuffers.size_farray(self._inventoryItemAmount, 'i', 64))

  def __str__(self):
    return '{type}(inventoryItemAmount={inventoryItemAmount})'.format(
      type=type(self).__name__,
      inventoryItemAmount=msgbuffers.shorten_sequence(self._inventoryItemAmount))

  def __repr__(self):
    return '{type}(inventoryItemAmount={inventoryItemAmount})'.format(
      type=type(self).__name__,
      inventoryItemAmount=repr(self._inventoryItemAmount))

Anki.Cozmo.InventoryList = InventoryList
del InventoryList


class SparkableThings(object):
  "Automatically-generated int_32 enumeration."
  NoCost           = 0
  DoATrick         = 1
  PlayAGame        = 2
  CodeLab          = 3
  CozmoSays        = 4
  CubePounce       = 5
  ExplorerMode     = 6
  QuickTap         = 7
  MeetCozmo        = 8
  MemoryMatch      = 9
  FistBump         = 10
  PeekABoo         = 11
  BuildPyramid     = 12
  PickUpCube       = 13
  StackCubes       = 14
  PounceOnFingers  = 15
  KnockOverStack   = 16
  PopAWheelie      = 17
  WorkoutWithCubes = 18
  RollCube         = 19
  TrackLaser       = 20

Anki.Cozmo.SparkableThings = SparkableThings
del SparkableThings


def GetSparkCosts(sparkableThings, defaultValue):
  return {
    SparkableThings.NoCost: 0,
    SparkableThings.DoATrick: 3,
    SparkableThings.PlayAGame: 5,
    SparkableThings.CodeLab: 0,
    SparkableThings.CozmoSays: 0,
    SparkableThings.CubePounce: 10,
    SparkableThings.ExplorerMode: 0,
    SparkableThings.QuickTap: 10,
    SparkableThings.MeetCozmo: 0,
    SparkableThings.MemoryMatch: 10,
    SparkableThings.FistBump: 6,
    SparkableThings.PeekABoo: 8,
    SparkableThings.BuildPyramid: 8,
    SparkableThings.PickUpCube: 4,
    SparkableThings.StackCubes: 5,
    SparkableThings.PounceOnFingers: 5,
    SparkableThings.KnockOverStack: 6,
    SparkableThings.PopAWheelie: 6,
    SparkableThings.WorkoutWithCubes: 8,
    SparkableThings.RollCube: 4,
    SparkableThings.TrackLaser: 8,
    }.get(sparkableThings, defaultValue)
Anki.Cozmo.GetSparkCosts = GetSparkCosts
del GetSparkCosts


