Skip to content

Commit

Permalink
기능개발
Browse files Browse the repository at this point in the history
  • Loading branch information
yjseo29 committed Apr 11, 2016
1 parent 923f67c commit e6d0a22
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 83 deletions.
44 changes: 17 additions & 27 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,15 @@ io.on('connection',function(socket){
rooms[url] = new Object();
rooms[url].title = data.title;
rooms[url].url = url;
rooms[url].last_turn = "";
rooms[url].passwd = data.passwd;
rooms[url].last_turn = "black";
rooms[url].password = data.password;
rooms[url].username = socket.username;
rooms[url].state = "ready";
rooms[url].time = getTime();
rooms[url].user_list = new Object();

//방목록 업데이트
var roomList = new Array();
for(var room in rooms){
roomList.push(rooms[room]);
}
io.sockets.in('lobby').emit('list_room',{rooms:roomList});
//클라이언트에게 추가된방 전송
io.sockets.in('lobby').emit('add_list_room',{room:rooms[url]});

//방생성 결과 응답
socket.emit('res_create_room', {result:true, url:url});
Expand All @@ -123,7 +119,8 @@ io.on('connection',function(socket){

if(rooms[url] != undefined) {

if(Object.keys(rooms[url].user_list).length)
if(rooms[url].state == "start")

socket.room = url;
socket.join(url);
socket.username = data.username;
Expand All @@ -149,14 +146,14 @@ io.on('connection',function(socket){
//게임상황 업데이트
io.sockets.in(url).emit('state_game', {state:rooms[url].state,time:getTime()});

//유저목록 업데이트
//유저목록 추가
var userList = new Array();
for(var user in rooms[url].user_list){
if (rooms[url].user_list.hasOwnProperty(user)) {
userList.push(rooms[url].user_list[user]);
}
}
io.sockets.in(url).emit('user_list', {users:userList});
io.sockets.in(url).emit('room_user_list', {users:userList});
}else{
console.log("!! 존재하지않는 방");
io.sockets.in(url).emit('init_game', {result:false});
Expand Down Expand Up @@ -195,31 +192,24 @@ io.on('connection',function(socket){
socket.on('disconnect', function(){
console.log("socket disconnect current room : "+ socket.room);
if(socket.room != undefined && socket.room != "lobby"){
delete rooms[socket.room].user_list[socket.id];
io.sockets.in(socket.room).emit('broadcast_msg', {msg:socket.username+"님이 퇴장하였습니다.",type:"system",time:getTime()});

//게임상황 업데이트
rooms[socket.room].state = "stop";
io.sockets.in(socket.room).emit('state_game', {state:rooms[socket.room].state,time:getTime()});
if(rooms[socket.room].user_list[socket.id].type == "black" || rooms[socket.room].user_list[socket.id].type == "white"){
rooms[socket.room].state = "stop";
io.sockets.in(socket.room).emit('state_game', {state:rooms[socket.room].state,time:getTime()});
}

//유저목록 업데이트
var userList = new Array();
for(var user in rooms[socket.room].user_list){
if (rooms[socket.room].user_list.hasOwnProperty(user)) {
userList.push(rooms[socket.room].user_list[user]);
}
}
io.sockets.in(socket.room).emit('user_list', {users:userList});
delete rooms[socket.room].user_list[socket.id];
io.sockets.in(socket.room).emit('del_room_user', {type:rooms[socket.room].user_list[socket.id].type});

io.sockets.in(socket.room).emit('broadcast_msg', {msg:socket.username+"님이 퇴장하였습니다.",type:"system",time:getTime()});

//유저가 아무도 없을시 방 없애기
if(Object.keys(rooms[socket.room].user_list).length == 0){
delete rooms[socket.room];
//방목록 업데이트
var roomList = new Array();
for(var room in rooms){
roomList.push(rooms[room]);
}
io.sockets.in('lobby').emit('list_room',{rooms:roomList});
io.sockets.in('lobby').emit('del_list_room',{url:socket.room});
}

socket.room = null;
Expand Down
37 changes: 29 additions & 8 deletions public/css/global-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ button:hover{
cursor: pointer;
}
a:focus{ outline:none; } :focus{ outline-color: transparent; outline-style: none; }.btn:focus{ outline: none; outline-style: none; }select:focus,button:focus{ outline: none; outline-style: none; }
::-webkit-input-placeholder {
input::-webkit-input-placeholder {
color: #bdc4c9;
}

:-moz-placeholder { /* Firefox 18- */
input:-moz-placeholder { /* Firefox 18- */
color: #bdc4c9;
}

::-moz-placeholder { /* Firefox 19+ */
input::-moz-placeholder { /* Firefox 19+ */
color: #bdc4c9;
}

:-ms-input-placeholder {
input:-ms-input-placeholder {
color: #bdc4c9;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
Expand Down Expand Up @@ -80,15 +80,32 @@ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
.modal-content{
border-radius: 3px;
box-shadow: 0 2px 26px rgba(0, 0, 0, .3), 0 0 0 1px rgba(0, 0, 0, .1);
padding: 15px;
padding: 15px 25px;
background: #fff;
width: 100%;
max-width: 400px;
margin: 0 auto;
position: relative;
}
.modal-content > .close{
position: absolute;
top: 10px;
right: 10px;
z-index: 10000;
background-color: transparent;
border: 0;
font-size: 22px;
color: #000;
opacity: 0.6;
text-shadow: 0 1px 0 #fff;
padding: 0;
}
.modal-content > .close:hover{
opacity: 0.85;
}
.modal-content > .title{
color: #4e5665;
font-weight: 400;
font-weight: 300;
margin-bottom: 25px;
}
.form-control{
Expand All @@ -100,19 +117,23 @@ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
width: 245px;
border-radius: 4px;
outline: none;
-webkit-transition: border-color .3s ease-out;
-moz-transition: border-color .3s ease-out;
-o-transition: border-color .3s ease-out;
transition: border-color .3s ease-out;
}
.form-control.block{
width: 100%;
display: block;
}
.form-control:focus{
border: 1px solid #0084ff;
border-color: #0084ff;
}
.btn-white{
margin-top:15px;
color:#0084ff;
border:0;
outline:none;
font-size:20px;
font-size:18px;
background:#fff;
}
Loading

0 comments on commit e6d0a22

Please sign in to comment.