Commit 5b969a26 authored by nanahira's avatar nanahira

add no watch room support

parent 7c838b81
......@@ -52,6 +52,7 @@
"watch_join": "joined as spectator.",
"watch_watching": "Spectating.",
"watch_denied": "Duel has begun, spectating is unallowed",
"watch_denied_room": "Spectating is unallowed in this room",
"rank_arena": ", Your ranking is",
"rank_blank": ", You are not ranked.",
"exp_value_part1": ", You have ",
......@@ -335,6 +336,7 @@
"watch_join": "加入了观战",
"watch_watching": "观战中",
"watch_denied": "决斗已开始,不允许观战",
"watch_denied_room": "本房间不允许观战",
"rank_arena": ",排名第",
"rank_blank": ",暂无排名",
"exp_value_part1": ",你有",
......
......@@ -785,6 +785,9 @@ class Room
if (rule.match /(^|,|,)(IGPRIORITY|PR)(,|,|$)/)
@hostinfo.enable_priority = true
if (rule.match /(^|,|,)(NOWATCH|NW)(,|,|$)/)
@no_watch = true
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'),
(if @hostinfo.no_check_deck then 'T' else 'F'), (if @hostinfo.no_shuffle_deck then 'T' else 'F'),
@hostinfo.start_lp, @hostinfo.start_hand, @hostinfo.draw_count, @hostinfo.time_limit, @hostinfo.replay_mode]
......@@ -1448,7 +1451,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else if room.error
ygopro.stoc_die(client, room.error)
else if room.started
if settings.modules.cloud_replay.enable_halfway_watch
if settings.modules.cloud_replay.enable_halfway_watch and !room.no_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
client.is_post_watcher = true
......@@ -1503,7 +1506,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else if settings.modules.challonge.enabled
pre_room = ROOM_find_by_name(info.pass)
if pre_room and pre_room.started and settings.modules.cloud_replay.enable_halfway_watch
if pre_room and pre_room.started and settings.modules.cloud_replay.enable_halfway_watch and !pre_room.no_watch
room = pre_room
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
......@@ -1563,7 +1566,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else if room.error
ygopro.stoc_die(client, room.error)
else if room.started
if settings.modules.cloud_replay.enable_halfway_watch
if settings.modules.cloud_replay.enable_halfway_watch and !room.no_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
client.is_post_watcher = true
......@@ -1644,7 +1647,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else if room.error
ygopro.stoc_die(client, room.error)
else if room.started
if settings.modules.cloud_replay.enable_halfway_watch
if settings.modules.cloud_replay.enable_halfway_watch and !room.no_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
client.is_post_watcher = true
......@@ -1655,6 +1658,8 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
client.write buffer
else
ygopro.stoc_die(client, "${watch_denied}")
else if room.no_watch and room.players.length == (if room.hostinfo.mode == 2 then 4 else 2)
ygopro.stoc_die(client, "${watch_denied_room}")
else
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
......@@ -1708,7 +1713,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
recorder.on 'error', (error)->
return
if settings.modules.cloud_replay.enable_halfway_watch and !room.watcher
if settings.modules.cloud_replay.enable_halfway_watch and !room.watcher and !room.no_watch
room.watcher = watcher = if settings.modules.test_mode.watch_public_hand then room.recorder else net.connect room.port, ->
ygopro.ctos_send watcher, 'PLAYER_INFO', {
name: "the Big Brother"
......@@ -2002,6 +2007,9 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
ygopro.ctos_follow 'HS_TOOBSERVER', true, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room
if room.no_watch
ygopro.stoc_send_chat(client, "${watch_denied_room}", ygopro.constants.COLORS.RED)
return true
if (!room.arena and !settings.modules.challonge.enabled) or client.is_local
return false
for player in room.players
......@@ -2028,13 +2036,16 @@ ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server)->
ygopro.stoc_send_chat_to_room(room, "#{player.name} ${kicked_by_player}", ygopro.constants.COLORS.RED)
return false
ygopro.stoc_follow 'TYPE_CHANGE', false, (buffer, info, client, server)->
ygopro.stoc_follow 'TYPE_CHANGE', true, (buffer, info, client, server)->
selftype = info.type & 0xf
is_host = ((info.type >> 4) & 0xf) != 0
# if room and room.no_watch and selftype == 7
# ygopro.stoc_die(client, "${watch_denied_room}")
# return true
client.is_host = is_host
client.pos = selftype
#console.log "TYPE_CHANGE to #{client.name}:", info, selftype, is_host
return
return false
ygopro.stoc_follow 'HS_PLAYER_CHANGE', false, (buffer, info, client, server)->
room=ROOM_all[client.rid]
......
......@@ -992,6 +992,9 @@
if (rule.match(/(^|,|,)(IGPRIORITY|PR)(,|,|$)/)) {
this.hostinfo.enable_priority = true;
}
if (rule.match(/(^|,|,)(NOWATCH|NW)(,|,|$)/)) {
this.no_watch = true;
}
}
param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, (this.hostinfo.enable_priority ? 'T' : 'F'), (this.hostinfo.no_check_deck ? 'T' : 'F'), (this.hostinfo.no_shuffle_deck ? 'T' : 'F'), this.hostinfo.start_lp, this.hostinfo.start_hand, this.hostinfo.draw_count, this.hostinfo.time_limit, this.hostinfo.replay_mode];
try {
......@@ -1769,7 +1772,7 @@
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.started) {
if (settings.modules.cloud_replay.enable_halfway_watch) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.no_watch) {
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
......@@ -1834,7 +1837,7 @@
});
} else if (settings.modules.challonge.enabled) {
pre_room = ROOM_find_by_name(info.pass);
if (pre_room && pre_room.started && settings.modules.cloud_replay.enable_halfway_watch) {
if (pre_room && pre_room.started && settings.modules.cloud_replay.enable_halfway_watch && !pre_room.no_watch) {
room = pre_room;
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
......@@ -1909,7 +1912,7 @@
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.started) {
if (settings.modules.cloud_replay.enable_halfway_watch) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.no_watch) {
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
......@@ -1986,7 +1989,7 @@
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.started) {
if (settings.modules.cloud_replay.enable_halfway_watch) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.no_watch) {
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
......@@ -2001,6 +2004,8 @@
} else {
ygopro.stoc_die(client, "${watch_denied}");
}
} else if (room.no_watch && room.players.length === (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
} else {
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
......@@ -2060,7 +2065,7 @@
});
recorder.on('error', function(error) {});
}
if (settings.modules.cloud_replay.enable_halfway_watch && !room.watcher) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.watcher && !room.no_watch) {
room.watcher = watcher = settings.modules.test_mode.watch_public_hand ? room.recorder : net.connect(room.port, function() {
ygopro.ctos_send(watcher, 'PLAYER_INFO', {
name: "the Big Brother"
......@@ -2434,6 +2439,10 @@
if (!room) {
return;
}
if (room.no_watch) {
ygopro.stoc_send_chat(client, "${watch_denied_room}", ygopro.constants.COLORS.RED);
return true;
}
if ((!room.arena && !settings.modules.challonge.enabled) || client.is_local) {
return false;
}
......@@ -2476,12 +2485,13 @@
return false;
});
ygopro.stoc_follow('TYPE_CHANGE', false, function(buffer, info, client, server) {
ygopro.stoc_follow('TYPE_CHANGE', true, function(buffer, info, client, server) {
var is_host, selftype;
selftype = info.type & 0xf;
is_host = ((info.type >> 4) & 0xf) !== 0;
client.is_host = is_host;
client.pos = selftype;
return false;
});
ygopro.stoc_follow('HS_PLAYER_CHANGE', false, function(buffer, info, client, server) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment