Skip to content

Commit 0d2a720

Browse files
committed
Update rustlabs static files
1 parent 8996b5a commit 0d2a720

File tree

9 files changed

+33623
-3192
lines changed

9 files changed

+33623
-3192
lines changed

src/external/process_rustlabs.js

Lines changed: 74 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,42 @@ const Utils = require('../util/utils.js');
2929

3030
const SLEEP_TIMEOUT_MS = 2000;
3131

32-
const RUSTLABS_ALL_ITEMS_URL = 'https://rustlabs.com/group=itemlist';
33-
const RUSTLABS_ITEM_URL = 'https://rustlabs.com/item/';
32+
const RUSTLABS_ALL_ITEMS_URL = 'https://wiki.rustclash.com/group=itemlist';
33+
const RUSTLABS_ITEM_URL = 'https://wiki.rustclash.com/item/';
3434

35-
const RUSTLABS_ALL_LOOT_CONTAINERS_URL = 'https://rustlabs.com/group=containers';
36-
const RUSTLABS_ENTITY_URL = 'https://rustlabs.com/entity/';
35+
const RUSTLABS_ALL_LOOT_CONTAINERS_URL = 'https://wiki.rustclash.com/group=containers';
36+
const RUSTLABS_ENTITY_URL = 'https://wiki.rustclash.com/entity/';
3737

38-
const RUSTLABS_ALL_BUILDING_BLOCKS_URL = 'https://rustlabs.com/group=building-blocks';
39-
const RUSTLABS_BUILDING_BLOCK_URL = 'https://rustlabs.com/building/';
38+
const RUSTLABS_ALL_BUILDING_BLOCKS_URL = 'https://wiki.rustclash.com/group=building-blocks';
39+
const RUSTLABS_BUILDING_BLOCK_URL = 'https://wiki.rustclash.com/building/';
4040

41-
const RUSTLABS_ALL_OTHER_URL = 'https://rustlabs.com/group=else';
42-
const RUSTLABS_OTHER_URL = 'https://rustlabs.com/entity/';
41+
const RUSTLABS_ALL_OTHER_URL = 'https://wiki.rustclash.com/group=else';
42+
const RUSTLABS_OTHER_URL = 'https://wiki.rustclash.com/entity/';
4343

4444

4545
const RUSTLABS_ALL_ITEMS_REGEX = /<a\shref="\/item\/(.*?)"\sclass.*?img\ssrc=.*?img\/.*?\/(.*?)\.png"\salt="(.*?)"/gm
46-
const RUSTLABS_ITEM_RECYCLE_AREA_REGEX = /Recycler<\/a><\/td>\n^.*?$\n^.*?$\n<\/td>/gm
47-
const RUSTLABS_ITEM_RECYCLE_REGEX = /<a\shref.*?img\/.*?\/(.*?)\.png.*?alt="(.*?)".*?text-in-icon">(.*?)<\/span><\/a>/gm
46+
const RUSTLABS_ITEM_RECYCLE_AREA_REGEX = /Recycler<\/th>(\n|.)*?<\/table>/gm
47+
const RUSTLABS_ITEM_RECYCLE_ROW_REGEX = /<td class="left">(\n|.)*?<\/tr>/gm
48+
const RUSTLABS_ITEM_RECYCLE_ITEM_REGEX = /\/entity\/(.*?)"/gm
49+
const RUSTLABS_ITEM_RECYCLE_ITEM_EFFICIENCY_REGEX = /<td\sdata-value="(.*?)">.*?%<\/td>/gm
50+
const RUSTLABS_ITEM_RECYCLE_OUTPUT_ITEMS_REGEX = /<a\shref.*?img\/.*?\/(.*?)\.png.*?alt="(.*?)".*?text-in-icon">(.*?)<\/span><\/a>/gm
4851

4952
const RUSTLABS_ITEM_CRAFT_AREA_REGEX = /data-name="craft"\sclass="tab-page(\n|.)*?<\/thead(\n|.)*?<\/tr>/gm
5053
const RUSTLABS_ITEM_CRAFT_INGREDIENTS_REGEX =
5154
/<a\shref.*?img\/.*?\/(.*?)\.png.*?alt="(.*?)".*?text-in-icon">(.*?)<\/span><\/a>/gm
52-
const RUSTLABS_ITEM_CRAFT_TIME_REGEX = /^<td\sdata-value="(.*?)">(.*?)<\/td>$/gm
55+
const RUSTLABS_ITEM_CRAFT_TIME_REGEX = /^\s*<td\sdata-value="(.*?)">(.*?)<\/td>/gm
5356

5457
const RUSTLABS_ITEM_RESEARCH_AREA_REGEX =
5558
/data-name="blueprint"\sclass="tab-page(\n|.)*?<table\sclass(\n|.)*?<\/table>/gm
5659
const RUSTLABS_ITEM_RESEARCH_ROW_REGEX = /<td\sclass="item-cell">(\n|.)*?<\/tr>/gm
5760
const RUSTLABS_ITEM_RESEARCH_TYPE_REGEX =
58-
/<td\sclass="item-cell">(\n|.)*?<img\sclass\ssrc="(\n|.)*?img\/(\n|.)*?\/(.*?)\.png/gm
61+
/<td\sclass="item-cell">(\n|.)*?<img\sclass=""\ssrc="(\n|.)*?img\/(\n|.)*?\/(.*?)\.png/gm
5962
const RUSTLABS_ITEM_RESEARCH_SCRAP_REGEX = /\/scrap\.png(\n|.)*?class="text-in-icon">(.*?)<\/span>/gm
6063
const RUSTLABS_ITEM_RESEARCH_TOTAL_SCRAP_REGEX = /<td\sclass="no-padding"\sdata-value="(.*?)">/gm
6164

6265
const RUSTLABS_ITEM_DURABILITY_AREA_REGEX1 = /<tr\sdata-group="(.*?)"\sdata-group2="(.*?)">(\n|.)*?<\/tr>/gm
6366
const RUSTLABS_ITEM_DURABILITY_AREA_REGEX2 = /<tr\sdata-group="(.*?)">(\n|.)*?<\/tr>/gm
64-
const RUSTLABS_ITEM_DURABILITY_TOOL_REGEX = /<img\sclass\ssrc=".*?\/img\/.*?\/(.*?)\.png"\salt="(.*?)">/gm
67+
const RUSTLABS_ITEM_DURABILITY_TOOL_REGEX = /<img\sclass=""\ssrc=".*?\/img\/.*?\/(.*?)\.png"\salt="(.*?)">/gm
6568
const RUSTLABS_ITEM_DURABILITY_CAPTION_IN_TOOL_REGEX = /caption-in-item-name">(.*?)</gm
6669
const RUSTLABS_ITEM_DURABILITY_QUANTITY_REGEX = /<td\sclass="no-padding"\sdata-value="(\d{1,7})">(.{1,10})<\/td>/gm
6770
const RUSTLABS_ITEM_DURABILITY_QUANTITY_APPROX_REGEX = /Approximate\sQuantity">(.*?)</gm
@@ -469,39 +472,72 @@ function processItemRecycle(rustlabsName, shortname, name, data) {
469472
}
470473
data = data[0];
471474

472-
const matches = data.matchAll(RUSTLABS_ITEM_RECYCLE_REGEX);
473-
const recycleItems = [];
474-
475-
for (const match of matches) {
476-
if (match.length !== 4) exit();
475+
const recycleData = new Object();
476+
recycleData['recycler'] = new Object();
477+
recycleData['recycler']['efficiency'] = null;
478+
recycleData['recycler']['yield'] = [];
479+
recycleData['shredder'] = new Object();
480+
recycleData['shredder']['efficiency'] = null;
481+
recycleData['shredder']['yield'] = [];
482+
recycleData['safe-zone-recycler'] = new Object();
483+
recycleData['safe-zone-recycler']['efficiency'] = null;
484+
recycleData['safe-zone-recycler']['yield'] = [];
485+
486+
const rows = data.matchAll(RUSTLABS_ITEM_RECYCLE_ROW_REGEX);
487+
for (const row of rows) {
488+
if (row.length !== 2) exit();
489+
const rowData = row[0];
477490

478-
const shortnameSub = match[1];
479-
const nameSub = Utils.decodeHtml(match[2]);
480-
let quantity = match[3];
481-
const id = Object.keys(ITEMS).find(e => ITEMS[e].shortname === shortnameSub && ITEMS[e].name === nameSub);
482-
if (id === undefined) exit();
491+
let recyclerType = null;
492+
const recyclerMatches = rowData.matchAll(RUSTLABS_ITEM_RECYCLE_ITEM_REGEX);
493+
for (const match of recyclerMatches) {
494+
if (match.length !== 2) exit();
495+
recyclerType = match[1];
496+
break;
497+
}
498+
if (recyclerType === null) exit();
483499

484-
let probability = 1;
485-
if (quantity === '') {
486-
quantity = 1;
500+
let efficiency = null;
501+
const efficiencyMatches = rowData.matchAll(RUSTLABS_ITEM_RECYCLE_ITEM_EFFICIENCY_REGEX);
502+
for (const match of efficiencyMatches) {
503+
if (match.length !== 2) exit();
504+
efficiency = match[1];
505+
break;
487506
}
488-
else {
489-
quantity = quantity.replace('×', '').replace(/,/g, '');
507+
recycleData[recyclerType]['efficiency'] = efficiency;
508+
509+
const matches = rowData.matchAll(RUSTLABS_ITEM_RECYCLE_OUTPUT_ITEMS_REGEX);
510+
for (const match of matches) {
511+
if (match.length !== 4) exit();
512+
513+
const shortnameSub = match[1];
514+
const nameSub = Utils.decodeHtml(match[2]);
515+
let quantity = match[3];
516+
const id = Object.keys(ITEMS).find(e => ITEMS[e].shortname === shortnameSub && ITEMS[e].name === nameSub);
517+
if (id === undefined) exit();
490518

491-
if (quantity.includes('%')) {
492-
probability = `0.${quantity.replace('%', '')}`;
519+
let probability = 1;
520+
if (quantity === '') {
493521
quantity = 1;
494522
}
495-
}
523+
else {
524+
quantity = quantity.replace('×', '').replace(/,/g, '');
496525

497-
recycleItems.push({
498-
id: id,
499-
probability: parseFloat(probability),
500-
quantity: parseFloat(quantity)
501-
});
526+
if (quantity.includes('%')) {
527+
probability = `0.${quantity.replace('%', '')}`;
528+
quantity = 1;
529+
}
530+
}
531+
532+
recycleData[recyclerType]['yield'].push({
533+
id: id,
534+
probability: parseFloat(probability),
535+
quantity: parseFloat(quantity)
536+
});
537+
}
502538
}
503539

504-
rustlabsRecycleData[itemId] = recycleItems;
540+
rustlabsRecycleData[itemId] = recycleData;
505541
}
506542

507543
function processItemDurability(rustlabsName, shortname, name, data, type = 'items') {
@@ -606,14 +642,14 @@ function processItemDurability(rustlabsName, shortname, name, data, type = 'item
606642
}
607643
}
608644
if (quantity === null) exit();
645+
609646
let quantityTypeId = null;
610647
if (quantityTypeShortname !== null && quantityTypeName !== null) {
611648
quantityTypeId = Object.keys(ITEMS).find(e =>
612649
ITEMS[e].shortname === quantityTypeShortname && ITEMS[e].name === quantityTypeName);
613650
if (!quantityTypeId) exit();
614651
}
615652

616-
617653
/* Time */
618654
let timeString = null, time = null;
619655
const timeMatches = [...dataMatch.matchAll(RUSTLABS_ITEM_DURABILITY_TIME_REGEX)];

src/staticFiles/rustlabsCraftData.json

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,8 @@
10031003
}
10041004
],
10051005
"workbench": "-1607980696",
1006-
"time": 30,
1007-
"timeString": "30 sec"
1006+
"time": 15,
1007+
"timeString": "15 sec"
10081008
},
10091009
"674734128": {
10101010
"ingredients": [
@@ -4561,6 +4561,17 @@
45614561
"time": 1.25,
45624562
"timeString": "1–2 sec"
45634563
},
4564+
"-839576748": {
4565+
"ingredients": [
4566+
{
4567+
"id": "69511070",
4568+
"quantity": 70
4569+
}
4570+
],
4571+
"workbench": "-41896755",
4572+
"time": 11.25,
4573+
"timeString": "7–15 sec"
4574+
},
45644575
"-1252059217": {
45654576
"ingredients": [
45664577
{
@@ -5315,8 +5326,8 @@
53155326
}
53165327
],
53175328
"workbench": "1524187186",
5318-
"time": 18.75,
5319-
"timeString": "7–30 sec"
5329+
"time": 9.375,
5330+
"timeString": "3–15 sec"
53205331
},
53215332
"-1539025626": {
53225333
"ingredients": [
@@ -5617,6 +5628,17 @@
56175628
"time": 22.5,
56185629
"timeString": "15–30 sec"
56195630
},
5631+
"-892718768": {
5632+
"ingredients": [
5633+
{
5634+
"id": "-858312878",
5635+
"quantity": 20
5636+
}
5637+
],
5638+
"workbench": "1524187186",
5639+
"time": 9.375,
5640+
"timeString": "3–15 sec"
5641+
},
56205642
"-986782031": {
56215643
"ingredients": [
56225644
{
@@ -6024,6 +6046,21 @@
60246046
"time": 3.125,
60256047
"timeString": "1–5 sec"
60266048
},
6049+
"-948291630": {
6050+
"ingredients": [
6051+
{
6052+
"id": "317398316",
6053+
"quantity": 3
6054+
},
6055+
{
6056+
"id": "73681876",
6057+
"quantity": 1
6058+
}
6059+
],
6060+
"workbench": "-41896755",
6061+
"time": 22.5,
6062+
"timeString": "15–30 sec"
6063+
},
60276064
"-904863145": {
60286065
"ingredients": [
60296066
{
@@ -6504,8 +6541,8 @@
65046541
}
65056542
],
65066543
"workbench": "-41896755",
6507-
"time": 22.5,
6508-
"timeString": "15–30 sec"
6544+
"time": 11.25,
6545+
"timeString": "7–15 sec"
65096546
},
65106547
"-1785231475": {
65116548
"ingredients": [
@@ -6875,8 +6912,8 @@
68756912
}
68766913
],
68776914
"workbench": null,
6878-
"time": 18.75,
6879-
"timeString": "7–30 sec"
6915+
"time": 9.375,
6916+
"timeString": "3–15 sec"
68806917
},
68816918
"-180129657": {
68826919
"ingredients": [
@@ -6949,8 +6986,8 @@
69496986
}
69506987
],
69516988
"workbench": null,
6952-
"time": 18.75,
6953-
"timeString": "7–30 sec"
6989+
"time": 9.375,
6990+
"timeString": "3–15 sec"
69546991
},
69556992
"-41896755": {
69566993
"ingredients": [

0 commit comments

Comments
 (0)