Skip to content

Commit

Permalink
many detail fix
Browse files Browse the repository at this point in the history
Signed-off-by: farteryhr <[email protected]>
  • Loading branch information
farteryhr committed Oct 18, 2015
1 parent 62da843 commit 7059e79
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 133 deletions.
Binary file modified bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h3>Hold</h3>
</div>

<nav class='menu on'>
<h1>Tetr.js - Dig v0.5</h1>
<h1>Tetr.js - Dig v0.51</h1>
<p>forked from: <span onclick="window.location='http://simon.lc/tetr.js/'"><u>&gt;&gt;simonlc</u></span><br/>
farter's Dig Mod</p>
<ul>
Expand All @@ -64,6 +64,8 @@ <h1>Tetr.js - Dig v0.5</h1>
<!-- <li><a onclick=init(2)>Play Ultra</a></li> -->
<li><a onclick="init(3,{digOffset:0})">⚠ Dig! 挖掘机</a></li>
<li><a onclick="init(4)">☕ Dig Race 挖掘练习</a></li>
<li><a onclick="init(5)">✈ Zen 修仙模式</a></li>

<li><a onclick="menu(6,1)">Replay(α) 回放(测试)</a></li>
<li><a onclick=menu(2)>✜ Controls 调整按键</a></li>
<li><a onclick=menu(1)>☑ Settings 调整设定</a></li>
Expand Down
7 changes: 7 additions & 0 deletions menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ function right(e) {
* LocalStorage functions
*/
function saveSetting(s) {
if (localStorage === void 0) {
localStorage = {};
}
localStorage['version'] = version;

document.getElementById(s)
Expand All @@ -164,6 +167,9 @@ function saveSetting(s) {
localStorage['settings'] = JSON.stringify(mySettings);
}
function loadLocalData() {
if (localStorage === void 0) {
localStorage = {};
}
if (localStorage['binds']) {
binds = JSON.parse(localStorage.getItem('binds'));
for (var i = 0, len = controlCells.length; i < len; i++) {
Expand All @@ -183,6 +189,7 @@ function loadLocalData() {
}
}
}

}

loadLocalData();
Expand Down
169 changes: 96 additions & 73 deletions ranking.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,78 +7,109 @@ function XMLHTTP(url,obj)
{// 4 = "loaded"
if (xmlhttp.status==200)
{
var res=JSON.parse(xmlhttp.responseText);
if(res.msg==="fail")
var res;
try
{
leaderboard.innerHTML = "←_←"
}
else if(res.msg=="ok")
{
leaderboard.innerHTML = ""
var ranks = res.ranks;
var now = (new Date()).getTime();
var gettimedifftext = function(t)
res = JSON.parse(xmlhttp.responseText);
if(res.msg==="fail")
{
t=Math.round(t/(60*1000));
if(t<100)
return t==0?"!":(t+"m");
else if(t<99*60)
return Math.round(t/60)+"h";
else
return Math.round(t/(60*24))+"d";
leaderboard.innerHTML = "error: "+res.info;
}
var gettimetext = function(t)
else if(res.msg==="ok")
{
var hs=Math.round(t/10);
var s=~~(hs/100);
var m=~~(s/60);
hs-=s*100;
s-=m*60;
if(m==0)
return s+"."+((hs>9?"":"0")+hs);
else if(m<10)
return m+":"+((s>9?"":"0")+s)+"."+((hs>9?"":"0")+hs);
else
return m+":"+((s>9?"":"0")+s)+"."+(~~(hs/10)); //
leaderboard.innerHTML = ""
var ranks = res.ranks;
var now = (new Date()).getTime();
var gettimedifftext = function(t)
{
t=Math.round(t/(60*1000));
if(t<100)
return t<=0?"!":(t+"m");
else if(t<99*60)
return Math.round(t/60)+"h";
else
return Math.round(t/(60*24))+"d";
}
var gettimetext = function(t)
{
var hs=Math.round(t/10);
var s=~~(hs/100);
var m=~~(s/60);
hs-=s*100;
s-=m*60;
if(m==0)
return s+"."+((hs>9?"":"0")+hs);
else if(m<10)
return m+":"+((s>9?"":"0")+s)+"."+((hs>9?"":"0")+hs);
else
return m+":"+((s>9?"":"0")+s)+"."+(~~(hs/10)); //
}
var getlinetxt = function(l)
{
if(l<1000)
return l+"L";
else
return l+"";
}
var getscoretext = function(s)
{
var arr=s.split("");
for(var i=arr.length-1-3;i>=0;i-=3){
arr[i]+=" ";
}
return arr.join("");
}
for (var i=0;i<ranks.length;i++) {
var div = document.createElement('div');
var spanname = document.createElement('span');
var spanlines = document.createElement('span');
var spantime = document.createElement('span');
var spandate = document.createElement('span');
var spanscore = document.createElement('span');
spanname.innerText = ranks[i].name;
spanname.style.width = "6em";
spanname.style["text-align"] = "left";
spanlines.innerText = ranks[i].lines + "L";
spanlines.style.width = "2.5em";
spantime.innerText = gettimetext(ranks[i].time);
spantime.style.width = "4em";
spandate.innerText = gettimedifftext(now-ranks[i].date);
spandate.style.width = "2.5em";
spandate.style["font-weight"] = "normal";
if(res.mode==="score")
{
spanscore.innerHTML = scorestring(ranks[i].score, 7);
spanscore.style.width = "15em";
spanscore.style.color = "#bdf";
}

div.appendChild(spanname);
div.appendChild(spanlines);
div.appendChild(spantime);
div.appendChild(spandate);
if(res.mode==="score")
{
div.appendChild(spanscore);
}
leaderboard.appendChild(div);
if(res.mode==="score" && i+1===5)
{
break;
}
}
}
var getlinetxt = function(l)
else
{
if(l<1000)
return l+"L";
else
return l+"";
}
for (var i in ranks) {
var div = document.createElement('div');
var spanname = document.createElement('span');
var spanlines = document.createElement('span');
var spantime = document.createElement('span');
var spandate = document.createElement('span');

spanname.innerText = ranks[i].name;
spanname.style.width = "6em";
spanname.style["text-align"] = "left";
spanlines.innerText = ranks[i].score + "L";
spanlines.style.width = "2.5em";
spantime.innerText = gettimetext(ranks[i].time);
spantime.style.width = "4em";
spandate.innerText = gettimedifftext(now-ranks[i].date);
spandate.style.width = "2.5em";
spandate.style["font-weight"] = "normal";

leaderboard.appendChild(div);
div.appendChild(spanname);
div.appendChild(spanlines);
div.appendChild(spantime);
div.appendChild(spandate);
leaderboard.innerText = "Problem retrieving leaderboard data\n" +
xmlhttp.status + "\n" + xmlhttp.readyState + "\n" + xmlhttp.statusText + "\n" +
xmlhttp.responseText;
}
}
}
else
{
leaderboard.innerText = "Problem retrieving leaderboard data\n" +
xmlhttp.status + "\n" + xmlhttp.readyState + "\n" + xmlhttp.statusText + "\n" +
xmlhttp.responseText;
catch(e)
{
leaderboard.innerText = "Problem retrieving leaderboard data\n" +
e.toString();
}
}
}
}
Expand All @@ -102,17 +133,9 @@ function XMLHTTP(url,obj)
}
}

var playername=void 0;

function submitscore(obj)
{
if(playername===void 0)
playername=prompt("Enter your nick: 请输入大名:");
if(playername===null)
return;
if(playername==="")
playername="unnamed";
obj.name=playername;
console.log(obj);
XMLHTTP("http://farter.tk:8888", obj);
//XMLHTTP("http://localhost:8888", obj);
}
11 changes: 11 additions & 0 deletions stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ Stack.prototype.addPiece = function(tetro) {
if (gametype === 1)
level = ~~(lines / 10);
score = score.add(scoreAdd);

var pc = true;
for (var x = 0; x < 10; x++)
for (var y = 0; y < 22; y++)
if (this.grid[x][y])
pc = false;
if (pc) {
score = score.add(bigInt(1000000).mul(bigInt(16).pow(allclear)));
allclear ++;
}

//if (scoreAdd.cmp(0) > 0)
//console.log(scoreAdd.toString());

Expand Down
Loading

0 comments on commit 7059e79

Please sign in to comment.