浏览代码

Tell the player how long they survived (fen-snack)

tags/v0.1.2
Fen Dweller 5 年前
父节点
当前提交
f4cc337b78
共有 1 个文件被更改,包括 30 次插入0 次删除
  1. +30
    -0
      stories/fen-snack.js

+ 30
- 0
stories/fen-snack.js 查看文件

@@ -95,6 +95,36 @@ stories.push({
if (state.player.stats.health.value <= 0) {
state.player.stats.health.value = 0;

const start = 86400 - 60 * 25 - 25;
const end = state.info.time.value;

const time_survived = end - start;
const minutes = Math.floor(time_survived / 60);
const seconds = time_survived % 60;
const minute_text = minutes + (minutes == 1 ? " minute" : " minutes");
const second_text = seconds + (seconds == 1 ? " second" : " seconds");

let time_text;

if (minutes == 0)
time_text = "You survived for " + second_text + ".";
else
time_text = "You survived for " + minute_text + " and " + second_text + ".";

startTimer({
id: "time-text",
func: state => {
print([time_text]);
return true;
},
delay: 2000,
loop: false,
classes: [
]
}, state);

if (location.startsWith("stomach")) {
goToRoom("digested-stomach", state);
}


正在加载...
取消
保存