Add Level Count down
This commit is contained in:
parent
18bc6a9c17
commit
0de883ae54
@ -98,6 +98,8 @@ class idManager():
|
||||
def setTimes(self, ip):
|
||||
self.ip_time[ip] = 0
|
||||
|
||||
# 1 For next step
|
||||
# 0 For not next step
|
||||
def getTimes(self, ip):
|
||||
|
||||
if ip not in self.ip_time.keys():
|
||||
|
30
main.py
30
main.py
@ -22,13 +22,16 @@ evalDataPath = "evals/"
|
||||
questionarePath = "data/questionare.csv"
|
||||
annotationPath = "data/annotation.csv"
|
||||
annotationPath2 = "data/annotation2.csv"
|
||||
feedbackPath = "data/feedback.csv"
|
||||
|
||||
#id=idm.getId(request.remote_addr)
|
||||
|
||||
# id=idm.getId(request.remote_addr)
|
||||
def getId():
|
||||
if 'name' not in session:
|
||||
session['name'] = str(uuid.uuid4())
|
||||
return session['name']
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def gamewelcome():
|
||||
ip = getId()
|
||||
@ -55,8 +58,8 @@ def gamepreplay():
|
||||
result.get("playedp"),
|
||||
result.get("gamestyle"),
|
||||
result.get("frequency"),
|
||||
result.get("age")+result.get("myAge"),
|
||||
result.get("gender")+result.get("myGender"),
|
||||
result.get("age") + result.get("myAge"),
|
||||
result.get("gender") + result.get("myGender"),
|
||||
""])
|
||||
idm.setControl(cid, result.get("control"))
|
||||
print(result.get("gamestyle"))
|
||||
@ -67,7 +70,8 @@ def gamepreplay():
|
||||
|
||||
@app.route('/gametutorial/<id>')
|
||||
def gametutorial(id):
|
||||
return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id),maxT=idm.tutorialMax,
|
||||
return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id),
|
||||
maxT=idm.tutorialMax,
|
||||
control=idm.getControl(id))
|
||||
|
||||
|
||||
@ -85,6 +89,7 @@ def gametutorialdata(id):
|
||||
def gameplay(id):
|
||||
gamelevels = idm.getLevels(id)
|
||||
return render_template('GamePlay.html', gamelevels=gamelevels, control=idm.getControl(id), levelNum=2,
|
||||
times=idm.getTimes(id),
|
||||
jump="/annotation")
|
||||
|
||||
|
||||
@ -93,7 +98,7 @@ def getJSONData(id):
|
||||
if request.method == 'POST':
|
||||
print("POST Game")
|
||||
resultList = list(request.form)[0].split(",")
|
||||
saveFile(replayDataPath, id + resultList[0][:-2], resultList[1:])
|
||||
saveFile(replayDataPath, id + "_" + resultList[0][:-2], resultList[1:])
|
||||
return "return!"
|
||||
|
||||
|
||||
@ -147,7 +152,7 @@ def getJSONData2(id):
|
||||
if request.method == 'POST':
|
||||
print("POST Game")
|
||||
resultList = list(request.form)[0].split(",")
|
||||
saveFile(replayDataPath, id + resultList[0][:-2], resultList[1:])
|
||||
saveFile(replayDataPath, id+"_" + resultList[0][:-2], resultList[1:])
|
||||
return "return!"
|
||||
|
||||
|
||||
@ -174,11 +179,8 @@ def gameanno2(id):
|
||||
def gameannoresult2(id):
|
||||
if request.method == 'POST':
|
||||
print("result: " + id)
|
||||
|
||||
resultList = list(request.form)[0].split(",")
|
||||
levelList = idm.getRecent(getId())
|
||||
|
||||
|
||||
idm.write_csv(annotationPath2,
|
||||
[getId(), resultList[0], resultList[1], resultList[2], levelList[0], levelList[1],
|
||||
levelList[2],
|
||||
@ -194,10 +196,18 @@ def gameannoresult2(id):
|
||||
@app.route("/gameover")
|
||||
def over():
|
||||
finish = idm.getTimes(getId())
|
||||
|
||||
return render_template("GameOver.html", finish=1, stage=1)
|
||||
|
||||
|
||||
@app.route("/gameover/<id>/feedback", methods=['POST'])
|
||||
def overa():
|
||||
if request.method == 'POST':
|
||||
resultList = list(request.form)[0].split(",")
|
||||
idm.write_csv(feedbackPath,
|
||||
[getId(), resultList[0],
|
||||
""])
|
||||
|
||||
|
||||
def saveFile(path, filename, content):
|
||||
cp = list(map(int, content))
|
||||
file_dir = os.path.join(os.getcwd(), path)
|
||||
|
@ -187,6 +187,7 @@
|
||||
<div class="col-md-12">
|
||||
<div align="center">
|
||||
<h3 id="Head">Level A</h3>
|
||||
<p id="leftLevel">There are 7 levels left</p>
|
||||
<p class="alert">If the game is not responding to your keyboard, please click on the game screen.</p>
|
||||
</div>
|
||||
<div align="center" id="GameWindow">
|
||||
@ -201,6 +202,7 @@
|
||||
cheerpjInit();
|
||||
var divElement = document.getElementById("GameWindow");
|
||||
var title = document.getElementById("Head");
|
||||
var leftLevel = document.getElementById("leftLevel")
|
||||
var levelNum = Number("{{levelNum}}")
|
||||
var levels = getLevels("{{gamelevels}}", levelNum);
|
||||
var levelNames = ["Level A", "Level B", "Level C", "Level D"];
|
||||
@ -215,8 +217,19 @@
|
||||
console.log("GameLoad Initialize Succeed!");
|
||||
document.getElementById("loading").style.visibility = 'hidden';
|
||||
})
|
||||
leftNum = 0;
|
||||
|
||||
if(levelNum === 3) {leftNum = 2}
|
||||
else {
|
||||
if ("{{times}}"==1){
|
||||
leftNum = 4;
|
||||
}else{
|
||||
leftNum = 6;
|
||||
}
|
||||
}
|
||||
|
||||
leftLevel.innerText = "There are " + leftNum +" levels left."
|
||||
leftNum--;
|
||||
for (i = 0; i < levelNum - 1; i++) {
|
||||
console.log("Play level: %s", levels[i])
|
||||
PlayLevel(levels[i], control)
|
||||
@ -225,6 +238,8 @@
|
||||
console.log(i)
|
||||
var index = levelNames.indexOf(title.innerText);
|
||||
title.innerText = levelNames[index + 1];
|
||||
leftLevel.innerText = "There are " + leftNum +" levels left."
|
||||
leftNum--;
|
||||
});
|
||||
}
|
||||
|
||||
@ -235,7 +250,9 @@
|
||||
});
|
||||
|
||||
|
||||
function LeftNum(times, level){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -312,23 +312,6 @@
|
||||
None of above
|
||||
</label>
|
||||
</p>
|
||||
<script>
|
||||
function renew( ){
|
||||
if ($("input[name='gender']").val()=="D"){
|
||||
$("input[name='gender']").val($("input[type='text']").val())
|
||||
}
|
||||
|
||||
if( $("input[name='age']").val()=="A"){
|
||||
$("input[name='age']").val($("input[type='number']").val())
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<p>
|
||||
<h4>4. How often do you play games?</h4>
|
||||
<label>
|
||||
@ -357,8 +340,8 @@
|
||||
<h4>5. What is your age?</h4>
|
||||
<label>
|
||||
|
||||
<input type="radio" class="option-input radio" name="age" value= "A">
|
||||
<input type="number" value="" step="1" placeholder="Input your age">
|
||||
<input type="radio" class="option-input radio" name="age" value="A">
|
||||
<input type="number" name="myAge" value="" step="1" placeholder="Input your age">
|
||||
|
||||
</label>
|
||||
|
||||
@ -403,16 +386,6 @@
|
||||
</label>
|
||||
|
||||
</p>
|
||||
|
||||
<script>
|
||||
function renew( ){
|
||||
|
||||
$("input[name='gender']").val($("input[type='text']").val())
|
||||
$("input[name='age']").val($("input[type='number']").val())
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<br>
|
||||
<p><b><input type="submit" value="Submit" class="cirButton"
|
||||
style="font-weight: 700; font-size: large; width: 60%;" onclick ="" /></b></p>
|
||||
|
Loading…
Reference in New Issue
Block a user