diff --git a/flask/testapp/static/javascript/beautyVote.js b/flask/testapp/static/javascript/beautyVote.js index 7f515d9..f66b235 100644 --- a/flask/testapp/static/javascript/beautyVote.js +++ b/flask/testapp/static/javascript/beautyVote.js @@ -126,8 +126,45 @@ //結果表示 case RESULT_SCENE: showResult(); + if(tapC == 1){ + tapC ++; + if(80 <= tapX && tapX <= 180 && 1080 <= tapY && tapY <= 1130){ + console.log("show result") + break; + } + else{ + for(var i = 0; i < MAX_ROUND; i ++){ + if(450 + 50*i < tapX && tapX < 450 + 50*i + 50 && 1080 < tapY && tapY < 1130){ + console.log("show round"+i) + showOtherResult(i) + view_result = i + scene = CHEAK_RESUlT + } + } + } + } break; - + + case CHEAK_RESUlT: + showOtherResult(view_result); + if(tapC == 1){ + tapC ++; + if(80 <= tapX && tapX <= 180 && 1080 <= tapY && tapY <= 1130){ + showResult(); + console.log("show result") + scene = RESULT_SCENE; + } + else{ + for(var i = 0; i < MAX_ROUND; i ++){ + if(450 + 50*i <= tapX && tapX <= 450 + 50*i + 50 && 1080 <= tapY && tapY <= 1130){ + showOtherResult(i) + console.log("show round"+(i+1)) + view_result = i + } + } + } + } + break; } } @@ -324,6 +361,7 @@ var WAIT_SCENE = 4; // nemoto追記 var WAIT_RESULT = 5; var WAIT_START = 6; // nemoto追記 +var CHEAK_RESUlT = 7; var scene = START_SCENE; @@ -367,4 +405,6 @@ ["ハサミの刃", "貝の殻", "栗の実", "両手"], ["そら豆", "えんどう豆", "いんげん豆", "ひよこ豆"], ["エレファント", "ホエール", "ダイナソー", "メガ"], - ["カニ", "ナマコ", "タコ", "ホタテ"]]; \ No newline at end of file + ["カニ", "ナマコ", "タコ", "ホタテ"]]; + +var view_result = 0; \ No newline at end of file diff --git a/flask/testapp/static/javascript/resultScreen.js b/flask/testapp/static/javascript/resultScreen.js index dd9d573..57e1007 100644 --- a/flask/testapp/static/javascript/resultScreen.js +++ b/flask/testapp/static/javascript/resultScreen.js @@ -42,42 +42,6 @@ } } -function showResult(){ - fill("silver"); - setAlp(50); - fRect(50, 50, 855, 100, "black"); - fText("結果発表 ", 480, 100, 80, "white"); - - fRect(45, 370, 865, 700, "white"); - fText("順位", 150, 410, 50, "black"); - fText("ユーザー名", 390, 410, 50, "black"); - 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"); - - let splitOrder = orderTable.split("\n"); - for (var i = 0; i < splitOrder.length; i++){ - let arr = splitOrder[i].split(" "); // 空白で文字列を分割 - if(arr[0]=="1位"){ - fText(arr[0], 150, 480+60*i, 50, "gold"); - } - else if(arr[0]=="2位"){ - fText(arr[0], 150, 480+60*i, 50, "silver"); - } - else if(arr[0]=="3位"){ - fText(arr[0], 150, 480+60*i, 50, "#8c4841"); - } - else{ - fText((i+1)+"位", 100, 480+60*i, 50, "black"); - } - fText(arr[1], 390, 480+60*i, 50, "black"); - fText(arr[2], 730, 480+60*i, 50, "black"); - } - } -} - function inputName(){ fill("silver"); @@ -156,11 +120,105 @@ fText("B.", 550, 425, 40, "white"); fText("C.", 100, 725, 40, "white"); fText("D.", 550, 725, 40, "white"); - - //fText(question[round].question, 480, 100, 30, "white"); - //fText(question[round].choiceA, 275, 425, 25, "white"); - //fText(question[round].choiceB, 725, 425, 25, "white"); fText("集計中...", 500, 500, 80, "black"); - //fText(question[round].choiceC, 275, 725, 25, "white"); - //fText(question[round].choiceD, 725, 725, 25, "white"); +} + +function showResult(){ + fill("silver"); + setAlp(50); + fRect(50, 50, 855, 100, "black"); + fText("結果発表 ", 480, 100, 80, "white"); + + fRect(45, 370, 865, 700, "white"); + fText("順位", 150, 410, 50, "black"); + fText("ユーザー名", 390, 410, 50, "black"); + 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"); + + let splitOrder = orderTable.split("\n"); + for (var i = 0; i < splitOrder.length; i++){ + let arr = splitOrder[i].split(" "); // 空白で文字列を分割 + if(arr[0]=="1位"){ + fText(arr[0], 150, 480+60*i, 50, "gold"); + } + else if(arr[0]=="2位"){ + fText(arr[0], 150, 480+60*i, 50, "silver"); + } + else if(arr[0]=="3位"){ + fText(arr[0], 150, 480+60*i, 50, "#8c4841"); + } + else{ + fText((i+1)+"位", 100, 480+60*i, 50, "black"); + } + fText(arr[1], 390, 480+60*i, 50, "black"); + fText(arr[2], 730, 480+60*i, 50, "black"); + } + } + fText("結果", 100, 1100, 50, "red"); + for(var i = 0; i < MAX_ROUND; i ++){ + fText((i+1), 480 + 50*i, 1100, 50, "black"); + } +} + + +// 他の設問の結果発表(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(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].answer1), int(question[show_round].answer2), int(question[show_round].answer3), int(question[show_round].answer4)] + let people_values = [int(question[show_round].people1), int(question[show_round].people2), int(question[show_round].people3), int(question[show_round].people4)] + let index = question_values.indexOf(i); + console.log(index) + if (index !== -1) { + return people_values[index]; + } else { + return 0; + } } \ No newline at end of file diff --git a/flask/testapp/views.py b/flask/testapp/views.py index 4e47696..e4594e4 100644 --- a/flask/testapp/views.py +++ b/flask/testapp/views.py @@ -6,7 +6,7 @@ user_score = {} # playerの数 -MAX_PLAYER = 3 +MAX_PLAYER = 1 # 何位まで表示するか(nemoto) max_order = 5 @@ -128,15 +128,15 @@ get_frequent_table += get_most_common_option + " " + get_most_common_count + "\n" # 2番目に多い要素 get_second_most_common_option = str(most_common[1][0]) if len(most_common) > 1 else str(4) - get_second_most_common_count = str(most_common[1][1]) if len(most_common) > 1 else str(4) + get_second_most_common_count = str(most_common[1][1]) if len(most_common) > 1 else str(0) get_frequent_table += get_second_most_common_option + " " + get_second_most_common_count + "\n" # 3番目に多い要素 get_third_most_common_option = str(most_common[2][0]) if len(most_common) > 2 else str(4) - get_third_most_common_count = str(most_common[2][1]) if len(most_common) > 2 else str(4) + get_third_most_common_count = str(most_common[2][1]) if len(most_common) > 2 else str(0) get_frequent_table += get_third_most_common_option + " " + get_third_most_common_count + "\n" # 4番目に多い要素 get_fourth_most_common_option = str(most_common[3][0]) if len(most_common) > 3 else str(4) - get_fourth_most_common_count = str(most_common[3][1]) if len(most_common) > 3 else str(4) + get_fourth_most_common_count = str(most_common[3][1]) if len(most_common) > 3 else str(0) get_frequent_table += get_fourth_most_common_option + " " + get_fourth_most_common_count return get_frequent_table