diff --git a/flask/testapp/static/javascript/beautyVote.js b/flask/testapp/static/javascript/beautyVote.js index c95c928..4abb9d3 100644 --- a/flask/testapp/static/javascript/beautyVote.js +++ b/flask/testapp/static/javascript/beautyVote.js @@ -53,7 +53,11 @@ case START_SCENE: inputName(); break; - + + case WAIT_START: + WaitStart(); + CheckStart(); + break; case GAME_SCENE: //ゲーム画面を表示 @@ -191,6 +195,28 @@ } } +//参加するプレイヤーが揃ったか確認(nemoto追記) +function CheckStart(){ + xhr.open('POST', '/form'); + xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + //待機コードを送信 + xhr.send('checkStart=' + "check"); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4 && xhr.status === 200) { + if(xhr.responseText=="START"){ + console.log(xhr.responseText); + scene = GAME_SCENE; + } + //他の参加者が集まるまで待機 + else{ + max_player = xhr.responseText + console.log(max_player); + } + } + } +} + + // 集計結果待機中処理 function CheckOthers(){ xhr.open('POST', '/form'); @@ -247,6 +273,7 @@ var round = 0; //変更 var MAX_ROUND = 1; +var max_player = 0; // 最大のplayer数 var timer = 0; var TIME_LIMIT = 900; @@ -265,6 +292,7 @@ var RESULT_SCENE = 3; var WAIT_SCENE = 4; // nemoto追記 var WAIT_RESULT = 5; +var WAIT_START = 6; // nemoto追記 var scene = START_SCENE; diff --git a/flask/testapp/static/javascript/resultScreen.js b/flask/testapp/static/javascript/resultScreen.js index e33f4b4..ddf67b1 100644 --- a/flask/testapp/static/javascript/resultScreen.js +++ b/flask/testapp/static/javascript/resultScreen.js @@ -105,7 +105,7 @@ if(200 <= tapX && tapX <= 760 && 500 <= tapY && tapY <= 700){ player.name = document.getElementById('textBox').value; document.getElementById('textBox').style.display = 'none'; - scene = GAME_SCENE; + scene = WAIT_START; timer = 0; sendName(); } @@ -113,6 +113,29 @@ } +// 他のプレイヤーが名前を書くのを待機 +function WaitStart(){ + fill("silver"); + + fRect(50, 50, 855, 100, "black"); + + + fText("美人投票ゲーム", 480, 100, 80, "white"); + setAlp(50); + fText("あなたの名前を入力してください", 480, 200, 50, "black"); + + setAlp(100); + fText("参加予定者:" + max_player + "人", 480, 300, 50, "black"); + current_participants = int(player.number) + 1 + fText("現在の参加者:" + str(current_participants) + "人", 480, 400, 50, "black"); + fText("参加者が揃うまでお待ちください...", 480, 600, 50, "red"); + + setAlp(20); + fRect(100, 800, 760, 300, "black"); + setAlp(100); + fTextN("ルール1\nルール2\nルール3\nルール4", 480, 950, 200, 50, "white"); +} + // 他のプレイヤーの終わりを待つ画面(nemoto変更) function WaitOthers(){ fill("silver"); @@ -137,7 +160,7 @@ //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, 25, "black"); + fText("集計中...", 500, 500, 80, "black"); //fText(question[round].choiceC, 275, 725, 25, "white"); //fText(question[round].choiceD, 725, 725, 25, "white"); } \ No newline at end of file diff --git a/flask/testapp/templates/testapp/index.html b/flask/testapp/templates/testapp/index.html index 4cfe3a9..5399aad 100644 --- a/flask/testapp/templates/testapp/index.html +++ b/flask/testapp/templates/testapp/index.html @@ -31,14 +31,15 @@ position: relative; height: 100%; /* キャンバスと同じ高さに設定 */ } - + +
- + diff --git a/flask/testapp/views.py b/flask/testapp/views.py index e21bc04..31cd020 100644 --- a/flask/testapp/views.py +++ b/flask/testapp/views.py @@ -6,9 +6,9 @@ user_score = {} # playerの数 -MAX_PLAYER = 3 +MAX_PLAYER = 2 -# 何位まで表示するか +# 何位まで表示するか(nemoto) max_order = 5 # scoreを保存するデータ @@ -48,6 +48,14 @@ # クライアントサイドに識別番号を返す return str(user_number - 1) + # 他のplayerが揃うのを待機(nemoto追記) + if request.form.get("checkStart"): + if user_number < MAX_PLAYER: + return str(MAX_PLAYER) + # 全員のデータが集まった場合は,ゲーム開始 + else: + return "START" + # ゲーム中に選択肢を取得し,集計する if request.form.get("choice"): if len(choices) >= MAX_PLAYER: @@ -143,7 +151,7 @@ order_table += ( str(now_order) + "位" + " " + user[int(labels[i + j])] + " " + str(scores[i + j]) + "pt" + "\n" ) - if i + j + 1 >= max: # 参照する配列がもうない時 + if i + j + 1 >= max: # 参照する配列がない時 break if order_table.endswith("\n"):