예제 #1
0
파일: enemy.py 프로젝트: nhandler/cs429
 def to_json(self):
     '''
     Serialize the important members of this class as a json object
     '''
     json = CreatureSprite.to_json(self)
     json['health'] = self.health
     return json
예제 #2
0
파일: player.py 프로젝트: nhandler/cs429
    def to_json(self):
        '''
        Serialize the important members of this class as a json object
        '''

        json = CreatureSprite.to_json(self)
        json['health'] = self.health
        json['count'] = self.count
        json['wep_tier'] = self.weapon_tier
        json['inventory'] = {}
        for item, num in self.inventory.items():
            json['inventory'][item.name] = num
        json['final inventory'] = []
        for item in self.final_inventory:
            json['final inventory'].append(item.name)
        json["bullets"] = self.bullets
        json['lives'] = self.lives

        return json