Commit 9d553918 authored by mercury233's avatar mercury233

fix & add ai log

parent c78c65d7
...@@ -322,9 +322,9 @@ class Room ...@@ -322,9 +322,9 @@ class Room
player.pre_establish_buffers = [] player.pre_establish_buffers = []
return return
return return
console.log @windbot
if @windbot if @windbot
spawn 'mono', ['WindBot.exe'], { log.info @windbot
@ai_process = spawn 'mono', ['WindBot.exe'], {
cwd: 'windbot', env: { cwd: 'windbot', env: {
YGOPRO_VERSION: settings.version YGOPRO_VERSION: settings.version
YGOPRO_HOST: '127.0.0.1' YGOPRO_HOST: '127.0.0.1'
...@@ -334,6 +334,12 @@ class Room ...@@ -334,6 +334,12 @@ class Room
YGOPRO_DIALOG: @windbot.dialog YGOPRO_DIALOG: @windbot.dialog
} }
} }
@ai_process.stdout.on 'data', (data)=>
log.info "AI stdout: " + data
return
@ai_process.stderr.on 'data', (data)=>
log.info "AI stderr: " + data
return
return return
catch catch
@error = "建立房间失败,请重试" @error = "建立房间失败,请重试"
......
...@@ -420,9 +420,9 @@ ...@@ -420,9 +420,9 @@
player.pre_establish_buffers = []; player.pre_establish_buffers = [];
}); });
}); });
console.log(_this.windbot);
if (_this.windbot) { if (_this.windbot) {
spawn('mono', ['WindBot.exe'], { log.info(_this.windbot);
_this.ai_process = spawn('mono', ['WindBot.exe'], {
cwd: 'windbot', cwd: 'windbot',
env: { env: {
YGOPRO_VERSION: settings.version, YGOPRO_VERSION: settings.version,
...@@ -433,6 +433,12 @@ ...@@ -433,6 +433,12 @@
YGOPRO_DIALOG: _this.windbot.dialog YGOPRO_DIALOG: _this.windbot.dialog
} }
}); });
_this.ai_process.stdout.on('data', function(data) {
log.info("AI stdout: " + data);
});
_this.ai_process.stderr.on('data', function(data) {
log.info("AI stderr: " + data);
});
} }
}; };
})(this)); })(this));
......
...@@ -31,6 +31,8 @@ settings.BANNED_IP = [] ...@@ -31,6 +31,8 @@ settings.BANNED_IP = []
settings.modules.hang_timeout = 90 settings.modules.hang_timeout = 90
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\d]+)/)[1], '16') settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\d]+)/)[1], '16')
settings.lflist = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g) settings.lflist = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/)
continue unless date
{date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD'), tcg: list.indexOf('TCG') != -1}) {date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD'), tcg: list.indexOf('TCG') != -1})
#组件 #组件
...@@ -339,7 +341,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -339,7 +341,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else else
windbot = _.sample settings.modules.windbot windbot = _.sample settings.modules.windbot
room = Room.find_or_create_by_name('AI#' + Math.random().toString()) # 这个 AI# 没有特殊作用, 仅作为标记 room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000)) # 这个 AI# 没有特殊作用, 仅作为标记
room.windbot = windbot room.windbot = windbot
room.private = true room.private = true
client.room = room client.room = room
......
// Generated by CoffeeScript 1.10.0 // Generated by CoffeeScript 1.10.0
(function() { (function() {
var Graveyard, Room, _, bunyan, crypto, debug, dialogues, execFile, fs, http, http_server, https, https_server, list, log, moment, net, options, os, path, pg, request, requestListener, roomlist, settings, tips, tribute, url, users_cache, wait_room_start, ygopro; var Graveyard, Room, _, bunyan, crypto, date, debug, dialogues, execFile, fs, http, http_server, https, https_server, list, log, moment, net, options, os, path, pg, request, requestListener, roomlist, settings, tips, tribute, url, users_cache, wait_room_start, ygopro;
net = require('net'); net = require('net');
...@@ -46,6 +46,10 @@ ...@@ -46,6 +46,10 @@
results = []; results = [];
for (k = 0, len = ref.length; k < len; k++) { for (k = 0, len = ref.length; k < len; k++) {
list = ref[k]; list = ref[k];
date = list.match(/!([\d\.]+)/);
if (!date) {
continue;
}
results.push({ results.push({
date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD'), date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD'),
tcg: list.indexOf('TCG') !== -1 tcg: list.indexOf('TCG') !== -1
...@@ -382,7 +386,7 @@ ...@@ -382,7 +386,7 @@
} else { } else {
windbot = _.sample(settings.modules.windbot); windbot = _.sample(settings.modules.windbot);
} }
room = Room.find_or_create_by_name('AI#' + Math.random().toString()); room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000));
room.windbot = windbot; room.windbot = windbot;
room["private"] = true; room["private"] = true;
client.room = room; client.room = room;
......
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