Closed kkpattern closed 11 years ago
Hi @kkpattern. Thanks for this, but it's not quite the way I want to do it. I think it would end up being more confusing for people adding content. Don't be put off: working out the best way to do things is an important part of adding new features.
Specifically, I want to keep items as largely tokens (they're currently string tokens), and have most of the code associated with the tiles. In order to be put in dictionaries, they'll need to be hashable tokens, i.e. class instances with __hash__
and __eq__
methods. It's probably worth having an ItemBase
class for that.
Some code will need to be attached to the objects. In particular, I'd like them to have a combine()
method, so you can combine objects to make new ones. Then there are all sorts of more specialist possibilities, like a sword that sometimes goes blunt and has to be sharpened.
I'll have a go at designing this, and let you comment on it before I merge it.
Actually, now that I'm implementing this, I'm coming back to something more like your design, with modules for items...
@takluyver Fantastic! I'm looking forward to see your implementing. So should I just close this pull request?
Oh yes. I'll close it now. I've nearly got something ready...
Have a look at #11
I try to add the item interface like the tile interface. If you want to create a new item, just create a module like
weatbag.items.sword
and then define the following methods in the module:Then, when player try to pick or use the item in the game, just do:
I rewrote the code about berries as an example. If you guys have any better ideas please tell me, I am happy to know.