Skip to content

Commit e88009f

Browse files
committed
base file
1 parent ffd9998 commit e88009f

File tree

11 files changed

+169
-0
lines changed

11 files changed

+169
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

client/login.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
9+
<div>
10+
<div><label>用户名</label><input type="text" id="a"></div>
11+
<button onclick="aa"> 登陆</button>
12+
</div>
13+
14+
<script>
15+
function post(url, data, cb) {
16+
var a = new XMLHttpRequest();
17+
xhr.open("POST", "url");
18+
xhr.send(data);
19+
xhr.addEventListener("load", function () {
20+
cb && cb()
21+
}, false);
22+
23+
}
24+
function aa() {
25+
var val = document.querySelector('#a').value;
26+
27+
var player=new Player({
28+
29+
})
30+
post('server', , function () {
31+
localStorage.setItem('u', val);
32+
location.href = 'index.html';
33+
})
34+
35+
36+
}
37+
</script>
38+
</body>
39+
</html>
File renamed without changes.
File renamed without changes.

server/player.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Created by a2014 on 14-6-20.
3+
*/
4+
/**
5+
* Created by a2014 on 14-6-20.
6+
*/
7+
8+
var role = {
9+
landlord: 'landlord', //地主
10+
peasants: 'peasants' //贫民
11+
}
12+
13+
var state = {
14+
trusteeship: 'trusteeship',
15+
normal: 'normal',
16+
offLine: 'offLine'
17+
}
18+
19+
playerHelper = {
20+
role: role,
21+
state: state
22+
}
23+
24+
25+
function Player(o) {
26+
//用户名
27+
this.uname = o.uname || 'player';
28+
//头像
29+
this.head = o.head || '';
30+
//角色
31+
this.role = o.role;
32+
//得分
33+
this.score = o.score || 0;
34+
//拥有的牌
35+
this.poker = o.poker || [];
36+
//状态
37+
this.state = o.state || state.normal
38+
}
39+
40+
Player.prototype = {
41+
42+
/**
43+
* 抢地主
44+
*
45+
* @method pillage
46+
*/
47+
pillage: function () {
48+
49+
},
50+
/**
51+
* 加一张牌
52+
*
53+
* @method addPoker
54+
* @param { Poker } poker - 一张牌
55+
* */
56+
addPoker: function (poker) {
57+
this.poker.push(poker);
58+
},
59+
60+
/**
61+
* 托管
62+
* @method trusteeship
63+
*
64+
*/
65+
setTrusteeship: function () {
66+
},
67+
68+
/**
69+
* 名牌
70+
*
71+
*/
72+
setLuckyNumber: function () {
73+
74+
},
75+
//出牌
76+
attack: function () {
77+
78+
}
79+
}
80+
exports.Player = player;
81+
exports.playerHelper = playerHelper;

0 commit comments

Comments
 (0)