Skip to content
This repository has been archived by the owner on Jan 7, 2019. It is now read-only.

Commit

Permalink
Lots of assorted ship/station parent work.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtaylor committed Oct 1, 2013
1 parent 2bc481c commit f7ea4fd
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/game/commands/general.py
Expand Up @@ -64,8 +64,8 @@ def get_examine_appearance(self, obj, invoker):

attributes_str = ' Parent: %s (%s)\n' % (obj.parent, obj.base_type)

if self.aliases:
attributes_str += ' Aliases: %s\n' % ', '.join(self.aliases)
if obj.aliases:
attributes_str += ' Aliases: %s\n' % ', '.join(obj.aliases)

if obj.location:
attributes_str += ' Location: %s\n' % obj.location.get_appearance_name(invoker)
Expand Down
17 changes: 6 additions & 11 deletions src/game/commands/staff.py
Expand Up @@ -63,24 +63,19 @@ def func(self, invoker, parsed_cmd):
if search_str.strip() == '':
raise CommandError('@find requires a name to search for.')

invoker.emit_to('\nSearching for "%s"' % search_str)

# Performs a global fuzzy name match. Returns a generator.
matches = mud_service.object_store.global_name_search(search_str)

# Buffer for returning everything at once.
retval = ''
match_counter = 0
buf = self._get_header_str('Searching for "%s"' % search_str)
for match in matches:
retval += '\n #%s %s %s' % (
str(match.id).ljust(6),
match.base_type.ljust(8),
match.name[:80]
)
buf += '\n %s' % match.get_appearance_name(invoker)
match_counter += 1
# Send the results in one burst.
invoker.emit_to(retval)
invoker.emit_to('\nMatches found: %d' % match_counter)
buf += self._get_footer_str(pad_char='-')
buf += '\n Matches found: %d' % match_counter
buf += self._get_footer_str()
invoker.emit_to(buf)


class CmdDig(BaseCommand):
Expand Down
16 changes: 5 additions & 11 deletions src/game/parents/base_objects/base.py
Expand Up @@ -494,6 +494,8 @@ def _find_name_or_alias_match(self, objects, query):
:param iterable objects: A list of ``BaseObject`` sub-class instances
to attempt to match to.
:param str query: The string to match against.
:rtype: BaseObject
:returns: The best match object for the given query.
"""

if not objects:
Expand All @@ -507,21 +509,13 @@ def _find_name_or_alias_match(self, objects, query):
return obj

processor = lambda x: fuzz_utils.full_process(x)
scorer = QRatio
results = list()

for choice in objects:
processed = processor(choice.name)
score = scorer(query, processed)
result = (choice, score)
if score > 0:
results.append(result)
if query in processed:
return choice

if not results:
return None
else:
results.sort(key=lambda i: i[1], reverse=True)
return results[0][0]
return None

def _find_object_id_match(self, desc):
"""
Expand Down
4 changes: 4 additions & 0 deletions src/game/parents/base_objects/player.py
Expand Up @@ -5,6 +5,8 @@ class PlayerObject(ThingObject):
"""
All players inherit this parent class. It further extends ThingObject with
player-specific behavior.
src.game.parents.base_objects.player.PlayerObject
"""

@property
Expand Down Expand Up @@ -54,6 +56,8 @@ def after_session_disconnect_event(self):
class AdminPlayerObject(PlayerObject):
"""
Parent for admin players. Changes or overrides some behaviors.
src.game.parents.base_objects.player.AdminPlayerObject
"""

def is_admin(self):
Expand Down
4 changes: 1 addition & 3 deletions src/game/parents/space/ships/interior/bridge.py
Expand Up @@ -69,9 +69,6 @@ def do_list_docks(self, invoker, parsed_cmd):

dockables = self.ship.location.get_dockable_obj_list(self.ship)

buf = "Dockable Locations -- %s\n" % (
self.solar_system.get_appearance_name(invoker),
)
buf = self._get_header_str("Dockable Locations near %s" %
self.ship.location.get_appearance_name(invoker))
for place in dockables:
Expand Down Expand Up @@ -135,6 +132,7 @@ class CmdStatus(BaseCommand):
"""

name = 'status'
aliases = ['st']

#noinspection PyUnusedLocal
def func(self, invoker, parsed_cmd):
Expand Down
3 changes: 2 additions & 1 deletion src/game/parents/space/ships/ship_classes/base.py
Expand Up @@ -95,7 +95,8 @@ def get_bridge_obj(self):
if isinstance(obj, SpaceShipBridgeObject):
return obj

raise ShipError("No bridge found for ship #s." % self.id)
raise ShipError("No bridge found for %s" % self.get_appearance_name(
None, force_admin_view=True))

def emit_to_interior(self, message):
"""
Expand Down
12 changes: 12 additions & 0 deletions src/game/parents/space/ships/ship_classes/stations/athena.py
@@ -0,0 +1,12 @@
from src.game.parents.space.ships.ship_classes.stations.base import BaseSpaceStationObject


class AthenaSpaceStationObject(BaseSpaceStationObject):
"""
A basic shuttle class ship.
src.game.parents.space.ships.ship_classes.stations.athena.AthenaSpaceStationObject
"""

ship_type_name = 'Athena'
ship_reference = 'ATH-1A'
2 changes: 2 additions & 0 deletions src/game/parents/space/solar_system.py
Expand Up @@ -27,6 +27,8 @@ class SolarSystemPlaceObject(ThingObject):
"""
An object in space that may be warped to. These are more or less 'rooms'
within the solar system.
src.game.parents.space.solar_system.SolarSystemPlaceObject
"""

def get_solar_system_obj(self):
Expand Down

0 comments on commit f7ea4fd

Please sign in to comment.