Skip to content

Commit

Permalink
Tweaked SpaceObject for ideal defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
QBFreak committed Sep 18, 2018
1 parent 839904a commit dc9c7a2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions world/spaceobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
import random


class SpaceObject(object):
# TODO: This should inherit from Object before we start using it with Evennia
class SpaceObject(Object):
# TODO: This should inherit from `Object` before we start using it with Evennia
# In order to run spaceobj-test.py, change it to `object`
"""
The SpaceObject class is the parent class for the individual classes for the
various types of objects you might find in space. It has all of the generic
functions necessary for an object that appears scattered through space.
"""
def __init__(self, seed, scale=100):
def __init__(self, seed, scale=2, selection=1):
self.seed = seed
self.scale = scale
self.selection = selection
random.seed(self.seed)
self.xoffset = random.random()
self.yoffset = random.random()
Expand All @@ -48,23 +50,23 @@ def object_at_coordinates(self, coordinates):
x, y, z = coordinates
n = snoise3(x + self.xoffset, y + self.yoffset, z + self.zoffset)
o = int(n * self.scale)
return o == self.seed
return o == self.selection


class Star(SpaceObject):
"""
One of the most basic space objects, the star simply exists
"""
def __init__(self, seed=38, scale=100):
super(Star, self).__init__(seed, scale)
def __init__(self, seed=39, scale=2, selection=1):
super(Star, self).__init__(seed, scale, selection)


class Planet(Star):
"""
The planet exists only where there are stars, but not in every location
"""
def __init__(self, seed=38, scale=100):
super(Planet, self).__init__(seed, scale)
def __init__(self, seed=39, scale=2, selection=1):
super(Planet, self).__init__(seed, scale, selection)
self.range = 5
self.occurs = 4

Expand All @@ -81,8 +83,8 @@ class Moon(Planet):
"""
The moon exists only where there is a planet, but not in every location
"""
def __init__(self, seed=38, scale=100):
super(Moon, self).__init__(seed, scale)
def __init__(self, seed=39, scale=2, selection=1):
super(Moon, self).__init__(seed, scale, selection)
self.range = 5
self.occurs = 3

Expand Down

0 comments on commit dc9c7a2

Please sign in to comment.