""" Copyright 2008 Ben Sarsgard This file is part of ZedZed. ZedZed is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ZedZed is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ZedZed. If not, see . """ from pygame.sprite import Sprite from helpers import * class Item(object): def __init__(self, description, weight, image='item.png'): self.weight = weight self.description = description self.image_name = image self.image = load_image(image, -1) def GetName(self): return "%s (W:%i)" % (self.description, self.weight) def __getstate__(self): #return (self.weight, self.description, self.image_name) self.image = None return self.__dict__ def __setstate__(self, state): #self.weight, self.description, self.image_name = state self.__dict__.update(state) self.image = load_image(self.image_name, -1) class Weapon(Item): def __init__(self, description, weight, damage, accuracy, reach, volume, image='weapon.png'): Item.__init__(self, description, weight, image) self.damage = damage self.accuracy = accuracy self.reach = reach self.volume = volume def GetName(self): return "%s (W:%i/D:%i/A:%i)" % (self.description, self.weight, self.damage, self.accuracy) class LoadableWeapon(Weapon): def __init__(self, description, weight, damage, accuracy, reach, volume, caliber, image='weapon_ranged.png'): Weapon.__init__(self, description, weight, damage, accuracy, reach, volume, image) self.caliber = caliber class Ammunition(Item): def __init__(self, description, weight, caliber, quantity, image='ammo.png'): Item.__init__(self, description, weight, image) self.caliber = caliber self.quantity = quantity def GetName(self): return "%s x %i (W:%i)" % (self.description, self.quantity, self.weight) class Armor(Item): def __init__(self, description, weight, protection, image='armor.png'): Item.__init__(self, description, weight, image) self.protection = protection def GetName(self): return "%s (W:%i/P:%i)" % (self.description, self.weight, self.protection) class Food(Item): def __init__(self, description, weight, hunger, thirst, image='food.png'): Item.__init__(self, description, weight, image) self.hunger = hunger self.thirst = thirst def GetName(self): return "%s (W:%i/H:%i/T:%i)" % (self.description, self.weight, self.hunger, self.thirst)