" +
"
" +
"
" +
"
"+
"
\n" +
"
\n" +
"
\n" +
"
"+
"
"+
"
"+
"
";
$(".day-box").eq(i-1).before(html);
//杀人信息显示
judgeKill2();
judgeVote2();
//详情隐藏
$(".day-box").eq(i-1).find(".proc-box").hide();
//高亮
$(".proc-box").eq(i-1).find(".process").css({"background":"#83b09a"});
$(".proc-box").eq(i-1).find(".trg").css({"border-right":"#83b09a solid .22rem"});
}
}
//天数点击展示\隐藏
$(".date").click(function(){
$(this).next().slideToggle();
});
$("#date_now").click(function(){
$(this).next().slideToggle();
});
//状态机
var fsm = new StateMachine({
init: stateNow,
transitions: [
{ name: 'kill', from: 'start', to: 'killed' },
{ name: 'speak', from: 'killed', to: 'spoke' },
{ name: 'talk', from: 'spoke', to: 'talked' },
{ name: 'vote', from: 'talked', to: 'voted' }
],
methods: {
onKill: function() {
$("#kill").css({"background":"#83b09a"});
$("#trg1").css({"border-right":"#83b09a solid .22rem"});
},
onSpeak: function() {
$("#speak").css({"background":"#83b09a"});
$("#trg2").css({"border-right":"#83b09a solid .22rem"});
},
onTalk: function() {
$("#talk").css({"background":"#83b09a"});
$("#trg3").css({"border-right":"#83b09a solid .22rem"});
},
onVote: function() {
$("#vote").css({"background":"#83b09a"});
$("#trg4").css({"border-right":"#83b09a solid .22rem"});
}
}
});
//开始杀人
$("#kill").click(function () {
if (fsm.state=='start'){
fsm.kill();
location.href='kill.html';
} else {
alert('请按顺序操作');
}
});
//死者自白
$("#speak").click(function () {
if (fsm.state=='killed'){
var YN = confirm('请死者亮明身份并且发表遗言');
if (YN==true){
fsm.speak();
stateNow = fsm.state;
sessionStorage.setItem("stateNow",stateNow);//当前状态
}
} else {
alert('请按顺序操作');
}
});
//玩家讨论
$("#talk").click(function () {
if (fsm.state=='spoke'){
var YN = confirm('玩家依次发言讨论');
if (YN==true){
fsm.talk();
stateNow = fsm.state;
sessionStorage.setItem("stateNow",stateNow);//当前状态
}
} else {
alert('请按顺序操作');
}
});
//玩家投票
$("#vote").click(function () {
if (fsm.state=='talked'){
fsm.vote();
stateNow = fsm.state;
sessionStorage.setItem("stateNow",stateNow);//当前状态
location.href='vote.html';
} else {
alert('请按顺序操作');
}
});
//状态判断
switch (fsm.state){
case "killed":
fsm.onKill();
judgeKill();
break;
case "spoke":
fsm.onKill();
fsm.onSpeak();
judgeKill();
break;
case "talked":
fsm.onKill();
fsm.onSpeak();
fsm.onTalk();
judgeKill();
break;
case "voted":
fsm.onKill();
fsm.onSpeak();
fsm.onTalk();
fsm.onVote();
judgeKill();
judgeVote();
}
//存储
sessionStorage.setItem("arr_player",JSON.stringify(arr_player));//玩家状态数组
sessionStorage.setItem('day',day);
});