Created
December 27, 2011 04:22
-
-
Save sli/1522716 to your computer and use it in GitHub Desktop.
Silly RPG stuff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 '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