Skip to content

Commit

Permalink
0.4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Aug 12, 2021
1 parent 4ad75f1 commit 5023a30
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 20 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ Ubuntu高版本中可能会出现GUI将可执行文件当做动态链接库的

没钱买苹果电脑,所以用VMware做了个黑苹果编译测试,安装系统版本10.14。在真机上可能会出现问题。

0.4.9版部分数据准确性存疑,正在尝试找到问题。

## 联系

如果发现任何bug,可以通过[github](https://github.com/zyr17/MajsoulPaipuAnalyzer/issues)或是jzjqz17@gmail.com说明。
Expand Down
7 changes: 7 additions & 0 deletions SimpleMahjong/paipu.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ class majsoulpaipuanalyze{
//太短是因为牌谱未被归档导致返回错误信息
let pdata = Protobuf2Object(data);
this.pdatarecords = pdata.records;
if (pdata.version && pdata.actions && pdata.actions.length){
let records = [];
for (let i in pdata.actions)
if (pdata.actions[i].result && pdata.actions[i].result.constructor.name.indexOf('Array') == -1)
records.push(pdata.actions[i].result);
this.pdatarecords = records;
}
//for (let i in pdata.records) View.IAction(pdata.records[i]);
this.analyzenextpart();
if (this.paipus != undefined){
Expand Down
6 changes: 6 additions & 0 deletions doc/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.4.9
1. 修复了新版本牌谱分析失败的问题。由于之前存档了错误分析的牌谱,需要对所有牌谱重新分析,需要较长耗时。(以后会进行问题牌谱筛选,减少出错后的重分析时间)
2. 将删去牌谱改为移动牌谱,避免将来程序BUG导致生成牌谱数据丢失。
3. 现在720P的显示器式微,稍微调整了窗口默认大小。
4. 依然存在牌谱数据分析不准确的问题,目前未复现,需要确认原因。

0.4.8
1. 修复了新版本牌谱获取失败,严重时会导致IP封禁的问题。
2. IP封禁原因为牌谱数据获取失败时逻辑有BUG导致短时间内向服务端发送大量请求所致,目前已修复。
Expand Down
5 changes: 3 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const { version, repository } = require('../package.json');

const defaultconfig = {
DefaultURL: 'https://game.maj-soul.com/1/',
PaipuMinVersion: '0.4.4',
ConfigMinVersion: '0.4.5'
PaipuMinVersion: '0.4.9',
GamedataMinVersion: '0.4.4',
ConfigMinVersion: '0.4.9'
};
var config = undefined;
const configfilename = 'config.json';
Expand Down
10 changes: 10 additions & 0 deletions lib/majsoul/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ function ProtobufDecode(arr8, recursive = true, ProtobufType = ProtobufWrapper){
data[key].actions[i] = ProtobufDecode(data[key].actions[i].data, recursive, ProtobufRoot.lookupType(data[key].actions[i].name));
}
}
else if (ProtobufType.fields[key].type == 'GameAction'){
console.log(data[key].length);
for (let i in data[key]){
if (data[key][i].result.constructor.name == 'String' || data[key][i].result.constructor.name == 'Uint8Array'){
let buffer = new Buffer(data[key][i].result, 'base64');
data[key][i].result = ProtobufDecode(new Uint8Array(buffer));
}
else console.log(data[key][i].result.constructor.name, JSON.stringify(data[key][i].result));
}
}
}
return data;
}
Expand Down
72 changes: 56 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const path = require('path').join,
const { analyze, paipugamedata, analyzeGameRecord, getUserID, setUserID, AnalyzeInit, Protobuf2Object, reporterror } = require('./lib/majsoul/analyze');

let InMacOS = process.platform == 'darwin';
let activate_devtool = 0;

var paipuversion = undefined;
var appPath = app.getAppPath();
Expand All @@ -30,17 +31,17 @@ if (InMacOS) dataPath = __dirname + '/../../../../' + dataPath;

const ready = () => {
var newWindow = new BrowserWindow({
width: 600,
height: 650,
width: 650,
height: 700,
title: `Simple Mahjong`,
show: false,
webPreferences: {
nodeIntegration: true
}
});
var browseWindow = new BrowserWindow({
width: 800,
height: 500,
width: 1280,
height: 770,
title: `browser`,
show: false,
webPreferences: {
Expand Down Expand Up @@ -462,18 +463,17 @@ const ready = () => {
submenu: [{
label: '清除配置数据',
click: function() {
dialog.showMessageBox({
let response = dialog.showMessageBoxSync({
type: 'warning',
title: '警告',
message: '是否清除配置数据?\n错误上报、默认服务器、更新检查等相关配置会被清除,data文件夹和config.json不会改动。',
cancelId: 1,
noLink: true,
buttons: ['是', '否']
}, function (response) {
if (response == 0){
config.clear();
}
});
if (response == 0){
config.clear();
}
}
}, {
label: '打开开发者工具',
Expand All @@ -484,6 +484,8 @@ const ready = () => {
}, {
label: '下载牌谱并保存',
click: function() {
if (activate_devtool != 3)
return;
prompt({
title: '输入牌谱号',
label: '牌谱号:',
Expand All @@ -492,16 +494,34 @@ const ready = () => {
browseWindow.webContents.send('fetchpaipudata', uuid, 'fetchpaipudatasave');
});
}
}, {
label: '选择牌谱并保存元信息',
click: function() {
if (activate_devtool != 3)
return;
let path = dialog.showOpenDialogSync({
title: '牌谱文件',
multiSelections: true
});
if (!path)
return;
for (let i in path){
let data = fs.readFileSync(path[i]);
data = analyze(data);
fs.writeFileSync(path[i] + '.json', JSON.stringify(data.toJSON()));
}
}
}, {
label: '关于',
click: function() {
dialog.showMessageBox({
let response = dialog.showMessageBoxSync({
type: 'info',
title: '关于',
noLink: true,
buttons: ['确定'],
buttons: ['确定', '取消'],
message: `MajsoulPaipuCrawler v${config.get('Version')}\nContact: jzjqz17@gmail.com\nGithub: https://github.com/zyr17/MajsoulPaipuAnalyzer`
});
activate_devtool |= response + 1;
}
}]
}];
Expand Down Expand Up @@ -538,7 +558,7 @@ const ready = () => {
let gamedata = gamedatas[i];
if (gamedata.length < 2) continue;
let gdata = JSON.parse(gamedata);
if (gdata.version == undefined || config.versionconvert(gdata.version) < config.versionconvert(config.get('PaipuMinVersion'))){
if (gdata.version == undefined || config.versionconvert(gdata.version) < config.versionconvert(config.get('GamedataMinVersion'))){
oldgamedatas.push(gdata);
continue;
}
Expand All @@ -555,6 +575,7 @@ const ready = () => {
message: `发现 ${oldgamedatas.length} 个旧版本获取的牌谱数据,请前往 牌谱 界面重新获取一遍牌谱数据。`
});

const paipu_bk_folder_name = 'old_paipu_backup';
paipuversion = {};
ppp = path(root, 'paipuversion.txt');
if (fs.existsSync(ppp))
Expand All @@ -565,6 +586,8 @@ const ready = () => {
let i = dirite.next();
if (i.done) break;
i = i.value;
if (i == paipu_bk_folder_name)
continue;
let add = false;
if (!paipuversion.hasOwnProperty(i)){
let paipudata = JSON.parse(String(fs.readFileSync(path(root, 'paipus', i))));
Expand All @@ -585,18 +608,35 @@ const ready = () => {
noLink: true,
buttons: ['确定'],
title: '发现旧牌谱',
message: `发现 ${oldpaipus.length} 个旧版本生成的牌谱,需要重新生成,会将旧牌谱删去,可能需要一定时间。`
message: `发现 ${oldpaipus.length} 个旧版本生成的牌谱,需要重新生成,会将旧牌谱移至备份文件夹,可能需要一定时间。`
});
let bkpaipupath = path(root, 'paipus', paipu_bk_folder_name);
if (fs.existsSync(bkpaipupath)){
/*
no need to do anything
dialog.showMessageBoxSync({
type: 'warning',
noLink: true,
buttons: ['确定'],
title: '备份文件夹已存在',
message: '备份文件夹已存在,可能由之前的牌谱备份操作创建,'
});
*/
}
else{
fs.mkdirSync(bkpaipupath);
}
for (let i in oldpaipus){
ppp = path(root, 'paipus', oldpaipus[i]);
fs.unlinkSync(ppp);
let ppp = path(root, 'paipus', oldpaipus[i]);
let ttt = path(bkpaipupath, oldpaipus[i]);
fs.renameSync(ppp, ttt);
}
dialog.showMessageBox({
type: 'info',
noLink: true,
buttons: ['确定'],
title: '发现旧牌谱',
message: `旧牌谱删除完成。`
message: `旧牌谱转移完成。`
});
}
ipcMain.on('downloadconvertresult', (event, data) => {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "majsoul-paipu-crawler",
"version": "0.4.8",
"version": "0.4.9",
"description": "Get Paipu from Majsoul",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 5023a30

Please sign in to comment.