Commit b2ade927 authored by mercury233's avatar mercury233

side tip and side timeout for mycard

parent a8b4148b
......@@ -1354,7 +1354,7 @@ if settings.modules.tips.get
load_tips()
setInterval ()->
for room in ROOM_all when room and room.established
ygopro.stoc_send_random_tip_to_room(room) unless room and room.started
ygopro.stoc_send_random_tip_to_room(room) if !room.started or room.changing_side
return
, 30000
......@@ -1538,7 +1538,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
buff_side = (info.deckbuf[i] for i in [info.mainc...info.mainc + info.sidec])
client.main = buff_main
client.side = buff_side
if room.random_type
if room.random_type or room.arena
if client.is_host
room.waiting_for_player = room.waiting_for_player2
room.last_active_time = moment()
......@@ -1585,7 +1585,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room and room.random_type
return unless room and (room.random_type or room.arena)
room.last_active_time = moment()
return
......@@ -1615,19 +1615,23 @@ ygopro.stoc_follow 'SELECT_HAND', false, (buffer, info, client, server)->
ygopro.stoc_follow 'SELECT_TP', false, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room and room.random_type
room.waiting_for_player = client
room.last_active_time = moment()
return unless room
room.changing_side = false
if room.random_type
room.waiting_for_player = client
room.last_active_time = moment()
return
ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room and room.random_type
if client.is_host
room.waiting_for_player = client
else
room.waiting_for_player2 = client
room.last_active_time = moment()
return unless room
room.changing_side = true
if room.random_type or room.arena
if client.is_host
room.waiting_for_player = client
else
room.waiting_for_player2 = client
room.last_active_time = moment()
return
ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
......@@ -1680,6 +1684,20 @@ if settings.modules.random_duel.enabled
return
, 1000
if settings.modules.mycard.enabled
setInterval ()->
for room in ROOM_all when room and room.started and room.arena and room.changing_side and room.last_active_time and room.waiting_for_player
time_passed = Math.floor((moment() - room.last_active_time) / 1000)
#log.info time_passed
if time_passed >= settings.modules.random_duel.hang_timeout
room.last_active_time = moment()
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
room.waiting_for_player.server.destroy()
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10)
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED)
return
, 1000
# spawn windbot
if settings.modules.windbot.spawn
windbot_process = spawn 'mono', ['WindBot.exe', settings.modules.windbot.port], {cwd: 'windbot'}
......
......@@ -1651,7 +1651,7 @@
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
if (room && room.established) {
if (!(room && room.started)) {
if (!room.started || room.changing_side) {
ygopro.stoc_send_random_tip_to_room(room);
}
}
......@@ -1912,7 +1912,7 @@
})();
client.main = buff_main;
client.side = buff_side;
if (room.random_type) {
if (room.random_type || room.arena) {
if (client.is_host) {
room.waiting_for_player = room.waiting_for_player2;
}
......@@ -1973,7 +1973,7 @@
ygopro.ctos_follow('RESPONSE', false, function(buffer, info, client, server) {
var room;
room = ROOM_all[client.rid];
if (!(room && room.random_type)) {
if (!(room && (room.random_type || room.arena))) {
return;
}
room.last_active_time = moment();
......@@ -2017,25 +2017,31 @@
ygopro.stoc_follow('SELECT_TP', false, function(buffer, info, client, server) {
var room;
room = ROOM_all[client.rid];
if (!(room && room.random_type)) {
if (!room) {
return;
}
room.waiting_for_player = client;
room.last_active_time = moment();
room.changing_side = false;
if (room.random_type) {
room.waiting_for_player = client;
room.last_active_time = moment();
}
});
ygopro.stoc_follow('CHANGE_SIDE', false, function(buffer, info, client, server) {
var room;
room = ROOM_all[client.rid];
if (!(room && room.random_type)) {
if (!room) {
return;
}
if (client.is_host) {
room.waiting_for_player = client;
} else {
room.waiting_for_player2 = client;
room.changing_side = true;
if (room.random_type || room.arena) {
if (client.is_host) {
room.waiting_for_player = client;
} else {
room.waiting_for_player2 = client;
}
room.last_active_time = moment();
}
room.last_active_time = moment();
});
ygopro.stoc_follow('REPLAY', true, function(buffer, info, client, server) {
......@@ -2116,6 +2122,26 @@
}, 1000);
}
if (settings.modules.mycard.enabled) {
setInterval(function() {
var j, len, room, time_passed;
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
if (!(room && room.started && room.arena && room.changing_side && room.last_active_time && room.waiting_for_player)) {
continue;
}
time_passed = Math.floor((moment() - room.last_active_time) / 1000);
if (time_passed >= settings.modules.random_duel.hang_timeout) {
room.last_active_time = moment();
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
room.waiting_for_player.server.destroy();
} else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10)) {
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${afk_warn_part1}" + (settings.modules.random_duel.hang_timeout - time_passed) + "${afk_warn_part2}", ygopro.constants.COLORS.RED);
}
}
}, 1000);
}
if (settings.modules.windbot.spawn) {
windbot_process = spawn('mono', ['WindBot.exe', settings.modules.windbot.port], {
cwd: 'windbot'
......
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