diff --git a/bigmin.js b/bigmin.js
new file mode 100644
index 0000000..88383b9
--- /dev/null
+++ b/bigmin.js
@@ -0,0 +1,15 @@
+var bigInt=function(n){function k(a,c){this.value=a;this.sign=c;this.isSmall=!1}function h(a){this.value=a;this.sign=0>a;this.isSmall=!0}function u(a){return-9007199254740992a}function x(a){return 1E7>a?[a]:1E14>a?[a%1E7,Math.floor(a/1E7)]:[a%1E7,Math.floor(a/1E7)%1E7,Math.floor(a/1E14)]}function y(a){w(a);var c=a.length;if(4>c&&0>z(a,L))switch(c){case 0:return 0;case 1:return a[0];case 2:return a[0]+1E7*a[1];default:return a[0]+1E7*(a[1]+1E7*a[2])}return a}function w(a){for(var c=
+a.length;0===a[--c];);a.length=c+1}function B(a){for(var c=Array(a),b=-1;++bl?(l+=1E7,d=1):d=0,e[g]=l;for(g=f;gl)l+=1E7;else{e[g++]=l;break}e[g]=l}for(;gg?g%1E7+1E7:g;e=y(e);return"number"===typeof e?(b&&(e=-e),new h(e)):new k(e,b)}function I(a,c){var b=a.length,f=c.length,e=B(b+f),d,g,l;for(g=0;gd)return b=K(e,d),d=y(b[0]),b=b[1],a.sign&&(b=-b),"number"===typeof d?(a.sign!==f.sign&&(d=-d),[new h(d),new h(b)]):[new k(d,a.sign!==f.sign),new h(b)];d=x(d)}b=z(e,d);if(-1===b)return[m[0],
+a];if(0===b)return[m[a.sign===f.sign?1:-1],m[0]];var g=d,l=e.length,d=g.length;b=B(g.length);var n=g[d-1],u=Math.ceil(1E7/(2*n)),e=C(e,u),g=C(g,u),t,p,v,q,w,D;e.length<=l&&e.push(0);g.push(0);n=g[d-1];for(t=l-d;0<=t;t--){l=Math.floor((1E7*e[t+d]+e[t+d-1])/n);v=p=0;w=g.length;for(q=0;qv?(e[t+q]=v+1E7,v=-1):(e[t+q]=v,v=0);for(;0!==v;){--l;for(q=p=0;qp?(e[t+q]=p+1E7,p=0):(e[t+q]=p,p=1);v+=p}b[t]=l}e=K(e,u)[0];
+b=[y(b),y(e)];d=b[0];f=a.sign!==f.sign;b=b[1];n=a.sign;"number"===typeof d?(f&&(d=-d),d=new h(d)):d=new k(d,f);"number"===typeof b?(n&&(b=-b),b=new h(b)):b=new k(b,n);return[d,b]}function z(a,c){if(a.length!==c.length)return a.length>c.length?1:-1;for(var b=a.length-1;0<=b;b--)if(a[b]!==c[b])return a[b]>c[b]?1:-1;return 0}function r(a){if(a instanceof k||a instanceof h)return a;if("number"===typeof a){if(u(a))return new h(a);a=String(a)}if("string"===typeof a){if(u(+a)){var c=+a;if(c===A(c))return new h(c);
+throw Error("Bad int");}(c="-"===a[0])&&(a=a.slice(1));var b=a.split(/e/i);if(2a)throw Error("No e-");a=b+=Array(a+1).join("0")}if(!/^([0-9][0-9]*)$/.test(a))throw Error("Bad int");for(var b=[],f=a.length,e=f-7;0e&&(e=0),f-=7;w(b);return new k(b,c)}}"https://github.com/peterolson/BigInteger.js";
+var L=x(9007199254740992);k.prototype.add=function(a){a=r(a);if(this.sign!==a.sign)return this.sub(a.neg());var c=this.value,b=a.value;if(a.isSmall)return new k(F(c,Math.abs(b)),this.sign);a=c.length>=b.length?E(c,b):E(b,c);return new k(a,this.sign)};h.prototype.add=function(a){a=r(a);var c=this.value;if(0>c!==a.sign)return this.sub(a.neg());var b=a.value;if(a.isSmall){if(u(c+b))return new h(c+b);b=x(Math.abs(b))}return new k(F(b,Math.abs(c)),0>c)};k.prototype.sub=function(a){var c=r(a);if(this.sign!==
+c.sign)return this.add(c.neg());a=this.value;var b=c.value;if(c.isSmall)return H(a,Math.abs(b),this.sign);c=this.sign;0<=z(a,b)?a=G(a,b):(a=G(b,a),c=!c);a=y(a);"number"===typeof a?(c&&(a=-a),a=new h(a)):a=new k(a,c);return a};h.prototype.sub=function(a){a=r(a);var c=this.value;if(0>c!==a.sign)return this.add(a.neg());var b=a.value;return a.isSmall?new h(c-b):H(b,Math.abs(c),0<=c)};k.prototype.neg=function(){return new k(this.value,!this.sign)};h.prototype.neg=function(){var a=this.sign,c=new h(-this.value);
+c.sign=!a;return c};k.prototype.abs=function(){return new k(this.value,!1)};h.prototype.abs=function(){return new h(Math.abs(this.value))};k.prototype.mul=function(a){var c=r(a);a=this.value;var b=c.value,f=this.sign!==c.sign;if(c.isSmall){if(0===b)return m[0];if(1===b)return this;if(-1===b)return this.neg();c=Math.abs(b);if(1E7>c)return new k(C(a,c),f);b=x(c)}return new k(I(a,b),f)};h.prototype.mul=function(a){a=r(a);var c=this.value,b=a.value;if(0===c)return m[0];if(1===c)return a;if(-1===c)return a.neg();
+if(a.isSmall){if(u(c*b))return new h(c*b);b=x(Math.abs(b))}c=Math.abs(c);return 1E7>c?new k(C(b,c),this.sign!==a.sign):new k(I(b,x(c)),this.sign!==a.sign)};k.prototype.sqr=function(){return new k(J(this.value),!1)};h.prototype.sqr=function(){var a=this.value*this.value;return u(a)?new h(a):new k(J(x(Math.abs(this.value))),!1)};k.prototype.divmod=function(a){a=M(this,a);return{quo:a[0],rem:a[1]}};h.prototype.divmod=k.prototype.divmod;k.prototype.pow=function(a){var c=r(a),b=this.value;a=c.value;var f;
+if(0===a)return m[1];if(0===b)return m[0];if(1===b)return m[1];if(c.sign)return m[0];if(!c.isSmall)throw Error("Exp too large");if(this.isSmall&&u(f=Math.pow(b,a)))return new h(A(f));f=this;for(c=m[1];;){a&1&&(c=c.mul(f),--a);if(0===a)break;a/=2;f=f.sqr()}return c};h.prototype.pow=k.prototype.pow;k.prototype.cmpAbs=function(a){a=r(a);return a.isSmall?1:z(this.value,a.value)};h.prototype.cmpAbs=function(a){a=r(a);var c=Math.abs(this.value),b=a.value;return a.isSmall?(b=Math.abs(b),c===b?0:c>b?1:-1):
+-1};k.prototype.cmp=function(a){a=r(a);return this.sign!==a.sign?a.sign?1:-1:a.isSmall?this.sign?-1:1:z(this.value,a.value)*(this.sign?-1:1)};h.prototype.cmp=function(a){a=r(a);var c=this.value,b=a.value;return a.isSmall?c==b?0:c>b?1:-1:0>c!==a.sign?0>c?-1:1:0>c?1:-1};k.prototype.toString=function(){for(var a=this.value,c=a.length,b=String(a[--c]),f;0<=--c;)f=String(a[c]),b+="0000000".slice(f.length)+f;return(this.sign?"-":"")+b};h.prototype.toString=function(){return String(this.value)};var m=function(a){return"undefined"===
+typeof a?m[0]:r(a)};for(n=0;10>n;n++)m[n]=new h(n),0Hold
+ 0 | Score 分 |
0 | Line 行 |
0 | Piece 块 |
00:00.00 |
@@ -145,6 +146,7 @@ Next
+
diff --git a/piece.js b/piece.js
index 6af9394..6bb95c4 100644
--- a/piece.js
+++ b/piece.js
@@ -50,7 +50,6 @@ Piece.prototype.new = function(index) {
if (settings.Gravity !== 0) {
this.gravity = gravityArr[settings.Gravity - 1];
} else if (gametype === 1) { //Marathon
- var level = ~~((lines)/10);
if (level < 20) {
this.gravity = [
1/60, 1/30, 1/25, 1/20, 1/15, 1/12, 1/10, 1/8, 1/6, 1/6,
@@ -67,9 +66,11 @@ Piece.prototype.new = function(index) {
// Check for blockout.
if (!this.moveValid(0, 0, this.tetro)) {
+ this.dead = true;
gameState = 9;
msg.innerHTML = 'BLOCK OUT!';
menu(3);
+ return;
}
piece.checkFall(); //real 20G !
diff --git a/stack.js b/stack.js
index 58ce49f..af0409b 100644
--- a/stack.js
+++ b/stack.js
@@ -15,8 +15,19 @@ Stack.prototype.new = function(x, y) {
* Adds tetro to the stack, and clears lines if they fill up.
*/
Stack.prototype.addPiece = function(tetro) {
+ var lineClear = 0;
+ var isSpin = false;
var once = false;
+ // spin check
+ if (
+ !piece.moveValid(-1, 0, piece.tetro) &&
+ !piece.moveValid( 1, 0, piece.tetro) &&
+ !piece.moveValid( 0,-1, piece.tetro)
+ ) {
+ isSpin = true;
+ }
+
// Add the piece to the stack.
var range = [];
var valid = false;
@@ -58,7 +69,7 @@ Stack.prototype.addPiece = function(tetro) {
// Clear the line. This basically just moves down the stack.
// TODO Ponder during the day and see if there is a more elegant solution.
if (count === 10) {
- lines++; // NOTE stats
+ lineClear++; // NOTE stats
if (gametype === 4) { // dig race
if (digLines.indexOf(row) !== -1) {
digLines.splice(digLines.indexOf(row), 1);
@@ -72,6 +83,47 @@ Stack.prototype.addPiece = function(tetro) {
}
}
+ var scoreAdd = bigInt(level + 1);
+ if (lineClear !== 0) {
+ console.log("C"+combo+" B"+b2b)
+ if (isSpin) {
+ scoreAdd = scoreAdd.mul(
+ bigInt([800,1200,1600,2000][lineClear - 1])
+ .mul(bigInt(2).pow(b2b + combo))
+ );
+ b2b += 1;
+ } else if(lineClear === 4) {
+ scoreAdd = scoreAdd.mul(
+ bigInt(800)
+ .mul(bigInt(2).pow(b2b + combo))
+ );
+ b2b += 1;
+ } else {
+ scoreAdd = scoreAdd.mul(
+ bigInt([100,300,500,800][lineClear - 1])
+ .mul(bigInt(2).pow(combo))
+ );
+ b2b = 0;
+ }
+ combo += 1;
+ } else {
+ if (isSpin) {
+ scoreAdd = scoreAdd.mul(
+ bigInt(2).pow(bigInt(b2b))
+ .mul(bigInt(400))
+ );
+ } else {
+ scoreAdd = bigInt(0);
+ }
+ combo = 0;
+ }
+ lines += lineClear;
+ if (gametype === 1)
+ level = ~~(lines / 10);
+ score = score.add(scoreAdd);
+ if (scoreAdd.cmp(0) > 0)
+ console.log(scoreAdd.toString());
+
statsFinesse += piece.finesse - finesse[piece.index][piece.pos][column];
piecesSet++; // NOTE Stats
// TODO Might not need this (same for in init)
diff --git a/style.css b/style.css
index b4b0a2f..94c87ac 100755
--- a/style.css
+++ b/style.css
@@ -205,6 +205,12 @@ nav a {
font-size: 1.125em;
display: block;
}
+#score {
+ text-align: center;
+ font-weight: 900;
+ font-size: 1em;
+ display: block;
+}
/* Menus */
.menu {
@@ -316,6 +322,7 @@ nav a {
height: 50%;
font-family: 'Lucida Console';
font-size: 0.5em;
+ word-wrap:break-word;
word-break:break-all;
background-color: #000;
color: #bfb;
diff --git a/tetris.js b/tetris.js
index 4b77809..5815857 100644
--- a/tetris.js
+++ b/tetris.js
@@ -22,6 +22,7 @@ var stats = document.getElementById('stats');
var statsTime = document.getElementById('time');
var statsLines = document.getElementById('line');
var statsPiece = document.getElementById('piece');
+var statsScore = document.getElementById('score');
var h3 = document.getElementsByTagName('h3');
var set = document.getElementById('settings');
var leaderboard = document.getElementById('leaderboard');
@@ -428,8 +429,14 @@ var gameparams;
// var dirtyHold, dirtyActive, dirtyStack, dirtyPreview;
var lastX, lastY, lastPos, lastLockDelay, landed;
+// Scoreing related status
+var b2b;
+var combo;
+var level;
+
// Stats
var lines;
+var score;
var statsFinesse;
var piecesSet;
var startTime;
@@ -780,8 +787,12 @@ function init(gt, params) {
preview.init()
//preview.draw();
+ b2b = 0;
+ combo = 0;
+ level = 0;
statsFinesse = 0;
lines = 0;
+ score = bigInt(0);
piecesSet = 0;
clear(stackCtx);
@@ -931,6 +942,14 @@ function statisticsStack() {
else{
statsLines.innerHTML = lines;
}
+
+ var strsplit = score.toString().split("");
+ var spacetoggle = 0;
+ for (var i = strsplit.length - 1 - 3; i >= 0; i -= 3) {
+ strsplit[i] += spacetoggle===0?" ":" ";
+ spacetoggle ^= 1;
+ }
+ statsScore.innerHTML = strsplit.join("");
}
// ========================== View ============================================