Skip to content

Commit

Permalink
RESOLVE #56: Add is_pilotable flag to Entity. (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecdavis committed Oct 12, 2016
1 parent 0d1ce6d commit 56abbec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions spacegame/core/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def save_user(user):

def player_name_exists(player_name):
for filename in os.listdir(config.path.player_dir):
p = storage.load_file(os.path.join(config.path.player_dir, filename), entity.Entity)
p = storage.load_file(os.path.join(config.path.player_dir, filename), entity.new_mobile)
if p.name == player_name:
return True
return False
Expand All @@ -89,7 +89,7 @@ def player_exists(player_uuid):


def load_player(player_uuid):
return storage.load_file(config.path.player_file_pattern % convert.uuid_to_base32(player_uuid), entity.Entity)
return storage.load_file(config.path.player_file_pattern % convert.uuid_to_base32(player_uuid), entity.new_mobile)


def save_player(player):
Expand Down
5 changes: 3 additions & 2 deletions spacegame/universe/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Entity(object):
"""
A representation of an entity in the game universe.
"""
def __init__(self, is_warp_beacon=False):
def __init__(self, is_pilotable=False, is_warp_beacon=False):
self.uuid = uuid.uuid4()
self.name = ""
self.universe = None
Expand All @@ -16,6 +16,7 @@ def __init__(self, is_warp_beacon=False):
self.position = (0, 0, 0)
self.vector = (1.0, 0.0, 0.0)
self.speed = 0
self.is_pilotable = is_pilotable
self.is_warp_beacon = is_warp_beacon
self.aux = auxiliary.new_data(aux_types.AUX_TYPE_ENTITY)

Expand Down Expand Up @@ -144,4 +145,4 @@ def velocity(self):


def new_mobile():
return Entity()
return Entity(is_pilotable=True)

0 comments on commit 56abbec

Please sign in to comment.