kill.txt 1.14 KB

def kill(id, params, players, mud):
    if len(params) == 0:
        mud.send_message(id, 'What did you want to attack?')
        return True
    room_monsters = utils.load_object_from_file('rooms/{}_monsters.json'.format(players[id]['room']))
    for mon_name, monster in room_monsters.items():
        if mon_name in params.lower():
            if len(monster['active']) > 0:
                if monster['active'][0]['target'] == players[id]['name']:
                    mud.send_message(id, 'You are already engaged in combat with that target.')
                    return True
                else:
                    room_monsters[mon_name]['active'][0]['target'] = players[id]['name']
                    mud.send_message(id, 'You attack the {}.'.format(mon_name), color=['red', 'bold'])
                    utils.save_object_to_file(room_monsters, 'rooms/{}_monsters.json'.format(players[id]['room']))
                    return True
    if params[0] in 'aeiou':
        mud.send_message(id, 'You do not see an {} here.'.format(params))
    else:
        mud.send_message(id, 'You do not see a {} here.'.format(params))

kill(id, params, players, mud)
del kill