diff --git a/flask/testapp/static/javascript/beautyVote.js b/flask/testapp/static/javascript/beautyVote.js index 9c8e239..6c1ab9f 100644 --- a/flask/testapp/static/javascript/beautyVote.js +++ b/flask/testapp/static/javascript/beautyVote.js @@ -24,6 +24,7 @@ constructor(){ this.points = Array(MAX_ROUND).fill(0); this.choice = 0; + this.score = 0; this.name = 0; this.number = 0; } @@ -41,6 +42,7 @@ canvasSize(960, 1200); lineW(3); timer = 0; + scene = START_SCENE; setQuestion(round); } @@ -97,7 +99,7 @@ //集計結果待ち case WAIT_SCENE: - WaitOthers() // 他のプレイヤーが終わるまで待機する画面 + showQuestion(); if(timer > 30){ timer = 0; CheckOthers(); // 他のプレイヤーが終わるまで待機する処理 @@ -105,10 +107,18 @@ break; case ROUND_RESULT: - showOtherResult(round-1); - if(timer > 30){ + showQuestion(); + if(timer > 90){ timer = 0; - scene = GAME_SCENE; + round ++; + if(round < MAX_ROUND){ + setQuestion(round); + scene = GAME_SCENE; + } + else{ + scene = WAIT_RESULT; + postForm(); + } } break; @@ -166,6 +176,7 @@ } + function setQuestion(round){ question[round].join(questions[round], realAnswer[round],choices[round][A], choices[round][B], choices[round][C], choices[round][D]); } @@ -191,12 +202,8 @@ break; } } - - round ++; + player.score = player.calcScore(); console.log(player.points[round]) - if(round < MAX_ROUND){ - setQuestion(round); - } } //スコアと識別番号をサーバーに送信する処理 @@ -204,7 +211,7 @@ xhr.open('POST', '/form'); xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); //識別番号とスコアを送信 - xhr.send('number='+player.number + '&score=' + player.calcScore()); //変更 + xhr.send('number='+player.number + '&score=' + player.score); //変更 } //選択をサーバーに送信する処理 @@ -293,20 +300,12 @@ question[round].answer[i] = arr_answer[0]; question[round].people[i] = arr_answer[1]; } - - //正解判定 - checkAnswer(); - timer = 0; - if(round < MAX_ROUND){ - scene = ROUND_RESULT; - //scene = GAME_SCENE; - } - //最終ラウンド終了時 - else{ - scene = WAIT_RESULT; - postForm(); - } } + + //正解判定 + checkAnswer(); + timer = 0; + scene = ROUND_RESULT; } } } @@ -363,7 +362,7 @@ var CHECK_RESULT = 7; var ROUND_RESULT = 8; -var scene = START_SCENE; +var scene = 0; var orderTable = ""; diff --git a/flask/testapp/static/javascript/resultScreen.js b/flask/testapp/static/javascript/resultScreen.js index bf48971..99158e1 100644 --- a/flask/testapp/static/javascript/resultScreen.js +++ b/flask/testapp/static/javascript/resultScreen.js @@ -9,8 +9,6 @@ fRect(50, 600, 400, 250, "black"); fRect(500, 600, 400, 250, "black"); - sRect(45, 880, 865, 40, "black"); - fRect(45, 880, (timer/900)*865, 40, "red"); setAlp(100); fText("A.", 100, 425, 40, "white"); @@ -24,22 +22,30 @@ fText(question[round].choiceC, 275, 725, 25, "white"); fText(question[round].choiceD, 725, 725, 25, "white"); - fText(int(timer/30), 900, 1100, 50, "red"); - - setAlp(50); fText((round+1) + "回戦", 100, 1000, 50, "red"); - for(var i = 0; i < MAX_ROUND; i ++){ - if(player.points[i] == CORRECT){ - fText("O", 480 + 50*i, 1000, 50, "red"); - } - else if(player.points[i] == WRONG) { - fText("X", 480 + 50*i, 1000, 50, "blue"); - } - else{ - fText("*", 480 + 50*i, 1000, 50, "black"); - } + fText("現在の点数: " + player.score + " Pt", 700, 1000, 50, "black"); + + if(scene == GAME_SCENE){ + setAlp(50); + sRect(45, 880, 865, 40, "black"); + fRect(45, 880, (timer/900)*865, 40, "red"); + setAlp(100); + fText(int(timer/30), 900, 1100, 50, "red"); } + 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(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(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"); + } } function inputName(){ @@ -81,7 +87,6 @@ fRect(50, 50, 855, 100, "black"); - fText("美人投票ゲーム", 480, 100, 80, "white"); setAlp(50); fText("あなたの名前を入力してください", 480, 200, 50, "black"); @@ -97,29 +102,6 @@ fTextN("ルール1\nルール2\nルール3\nルール4", 480, 950, 200, 50, "white"); } -// 他のプレイヤーの終わりを待つ画面(nemoto変更) -function WaitOthers(){ - fill("silver"); - setAlp(50); - fRect(50, 50, 855, 100, "black"); - fText("Q.", 110, 100, 50, "white"); - fRect(45, 295, 865, 560, "white"); - fRect(50, 300, 400, 250, "black"); - fRect(500, 300, 400, 250, "black"); - fRect(50, 600, 400, 250, "black"); - fRect(500, 600, 400, 250, "black"); - - sRect(45, 880, 865, 40, "black"); - fRect(45, 880, (timer/900)*865, 40, "red"); - setAlp(100); - - fText("A.", 100, 425, 40, "white"); - fText("B.", 550, 425, 40, "white"); - fText("C.", 100, 725, 40, "white"); - fText("D.", 550, 725, 40, "white"); - fText("集計中...", 500, 500, 80, "black"); -} - function showResult(){ fill("silver"); setAlp(50); @@ -132,9 +114,7 @@ fText("スコア", 730, 410, 50, "black"); if(scene == RESULT_SCENE){ - fText(player.name+"さんのスコアは" + player.calcScore() + "点です!", 480, 200, 50, "gold"); - // fTextN(orderTable, 500, 770, 600, 50, "silver"); - + fText(player.name+"さんのスコアは" + player.calcScore() + "点です!", 480, 200, 50, "gold"); let splitOrder = orderTable.split("\n"); for (var i = 0; i < splitOrder.length; i++){ let arr = splitOrder[i].split(" "); // 空白で文字列を分割 @@ -160,57 +140,7 @@ } } - -// 他の設問の結果発表(nemoto追記) -function showOtherResult(show_round){ - - fill("silver"); - setAlp(50); - fRect(50, 50, 855, 100, "black"); - fText("Q.", 110, 100, 50, "white"); - fRect(45, 295, 865, 560, "white"); - fRect(50, 300, 400, 250, "black"); - fRect(500, 300, 400, 250, "black"); - fRect(50, 600, 400, 250, "black"); - fRect(500, 600, 400, 250, "black"); - - setAlp(100); - - fText("A.", 100, 425, 40, "white"); - fText("B.", 550, 425, 40, "white"); - fText("C.", 100, 725, 40, "white"); - fText("D.", 550, 725, 40, "white"); - - fText(question[show_round].question, 480, 100, 30, "white"); - fText(question[show_round].choiceA, 275, 425, 25, "white"); - fText(CheckPeople(0, show_round) +"人", 275, 425, 50, "black"); - - fText(CheckPeople(0, show_round) +"人", 275, 425, 50, "black"); - - fText(question[show_round].choiceB, 725, 425, 25, "white"); - fText(CheckPeople(1, show_round)+"人", 725, 425, 50, "black"); - - fText(question[show_round].choiceC, 275, 725, 25, "white"); - fText(CheckPeople(2, show_round)+"人", 275, 725, 50, "black"); - - fText(question[show_round].choiceD, 725, 725, 25, "white"); - fText(CheckPeople(3, show_round)+"人", 725, 725, 50, "black"); - - setAlp(50); - - fText("結果", 100, 1100, 50, "black"); - for(var i = 0; i < MAX_ROUND; i ++){ - if(i == show_round){ - fText((i+1), 480 + 50*i, 1100, 50, "red"); - } - else{ - fText((i+1), 480 + 50*i, 1100, 50, "black"); - } - } -} - function CheckPeople(i, show_round){ - let question_values = [int(question[show_round].answer[0]), int(question[show_round].answer[1]), int(question[show_round].answer[2]), int(question[show_round].answer[3])] let people_values = [int(question[show_round].people[0]), int(question[show_round].people[1]), int(question[show_round].people[2]), int(question[show_round].people[3])] let index = question_values.indexOf(i); diff --git a/flask/testapp/views.py b/flask/testapp/views.py index d21ecfe..b23a65d 100644 --- a/flask/testapp/views.py +++ b/flask/testapp/views.py @@ -9,7 +9,7 @@ # playerの数 MAX_PLAYER = 2 -WAIT_TIME = 35 +WAIT_TIME = 40 # 何位まで表示するか(nemoto) max_order = 5 @@ -132,6 +132,7 @@ if order_table == "": return "WAIT" else: + user_number = 0 return order_table return "WAIT"