コード例 #1
0
def create_ingame_screen(world, scheduler, end_game):
    """ Create entities for the ingame screen """
    sound_system = SoundSystem(
        {
            "furniture": "sound/furniture.ogg",
            "furniture-short": "sound/furniture-short.ogg",
            "bubble": "sound/pop.ogg",
            "wind": "sound/wind.ogg",
            "window": "sound/window.ogg",
            "cash-register": "sound/cash-register.ogg"
        }
    )

    create_room(world, sound_system)
    scenario_state = {}

    create_compartment(world, scenario_state)
    create_father(world, scenario_state)
    create_mother(world, scenario_state)
    create_burglar(world, scenario_state)
    create_bubble(world, scenario_state)

    create_building(world, scenario_state, sound_system)

    sky = create_sky_effect(
        world,
        (0, 0),
        (700, 550),
        300
    )

    scenario_state["sky"] = sky

    setup_animation(world, scheduler, end_game, scenario_state, sound_system)
コード例 #2
0
def add_room():
    rooms = roomTable.get_records()
    if len(rooms) == 0:
        room_id = 0
    else:
        room_id = rooms[len(rooms) - 1].room_id + 1
    room = create_room(room_id)
    roomTable.add_record(room)
    print("Operation Successful")
コード例 #3
0
ファイル: room_data.py プロジェクト: CseTitan/CseTitanHotel
def add_room():
    rooms = roomTable.get_records()
    if len(rooms) == 0:
        room_id = 0
    else:
        room_id = rooms[len(rooms) - 1].room_id + 1
    room = create_room(room_id)
    roomTable.add_record(room)
    print("Room Added")
コード例 #4
0
def add_room(database, cursor):
    room = create_room()
    query = "insert into {0}(room_no,floor,beds,available) values({1},'{2}',{3},{4})".\
            format(TABLE_NAME, room.room_no, room.floor, room.beds, room.available)
    try:
        cursor.execute(query)
        database.commit()
    except mysql.connector.Error as err:
        create_table(database)
        cursor.execute(query)
        database.commit()
    print("Operation Successful")
コード例 #5
0
def create_room_path():
    host_id = request.form["userID"]
    room_id = request.form["roomID"]
    context = Context(room_id=room_id, room_manager=room_manager, user=host_id)
    result = create_room(context)
    result_object = result.toDict()
    #Create URL to go alongside
    payload = {"url":"/room/{}".format(room_id), "users": [host_id]}
    result_object["payload"] = payload
    res = app.make_response(jsonify(result_object))
    res.set_cookie("roomID", room_id)
    res.set_cookie("userID", host_id)
    return res
コード例 #6
0
def create():
    if session.get('start') != None:
        return render_template('game_on.html')
    elif session.get('pwd') != None:
        userfile = session['userfile']
        users = open(userfile).read().split("\n")
        name = session['name']
        pwd = session['pwd']
        users = list(dict.fromkeys(users))
        try:
            users.remove('')
        except:
            pass
        return render_template("startgame.html",
                               name=name,
                               pwd=pwd,
                               users=users)
    elif request.method == "POST":
        if session.get('pwd') == None:
            session['user'] = request.form['user']
            user = session['user']
            name, pwd, userfile, numbersfile, winnerfile = create_room(user)
            users = open(userfile).read().split("\n")
            session['userfile'] = userfile
            session['numbersfile'] = numbersfile
            session['winnerfile'] = winnerfile
            session['name'] = name
            session['pwd'] = pwd
            users = list(dict.fromkeys(users))
            try:
                users.remove('')
            except:
                pass
        else:
            userfile = session['userfile']
            users = open(userfile).read().split("\n")
            name = session['name']
            pwd = session['pwd']
            users = list(dict.fromkeys(users))
            try:
                users.remove('')
            except:
                pass
        return render_template("startgame.html",
                               name=name,
                               pwd=pwd,
                               users=users)
    return render_template("create.html")
コード例 #7
0
ファイル: layouts.py プロジェクト: jtruscott/pyweek13
    def setup(self):
        #actually load the layout's rooms
        y = 0
        for row in self.map:
            room_row = []
            x = 0
            for col in row:
                filenames, prop = col
                if filenames is None:
                    room = None
                else:
                    room = create_room(random.choice(filenames), prop=prop)
                room_row.append(room)
                x += 1
            self.rooms.append(room_row)
            y += 1

        self.curr_room = self.rooms[self.start_y][self.start_x]
コード例 #8
0
ファイル: map.py プロジェクト: vwood/7drl
 def empty_room():
     "An empty room structure."
     this_room = [room.create_room(map), None, None, None, None]
     all_rooms.append(this_room)
     return this_room
コード例 #9
0
def analyze_rooms(rooms, boundary_location=1):
    """Convert revit rooms to dynosaur rooms.

    This script will only work from inside Dynamo nodes. for a similar script
    forRrevit check this link for more details:
    https://github.com/jeremytammik/SpatialElementGeometryCalculator/
        blob/master/SpatialElementGeometryCalculator/Command.cs
    """
    # unwrap room elements
    # this is not the right way of logging in python and probably any other language
    log = []
    rooms = tuple(_get_internalelement_collector(rooms))
    if not rooms:
        return []

    # create a spatial element calculator to calculate room data
    doc = rooms[0].Document
    options = SpatialElementBoundaryOptions()
    options.SpatialElementBoundaryLocation = get_boundary_location(boundary_location)
    calculator = SpatialElementGeometryCalculator(doc, options)

    opt = Options()
    element_collector = []
    room_collector = range(len(rooms))
    # surface_collector = {}  # collect hbSurfaces so I can set adjucent surfaces
    for room_count, revit_room in enumerate(rooms):
        # initiate zone based on room id
        element_collector.append([])
        new_room = room.create_room(revit_room.Id)

        # calculate spatial data for revit room
        revit_room_spatial_data = calculator.CalculateSpatialElementGeometry(revit_room)
        # get the geometry of the room
        revit_room_geometry = revit_room_spatial_data.GetGeometry()
        # Cast revit room faces to dynamo geometry using ToProtoType method
        room_faces_dyn = \
            tuple(face.ToProtoType()[0] for face in revit_room_geometry.Faces)

        assert revit_room_geometry.Faces.Size == len(room_faces_dyn), \
            "Number of rooms elements ({}) doesn't match number of faces ({}).\n" \
            "Make sure the Room is bounded.".format(revit_room_geometry.Faces.Size,
                                                    len(room_faces_dyn))

        for count, face in enumerate(revit_room_geometry.Faces):
            # base face is useful to project the openings to room boundary
            base_face_dyn = room_faces_dyn[count]

            # Revit is strange! if two roofs have a shared wall then it will be
            # duplicated! By checking the values inside the _collector I try to avoid
            # that.
            _collector = []

            boundary_faces = revit_room_spatial_data.GetBoundaryFaceInfo(face)

            if len(boundary_faces) == 0:
                # There is no boundary face! I don't know what does this exactly mean
                # in the Revit world but now that there is no boundary face we can just
                # use the dynamo face and create the surface!
                face_vertices = tuple(v.PointGeometry for v in base_face_dyn.Vertices)

                new_surface = surface.create_surface(
                    "%s_%s" % (new_room['name'], create_uuid()),
                    new_room['name'],
                    face_vertices
                )

                room.add_surface_to_room(new_room, new_surface)
                continue

            for boundary_face in boundary_faces:
                # boundary_face is a SpatialElementBoundarySubface
                # we need ti get the element (Wall, Roof, etc) first
                boundary_element = doc.GetElement(
                    boundary_face.SpatialBoundaryElement.HostElementId
                )

                # initiate honeybee surface
                face_vertices = tuple(v.PointGeometry for v in base_face_dyn.Vertices)

                # TODO(mostapha) This should be done once when all the surfaces are
                # created.
                if face_vertices in _collector:
                    continue

                new_surface = surface.create_surface(
                    "%s_%s" % (new_room['name'], boundary_element.Id),
                    new_room['name'],
                    face_vertices
                )

                # TODO(mostapha) This should be done once when all the surfaces are
                # created.
                _collector.append(face_vertices)

                # collect element id for each face.
                # this can be part of the object itself. I need to think about it before
                # adding it to the object. Trying to keep it as light as possible
                element_collector[room_count].append(doc.GetElement(
                    boundary_face.SpatialBoundaryElement.HostElementId
                ))

                # I'm not sure how this works in Revit but I assume there is an easy
                # way to find the adjacent surface for an element. Let's hope this time
                # revit doesn't let me down!
                # if boundary_element.Id not in surface_collector:
                #     surface_collector[boundary_element.Id] = new_surface
                # else:
                #     # TODO(mostapha): set adjacent surface
                #     pass
                # ----------------------- child surfaces --------------------------- #
                # time to find child surfaces (e.g. windows!)
                # this is the reason dynosaur exists in the first place

                # Take care of curtain wall systems
                # This will most likely fail for custom curtain walls
                if get_parameter(boundary_element, 'Family') == 'Curtain Wall':
                    # get cooredinates and element ids for this curtain wall.
                    _elementIds, _coordinates = extract_panels_vertices(
                        boundary_element, base_face_dyn, opt)

                    for count, coordinate in enumerate(_coordinates):
                        if not coordinate:
                            log.append("{} has an opening with less than "
                                       "two coordinates. It has been removed!"
                                       .format(_elementIds[count]))
                            continue

                        # create honeybee surface - use element id as the name
                        new_fen_surface = surface.create_fen_surface(
                            _elementIds[count],
                            new_surface['name'],
                            coordinate)

                        # get element and add it to the collector
                        elm = boundary_element.Document.GetElement(_elementIds[count])
                        element_collector[room_count].append(elm)

                        # add fenestration surface to base surface
                        surface.add_fenestration_to_surface(new_surface, new_fen_surface)
                else:
                    # collect child elements for non-curtain wall systems
                    childelement_collector = get_child_elemenets(boundary_element)

                    if childelement_collector:

                        _coordinates = exctract_glazing_vertices(
                            boundary_element,
                            base_face_dyn,
                            opt
                        )

                        for count, coordinate in enumerate(_coordinates):

                            if not coordinate:
                                log.append("{} in {} has an opening with less than "
                                           "two coordinates. It has been removed!"
                                           .format(
                                               childelement_collector[count].Id,
                                               new_room['name']
                                           ))

                            # create honeybee surface - use element id as the name
                            new_fen_surface = surface.create_fen_surface(
                                childelement_collector[count].Id,
                                new_room['name'],
                                coordinate
                            )

                            # add fenestration surface to base honeybee surface
                            element_collector[room_count].append(
                                childelement_collector[count]
                            )
                            # add fenestration surface to base surface
                            surface.add_fenestration_to_surface(new_surface,
                                                                new_fen_surface)

                # add surface to dynosaur room
                room.add_surface_to_room(new_room, new_surface)
                # clean up!
                boundary_element.Dispose()

        room_collector[room_count] = new_room

        # clean up!
        revit_room_spatial_data.Dispose()

    calculator.Dispose()
    return room_collector, element_collector, log