Пример #1
0
    def BuildBuilding(self, tile, building):
        from buildings import Building
        from city import city

        newBuilding = Building(building, tile)
        tile.AddBuilding(newBuilding)
        newBuilding.SelfBitmasking()
        self.CalculateLandValue()
        self.FindValidRoadTiles()
        self.FindValidBuildingSpots()
        city.bank -= building.cost
Пример #2
0
def drawNewBuilding(x, theScore):
    global buildingList, objectList, scrollSpeed, bomb, walls, pigeonList

    startX = x
    startY = random.getrandbits(5) + 30
    if startY > 70:
        startY = 70

    wallId = random.getrandbits(3) + 1

    if wallId > 3:
        wallId = 3

    buildingLength = ((random.getrandbits(3) + 1) * 3) + 2
    if buildingLength < 10:
        buildingLength = 10
        wallId = 0

    spacing = random.getrandbits(2) + 1

    # Do we need birds
    if buildingLength > 15 and random.getrandbits(7) > 100:
        ctr = 4
        for bird in pigeonList:
            bird.reset(startX + ctr + 20 + (spacing * 8), startY - 6)
            ctr += 7

    floorId = random.getrandbits(3)
    if floorId > 3:
        floorId = 3

    # Create a box or bomb if building is long enough and not the first building
    if theScore > 100:
        # Don't do this on first building
        if x != 0:
            objType = random.getrandbits(1)

            if buildingLength > 15:
                if random.getrandbits(3) > 5:
                    # Crate
                    if objType == 0:
                        objectList.append(
                            Object(blocks, startX + (buildingLength * 8) // 2,
                                   startY, objType, 14, 14))

                    # Bomb
                    else:
                        objectList.append(
                            Object(bomb, startX + ((buildingLength - 3) * 8),
                                   startY, objType, 18, 11))

    windowId = random.getrandbits(1)

    if x == 0:
        spacing = 0

    buildingList.append(
        Building(startX, startY, buildingLength, spacing, floorId, wallId,
                 windowId))
Пример #3
0
    def extractBuildings(self, propertyid):
        bldg_list = Building.extract(propertyid)
        self.buildings = bldg_list

        get_details = True
        if get_details:
            for b in bldg_list:
                b.extractBuildingDetails()
Пример #4
0
def init():
    """ Init game """
    os.system('cls')
    print("\n====================")
    print("Welcome to LE HAVRE!")
    print("====================")
    random.shuffle(game_state.bases)  # shuffle bases

    # print("Add Players")
    # player_count = 2  # int(input("Enter total player count (1-5): "))
    # ai_count = 1 # int(input("Enter AI player count: "))
    # for i in range(0, player_count - ai_count):
    #     pname = input("P" + str(i+1) + " name: ")
    game_state.players.append(Player.create_player("Marvel"))
    # for i in range(0, ai_count):
    game_state.players.append((Player.create_player("AI")))
    Building.setup_offers(game_state)
    Ship.setup_rounds(game_state)
Пример #5
0
 def build_building(self, building_type):
     if self.has_resources(building_type):
         building_id = data_service.build_building_with_resources(
             self.user_id, building_type, BUILDING_CONFIG[building_type]['cost'])
         self.apply_cost(BUILDING_CONFIG[building_type]['cost'])
         new_building_specs = data_service.get_one_building(building_id)
         self.buildings.append(Building(**new_building_specs))
     else:
         print('Not enough resources!')
Пример #6
0
 def set_buildings(self, cell, biome):
     if (len(cell.trees) + len(cell.bushes)
             == 0) and rnd(1) < biome.building_freq:
         cell.building = Building(
             myrange(self.config.buildings_w_range),
             myrange(self.config.buildings_h_range),
             Vec2(self.cell_size / 2, self.cell_size / 2),
             myrange(self.config.buildings_height_range),
             self.config.buildings_colours[flr(rnd(16)) % len(
                 self.config.buildings_colours)])
Пример #7
0
    def businessTurnOver(self):
        for hold in self.holdings:
            self.credit = hold.sellProduce(self.credit)
            self.credit = hold.buyProduce(self.credit)

        if (self.credit > 5000):
            self.holdings.append(Building())
            print("new building: {}".format(self.holdings[-1].product))
            self.credit -= 5000
        self.actShare = int((self.credit + (len(self.holdings)-2) * 5000)/100)
        self.currentShare = int((self.actShare - self.currentShare) /2)
Пример #8
0
 def __init__(self):
     ShowBase.__init__(self)
     self.setBackgroundColor(0.8, 0.8, 0.8)
     fog = Fog("Fog Name")
     fog.setColor(0.6, 0.6, 0.6)
     fog.setExpDensity(0.001)
     self.render.setFog(fog)
     # Terrain
     terarin = Terrain()
     nodePath = self.render.attachNewNode(terarin.node())
     # Landmarks
     landmarks = Landmarks(8000, 2.5 / 1000000)
     nodePath = self.render.attachNewNode(landmarks.node())
     nodePath.setRenderModeThickness(1)
     # Box
     for i in range(50):
         x, y = random_in_circle()
         x *= 5000
         y *= 5000
         z = elevation(x, y) - 10
         border = (
             Vec3(x, y, z),
             Vec3(x, y + 50.0, z),
             Vec3(x + 50.0, y + 50.0, z),
             Vec3(x + 50.0, y, z),
         )
         tops = [i * 2.5 for i in range(int(40 + random() * 60))]
         building = Building(border=border, tops=tops)
         nodePath = self.render.attachNewNode(building.node())
         nodePath.setTwoSided(True)
     self.disableMouse()
     self.taskMgr.add(self.camera_task, "CameraTask")
     self.height = 100
     self.accept('wheel_up', self.wheel_up)
     self.accept('wheel_down', self.wheel_down)
     self.accept('w-repeat', self.advance)
     # self.accept('a', self.left)
     self.accept('s-repeat', self.retreat)
     # self.accept('d', self.right)
     self.position = Vec3(0.0, 0.0, 0.0)
     self.movement = Vec3(0.0, 0.0, 2.0)
Пример #9
0
    def __init__(self):
        logging.info('Initializing pygame')
        pygame.init()
        with open('settings.yaml') as f:
            self.settings = yaml.load(f)
        self.get_screen()
        self.clock = pygame.time.Clock()
        self.fps = self.settings['fps']
        self.console = Console()

        self.fonts = {'console.font': pygame.font.Font(None, 28)}

        self.buildings = [Building(self.settings, 'warehouse', (0, 0))]
        self.connections = []

        self.run()
Пример #10
0
 def __init__(self):
     self.holdings = [Building(),Building()]
     self.credit = 100
     self.currentShare = int(self.credit/1000)
     self.actShare = int(self.credit/1000)
Пример #11
0
def parse_buildings_from_lines(lines):
    for line in lines:
        columns = line.split("\t")
        number, name, abbreviation = columns[0], columns[1], columns[2]
        yield Building(int(number), name, abbreviation)
Пример #12
0
from buildings import Building


class City:
    def __init__(self, name, mayor, year_est, all_buildings):
        self.name = name
        self.mayor = mayor
        self.year_est = year_est
        self.all_buildings = list()

    def new_building(self):
        self.all_buildings.append()


building_1 = Building("101 Avenue", "5")
building_2 = Building("102 Avenue", "6")
building_3 = Building("103 Avenue", "7")
building_4 = Building("104 Avenue", "8")
building_5 = Building("105 Avenue", "9")
Пример #13
0
    def load_building(building_spec):

        return Building(**building_spec)