from modules.basemodule import BaseModule

import random
import re


def nothingToMine(mud, _):
    dirs = list(mud.gmcp['room']['info']['exits'].keys())
    return random.choice(dirs) + '\n' + 'mastermine'

def getWater(mud, _):
    mud.send(mud.world.mapper.path(-565510123) + '\nfill barrel sink\ndrink sink\ndrink sink\nmastermine')


ALIASES = {
        }
TRIGGERS = {
        'You are thirsty.': 'drink barrel',
        'You are hungry.': 'eat bread',
        'You are done building a fire.': 'chop',
        'You manage to chop up \d+ pounds? of (\w+)\.': lambda  world, matches: 'chop bundle all ' + matches[0],
        'You manage to mine \d+ pounds? of (.+)\.': lambda world, matches: \
                'mastermine bundle all {}\nmastermine'.format(matches[0]),
        'You are done chopping.': 'light fire',
        'You can\'t seem to find anything worth mining here.': nothingToMine,
        'A wood barrel is empty.': getWater,
        }


class Gaoler(BaseModule):
    def __init__(self, mud):
        super().__init__(mud)
        self.aliases.update(ALIASES)
        self.triggers.update(TRIGGERS)


def getClass():
    return Gaoler

@@ -201,16 +201,149 @@
 rmine'%0A%0A
+def nothingToChop(mud, _):%0A    dirs = list(mud.gmcp%5B'room'%5D%5B'info'%5D%5B'exits'%5D.keys())%0A    return random.choice(dirs) + '%5Cn' + 'chop'%0A%0A
 def getW
@@ -352,24 +352,24 @@
 er(mud, _):%0A
-
     mud.send
@@ -744,16 +744,27 @@
 tches%5B0%5D
+ + '%5Cnchop'
 ,%0A      
@@ -948,18 +948,12 @@
 ': '
-light fire
+chop
 ',%0A 
@@ -1042,42 +1042,344 @@
    '
-A wood barrel is empty.': getWater
+You can%5C't seem to find any trees worth cutting around here.': nothingToChop,%0A        'You can%5C't find anything to chop here.': 'run 3s%5Cnchop',%0A        'You don%5C't see .* here.': 'light fire',%0A        'You can%5C't see to do that!': 'light fire',%0A        'A wood barrel is empty.': getWater,%0A        'You need to stand up!': 'stand%5Cnchop'
 ,%0A  

update gaoler