Skip to content

Instantly share code, notes, and snippets.

@sli
Created December 27, 2011 04:22
Show Gist options
  • Select an option

  • Save sli/1522716 to your computer and use it in GitHub Desktop.

Select an option

Save sli/1522716 to your computer and use it in GitHub Desktop.
Silly RPG stuff.
import textwrap
wrapper = textwrap.TextWrapper(width=50,subsequent_indent=' '*13)
class Item(object):
def __init__(self, name, description='No description.'):
self.name = name
self.description = description
def display(self):
print '-'*50
print self.name
print wrapper.fill('Description: %s' % self.description)
print '-'*50
def __unicode__(self):
return self.name
def __str__(self):
return self.name
class Weapon(Item):
def __init__(self, name, description='No description.'):
super(Weapon, self).__init__(name, description)
if __name__ == '__main__':
print 'An item:'
test_item = Item('Test Item', 'This is a test item with a really long description. This is a test item with a really long description. This is a test item with a really long description. This is a test item with a really long description. This is a test item with a really long description.')
test_item.display()
print
print 'A weapon:'
test_weapon = Weapon('Test Weapon', 'This weapon does nothing. It also has a pretty long description, but not as long as the test item\'s.')
test_weapon.display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment