コード例 #1
0
def game():
    room_name = session.get('room_name')
    if request.method == "GET":
        if room_name:
            room = planisphere.load_room(room_name)
            return render_template("show_room.html", room=room)
        else:
            #why is there here? do you need it?
            return render_template("you_died.html")
    else:
        action = request.form.get('action')
        print(f"action={action}")
        if room_name and action:
            room = planisphere.load_room(room_name)
            next_room = room.go(action)
            print(f"next_room={next_room}")
            if not next_room:
                try:
                    print(f"room.retryAttemptsLimit={room.retryAttemptsLimit}")
                    print(f"room.retryAttempts={room.retryAttempts}")
                    if int(room.retryAttemptsLimit) < room.retryAttempts:
                        if room.deathOnFailure:
                            return render_template("you_died.html")
                    else:
                        room.retryAttempts = int(room.retryAttempts) + 1
                except:
                    pass
                session['room_name'] = planisphere.name_room(room)
            else:
                session['room_name'] = planisphere.name_room(next_room)
        return redirect(url_for("game"))
コード例 #2
0
ファイル: app.py プロジェクト: ojalatodd/gothonweb
def game():
    room_name = session.get('room_name')

    if request.method == "GET":
        if room_name:
            room = planisphere.load_room(room_name)
            help = session['help']
            session['help'] = False
            return render_template("show_room.html", room=room, help=help)
        else:
            # why is this here? do you need it?
            return render_template("you_died.html")
    else:
        action = request.form.get('action')
        next_room = None

        if room_name and action:
            room = planisphere.load_room(room_name)
            if action == 'help':
                session['help'] = True
            else:
                next_room = room.go(action)

            if not next_room:
                session['room_name'] = planisphere.name_room(room)
                #return room_name
            else:
                session['room_name'] = planisphere.name_room(next_room)

            return redirect(url_for("game"))
コード例 #3
0
def game():
    room_name = session.get('room_name')

    if request.method == "GET":
        if room_name:
            room = planisphere.load_room(room_name)
            return render_template("show_room.html", room=room)
        else:
            # why is this here? do you need it?
            return render_template("show_death.html")
    else:
        action = request.form.get('action')

        if room_name and action:
            room = planisphere.load_room(room_name)
            next_room = room.go(action)

            if not next_room and room.name == "Laser Weapon Armory":
                if room.iters < 9:
                    print("room.iters is: " + str(room.iters))
                    room.iters = room.iters + 1
                    next_room = None
                else:
                    next_room = room.go('*')
            elif not next_room:
                next_room = room.go('*')


            if not next_room:
                session['room_name'] = planisphere.name_room(room)
            else:
                session['room_name'] = planisphere.name_room(next_room)

        return redirect(url_for("game")) # to create a loop
コード例 #4
0
ファイル: app.py プロジェクト: leprechaunne/Python
def game():
	room_name = session.get('room_name')

	if request.method == "GET":
		if room_name and room_name != "generic_death":
			room = planisphere.load_room(room_name)
			return render_template("show_room.html", room=room)
		else:
			""" if not GET is passed, player died or a bug occured """
			return render_template("you_died.html")
	else:
		action = request.form.get('action')

		if room_name and action:
			room = planisphere.load_room(room_name)
			next_room = room.go(action)

			if not next_room:
				session['room_name'] = planisphere.name_room(next_room)
			else:
				session['room_name'] = planisphere.name_room(next_room)
		return redirect(url_for("game"))
コード例 #5
0
ファイル: app.py プロジェクト: HMBaytam/python
def game():
    room_name = session.get('room_name')

    if request.method == 'GET':
        if room_name:
            room = planisphere.load_room(room_name)
            return render_template('show_room.html', room=room)
        else:
            return render_template('you_died.html')
    else:
        action = request.form.get('action')

        if room_name and action:
            room = planisphere.load_room(room_name)
            next_room = room.go(action)

            if not next_room:
                session['room_name'] = planisphere.name_room(room)
            else:
                session['room_name'] = planisphere.name_room(next_room)

            return redirect(url_for('game'))
コード例 #6
0
def game():
    room_name = session.get('room_name')
    if not room_name:
        redirect(url_for('index'))
    else:
        if "ru" in room_name:
            map = planisphere_ru.rooms
        else:
            map = planisphere.rooms

    if request.method == 'GET':
        if room_name:
            room = planisphere.load_room(map, room_name)
            return render_template("show_room.html", room=room)
        else:
            return redirect(url_for('index'))
    else:
        action = request.form.get('action')

        if room_name and action:
            room = planisphere.load_room(map, room_name)
            next_room = room.go(action)

            if not next_room:
                session['room_name'] = planisphere.name_room(map, room)
            else:
                session['room_name'] = planisphere.name_room(map, next_room)
                if 'generic_death' not in planisphere.name_room(
                        map, next_room):
                    user = User.query.filter_by(
                        username=current_user.username).first()
                    if 'the_end_winner' not in planisphere.name_room(
                            map, next_room):
                        user.score += 10
                    else:
                        user.score += 100
                    db.session.commit()
        return redirect(url_for("game"))
コード例 #7
0
def game():
    room_name = session.get('room_name')

    if request.method == "GET":
        if room_name:
            room = planisphere.load_room(room_name)
            return render_template("show_room.html", room=room)
        else:
            # why is there here? do you need it?
            return render_template('you_died.html')
    else:
        action = request.form.get('action')

        if room_name and action:
            room = planisphere.load_room(room_name)
            next_room = room.go(action)

            if not next_room:
                session['room_name'] = planisphere.name_room(room)
            else:
                session['room_name'] = planisphere.name_room(next_room)

        return redirect(url_for("game"))