function showQuestion(){
fill("silver");
setAlp(45);
fRect(50, 50, 855, 100, "black");
fRect(45, 295, 860, 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");
if (player.choice == A){
setAlp(50);
fRect(50, 300, 400, 250, "black");
}
else if (player.choice == B){
setAlp(50);
fRect(500, 300, 400, 250, "black");
}
else if (player.choice == C){
setAlp(50);
fRect(50, 600, 400, 250, "black");
}
else if (player.choice == D){
setAlp(50);
fRect(500, 600, 400, 250, "black");
}
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");
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(question[round].choiceC, 275, 725, 25, "white");
fText(question[round].choiceD, 725, 725, 25, "white");
if(language==JPN){
fText((round+1) + "回戦", 100, 1000, 50, "red");
fText("現在の点数: " + player.score + " Pt", 700, 1000, 50, "black");
}
else{
fText("ROUND " + (round+1), 150, 1000, 50, "red");
fText("Current Points: " + player.score + " Pt", 650, 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(A, round) +"人", 275, 500, 50, "black");
fText(checkOrder(A, round) + "Pt", 400, 500, 50, "black");
fText(CheckPeople(B, round)+"人", 725, 500, 50, "black");
fText(checkOrder(B, round) + "Pt", 850, 500, 50, "black");
fText(CheckPeople(C, round)+"人", 275, 800, 50, "black");
fText(checkOrder(C, round) + "Pt", 400, 800, 50, "black");
fText(CheckPeople(D, round)+"人", 725, 800, 50, "black");
fText(checkOrder(D, round) + "Pt", 850, 800, 50, "black");
*/
//fText(CheckPeople(A, round) +"人", 100, 500, 50, "white");
//fText(CheckPeople(A, round) +"人", 100, 330, 50, "white");
fText(CheckPeople(A, round) +"人", 400, 330, 50, "white");
fText(checkOrder(A, round) + "Pt", 400, 500, 50, "white");
fText(CheckPeople(B, round)+"人", 850, 330, 50, "white");
fText(checkOrder(B, round) + "Pt", 850, 500, 50, "white");
fText(CheckPeople(C, round)+"人", 400, 630, 50, "white");
fText(checkOrder(C, round) + "Pt", 400, 800, 50, "white");
fText(CheckPeople(D, round)+"人", 850, 630, 50, "white");
fText(checkOrder(D, round) + "Pt", 850, 800, 50, "white");
fText("正解:"+string[question[round].realAnswer], 800, 900, 50, "black");
}
if(scene == WAIT_SCENE){
setAlp(50);
fRect(200, 475, 560, 200, "#208")
sRect(200, 475, 560, 200, "black")
setAlp(100)
if(language==JPN){
fText("集計中...", 500, 575, 80, "white");
}
else{
fText("Counting...", 500, 575, 80, "white");
}
}
}
function inputName(){
fill("silver");
fRect(50, 50, 855, 100, "black");
setAlp(20);
fRect(100, 800, 760, 300, "black");
setAlp(100);
if(language==JPN){
fText("美人投票ゲーム", 480, 100, 80, "white");
fTextN("ルール説明\n\n・好きな選択肢を選んでください\n・選んだ選択肢が多数派なら高得点GET!\n・制限時間は30秒\n・途中参加、途中退出は不可", 480, 950, 250, 40, "black");
}
else{
fText("Beauty Vote", 480, 100, 80, "white");
fTextN("Rule Explanation\n\n・Please choose your favorite option\n・If the chosen option is the majority,\nyou get high points!\n・The time limit is 30 seconds\n・No mid-term participation or withdrawal", 480, 950, 230, 35, "black");
}
if(tapC == 1){
tapC ++;
if(200 <= tapX && tapX <= 760 && 500 <= tapY && tapY <= 700){
player.name = document.getElementById('textBox').value;
document.getElementById('textBox').style.display = 'none';
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){
if(language==JPN){
fTextN("次のゲームが始まるまで\nお待ちください...", 480, 500, 100, 50, "red");
}
else{
fText("Please Wait for Next Game...", 480, 500, 50, "red");
}
}
}
// 他のプレイヤーが名前を書くのを待機(nemoto変更)
function WaitStart(){
fill("silver");
fRect(50, 50, 855, 100, "black");
setAlp(20);
fRect(100, 800, 760, 300, "black");
setAlp(100);
if(language==JPN){
fText("美人投票ゲーム", 480, 100, 80, "white");
fText("参加予定者:" + max_player + "人", 480, 300, 50, "black");
fText("現在の参加者:" + current_player + "人", 480, 400, 50, "black");
fText("参加者が揃うまでお待ちください...", 480, 500, 50, "red");
fTextN("ルール説明\n\n・好きな選択肢を選んでください\n・選んだ選択肢が多数派なら高得点GET!\n・制限時間は30秒\n・途中参加、途中退出は不可", 480, 950, 250, 40, "black");
}
else{
fText("Beauty Vote", 480, 100, 80, "white");
fText("Prospective Participant : " + max_player + " players", 480, 300, 50, "black");
fText("Current Participant : " + current_player + " players", 480, 400, 50, "black");
fTextN("Please Wait until\n All Participants are Present...", 480, 500, 50, 50, "red");
fTextN("Rule Explanation\n\n・Please choose your favorite option\n・If the chosen option is the majority,\nyou get high points!\n・The time limit is 30 seconds\n・No mid-term participation or withdrawal", 480, 950, 230, 35, "black");
}
if(player.number == 0){
setAlp(95);
fRect(200, 580, 560, 200, "black");
sRect(200, 580, 560, 200, "blue");
setAlp(100);
if(language==JPN){
fText("ゲーム開始!", 480, 680, 50, "white");
}
else{
fText("GAME START!", 480, 680, 50, "white");
}
if(tapC == 1){
tapC ++;
if(200 <= tapX && tapX <= 760 && 580 <= tapY && tapY <= 780){
fRect(200, 580, 560, 200, "black");
sendStart();
}
}
}
}
// function showResult(){
// if(language==JPN){
// window.open("showResultJPN.html")
// }
// else if (language==ENG){
// window.open("showResultENG.html")
// }
// }
// function showResult(){
// if(language==JPN){
// fText("結果発表", 480, 100, 80, "white");
// fText("順位", 150, 410, 50, "black");
// fText("ユーザー名", 390, 410, 50, "black");
// fText("スコア", 730, 410, 50, "black");
// fText("結果", 100, 1100, 50, "red");
// }
// else{
// fText("RESULT", 480, 100, 80, "white");
// fText("order", 150, 410, 50, "black");
// fText("username", 390, 410, 50, "black");
// fText("score", 730, 410, 50, "black");
// fText("result", 100, 1100, 50, "red");
// }
// if(scene == RESULT_SCENE){
// if(language==JPN){
// fText(player.name+"さんのスコアは" + player.score + "点です!", 480, 200, 50, "gold");
// }
// else{
// fText(player.name+"'s score is " + player.score + "Points!", 480, 200, 50, "gold");
// }
// 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)+"位", 150, 480+60*i, 50, "black");
// }
// fText(arr[1], 390, 480+60*i, 50, "black");
// fText(arr[2], 730, 480+60*i, 50, "black");
// }
// }
// for(var i = 0; i < MAX_ROUND; i ++){
// fText((i+1), 480 + 50*i, 1100, 50, "black");
// }
// }
function showResult(){
fill("silver");
setAlp(50);
fRect(50, 50, 855, 100, "black");
fRect(45, 370, 865, 700, "white");
if(language==JPN){
fText("結果発表", 480, 100, 80, "white");
fText("順位", 150, 410, 50, "black");
fText("ユーザー名", 390, 410, 50, "black");
fText("スコア", 730, 410, 50, "black");
fText("結果", 100, 1100, 50, "red");
}
else{
fText("RESULT", 480, 100, 80, "white");
fText("order", 150, 410, 50, "black");
fText("username", 390, 410, 50, "black");
fText("score", 730, 410, 50, "black");
fText("result", 100, 1100, 50, "red");
}
}
function showOtherResult(show_click_round){
fill("silver");
setAlp(50);
fRect(50, 50, 855, 100, "black");
fRect(45, 295, 860, 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("Q.", 110, 100, 40, "white");
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_click_round].question, 480, 100, 30, "white");
fText(question[show_click_round].choiceA, 275, 425, 25, "white");
fText(question[show_click_round].choiceB, 725, 425, 25, "white");
fText(question[show_click_round].choiceC, 275, 725, 25, "white");
fText(question[show_click_round].choiceD, 725, 725, 25, "white");
fText(CheckPeople(A, show_click_round) +"人", 275, 425, 50, "yellow");
fText(checkOrder(A, show_click_round) + "Pt", 400, 500, 50, "black");
fText(CheckPeople(B, show_click_round)+"人", 725, 425, 50, "yellow");
fText(checkOrder(B, show_click_round) + "Pt", 850, 500, 50, "black");
fText(CheckPeople(C, show_click_round)+"人", 275, 725, 50, "yellow");
fText(checkOrder(C, show_click_round) + "Pt", 400, 800, 50, "black");
fText(CheckPeople(D, show_click_round)+"人", 725, 725, 50, "yellow");
fText(checkOrder(D, show_click_round) + "Pt", 850, 800, 50, "black");
fText("結果", 100, 1100, 50, "black");
for(var i = 0; i < MAX_ROUND; i ++){
if(i == show_click_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);
if (index !== -1) {
return people_values[index];
} else {
return 0;
}
}
function checkOrder(choice, show_round){
var j = 0;// 選択した人数が同じ数のpoint調整変数
for(var i = 0; i < CHOICE_NUMBER; i ++){
// 各選択肢の該当人数が同じとき
if (i>=1){
if(question[show_round].people[i]==question[show_round].people[i-1]){
j ++;
}
}
// 未選択を選んだ場合
if(choice == question[show_round].answer[i]){
// 未選択を選んだ場合(E==4)
if(choice == 4){
return 0;
}
else{
return 4-i+j;
}
}
}
return 0;
}