Exemple #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))
Exemple #2
0
    def status(self):
        self.population.show_status()

        for r in self.resources:
            say('%s: %s' % (r.capitalize(), self.resources[r]))

        say("Current day: %s" % (self.current_day))
Exemple #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']))
Exemple #4
0
    def show_buildings(self):

        if len(self.buildings) == 0:
            say('There is not a single building. Let\'s create a new one')
        buildings_to_show = {}
        for b in self.available_buildings:
            buildings_to_show[b.type] = 0
        for b in self.buildings:
            buildings_to_show[b.type] = buildings_to_show[b.type] + 1

        for b in buildings_to_show:
            if buildings_to_show[b] == 1:
                say('%s (only %s building)' % (b, buildings_to_show[b]))
            elif buildings_to_show[b] > 1:
                say('%s (%s buildings)' % (b, buildings_to_show[b]))
Exemple #5
0
 def increase_limit(self, increment):
     self.limit = self.limit + increment
     say("Your population limit increased in %s units" % (increment,))
Exemple #6
0
 def show_status(self):
     say('Population: %s/%s' % (self.current, self.limit,))
Exemple #7
0
def test():
    # Method is handled before. So that line is not executed
    say("Test commands works!")
Exemple #8
0
import txtgamelib

from txtgamelib import when, say

@when('test')
def test():
    # Method is handled before. So that line is not executed
    say("Test commands works!")

say('Testing say')

txtgamelib.start()

Exemple #9
0
def toggle_debug():
    gameData.toggle_debug()
    say('Debug mode is %s' % (gameData.debug_mode, ))
Exemple #10
0
def show_buildings():
    gameData.show_buildings()


@when('workers')
def show_workers():
    gameData.show_workers()


@when('build list')
def list_what_can_be_built():
    gameData.show_what_can_be_built()


@when('build BUILDING')
def create_building(building):
    gameData.create_building(building)


@when('debug toggle')
def toggle_debug():
    gameData.toggle_debug()
    say('Debug mode is %s' % (gameData.debug_mode, ))


say('Try to build a great empire')

gameData.add_workers()
gameData.start_update_loop()
txtgamelib.start()
Exemple #11
0
 def show_what_can_be_built(self):
     say('You can build:')
     index = 0
     for b in self.available_buildings:
         say('%s - %s' % (index, b.name))
         index = index + 1
Exemple #12
0
 def show_workers(self):
     say('workers: %s' % (self.total_workers, ))
Exemple #13
0
 def pay_cost(self, cost):
     for c in cost:
         say('You spend %s %s' % (cost[c], c))
         self.resources[c] = self.resources[c] - cost[c]