Пример #1
0
    def gather(self, resource, place, num_people):
        logsystem.log("gather resource %s at %s with %s people" %
                      (resource, place, num_people))

        if self.gathering.can_gather(resource, place, num_people, self):
            self.gathering.assign_people(resource, place, num_people, self)
            say('%s people starts to gather %s' % (num_people, resource))
Пример #2
0
 def add_new_people(self, total_new_people):
     if self.current + total_new_people <= self.limit:
         for p in range(0, total_new_people):
             new_person = Person()
             new_person.name = "Person_" + str(self.current + p + 1)
             self.people.append(new_person)
         self.current = self.current + total_new_people
         logsystem.log('New people just arrived: your population incremented in %s' % (total_new_people,) )
Пример #3
0
    def build(self, building_obj):
        b = building_obj
        if self.verify_cost(b.cost):
            self.pay_cost(b.cost)

            logsystem.log('create_building - lets create a ' + b.name)
            new_building = b.create_new(self)
            self.buildings.append(new_building)
            say('You %s building is ready!' % (new_building.type))
        else:
            say("You don't have %s gold" % (b.cost['gold']))
Пример #4
0
    def create_building(self, building_name):
        logsystem.log('debug: create_building - ' + building_name)

        if utils.is_int(building_name):
            b = self.available_buildings[int(building_name)]
            self.build(b)
            return

        for b in self.available_buildings:
            if b.name.lower() == building_name.lower():
                self.build(b)
                return
Пример #5
0
    def world_update(self, game_data):
        self.verify_new_people(game_data)

        total_meat_consumption_day = 0

        for p in self.people:
            # Activity
            if p.current_activity is not None:
                p.current_activity(p)

            # Consumption
            consumption_day = 0
            if p.state == 'idle':
                consumption_day = 0.1 * random.randint(5, 10)
            else:
                consumption_day = 0.15 * random.randint(5, 10)

            total_meat_consumption_day += consumption_day
            game_data.resources["meat"] -= consumption_day

        logsystem.log("people consumed %f meat today" % (total_meat_consumption_day,))
Пример #6
0
    def world_update(self):
        self.population.world_update(self)
        self.gathering.world_update(self)
        logsystem.log('World Update!')

        self.current_day += 1