boundary cond

This commit is contained in:
Daniel Tsvetkov 2022-01-18 22:13:06 +01:00
parent be964567e6
commit 00c493e492
2 changed files with 3 additions and 3 deletions

4
app.py
View File

@ -9,7 +9,7 @@ from play import build_non_letter_hint, build_letter_hint
app = Flask(__name__) app = Flask(__name__)
app.config['SECRET_KEY'] = sensitive.SECRET_KEY app.config['SECRET_KEY'] = sensitive.SECRET_KEY
NUM_GAMES = 4593 NUM_GAMES = len(list(cat_words())) - 1
GUESS_SPLITTER = '|' GUESS_SPLITTER = '|'
STATE_PLAYING = 'PLAYING' STATE_PLAYING = 'PLAYING'
STATE_WIN = 'WIN' STATE_WIN = 'WIN'
@ -39,7 +39,7 @@ def init_random_game():
@app.route('/init/deterministic', methods=['post']) @app.route('/init/deterministic', methods=['post'])
def init_deterministic_game(): def init_deterministic_game():
game_id = request.form.get('game_id') game_id = request.form.get('game_id')
if not game_id.isdigit() or not 0 <= int(game_id) < NUM_GAMES: if not game_id.isdigit() or not 0 <= int(game_id) <= NUM_GAMES:
flash("game_id must be between 0 and {}".format(NUM_GAMES)) flash("game_id must be between 0 and {}".format(NUM_GAMES))
return redirect(url_for('home')) return redirect(url_for('home'))
return redirect(url_for('init_deterministic_game_id', game_id=game_id)) return redirect(url_for('init_deterministic_game_id', game_id=game_id))

View File

@ -2,7 +2,7 @@
{% block body %} {% block body %}
<a href="{{url_for('init_random_game')}}">Random game</a> <a href="{{url_for('init_random_game')}}">Random game</a>
<form method="post" action="{{url_for('init_deterministic_game')}}"> <form method="post" action="{{url_for('init_deterministic_game')}}">
<label>Predefined (0 to {{ num_games }})</label> <label>Deterministic (0 to {{ num_games }})</label>
<input type="number" min="0" max="{{ num_games }}" name="game_id" autofocus/> <input type="number" min="0" max="{{ num_games }}" name="game_id" autofocus/>
<input type="submit"> <input type="submit">
</form> </form>