Пример #1
0
def pull_comms():
    global login_info
    global last_pull_time
    update_time = False
    db = mysql.connect(host=login_info[0], user=login_info[1],passwd=login_info[2],
            db='achaea',cursorclass=MySQLdb.cursors.DictCursor)
    cur=db.cursor()
    cur.execute('select `char`, `talker`, `channel`, `message` from achaea.messages_heard '
                ' where `time` > %s and `char` != %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        output = '%s heard %s say on %s : %s' % (res['char'],  res['talker'],
                res['channel'], res['message'])
        sage.echo(output)

    cur.execute('select `from_char`, `message` from achaea.messages_sent'
                ' where `time` > %s and `to_char` = %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        sage.echo(res['from_char'] + " said do " + res['message'])
        sage.send(res['message'])

    if(update_time):
        last_pull_time = time.time()

    cur.close()
    db.commit()
    db.close()

    if do_pull:
        sage.delay(5, pull_comms)
Пример #2
0
 def echo_dstab(self, target, line):
     if (len(self.venoms) == 2):
         self.text = ansi.bold_green(
             "You Doublestab %s : %s %s" %
             (target, self.venoms[0], self.venoms[1]))
     else:
         sage.echo(line)
Пример #3
0
def chatstuffThreaded(talker, channel, text):
    global convos
    global last_response
    global talkon
    key = (talker, channel)
    if (player.name in text) or (channel
                                 == 'says') or (channel.startswith('tell')):
        if (talker, channel) not in convos:
            sage.echo("Starting a new convo")
            val = {
                'time': time.time(),
                'response': '',
                'bot': cleverbot.Cleverbot()
            }
            convos[key] = val
        val = convos[key]
        response = ''
        if channel == 'says':
            response = 'say '
        elif channel.startswith('clt'):
            response = 'clan switch %s;clt ' % (re.sub('clt', '', channel))
        elif channel.startswith('tell'):
            response = channel + ' '
        else:
            sage.echo("SOMEONE SAID MY NAME OVER %s!!!" % channel)
            return
        sage.echo(re.sub('"', '', re.sub('.*, "', '', text)))
        sage.echo(talker)
        sage.echo(channel)
        response = response + ' ' + val['bot'].ask(text)

        last_response = max(time.time(), last_response)
        time_to_type = len(response) / 5.0
        last_response = last_response + time_to_type
        sage.delay(last_response - time.time(), sage.send, response)
Пример #4
0
def chatstuffThreaded(talker, channel, text):
    global convos
    global last_response
    global talkon
    key = (talker, channel)
    if (player.name in text) or (channel == 'says') or (channel.startswith('tell')):
        if (talker, channel) not in convos:
            sage.echo("Starting a new convo")
            val = {
                    'time' : time.time(),
                    'response' : '',
                    'bot' : cleverbot.Cleverbot()
                   }
            convos[key] = val
        val = convos[key]
        response = ''
        if channel == 'says':
            response = 'say '
        elif channel.startswith('clt'):
            response = 'clan switch %s;clt '%(re.sub('clt','',channel))
        elif channel.startswith('tell'):
            response = channel + ' '
        else:
            sage.echo("SOMEONE SAID MY NAME OVER %s!!!"%channel)
            return
        sage.echo(re.sub('"','',re.sub('.*, "','',text)))
        sage.echo(talker)
        sage.echo(channel)
        response = response + ' ' + val['bot'].ask(text)

        last_response = max(time.time(), last_response)
        time_to_type = len(response)/5.0
        last_response = last_response + time_to_type
        sage.delay(last_response-time.time(), sage.send, response)
Пример #5
0
def get_miner_deploy(alias):
    query = alias.line.split()
    if len(query) < 4:
        sage.echo("USAGE: miner deploy (army|miner) (number) (assualt)")
    mtype = query[2]
    count = int(query[3])
    get_miner_stats(alias)
    sage.delay(1, deploy_miners, count, mtype)
Пример #6
0
def get_miner_deploy(alias):
    query = alias.line.split()
    if len(query) < 4:
        sage.echo("USAGE: miner deploy (army|miner) (number) (assualt)")
    mtype = query[2]
    count = int(query[3])
    get_miner_stats(alias)
    sage.delay(1, deploy_miners, count, mtype)
Пример #7
0
 def find_room_like(self, name, doecho=False):
     res = []
     counter=1
     for roomid,room in self.rooms.iteritems():
         if name in room['name']:
             res.append(roomid)
             if doecho:
                 echo("%s#%s : (%s) %s"%(counter,roomid,room['area'],room['name']))
                 counter = counter+1
     return res
Пример #8
0
    def privmsg(self, user, channel, msg):
        """ This will get called when the client receives a message. """

        user = user.split('!', 1)[0]

        # Check to see if they're sending a private message
        if channel == self.nickname:
            echo('[IRC] %s->You: %s' % (user, msg))
            return

        echo('[%s] <%s> %s' % (channel, user, msg))
Пример #9
0
def xplr_lmine(alias):
    query = alias.line.split()
    if len(query) > 2:
        query= " ".join(query[2:])
    else:
        query=None
    for entry in explr.all_mines:
        output = "(%s, %s): %s %s %s %s"%(entry[3],entry[4],entry[0],
                entry[1], entry[2], entry[6])
        if query is None or query in output:
            sage.echo(output)
Пример #10
0
 def confirm_cure(self, aff, line):
     for i in xrange(len(self.cures)):
         cure = self.cures[i]
         print cure, aff, self.cure_map[cure[0]]
         if aff in self.cure_map[cure[0]]:
             sage.echo(ansi.bold_green("Cured %s"%aff))
             self.echo_affs()
             del self.cures[i]
             return True
     self.cures.append(('',line))
     return False
Пример #11
0
def xplr_lmine(alias):
    query = alias.line.split()
    if len(query) > 2:
        query = " ".join(query[2:])
    else:
        query = None
    for entry in explr.all_mines:
        output = "(%s, %s): %s %s %s %s" % (entry[3], entry[4], entry[0],
                                            entry[1], entry[2], entry[6])
        if query is None or query in output:
            sage.echo(output)
Пример #12
0
 def find_room_like(self, name, doecho=False):
     res = []
     counter = 1
     for roomid, room in self.rooms.iteritems():
         if name in room['name']:
             res.append(roomid)
             if doecho:
                 echo("%s#%s : (%s) %s" %
                      (counter, roomid, room['area'], room['name']))
                 counter = counter + 1
     return res
Пример #13
0
 def confirm_cure(self, aff, line):
     for i in xrange(len(self.cures)):
         cure = self.cures[i]
         print cure, aff, self.cure_map[cure[0]]
         if aff in self.cure_map[cure[0]]:
             sage.echo(ansi.bold_green("Cured %s" % aff))
             self.echo_affs()
             del self.cures[i]
             return True
     self.cures.append(('', line))
     return False
Пример #14
0
 def path_to_room_in_set(self, start, already_visited, area, blocked=[]):
     start = long(start)
     allpaths = []
     for room in (area - already_visited):
         p = self.path_to_room(start, room)
         if p is not None:
             allpaths.append(p)
     allpaths.sort(key=lambda p: len(p.route))
     if (len(allpaths) == 0):
         echo("No path found")
         return None
     return allpaths[0]
Пример #15
0
 def path_to_room_in_set(self, start, already_visited, area, blocked=[]):
     start = long(start)
     allpaths = []
     for room in (area-already_visited):
         p = self.path_to_room(start, room)
         if p is not None:
             allpaths.append(p)
     allpaths.sort(key=lambda p : len(p.route))
     if(len(allpaths) == 0):
         echo("No path found")
         return None
     return allpaths[0]
Пример #16
0
    def path_to_new_room(self, start, already_visited, area, blocked=[]):
        start = long(start)
        # maintain a queue of paths
        queue = deque()
        visited = set()
        cur_room = self.rooms[start]
        area = None
        if ('area' in cur_room):
            area = self.rooms[start]['area']
        else:
            print cur_room

        # scoping optimization tricks
        q_append = queue.append
        q_pop = queue.popleft
        v_add = visited.add
        matrix = self.matrix

        # push the first path into the queue
        q_append([start])

        while queue:
            # get the first path from the queue
            path = q_pop()
            # get the last node from the path
            node = path[-1]

            if (node in visited):
                continue

            # path found
            if node not in already_visited:
                return Path(path, self)

            v_add(node)

            # enumerate all adjacent nodes, construct a new path and push it into the queue
            for adjacent in self.rooms[node]['exits'].keys():
                if (((adjacent not in self.rooms) or
                     (self.rooms[adjacent]['area'] == area))
                        and (adjacent not in blocked)):
                    new_path = path[:]
                    new_path.append(adjacent)
                    q_append(new_path)
        echo("No path found")
        return None
Пример #17
0
    def path_to_new_room(self, start, already_visited, area, blocked=[]):
        start = long(start)
        # maintain a queue of paths
        queue = deque()
        visited = set()
        cur_room = self.rooms[start]
        area = None
        if('area' in cur_room):
            area = self.rooms[start]['area'];
        else:
            print cur_room

        # scoping optimization tricks
        q_append = queue.append
        q_pop = queue.popleft
        v_add = visited.add
        matrix = self.matrix

        # push the first path into the queue
        q_append([start])

        while queue:
            # get the first path from the queue
            path = q_pop()
            # get the last node from the path
            node = path[-1]

            if (node in visited):
                continue

            # path found
            if node not in already_visited:
                return Path(path, self)

            v_add(node)

            # enumerate all adjacent nodes, construct a new path and push it into the queue
            for adjacent in self.rooms[node]['exits'].keys():
                if (((adjacent not in self.rooms) or (self.rooms[adjacent]['area'] == area))
                        and (adjacent not in blocked)):
                    new_path = path[:]
                    new_path.append(adjacent)
                    q_append(new_path)
        echo("No path found")
        return None
Пример #18
0
    def check(self, line):
        if line.strip() == '' or line == '\n' or line == ' ':
            return (1, False)
        db = mysql.connect(host=self.login[0], user=self.login[1],passwd=self.login[2],
                db='achaea',cursorclass=MySQLdb.cursors.DictCursor)
        cur=db.cursor()
        cur.execute('SELECT `name` from achaea.rooms '
                ' WHERE %s = concat(`name`,".")', line)
        roomres = cur.fetchall()
        cur.execute('SELECT rawtxt, mytxt, regex, replace_str, hold, gag from achaea.filter '
                ' WHERE %s = rawtxt or %s rlike mytxt', (line, line))
        allres = cur.fetchall()
        cur.close()
        db.commit()
        db.close()

        if len(roomres) > 0:
            return(1,False)
        if allres is None or len(allres) != 1:
            sage.echo("No match found : %s"%len(allres))
            if (len(allres) > 1):
                for res in allres:
                    print line
                    sage.echo(line)
                    sage.echo(res)

            return (len(allres), False)

        for res in allres:
            if res['replace_str'] == "":
                return (1, res['gag']==1)
            m = re.match(res['replace_str'], line)
            if m is None:
                sage.echo("LINE NOT MATCHED!")
                return (1, False)
            newline = res['replace_str']%m.groups()
            self.sofar = self.sofar + newline + " " 
            if res['hold'] == 1:
                self.sofar = self.sofar + " " + newline
            else:
                sage.echo(self.sofar)
                selfsofar = ""
            if res['gag'] == 1:
                return (1, True)
        return (1, False)
Пример #19
0
def xplr_add(alias):
    explr.times['last_action'] = time.time()
    query = ' '.join(alias.line.split()[2:])
    sage.echo("Searching for area: %s " % query)
    areas = set([room['area'] for room in explr.map.rooms.values()])
    matches = [area for area in areas if query.lower() in area.lower()]
    sage.echo("Matches for area: %s" % matches)

    if len(matches) == 1:
        explr.explore_area.append(matches[0])
        sage.echo("Area added.")
    else:
        sage.echo("Need only one area to match. Nothing added.")
Пример #20
0
def xplr_add(alias):
    explr.times['last_action'] = time.time()
    query = ' '.join(alias.line.split()[2:])
    sage.echo("Searching for area: %s " % query)
    areas = set([room['area'] for room in explr.map.rooms.values()])
    matches = [area for area in areas if query.lower() in area.lower()]
    sage.echo("Matches for area: %s" % matches)

    if len(matches) == 1:
        explr.explore_area.append(matches[0])
        sage.echo("Area added.")
    else:
        sage.echo("Need only one area to match. Nothing added.")
Пример #21
0
    def path_to_room(self, start, end, blocked=[]):
        #print "find a path to a room"
        start = long(start)
        end = long(end)
        # maintain a queue of paths
        queue = deque()
        visited = set()

        # scoping optimization tricks
        q_append = queue.append
        q_pop = queue.popleft
        v_add = visited.add
        matrix = self.matrix

        # push the first path into the queue
        q_append([start])

        while queue:
            # get the first path from the queue
            path = q_pop()
            # get the last node from the path
            node = path[-1]

            if (node in visited):
                continue

            # path found
            if node == end:
                return Path(path, self)

            v_add(node)

            # enumerate all adjacent nodes, construct a new path and push it into the queue
            if node in self.rooms:
                for adjacent in self.rooms[node]['exits'].keys():
                    if (adjacent not in blocked):
                        new_path = path[:]
                        new_path.append(adjacent)
                        q_append(new_path)
        echo("No path found")
        return None
Пример #22
0
    def path_to_room(self, start, end, blocked=[]):
        #print "find a path to a room"
        start = long(start)
        end = long(end)
        # maintain a queue of paths
        queue = deque()
        visited = set()

        # scoping optimization tricks
        q_append = queue.append
        q_pop = queue.popleft
        v_add = visited.add
        matrix = self.matrix

        # push the first path into the queue
        q_append([start])

        while queue:
            # get the first path from the queue
            path = q_pop()
            # get the last node from the path
            node = path[-1]

            if (node in visited):
                continue

            # path found
            if node == end:
                return Path(path, self)

            v_add(node)

            # enumerate all adjacent nodes, construct a new path and push it into the queue
            if node in self.rooms:
                for adjacent in self.rooms[node]['exits'].keys():
                    if (adjacent not in blocked):
                        new_path = path[:]
                        new_path.append(adjacent)
                        q_append(new_path)
        echo("No path found")
        return None
Пример #23
0
def xplr_go(alias):
    query = ' '.join(alias.line.split()[2:])
    explr.times['last_action'] = time.time()
    if query.isdigit():
        explr.explore_area = []
        explr.path = None
        explr.path = explr.map.path_to_room(player.room.id, query,
                                            explr.blocked)
    elif query[0] == '#' and query[1:].isdigit():
        query = int(query[1:]) - 1
        if (len(explr.search_roomids) < query):
            sage.echo("Room id not stored. current length is %s : %s" %
                      (len(explr.search_roomids), explr.search_roomids))
            return
        explr.explore_area = []
        explr.path = None
        explr.path = explr.map.path_to_room(player.room.id,
                                            explr.search_roomids[query],
                                            explr.blocked)
    else:
        sage.echo("Searching for room: %s " % query)
        explr.search_roomids = explr.map.find_room_like(query, doecho=True)
        sage.echo("Matches for room: %s" % explr.search_roomids)
        if len(explr.search_roomids) == 1:
            explr.explore_area.append(explr.search_roomids[0])
            explr.explore_area = []
            explr.path = None
            explr.path = explr.map.path_to_room(player.room.id,
                                                explr.search_roomids[0],
                                                explr.blocked)
Пример #24
0
 def buyElixirs(self):
     mana_count = 0
     health_count = 0
     manaClass = [
         'alchemist', 'apostate', 'magi', 'occultist', 'shaman', 'sylvan'
     ]
     sage.echo("Current sips: (%s, %s)" %
               (self.sips_health, self.sips_mana))
     if self.sips_health < 200:
         health_count = health_count + 1
     if self.sips_mana < 200:
         mana_count = mana_count + 1
     if self.vials_empty > mana_count + health_count:
         if player.combatclass in manaClass:
             cur_mana = int(self.sips_mana / 200) + mana_count
             cur_health = int(self.sips_health / 200) + health_count
             mana_count = max(
                 int((self.vials_empty + cur_mana + cur_health) * .3) -
                 cur_mana, 0)
         health_count = max(health_count, self.vials_empty - mana_count)
     sage.send('tg')
     sage.echo("Buying %s health" % health_count)
     sage.echo("Buying %s mana" % mana_count)
     for i in range(0, health_count):
         sage.send('refill empty from health')
     for i in range(0, mana_count):
         sage.send('refill empty from mana')
     self.vials_empty = 0
     vial_triggers('vial_empty').disable()
     vial_triggers('vial_stat').disable()
     sage.send('pg')
     if player.willpower.value < player.endurance.value:
         sage.send('meditate')
     else:
         sage.send('sleep')
Пример #25
0
 def buyElixirs(self):
     mana_count = 0
     health_count = 0
     manaClass = ['alchemist', 'apostate','magi','occultist','shaman','sylvan']
     sage.echo("Current sips: (%s, %s)"%(self.sips_health, self.sips_mana))
     if self.sips_health < 200:
         health_count = health_count + 1
     if self.sips_mana < 200:
         mana_count = mana_count + 1
     if self.vials_empty > mana_count + health_count:
         if player.combatclass in manaClass:
             cur_mana = int(self.sips_mana/200)+mana_count
             cur_health = int(self.sips_health/200)+health_count
             mana_count = max(int((self.vials_empty + cur_mana + cur_health) * .3) - cur_mana, 0)
         health_count = max(health_count,self.vials_empty - mana_count)
     sage.send('tg')
     sage.echo("Buying %s health"%health_count)
     sage.echo("Buying %s mana"%mana_count)
     for i in range(0,health_count):
         sage.send('refill empty from health')
     for i in range(0,mana_count):
         sage.send('refill empty from mana')
     self.vials_empty = 0
     vial_triggers('vial_empty').disable()
     vial_triggers('vial_stat').disable()
     sage.send('pg')
     if player.willpower.value < player.endurance.value:
         sage.send('meditate')
     else:
         sage.send('sleep')
Пример #26
0
def pull_comms():
    global login_info
    global last_pull_time
    update_time = False
    db = mysql.connect(host=login_info[0],
                       user=login_info[1],
                       passwd=login_info[2],
                       db='achaea',
                       cursorclass=MySQLdb.cursors.DictCursor)
    cur = db.cursor()
    cur.execute(
        'select `char`, `talker`, `channel`, `message` from achaea.messages_heard '
        ' where `time` > %s and `char` != %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        output = '%s heard %s say on %s : %s' % (
            res['char'], res['talker'], res['channel'], res['message'])
        sage.echo(output)

    cur.execute(
        'select `from_char`, `message` from achaea.messages_sent'
        ' where `time` > %s and `to_char` = %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        sage.echo(res['from_char'] + " said do " + res['message'])
        sage.send(res['message'])

    if (update_time):
        last_pull_time = time.time()

    cur.close()
    db.commit()
    db.close()

    if do_pull:
        sage.delay(5, pull_comms)
Пример #27
0
def xplr_go(alias):
    query = ' '.join(alias.line.split()[2:])
    explr.times['last_action'] = time.time()
    if query.isdigit():
        explr.explore_area = []
        explr.path = None
        explr.path = explr.map.path_to_room( player.room.id, query, explr.blocked)
    elif query[0] == '#' and query[1:].isdigit():
        query=int(query[1:])-1
        if(len(explr.search_roomids) < query):
            sage.echo("Room id not stored. current length is %s : %s"%(len(explr.search_roomids),
                explr.search_roomids))
            return
        explr.explore_area = []
        explr.path = None
        explr.path = explr.map.path_to_room( player.room.id, explr.search_roomids[query], explr.blocked)
    else:
        sage.echo("Searching for room: %s " % query)
        explr.search_roomids = explr.map.find_room_like(query,doecho=True)
        sage.echo("Matches for room: %s" % explr.search_roomids)
        if len(explr.search_roomids) == 1:
            explr.explore_area.append(explr.search_roomids[0])
            explr.explore_area = []
            explr.path = None
            explr.path = explr.map.path_to_room( player.room.id, explr.search_roomids[0], explr.blocked)
Пример #28
0
def search_room(alias):
    """ Look for rooms with substr search """
    results = mapdata.search_room_substring(alias.suffix.lower().strip())
    header = "{:<12s}{:<68s}"
    echo(header.format("ID", "Room Name"))
    echo(ansi.strfcolor("%g{:-<80}%0".format("")))
    for room in results:
        fmt = "{:<12d}{:<68s}"
        echo(fmt.format(room, mapdata.rooms[room]['name']))
Пример #29
0
def deploy_miners(count, mtype):
    global minermap
    squadstr = ""
    total = 0
    for x in sorted(minermap.iteritems(), key=lambda(x, y): y['size'], reverse=True):
        valid = x[1]['type'] == 'miners' if mtype == 'miner' else x[1]['type'] != 'miners' 
        if x[1]['status'] != 'deployed' and valid:
            if x[1]['size'] < count:
                squadstr = "%s %s"%(squadstr,x[0])
                sage.echo(x[1])
                total += x[1]['size']
                count -= x[1]['size']
                sage.echo("count left: %s"%count)
    sage.echo("legion deploy squads %s"%squadstr)
    sage.send("legion deploy squads %s"%squadstr)
Пример #30
0
def legion_list_over(trigger):
    trigger.line.gag()
    global minermap
    xplr_triggers('legion_list').disable()
    xplr_triggers('legion_ignore_dash').disable()
    xplr_triggers('legion_ignore_id').disable()
    xplr_triggers('legion_list_over').disable()
    deployed_miners = 0
    deployed_army = 0
    avail_miners = 0
    avail_army = 0
    for val in minermap.values():
        if val['type'] == 'miners' and val['status'] == 'deployed':
            deployed_miners += val['size']
        if val['type'] == 'miners' and val['status'] != 'deployed':
            avail_miners += val['size']
        if val['type'] != 'miners' and val['status'] == 'deployed':
            deployed_army += val['size']
        if val['type'] != 'miners' and val['status'] != 'deployed':
            avail_army += val['size']
    sage.echo("Avail Miners: %s" % avail_miners)
    sage.echo("Avail Army: %s" % avail_army)
    sage.echo("Deployed Miners: %s" % deployed_miners)
    sage.echo("Deployed Army: %s" % deployed_army)
Пример #31
0
def legion_list_over(trigger):
    trigger.line.gag()
    global minermap
    xplr_triggers('legion_list').disable()
    xplr_triggers('legion_ignore_dash').disable()
    xplr_triggers('legion_ignore_id').disable()
    xplr_triggers('legion_list_over').disable()
    deployed_miners = 0
    deployed_army = 0
    avail_miners = 0
    avail_army = 0
    for val in minermap.values():
        if val['type'] == 'miners' and val['status'] == 'deployed':
            deployed_miners += val['size']
        if val['type'] == 'miners' and val['status'] != 'deployed':
            avail_miners += val['size']
        if val['type'] != 'miners' and val['status'] == 'deployed':
            deployed_army += val['size']
        if val['type'] != 'miners' and val['status'] != 'deployed':
            avail_army += val['size']
    sage.echo("Avail Miners: %s"%avail_miners)
    sage.echo("Avail Army: %s"%avail_army)
    sage.echo("Deployed Miners: %s"%deployed_miners)
    sage.echo("Deployed Army: %s"%deployed_army)
Пример #32
0
def deploy_miners(count, mtype):
    global minermap
    squadstr = ""
    total = 0
    for x in sorted(minermap.iteritems(),
                    key=lambda (x, y): y['size'],
                    reverse=True):
        valid = x[1]['type'] == 'miners' if mtype == 'miner' else x[1][
            'type'] != 'miners'
        if x[1]['status'] != 'deployed' and valid:
            if x[1]['size'] < count:
                squadstr = "%s %s" % (squadstr, x[0])
                sage.echo(x[1])
                total += x[1]['size']
                count -= x[1]['size']
                sage.echo("count left: %s" % count)
    sage.echo("legion deploy squads %s" % squadstr)
    sage.send("legion deploy squads %s" % squadstr)
Пример #33
0
    def end(self, signal):
        if self.text != "":
            if self.got_dstab:
                self.got_dstab = False
                if(len(self.venoms) != 2):
                    self.text = ""
                    self.text = player.afflictions
                else:
                    self.text = ansi.bold_red(self.text +" %s %s"%(self.venoms[0], self.venoms[1]))
            sage.echo(self.text)
            self.text = ""

        if self.echo_aff:
            sage.echo(ansi.bold_yellow(self.aff_str))
            self.echo_aff = False
        if len(self.cures) > 0:
            for cure in self.cures:
                sage.echo(cure[1])
            self.cures=[]
        self.venoms=[]
Пример #34
0
    def end(self, signal):
        if self.text != "":
            if self.got_dstab:
                self.got_dstab = False
                if (len(self.venoms) != 2):
                    self.text = ""
                    self.text = player.afflictions
                else:
                    self.text = ansi.bold_red(self.text + " %s %s" %
                                              (self.venoms[0], self.venoms[1]))
            sage.echo(self.text)
            self.text = ""

        if self.echo_aff:
            sage.echo(ansi.bold_yellow(self.aff_str))
            self.echo_aff = False
        if len(self.cures) > 0:
            for cure in self.cures:
                sage.echo(cure[1])
            self.cures = []
        self.venoms = []
Пример #35
0
    def attacks(self):
        is_hindered = ('webbed' in player.afflictions
                       or 'paralyzed' in player.afflictions
                       or 'prone' in player.afflictions
                       or 'sleeping' in player.afflictions
                       or 'transfixation' in player.afflictions
                       or 'aeon' in player.afflictions
                       or 'entangled' in player.afflictions)
        has_balance = player.balance.is_on() and player.equilibrium.is_on()

        self.can_move = not is_hindered and has_balance

        items = [
            self.imap.items[iid] for iid in player.room.items.keys()
            if iid in self.imap.items
        ]
        to_attack = []
        for item in items:
            if 'classified' in item:
                if item['classified'] and 'kill' in item['classified']:
                    to_attack.append(item)
            else:
                print 'item not classified'

        to_attack = [
            item for item in items
            if item['classified'] and 'kill' in item['classified']
        ]
        lagging = self.times['last_action'] > self.times['last_ping']
        self.to_attack = to_attack

        if self.leader_following:
            #### Get the leader's location
            db = mysql.connect(host=self.login[0],
                               user=self.login[1],
                               passwd=self.login[2],
                               db='achaea',
                               cursorclass=MySQLdb.cursors.DictCursor)
            cur = db.cursor()
            cur.execute(
                "select ally,roomid from achaea.allies where `leader`=1")
            allres = cur.fetchall()
            if allres is not None and len(allres) == 1:
                leader = allres[0]['ally'].lower()
                self.leader_room = long(allres[0]['roomid'])
                if (leader != self.leader):
                    sage.echo("Changing leader from %s to %s" %
                              (self.leader, leader))
                    self.leader = leader
            cur.close()
            db.commit()
            db.close()

            others_here = [p.lower() for p in player.room.players]

            if self.leader_here and self.path is not None and self.can_move and self.state == State.EXPLORE:
                sage.send('follow %s' % self.leader)
                self.path = None
                self.leader_here = self.leader in others_here

        if (len(to_attack) == 0 or self.canAttack == False or lagging
                or self.state == State.QUEST or self.state == State.RETREAT
                or self.state == State.PROSP or not self.leader_here):
            return

        if not self.cur_target or self.cur_target not in player.room.items.keys(
        ):
            self.cur_target = to_attack[0]['itemid']
            sage.send('st %s' % self.cur_target)

        from skills.skills import smap
        if smap.use_br(target=self.cur_target, shield=self.break_shield):
            self.break_shield = False

        if has_balance and not is_hindered and self.killon:
            #if(player.combatclass.lower() == 'shaman') and (smap.swiftcurses < 2):
            #    sage.send('swiftcurse')
            #elif (player.combatclass.lower() == 'shaman'):
            #    sage.send('swiftcurse %s bleed' % self.cur_target)
            #el
            if (player.combatclass.lower() == 'shaman'):
                sage.send('invoke roar %s' % self.cur_target)
            elif (player.combatclass.lower() == 'magi'
                  and player.mana.value < player.mana.max * self.manamin):
                sage.send('punch %s' % self.cur_target)
            else:
                sage.send('kill %s' % self.cur_target)
            self.times['last_action'] = time.time()
Пример #36
0
    def other(self):
        #print self.times
        idle_time = self.times['time'] - self.times['last_action']
        action_idle = self.times['time'] - self.times['last_action']
        idle_time = min(idle_time,
                        self.times['time'] - self.times['last_room'])
        lagging = self.times['last_ping'] < self.times['last_action']
        healthy = (player.health.value > player.health.max * .99
                   and player.mana.value > player.mana.max * .9)

        if self.path is not None and len(self.path.route) < self.path.step:
            self.path = None

        #sage.echo("health status: (%s,%s,%s)"%(self.htracker.health, self.htracker.ema_health_loss, self.htracker.cur_health_loss))
        if ((self.htracker.health < 1.5 *
             max(self.htracker.ema_health_loss, self.htracker.cur_health_loss)
             and (player.health.value < player.health.max * .7)
             or self.htracker.mana < 200) and self.state != State.RETREAT
                and not healthy):
            sage.echo("Retreat!")
            self.pre_state = self.state
            self.state = State.RETREAT
            self.path = None

        if (idle_time > 10 and self.path is not None
                and self.state != State.REST):
            if (len(self.path.route) > self.path.step
                    and player.room.id != self.path.route[self.path.step]):
                sage.echo("Blocking room %s"
                          ", current room %s"
                          ", path: %s" % (self.path.route[self.path.step],
                                          player.room.id, self.path.route))
                self.blocked.append(self.path.route[self.path.step])
                self.visited.add(self.path.route[self.path.step])
                self.times['last_action'] = time.time()
            self.path = None

        min_will = 500
        max_will = player.willpower.max
        do_rest = ((self.state != State.REST)
                   and ((player.willpower.value <
                         (min_will + max_will / 10)) or
                        (player.endurance.value < min_will + max_will / 10))
                   and (player.room.id == 6838))

        if do_rest:
            sage.echo("Setting the state to be rest")
            self.path = None
            self.state = State.REST
            self.times['last_action'] = time.time()
            self.vials_empty = 0
            self.sips_health = 0
            self.sips_mana = 0
            vial_triggers('vial_empty').enable()
            vial_triggers('vial_stat').enable()
            sage.send('consolidate health')
            sage.send('consolidate mana')
            sage.send('elixsum health')
            sage.send('elixsum mana')
            sage.send('elixlist empty')
            sage.delay(1, self.buyElixirs)
            #if player.willpower.value < player.endurance.value:
            #    sage.send('meditate')
            #else:
            #    sage.send('sleep')

        end_rest = ((self.state == State.REST) and (
            (player.willpower.value >= min(max_will, player.willpower.max)) and
            (player.endurance.value >= min(max_will, player.endurance.max)))
                    and (player.room.id == 6838))

        if end_rest:
            sage.echo("Done resting!")
            self.state = State.EXPLORE
            self.times['last_action'] = time.time()
            if (len(self.explore_area) > 0):
                self.path = self.map.path_to_area(player.room.id,
                                                  self.explore_area[0],
                                                  self.blocked)

        go_to_rest = ((self.state != State.REST)
                      and (self.state != State.QUEST)
                      and ((player.willpower.value < min_will) or
                           (player.endurance.value < min_will)))

        find_new_quest = ((self.state == State.QUEST)
                          and ((self.path is None) or
                               (self.path.route[-1] == player.room.id)))

        find_new_room = ((self.state == State.EXPLORE)
                         and ((self.path is None) or
                              (self.path.route[-1] == player.room.id) or
                              (idle_time > 20)) and len(self.explore_area) > 0)
        #print find_new_room, self.state, self.path, self.explore_area

        if (not self.leader_here and self.state == State.EXPLORE
                and player.room.id != self.leader_room and
            (self.path is None or self.leader_room != self.path.route[-1])):
            sage.echo("Setting path to walk to leader")
            self.path = self.map.path_to_room(player.room.id, self.leader_room,
                                              self.blocked)

        if go_to_rest:
            sage.echo("Setting the state to be quest to walk to sleepzone")
            self.state = State.QUEST
            self.path = self.map.path_to_room(player.room.id, 6838,
                                              self.blocked)
            find_new_quest = find_new_room = False

        if (self.state == State.RETREAT) and (len(self.visited_order) > 1):
            if (player.health.value > player.health.max * .9
                    and player.mana.value > player.mana.max * self.manamin):
                self.times['last_action'] = time.time()
                sage.echo("Done with retreat!")
                self.state = self.pre_state
            if ((player.room.id == self.visited_order[-1])
                    and (idle_time > 0.5) and (len(self.to_attack) > 0)
                    and self.path == None):
                self.visited.remove(self.visited_order[-1])
                self.visited_order.pop()
                self.path = self.map.path_to_room(player.room.id,
                                                  self.visited_order[-1],
                                                  self.blocked)
                sage.echo("Moving to retreat room")
                sage.echo(self.path.route)

        if find_new_room:
            self.visited.add(player.room.id)
            if player.room.area == self.explore_area[0]:
                self.path = self.map.path_to_new_room(player.room.id,
                                                      self.visited,
                                                      self.explore_area[0],
                                                      self.blocked)
            else:
                self.path = self.map.path_to_area(player.room.id,
                                                  self.explore_area[0],
                                                  self.blocked)

            if self.path is None:
                echo("Done exploring area: %s" % self.explore_area[0])
                self.took_items = []
                self.state = State.QUEST
                self.visited = set()
                old_area = self.explore_area.pop(0)
                if self.explore_loop:
                    self.explore_area.append(old_area)

        if find_new_quest:
            items = [
                self.imap.items[iid] for iid in player.inv.keys()
                if iid in self.imap.items
            ]
            items = [
                item for item in items
                if item['quest_actions'] != '' and item['quest_actions']
                is not None and item['itemid'] not in self.unquest_items
            ]
            found_quest = False
            for item in items:
                print "command: ", item['quest_actions']
                commands = item['quest_actions'].split(';')
                for command in commands:
                    action = command.split(' ')[0]
                    if (action == 'give'):
                        target = command.split(' ')[2]
                        targ_item = self.imap.items[long(target)]
                        if targ_item['lastroom'] != player.room.id:
                            self.path = self.map.path_to_room(
                                player.room.id, targ_item['lastroom'],
                                self.blocked)
                            found_quest = True
                            if self.path is None:
                                self.unquest_items.append(item['itemid'])
                                found_quest = False
                            elif self.state == State.QUEST:
                                break
            if not found_quest and len(self.explore_area) > 0:
                self.state = State.EXPLORE

        #if('shop' in player.room.details):
        #    check_shop()

        if self.path is None:
            return

        if ((self.path is not None)
                and (player.room.id == self.path.route[-1])):
            self.visited.add(player.room.id)
            if (self.state != State.PROSP):
                if self.leader_following:
                    sage.send("follow %s" % self.leader)
                echo("We appear to be at the end of our route:"
                     "{end},{cur}".format(end=self.path.route[-1],
                                          cur=player.room.id))
                self.path = None
                return
            self.path.step = self.path.step + 1
            return

        do_move = ((self.state == State.EXPLORE or self.state == State.QUEST or
                    self.state == State.RETREAT or self.state == State.PROSP)
                   and idle_time > self.move_idle_wait and not lagging
                   and self.can_move and action_idle > self.action_idle_wait)
        if self.path.step >= len(self.path.route):
            self.path = None
            return

        if (player.room.id == self.path.route[self.path.step] and do_move):
            sage.send(self.path.directions[self.path.step])
            self.last_move = self.path.directions[self.path.step]
            self.path.step = self.path.step + 1
            #self.times['last_action'] = self.times['time']
            self.times['last_move'] = self.times['time']
Пример #37
0
    def scope_it_out(self):
        if not self.do_scope:
            return

        if player.room is not None and player.room.id is not None and player.name is not None:
            db = mysql.connect(host=self.login[0],
                               user=self.login[1],
                               passwd=self.login[2],
                               db='achaea',
                               cursorclass=MySQLdb.cursors.DictCursor)
            cur = db.cursor()
            cur.execute(
                "INSERT into achaea.allies (`ally`,`roomid`) VALUES (%s,%s)"
                " ON DUPLICATE KEY UPDATE ally=ally, roomid=values(roomid) ",
                (player.name, player.room.id))
            cur.execute(
                "select ally,roomid from achaea.allies where `leader`=1")
            allres = cur.fetchall()
            if allres is not None and len(allres) == 1:
                leader = allres[0]['ally'].lower()
                self.leader_room = long(allres[0]['roomid'])
                if (leader != self.leader):
                    sage.echo("Changing leader from %s to %s" %
                              (self.leader, leader))
                    self.leader = leader
            cur.close()
            db.commit()
            db.close()

        self.do_scope = False
        just_entered = False

        if (player.room.id !=
                self.cur_room) or (time.time() - self.times['entered'] < 0.5):
            self.cur_room = player.room.id
            just_entered = True
            self.times['entered'] = time.time()
            if (self.roomact is not None):
                if self.roomact.startswith('wait '):
                    waittime = float(
                        re.sub('wait ', '',
                               self.roomact.split('/')[0]))
                    sage.delay(waittime, sage.send, self.roomact.split('/')[1])
                else:
                    sage.send(self.roomact)
        just_entered = just_entered and (self.times['last_room'] >
                                         self.times['last_scope'])

        others_here = [p.lower() for p in player.room.players]
        allies_here = list(set(others_here) & set(self.allies))
        others_here = list(set(others_here) - set(self.allies))

        if self.leader_following:
            self.leader_here = self.leader in others_here or self.leader in allies_here
        else:
            self.leader_here = True

        room_dps = len([
            iid for iid, item in player.room.items.iteritems() if item.denizen
        ])

        if just_entered:
            #print 'just entered'
            self.canAttack = True

        if just_entered and len(others_here) != 0:
            print 'people here'
            self.canAttack = False
            self.can_take_stuff = False
        elif just_entered:
            self.can_take_stuff = not self.block_can_take_stuff

        if room_dps > self.my_hps * (1 + len(self.allies)):
            print 'dps too high'
            self.canAttack = False
        self.times['last_scope'] = self.times['time']
Пример #38
0
    def kickedFrom(self, channel, kicker, message):
        """ You have been kicked from the channel """

        echo('[%s] You have been kicked from %s by %s: %s' % (channel, channel, kicker, message))
Пример #39
0
def chatteron(alias):
    sage.echo("Enabling filter for combat chatter")
    chatter_trigs.enable()
Пример #40
0
    def irc_NICK(self, prefix, params):
        """ Called when an IRC user changes their nickname """

        old_nick = prefix.split('!')[0]
        new_nick = params[0]
        echo("[IRC] %s is now known as %s" % (old_nick, new_nick))
Пример #41
0
def xplr_follow(alias):
    explr.leader_following = not explr.leader_following
    sage.echo("Switching following to %s" % explr.leader_following)
Пример #42
0
def chatteroff(alias):
    sage.echo("Disabling filter for combat chatter")
    chatter_trigs.disable()
Пример #43
0
 def echo_dstab(self, target, line):
     if(len(self.venoms) == 2):
         self.text = ansi.bold_green("You Doublestab %s : %s %s"%(target, self.venoms[0], self.venoms[1]))
     else:
         sage.echo(line)
Пример #44
0
def got_curare(trigger):
    if 'paralysis' in player.afflictions:
        tracker.echo_affs()
        tracker.add_venom('curare')
        sage.echo((tracker.venoms))
    trigger.line.gag()
Пример #45
0
def xplr_mana(alias):
    explr.times['last_action'] = time.time()
    query = alias.line.split()[2]
    sage.echo("Setting mana percent: %s " % query)
    explr.manamin = float(query)
Пример #46
0
def got_names(nicklist):
        nicklist.sort()
        echo('%s members:' % channel)
        echo('-' * 10)
        for nick in nicklist:
            echo(nick)
Пример #47
0
    def userKicked(self, kickee, channel, kicker, message):
        """ A user has been kicked from the channel """

        echo('[%s] %s has been kicked by %s in %s: %s' % (channel, kickee, kicker, channel, message))
Пример #48
0
def got_kalmia(trigger):
    if 'asthma' in player.afflictions:
        tracker.echo_affs()
        tracker.add_venom('kalmia')
        sage.echo((tracker.venoms))
    trigger.line.gag()
Пример #49
0
def vial_stat(trigger):
    sage.echo(trigger.groups[0])
    sage.echo(trigger.groups[1])
    explr.set_sips(trigger.groups[0].lower(), (int)(trigger.groups[1]))
Пример #50
0
def xaff(alias):
    sage.echo(player.afflictions)
Пример #51
0
def xplr_help(alias):
    sage.echo("xplr Commands: ")
    sage.echo("     start ")
    sage.echo("     pause ")
    sage.echo("     stop ")
    sage.echo("     clear ")
    sage.echo("     clear path ")
    sage.echo("     vpath")
    sage.echo("     takeoff ")
    sage.echo("     takeon ")
    sage.echo("     loop ")
    sage.echo("     ally <target> ")
    sage.echo("     delay <target> ")
    sage.echo("     add <target> ")
Пример #52
0
def xdef(alias):
    sage.echo(player.defences)
Пример #53
0
def xplr_view_path(alias):
    sage.echo(explr.explore_area)
Пример #54
0
 def set_sips(self, elixname, sips):
     sage.echo('%s : %s' % (elixname, sips))
     if elixname == 'health':
         self.sips_health = sips
     if elixname == 'mana':
         self.sips_mana = sips
Пример #55
0
    def userQuit(self, user, quitMessage):
        ''' User quitting the network '''

        user = user.split('!', 1)[0]
        echo('[IRC] %s has disconnected. Reason: %s' % (user, quitMessage))
Пример #56
0
def echo_aff(signal,affliction):
    sage.echo(ansi.bold_red("ADDED AFFLICTION: %s"%affliction))
Пример #57
0
def echo_aff_rem(signal,affliction):
    sage.echo(ansi.bold_green("REMOVED AFFLICTION: %s"%affliction).encode('utf-8'))
Пример #58
0
def xplr_tars_echo(alias):
    sage.echo(explr.tars)