diff --git a/flask/testapp/static/javascript/beautyVote.js b/flask/testapp/static/javascript/beautyVote.js index 1460e28..bc8fc98 100644 --- a/flask/testapp/static/javascript/beautyVote.js +++ b/flask/testapp/static/javascript/beautyVote.js @@ -53,6 +53,7 @@ switch(scene){ case START_SCENE: + case CAPASITY_ERROR: inputName(); break; @@ -241,7 +242,7 @@ xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { if(xhr.responseText == "Capasity ERROR"){ - scene = RESULT_SCENE; + scene = CAPASITY_ERROR; } else{ console.log("識別番号:" + xhr.responseText); @@ -305,7 +306,6 @@ } //正解選択肢を取得(選択が多い順に表示) else{ - timer = 0; console.log(xhr.responseText); answerTable = xhr.responseText var splitAnswer = answerTable.split("\n"); @@ -314,13 +314,13 @@ var arr_answer = splitAnswer[i].split(" "); question[round].answer[i] = arr_answer[0]; question[round].people[i] = arr_answer[1]; - } + } + //正解判定 + checkAnswer(); + timer = 0; + scene = ROUND_RESULT; } - //正解判定 - checkAnswer(); - timer = 0; - scene = ROUND_RESULT; } } } @@ -376,6 +376,7 @@ var WAIT_START = 6; // nemoto追記 var CHECK_RESULT = 7; var ROUND_RESULT = 8; +var CAPASITY_ERROR = 9; var scene = 0; diff --git a/flask/testapp/static/javascript/resultScreen.js b/flask/testapp/static/javascript/resultScreen.js index 591f1cf..bdb865d 100644 --- a/flask/testapp/static/javascript/resultScreen.js +++ b/flask/testapp/static/javascript/resultScreen.js @@ -2,8 +2,7 @@ fill("silver"); setAlp(50); fRect(50, 50, 855, 100, "black"); - fText("Q.", 110, 100, 50, "white"); - fRect(45, 295, 865, 560, "white"); + fRect(45, 295, 860, 560, "white"); fRect(50, 300, 400, 250, "black"); fRect(500, 300, 400, 250, "black"); fRect(50, 600, 400, 250, "black"); @@ -11,6 +10,8 @@ setAlp(100); + fText("Q.", 110, 100, 40, "white"); + fText("A.", 100, 425, 40, "white"); fText("B.", 550, 425, 40, "white"); fText("C.", 100, 725, 40, "white"); @@ -35,16 +36,20 @@ } if(scene == ROUND_RESULT){ fText(CheckPeople(0, round) +"人", 275, 425, 50, "black"); - fText(CHOICE_NUMBER-question[round].answer[A] + "Pt", 350, 500, 50, "black"); + fText(CHOICE_NUMBER-question[round].answer[A] + "Pt", 400, 500, 50, "black"); fText(CheckPeople(1, round)+"人", 725, 425, 50, "black"); fText(CHOICE_NUMBER-question[round].answer[B] + "Pt", 850, 500, 50, "black"); fText(CheckPeople(2, round)+"人", 275, 725, 50, "black"); - fText(CHOICE_NUMBER-question[round].answer[C] + "Pt", 350, 800, 50, "black"); + fText(CHOICE_NUMBER-question[round].answer[C] + "Pt", 400, 800, 50, "black"); fText(CheckPeople(3, round)+"人", 725, 725, 50, "black"); fText(CHOICE_NUMBER-question[round].answer[A] + "Pt", 850, 800, 50, "black"); } if(scene == WAIT_SCENE){ - fText("集計中...", 500, 500, 80, "black"); + setAlp(50); + fRect(200, 475, 560, 200, "#208") + sRect(200, 475, 560, 200, "black") + setAlp(100) + fText("集計中...", 500, 575, 80, "white"); } } @@ -53,16 +58,10 @@ fRect(50, 50, 855, 100, "black"); - fText("美人投票ゲーム", 480, 100, 80, "white"); setAlp(50); fText("あなたの名前を入力してください", 480, 200, 50, "black"); - fRect(200, 500, 560, 200, "black"); - sRect(200, 500, 560, 200, "blue"); - setAlp(100); - fText("ゲームに参加", 480, 600, 50, "white"); - setAlp(20); fRect(100, 800, 760, 300, "black"); setAlp(100); @@ -78,6 +77,16 @@ sendName(); } } + + if(scene == START_SCENE){ + fRect(200, 500, 560, 200, "black"); + sRect(200, 500, 560, 200, "blue"); + setAlp(100); + fText("ゲームに参加", 480, 600, 50, "white"); + } + if(scene == CAPASITY_ERROR){ + fTextN("次のゲームが始まるまで\nお待ちください...", 480, 500, 100, 50, "red"); + } } @@ -100,11 +109,11 @@ sRect(200, 580, 560, 200, "blue"); setAlp(100); fText("ゲーム開始!", 480, 680, 50, "white"); - if(tapC > 1){ + if(tapC == 1){ tapC ++; if(200 <= tapX && tapX <= 760 && 580 <= tapY && tapY <= 780){ sendStart(); - console.log("START"); + console.log("GAMESTART"); } } } diff --git a/flask/testapp/views.py b/flask/testapp/views.py index 54bb649..3be662b 100644 --- a/flask/testapp/views.py +++ b/flask/testapp/views.py @@ -7,7 +7,7 @@ user_score = {} # playerの数 -MAX_PLAYER = 2 +MAX_PLAYER = 30 WAIT_TIME = 40 @@ -42,7 +42,7 @@ @app.route("/form", methods=["GET", "POST"]) def index(): - global frequent_table, user_number, data_count, order_table, most_common_option, max_order, current_player, start, end + global frequent_table, user_number, data_count, order_table, most_common_option, max_order, current_player, start, end, start_flag if request.method == "GET": return render_template("testapp/index.html") @@ -52,7 +52,7 @@ if request.form.get("username"): # ユーザー名を取得し,ユーザー情報を登録 username = request.form.get("username") - if user_number >= MAX_PLAYER: + if user_number >= MAX_PLAYER or start_flag: return "Capasity ERROR" user[user_number] = username @@ -66,23 +66,16 @@ # 他のplayerが揃うのを待機(nemoto追記) if request.form.get("checkStart"): - if user_number >= MAX_PLAYER or startFlag: + if user_number >= MAX_PLAYER or start_flag: + start = time.time() return "START" # 全員のデータが集まった場合は,ゲーム開始 else: return str(MAX_PLAYER) + " " + str(user_number) - + # 他のplayerが揃うのを待機(nemoto追記) if request.form.get("start"): - print(request.form.get("start")) - if user_number < MAX_PLAYER: - return str(MAX_PLAYER) + " " + str(user_number) - # 全員のデータが集まった場合は,ゲーム開始 - else: - start = time.time() - # print(f"START: {start}") - return "START" - + start_flag = True # ゲーム中に選択肢を取得し,集計する if request.form.get("choice"): @@ -90,21 +83,14 @@ choices.clear() choices.append(request.form.get("choice")) print("Received choice:", choices) - """ - if len(choices) >= current_player: - frequent_table = calculate_majority(choices) - return "WAIT - """ # 他の人が終わるまで待機 if request.form.get("checkothers"): end = time.time() - # print(f"END: {end}") print(f"TIME: {end-start}") if len(choices) >= current_player or end - start > WAIT_TIME: start = time.time() current_player = len(choices) - # print(f"START: {start}") print(f"現在の参加人数:{current_player}") return calculate_majority(choices) else: @@ -144,6 +130,7 @@ return "WAIT" else: user_number = 0 + start_flag = False return order_table return "WAIT"