function MapCharacterTable(characterUse) { var characterArray = characterUse.textContent.split('\n'); var table = this.table = {}; for (var i=0, l=characterArray.length; i= 0) this.cumulateTimes++; else { if (cumulateTimes <= -3) respondWindow.say("耶!對了!",'good'); else respondWindow.say("對。",'good'); this.cumulateTimes = 0; } } else { if (cumulateTimes <= 0) this.cumulateTimes--; else { if (cumulateTimes >= 5) respondWindow.say("啊,錯了?",'bad'); else respondWindow.say("錯了。",'bad'); this.cumulateTimes = 0; } } }, chatBack: function () { function chatBackLater(){ var respond = document.getElementById('chatBack').children[0] respond.className = 'gm'; respondWindow.show(respond); } setTimeout(chatBackLater, 1000 + 2000*Math.random()); }, cumulateRespond: function () { var sentence, point, cumulateTimes = this.cumulateTimes; if(cumulateTimes > 0) { sentence = '對!'; point = 'good'; } else if(cumulateTimes < 0){ sentence = '錯。'; point = 'bad'; } switch(cumulateTimes){ case 3: sentence = '不錯喔!'; break; case 5: sentence = '欸唷,這個屌!'; break; case -2: sentence = '又錯了。'; break; case -3: sentence = '還是錯……'; break; } if (Math.random() < 0.07) sentence = '幫我撐十秒!'; sentence && respondWindow.say(sentence,point); }, hintRespond: function () { if (this.inputTimes%7 == 6 && this.current == 0) { function sayHint(){ var paragraph = document.getElementById('respondMaterial').children[0] || false; paragraph.className = 'gm'; respondWindow.show(paragraph); } window.setTimeout(sayHint, 3 + Math.random()*3); } }, endStage: function () { var currentStage = tabler.getCurrentId(), paragraph = []; for (var i=0; i<3; i++) { paragraph[i] = document.getElementById( 'nextStage' ).children[i].cloneNode(true); paragraph[i].className = 'system'; } var paragraphText = paragraph[1].textContent; paragraphText = paragraphText.replace('tableId',currentStage); paragraphText = paragraphText.replace('leftTable',31-currentStage); paragraph[1].textContent = paragraphText; var anchor = paragraph[2].children[0]; anchor.href = '#' + (currentStage + 1) ; var anchorText = anchor.textContent; anchorText = anchorText.replace('nextTableId',currentStage+1); anchor.textContent = anchorText; for (i=0; i<3; i++) respondWindow.show(paragraph[i]); }, inputRespond: function (state) { this.current = state; this.inputTimes++; this.hintRespond(); this.doCumulate(); this.cumulateRespond(); }, }; var fontPx = document.getElementById('fontPx').children[1]; fontPx.oninput = function () { document.body.style.fontSize = this.value + 'pt'; } inputBar.oninput = function(){ var allAlphabet = this.value; if (allAlphabet.substr(-1) === '\n') { if (respondWindow.say(allAlphabet)) respondRobot.chatBack(); this.value = ''; } else if (allAlphabet.charAt(0) == ':') ; else if (allAlphabet.substr(-1) === ' ') { this.value = ''; visualBar.node.textContent = characterTable.findCharacter( allAlphabet.substr(0, allAlphabet.length-1) ) || '_'; if (visualBar.verifyCharacter()) questCharacter.nextCharacter(); else hintBar.hintCharacter(); } else visualBar.generateCharacter(allAlphabet); }; function init() { tabler.setTable(); characterTable = new MapCharacterTable( document.getElementById( tabler.getCurrentId() ) ); if (!characterTable.findCharacter(questCharacter.node.title)) { questCharacter.nextCharacter(); } hintBar.newHintState(); inputBar.focus(); inputBar.select(); } window.onhashchange = init; document.body.onload = init;