Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
tiansh committed Jul 28, 2011
1 parent 6700554 commit 3016a7a
Show file tree
Hide file tree
Showing 27 changed files with 479 additions and 93 deletions.
37 changes: 23 additions & 14 deletions css/hup.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@
}

#hup1, #hup2 {
left:140px;
height:60px;
width:530px;
margin:0 0 -60px 0;
}

#hup1 {
left:140px;
width:530px;
}

#hup2 {
left:120px;
width:570px;
}

#hup1 {
top:140px;
}
Expand All @@ -43,6 +51,11 @@
width:300px;
}

#hup2>:nth-child(3n+4)
{
margin-left:12px;
}

#hup1.p0>:nth-child(14),
#hup1.p1>:nth-child(11),
#hup1.p2>:nth-child( 8),
Expand All @@ -52,23 +65,19 @@
margin-left:16px;
}

#hup1.p1>:nth-child(n+12),
#hup1.p2>:nth-child(n+9),
#hup1.p3>:nth-child(n+6),
#hup1.p4>:nth-child(n+3)
#hup>.p1>:nth-child(n+12),
#hup>.p2>:nth-child(n+9),
#hup>.p3>:nth-child(n+6),
#hup>.p4>:nth-child(n+3)
{
margin-left:-8px;
}

#hup1.p1>:nth-child(3n+12),
#hup1.p2>:nth-child(3n+9),
#hup1.p3>:nth-child(3n+6),
#hup1.p4>:nth-child(3n+3)
#hup>.p1>:nth-child(3n+12),
#hup>.p2>:nth-child(3n+9),
#hup>.p3>:nth-child(3n+6),
#hup>.p4>:nth-child(3n+3)
{
margin-left:16px !important;
}

#hup2>:nth-child(3n+4)
{
margin-left:12px;
}
22 changes: 22 additions & 0 deletions css/lp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#lp {
display:block;
left:80px;
position:relative;
top:425px;
width:80px;
height:24px;
margin:0 0 -32px;
text-align:left;
}

#lp.d {
color:#CCC;
}

#lp:hover {
cursor:pointer;
}

#act.mv~*, #act.mv~*:hover, #act.mv~* *:hover {
cursor:move !important;
}
44 changes: 43 additions & 1 deletion css/pz.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
background-repeat:no-repeat;
background-origin:content-box;
background-position:0 10px;
}
}


.w1 { background-image:url("../tp/w/1.png"); }
.w2 { background-image:url("../tp/w/2.png"); }
.w3 { background-image:url("../tp/w/3.png"); }
Expand Down Expand Up @@ -51,3 +53,43 @@
.z7 { background-image:url("../tp/z/7.png"); }
.z8 { background-image:url("../tp/z/8.png"); }
.z9 { background-image:url("../tp/z/9.png"); }

#hxsp { display:none; }

#hxsp.w1~* .w1 { background-image:url("../tp/h.png"), url("../tp/w/1.png"); }
#hxsp.w2~* .w2 { background-image:url("../tp/h.png"), url("../tp/w/2.png"); }
#hxsp.w3~* .w3 { background-image:url("../tp/h.png"), url("../tp/w/3.png"); }
#hxsp.w4~* .w4 { background-image:url("../tp/h.png"), url("../tp/w/4.png"); }
#hxsp.w5~* .w5 { background-image:url("../tp/h.png"), url("../tp/w/5.png"); }
#hxsp.w6~* .w6 { background-image:url("../tp/h.png"), url("../tp/w/6.png"); }
#hxsp.w7~* .w7 { background-image:url("../tp/h.png"), url("../tp/w/7.png"); }
#hxsp.w8~* .w8 { background-image:url("../tp/h.png"), url("../tp/w/8.png"); }
#hxsp.w9~* .w9 { background-image:url("../tp/h.png"), url("../tp/w/9.png"); }
#hxsp.b1~* .b1 { background-image:url("../tp/h.png"), url("../tp/b/1.png"); }
#hxsp.b2~* .b2 { background-image:url("../tp/h.png"), url("../tp/b/2.png"); }
#hxsp.b3~* .b3 { background-image:url("../tp/h.png"), url("../tp/b/3.png"); }
#hxsp.b4~* .b4 { background-image:url("../tp/h.png"), url("../tp/b/4.png"); }
#hxsp.b5~* .b5 { background-image:url("../tp/h.png"), url("../tp/b/5.png"); }
#hxsp.b6~* .b6 { background-image:url("../tp/h.png"), url("../tp/b/6.png"); }
#hxsp.b7~* .b7 { background-image:url("../tp/h.png"), url("../tp/b/7.png"); }
#hxsp.b8~* .b8 { background-image:url("../tp/h.png"), url("../tp/b/8.png"); }
#hxsp.b9~* .b9 { background-image:url("../tp/h.png"), url("../tp/b/9.png"); }
#hxsp.t1~* .t1 { background-image:url("../tp/h.png"), url("../tp/t/1.png"); }
#hxsp.t2~* .t2 { background-image:url("../tp/h.png"), url("../tp/t/2.png"); }
#hxsp.t3~* .t3 { background-image:url("../tp/h.png"), url("../tp/t/3.png"); }
#hxsp.t4~* .t4 { background-image:url("../tp/h.png"), url("../tp/t/4.png"); }
#hxsp.t5~* .t5 { background-image:url("../tp/h.png"), url("../tp/t/5.png"); }
#hxsp.t6~* .t6 { background-image:url("../tp/h.png"), url("../tp/t/6.png"); }
#hxsp.t7~* .t7 { background-image:url("../tp/h.png"), url("../tp/t/7.png"); }
#hxsp.t8~* .t8 { background-image:url("../tp/h.png"), url("../tp/t/8.png"); }
#hxsp.t9~* .t9 { background-image:url("../tp/h.png"), url("../tp/t/9.png"); }
#hxsp.z0~* .z0 { background-image:url("../tp/h.png"), url("../tp/z/0.png"); }
#hxsp.z1~* .z1 { background-image:url("../tp/h.png"), url("../tp/z/1.png"); }
#hxsp.z2~* .z2 { background-image:url("../tp/h.png"), url("../tp/z/2.png"); }
#hxsp.z3~* .z3 { background-image:url("../tp/h.png"), url("../tp/z/3.png"); }
#hxsp.z4~* .z4 { background-image:url("../tp/h.png"), url("../tp/z/4.png"); }
#hxsp.z5~* .z5 { background-image:url("../tp/h.png"), url("../tp/z/5.png"); }
#hxsp.z6~* .z6 { background-image:url("../tp/h.png"), url("../tp/z/6.png"); }
#hxsp.z7~* .z7 { background-image:url("../tp/h.png"), url("../tp/z/7.png"); }
#hxsp.z8~* .z8 { background-image:url("../tp/h.png"), url("../tp/z/8.png"); }
#hxsp.z9~* .z9 { background-image:url("../tp/h.png"), url("../tp/z/9.png"); }
10 changes: 5 additions & 5 deletions css/sp.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
}


#act.p4~#su>#su4.p0>div:hover,
#act.p4~#su>#su4.p1>div:nth-last-child(n+4):hover,
#act.p4~#su>#su4.p2>div:nth-last-child(n+7):hover,
#act.p4~#su>#su4.p3>div:nth-last-child(n+10):hover,
#act.p4~#su>#su4.p4>div:nth-last-child(n+13):hover
#act.p4:not(.mv)~#su>#su4.p0>div:hover,
#act.p4:not(.mv)~#su>#su4.p1>div:nth-last-child(n+4):hover,
#act.p4:not(.mv)~#su>#su4.p2>div:nth-last-child(n+7):hover,
#act.p4:not(.mv)~#su>#su4.p3>div:nth-last-child(n+10):hover,
#act.p4:not(.mv)~#su>#su4.p4>div:nth-last-child(n+13):hover
{
background-position:0 0;
cursor:pointer;
Expand Down
16 changes: 11 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!doctype html>
<!--
天津麻将
Copyright (C) 2011 田生
Tianjin Mahjong
Copyright (C) 2011 TIAN Sheng
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -15,24 +16,26 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
----
- - - -
All mahjong tiles were drawn by Jerry Crimson Mann From Wikipedia.
-->
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="mahjong.ico" type="image/x-icon" />
<title>天津麻将</title>
<script src="js/zhang.js"></script> <!-- 牌张 -->
<script src="js/var.js"></script> <!-- 变量定义 -->
<script src="js/const.js"></script> <!-- 常量定义 -->
<script src="js/buttons.js"></script> <!-- 绘制按钮 -->
<script src="js/zhuang.js"></script> <!-- 庄 -->
<script src="js/pq.js"></script> <!-- 牌墙 -->
<script src="js/px.js"></script> <!-- 手牌理牌 -->
<script src="js/ba.js"></script> <!-- 手牌 -->
<script src="js/pdhp.js"></script> <!-- 判断和牌 -->
<script src="js/hpxs.js"></script> <!-- 和牌显示 -->
<script src="js/fs.js"></script> <!-- 分数计算 -->
<script src="js/init.js"></script> <!-- 初始化 -->
<script src="js/wj.js"></script> <!-- 玩家打牌 -->
Expand All @@ -53,9 +56,11 @@
<link rel="stylesheet" href="css/hup.css" /> <!-- 和牌 -->
<link rel="stylesheet" href="css/huangp.css" /> <!-- 荒牌 -->
<link rel="stylesheet" href="css/gz.css" /> <!-- 规则 -->
<link rel="stylesheet" href="css/lp.css" /> <!-- 理牌 -->
<body>
<div id="main_body">
<div id="act">GNU GPL 3(+); 版本 0.1; 田生</div>
<div id="act"><a href="http://www.gnu.org/licenses/" rel="nofollow">GNU GPL 3</a>; 版本 0.1; 田生</div>
<div id="hxsp"></div>
<header>
<div id="gz">
<button id="gzsd">规则设定</button>
Expand Down Expand Up @@ -87,6 +92,7 @@
<div id="xp">
<div id="xz">
<div id="xzm"></div>
<button id="lp">自动理牌</button>
</div>
<div id="huangp">
荒牌
Expand Down
13 changes: 7 additions & 6 deletions js/ba.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Foobar is distributed in the hope that it will be useful,
Tianjin Mahjong is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
along with Tianjin Mahjong. If not, see <http://www.gnu.org/licenses/>.
*/

// 手牌
Expand All @@ -36,7 +36,7 @@ ba.prototype.init=function (pos, a) {
// 是不是杠gang[3]表示最右面(最先)一副
this.gang=[false, false, false, false];
// 理牌
this.sort();
if (pos!==4||autosort) this.sort();
}
ba.prototype.length=14;
// 除去碰杠外剩余的张数
Expand All @@ -58,19 +58,20 @@ ba.prototype.print=function () {
// 理牌
ba.prototype.sort=function () {
// 比较牌张大小
var zhangcmp=function (a,b) {
var zhangcmp
zhangcmp=function (a,b) {
var as=a.lb===0&&a.sz===9;
var bs=b.lb===0&&b.sz===9;
if (as&&!bs) return 1000;
else if (!as&&bs) return -1000;
var ah=a.samehuir(), bh=b.samehuir();
if (ah!==bh) return ah?-100:100;
return -10*(a.lb-b.lb)+(a.sz-b.sz);
};
}
// 只对没有碰的牌进行排序
var t=this.pz();
var i, j;
for (i=0;i<t-1;i++) for (j=i+1;j<t;j++)
for (i=0;i<t-2;i++) for (j=i+1;j<t;j++)
if (zhangcmp(this[i],this[j])>0) {
var temp=this[i]; this[i]=this[j]; this[j]=temp;
}
Expand Down
4 changes: 2 additions & 2 deletions js/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Foobar is distributed in the hope that it will be useful,
Tianjin Mahjong is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
along with Tianjin Mahjong. If not, see <http://www.gnu.org/licenses/>.
*/

// 清除所有按钮
Expand Down
4 changes: 2 additions & 2 deletions js/comq.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Foobar is distributed in the hope that it will be useful,
Tianjin Mahjong is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
along with Tianjin Mahjong. If not, see <http://www.gnu.org/licenses/>.
*/

// 保存各种牌现在还剩下多少
Expand Down
4 changes: 2 additions & 2 deletions js/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Foobar is distributed in the hope that it will be useful,
Tianjin Mahjong is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
along with Tianjin Mahjong. If not, see <http://www.gnu.org/licenses/>.
*/

// 常量定义
Expand Down
31 changes: 25 additions & 6 deletions js/dn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,39 @@
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Foobar is distributed in the hope that it will be useful,
Tianjin Mahjong is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
along with Tianjin Mahjong. If not, see <http://www.gnu.org/licenses/>.
*/

// 控制电脑打牌速度
var timer_dn, timeout_dn=100;

// 电脑打牌——选择
var dap_dn=function () {
setTimeout(function(){timer_dn=true},timeout_dn);
timer_dn=false;
var s=sp[zpos];
if (s.pdhp(chty===2).ky) {
callfunc(hup);
callfunc(hup_dn);
} else {
// 判断暗杠和小明杠
var i,j,c;
for (i=0;i<14;i++) if(!s[i].samehuir()) {
for (j=i,c=0;j<14;c+=(s[j++].same(s[i]))?1:0);
if (c===4) if (dnag(s,s[i])) {
dapc=new zhang(s[i].lb,s[i].sz);
callfunc(xm_agang);
callfunc(xm_agang_dn);
return;
}
}
var d=comchose(s);
dapc=new zhang(d.lb,d.sz);
callfunc(dac);
callfunc(dac_dn);
}
}

Expand All @@ -47,4 +52,18 @@ var pg_dn=function () {
if (c===3 && h==="g") callfunc(dmgang);
else if (h==="p") callfunc(peng);
else callfunc(pgqx);
}
}

hup_dn=function () {
if (timer_dn) callfunc(hup);
else setTimeout(hup_dn,10);
}
xm_agang_dn=function () {
if (timer_dn) callfunc(xm_agang);
else setTimeout(xm_agang_dn,10);
}
dac_dn=function () {
if (timer_dn) callfunc(dac);
else setTimeout(dac_dn,10);
}

Loading

0 comments on commit 3016a7a

Please sign in to comment.