Skip to content

Commit

Permalink
Update SobResult.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bcgameProject authored Sep 16, 2024
1 parent b682537 commit 477bae6
Showing 1 changed file with 7 additions and 32 deletions.
39 changes: 7 additions & 32 deletions lib/SobResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,11 @@ class SobResult {
this.bonusData = this.formatBonusByCSV(bonus_csv);
}

/**
* 通过index获取表格
* @param data 目标表
* @param cowIndexs 索引列表
*/

getDataByIndex(data, cowIndexs) {
return this.cowNums.map((num, index) => {
//cowIndex下标是1开始的
const start = cowIndexs[index];
const end = start + num;
// 补齐end
let dataCow = data[index].concat(data[index].slice(0, num));
return dataCow.slice(start, end);
});
Expand All @@ -281,18 +275,14 @@ class SobResult {
return this.getDataByIndex(this.freeData, cowIndexs);
}

/**
* 格式化出来csv文件
*/

formatCsv(csvData) {
return (csvData)
.split('\n')
.map((it) => it.split(',').map((it) => Number(it)));
}

/**
* 格式表数据
*/

formatDataByCSV(csvData) {
const currData = this.formatCsv(csvData);
const data = [[], [], [], [], []];
Expand All @@ -307,10 +297,7 @@ class SobResult {
return data;
}

/**
* 格式化线数据
* @param csvData
*/

formatLinesByCSV(csvData) {
const currData = this.formatCsv(csvData);
const data = [];
Expand All @@ -320,10 +307,7 @@ class SobResult {
return data;
}

/**
* 格式化bonus数据
* @param csvData
*/

formatBonusByCSV(csvData) {
const currData = this.formatCsv(csvData);
console.log('currData', currData);
Expand All @@ -336,11 +320,7 @@ class SobResult {
return data;
}

/**
* 分割hash数值
* @param hash hash
* @param step 步长
*/

getNumsByHash(hash, step = 2) {
let res = [];
for (let i = 0; i < hash.length; i += step) {
Expand All @@ -351,12 +331,7 @@ class SobResult {
return res;
}

/**
* 通过模数获取hash结果
* @param hash
* @param modulusList 模数
* @param step 步长
*/

getResultNumsByHash(hash, modulusList, step = 4) {
let hashNums = this.getNumsByHash(hash);
return modulusList.map((modulus, i) => {
Expand Down

0 comments on commit 477bae6

Please sign in to comment.