diff --git a/flask/testapp/static/javascript/beautyVote.js b/flask/testapp/static/javascript/beautyVote.js index e079349..a9caaed 100644 --- a/flask/testapp/static/javascript/beautyVote.js +++ b/flask/testapp/static/javascript/beautyVote.js @@ -195,14 +195,6 @@ console.log(xhr.responseText); scene = CAPASITY_ERROR } - else{ - var get_players_information = xhr.responseText - var get_split_players_information = get_players_information.split(" "); - sent_player = get_split_players_information[0] - round_player = get_split_players_information[1] - console.log("送った人数" + sent_player); - console.log("現在のラウンドの全プレイヤー" + round_player) - } } } } @@ -275,26 +267,31 @@ xhr.send('checkothers=' + "check"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { - if(xhr.responseText=="WAIT"){ - console.log(xhr.responseText); + console.log(xhr.responseText); + answerTable = xhr.responseText + var splitAnswer = answerTable.split("\n"); + // 送信した人数の進捗の把握 + if((splitAnswer.length)!=CHOICE_NUMBER) + { + sent_player = splitAnswer[0]; + round_player = splitAnswer[1]; + console.log(sent_player) + console.log(round_player) } - //正解選択肢を取得(選択が多い順に表示) else{ - console.log(xhr.responseText); - answerTable = xhr.responseText - var splitAnswer = answerTable.split("\n"); for(var i = 0; i < CHOICE_NUMBER; i ++){ // i番目に多かった答えと人数 var arr_answer = splitAnswer[i].split(" "); question[round].answer[i] = arr_answer[0]; question[round].people[i] = arr_answer[1]; - } + } + sent_player = " "; + round_player = " "; //正解判定 checkAnswer(); timer = 0; scene = ROUND_RESULT; } - } } } @@ -348,8 +345,8 @@ var max_player = 0; // 最大のplayer数(変更不要) var current_player = 0; -var sent_player = 0; // 各ラウンドで、答えを送信した人数 -var round_player = 0; // 各ラウンドでの参加人数 +var sent_player = " "; // 各ラウンドで、答えを送信した人数 +var round_player = " "; // 各ラウンドでの参加人数 var timer = 0; var TIME_LIMIT = 900; diff --git a/flask/testapp/views.py b/flask/testapp/views.py index a8e04c3..64d39d7 100644 --- a/flask/testapp/views.py +++ b/flask/testapp/views.py @@ -107,7 +107,6 @@ if int(request.form.get("round")) == current_round: choices.append(request.form.get("choice")) print(f"Received choice:{choices} Round:{current_round+1}") - return str(len(choices)) + " " + str(current_player) else: return "FAILED" @@ -120,8 +119,8 @@ current_player = len(choices) print(f"現在の参加人数:{current_player}") return calculate_majority(choices) - else: - return "WAIT" + else: # 進捗を送信 + return str(len(choices)) + "\n" + str(current_player) # ゲーム終了時,識別番号とスコアを受け取る if request.form.get("number") and request.form.get("score"):