find command now shows tunnels

doc_update
Joey Hines 2018-07-22 20:03:24 -05:00
parent cc1324c5bb
commit 847e33ed6e
2 changed files with 11 additions and 5 deletions

View File

@ -140,7 +140,7 @@ class DatabaseInterface:
return player
def search_all_fields(self, session, search):
loc_string = ''
loc_string = '\n**Locations:**'
count = 0
expr = Location.owner.has(Player.name.ilike('%{}%'.format(search))) | Location.name.ilike('%{}%'.format(search))
@ -148,9 +148,11 @@ class DatabaseInterface:
loc_string = "{}\n{}".format(loc_string, loc)
count += 1
expr = Tunnel.owner.has(Player.name.ilike('%{}%'.format(search))) & Tunnel.location is None
for loc in self.database.query_by_filter(session, Tunnel, expr):
loc_string = "{}\n{}".format(loc_string, loc)
loc_string = loc_string + '\n\n**Tunnels:**'
expr = Tunnel.owner.has(Player.name.ilike('%{}%'.format(search))) & Tunnel.location == None
for tunnel in self.database.query_by_filter(session, Tunnel, expr):
loc_string = "{}\n{}".format(loc_string, tunnel.full_str())
count += 1
if count == 0:

View File

@ -154,6 +154,9 @@ class Tunnel(SQL_Base):
except (ValueError, IndexError):
raise TunnelInitError
def full_str(self):
return 'Owner: **{}**\'s Tunnel: **{}**'.format(self.owner.name, self.__str__())
def __str__(self):
return '{} {}'.format(self.tunnel_direction.value.title(), self.tunnel_number)
@ -201,7 +204,8 @@ class Location(SQL_Base):
return '(x= {}, z= {}) in the {}'.format(self.x, self.z, self.dimension.value.title())
def info_str(self):
return "Name: **{}**, Type: **{}** Position: **{}**".format(self.name, self.type, self.pos_to_str())
return "Name: **{}**, Type: **{}**, Owner: **{}** Position: **{}**".format(self.name, self.type,
self.owner.name, self.pos_to_str())
def full_str(self):
return self.__str__() + '\n' + self.dynmap_link()