# Path: twistedbot/plugins/base.py
# class PluginChatBase(PluginBase):
# 
#     def send_chat_message(self, msg):
#         self.world.chat.send_chat_message(msg)
# 
#     @abc.abstractproperty
#     def command_verb(self):
#         pass
# 
#     @property
#     def aliases(self):
#         return []
# 
#     @abc.abstractproperty
#     def help(self):
#         pass
# 
#     @abc.abstractmethod
#     def command(self, sender, command, args):
#         pass
# 
# Path: twistedbot/behavior_tree.py
# class CollectResources(BTGoal):
#     def __init__(self, itemstack=None, **kwargs):
#         super(CollectResources, self).__init__(**kwargs)
#         self.itemstack = itemstack
#         self.count = itemstack.count
#         self.collect_count = self.blackboard.inventory_item_collected_count(self.itemstack)
#         self.collect_goal_count = self.collect_count + self.count
#         self.name = 'gather %s' % self.itemstack
# 
#     def is_valid(self):
#         return True
# 
#     @classmethod
#     def parse_parameters(cls, params):
#         if len(params) < 2:
#             return None, None
#         item_count = params[0]
#         item_name = " ".join(params[1:])
#         try:
#             istack = items.item_db.item_by_name(item_name)
#         except KeyError:
#             istack = None
#         try:
#             count = int(item_count)
#         except ValueError:
#             count = None
#         if istack is not None and count is not None:
#             istack.inc_count(count - 1)
#         return istack, count
# 
#     @property
#     def goal_reached(self):
#         return self.blackboard.inventory_item_collected_count(self.itemstack) >= self.collect_goal_count
# 
#     def choices(self):
#         while True:
#             yield self.make_behavior(Collect, itemstack=self.itemstack)


from twistedbot.plugins.base import PluginChatBase
from twistedbot.behavior_tree import CollectResources



class Collect(PluginChatBase):
    @property
    def command_verb(self):
        return "collect"

    @property
    def help(self):
        return "collect amount of item "

    def command(self, sender, command, args):
        if subject:
            itemstack, count = CollectResources.parse_parameters(subject)
            if itemstack is None:
                self.send_chat_message("collect what item?")
                return
            if count is None:
                self.send_chat_message("what amount of %s to collect?" % itemstack.name)
                return
            if count < 1:
                self.send_chat_message("amount has to be bigger that zero" % itemstack.name)
                return

# Path: twistedbot/plugins/base.py
# class PluginChatBase(PluginBase):
# 
#     def send_chat_message(self, msg):
#         self.world.chat.send_chat_message(msg)
# 
#     @abc.abstractproperty
#     def command_verb(self):
#         pass
# 
#     @property
#     def aliases(self):
#         return []
# 
#     @abc.abstractproperty
#     def help(self):
#         pass
# 
#     @abc.abstractmethod
#     def command(self, sender, command, args):
#         pass
# 
# Path: twistedbot/behavior_tree.py
# class CollectResources(BTGoal):
#     def __init__(self, itemstack=None, **kwargs):
#         super(CollectResources, self).__init__(**kwargs)
#         self.itemstack = itemstack
#         self.count = itemstack.count
#         self.collect_count = self.blackboard.inventory_item_collected_count(self.itemstack)
#         self.collect_goal_count = self.collect_count + self.count
#         self.name = 'gather %s' % self.itemstack
# 
#     def is_valid(self):
#         return True
# 
#     @classmethod
#     def parse_parameters(cls, params):
#         if len(params) < 2:
#             return None, None
#         item_count = params[0]
#         item_name = " ".join(params[1:])
#         try:
#             istack = items.item_db.item_by_name(item_name)
#         except KeyError:
#             istack = None
#         try:
#             count = int(item_count)
#         except ValueError:
#             count = None
#         if istack is not None and count is not None:
#             istack.inc_count(count - 1)
#         return istack, count
# 
#     @property
#     def goal_reached(self):
#         return self.blackboard.inventory_item_collected_count(self.itemstack) >= self.collect_goal_count
# 
#     def choices(self):
#         while True:
#             yield self.make_behavior(Collect, itemstack=self.itemstack)


# Path: twistedbot/plugins/core/chat_collect.py
from twistedbot.plugins.base import PluginChatBase
from twistedbot.behavior_tree import CollectResources




class Collect(PluginChatBase):
    @property
    def command_verb(self):
        return "collect"

    @property
    def help(self):
        return "collect amount of item "

    def command(self, sender, command, args):
        if subject:
            itemstack, count = CollectResources.parse_parameters(subject)
            if itemstack is None:
                self.send_chat_message("collect what item?")
                return
            if count is None:
                self.send_chat_message("what amount of %s to collect?" % itemstack.name)
                return
            if count < 1:
                self.send_chat_message("amount has to be bigger that zero" % itemstack.name)
                return

            self.world.bot.behavior_tree.new_command(CollectResources, itemstack=itemstack)