| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736 |
- //const fs = require('fs-extra');
- //const csv = require('fast-csv');
- const dateFormat = require('dateformat');
- //const path = require('path');
- //const sanitize = require('sanitize-filename');
- module.exports = {
- defaultConfig: {
- enabled: true,
- debug: true
- },
- pluginName: 'SWDB',
- pluginDescription: 'Saves runs to SWDB.',
- target_host: 'http://localhost',
- target_port: '80',
- target_url: '/API/v1/log-run',
- temp: {},
- proxy: null,
- config: null,
- /**
- * Initializes he plugin.
- *
- * @param proxy The proxy.
- * @param Global configurations.
- */
- init(proxy, config) {
- this.proxy = proxy;
- this.config = config;
- proxy.on('apiCommand', (req, resp) => {
- try {
- wizardID = '';
- command = '';
- if (config.Config.Plugins[this.pluginName].enabled) {
- //const { command, wizard_id: wizardID } = req;
- command = req["command"];
- wizardID = req["wizard_id"];
- }
- if (!this.temp[wizardID]) {
- this.temp[wizardID] = {};
- }
- if (command === 'BattleScenarioStart') {
- //for (var key in req) {
- // this.log('DEBUG', `IVV SCE START: ${key}: ${req[key]}`);
- //}
- if (req["helper_list"] != null || req["mentor_helper_list"] != null || req["npc_friend_helper_list"] != null ){
- this.temp[wizardID].helper = 1;
- }
- else{
- this.temp[wizardID].helper = 0;
- }
- this.temp[wizardID].area = req.region_id;
- this.temp[wizardID].stage = req.stage_no;
- this.temp[wizardID].difficulty = req.difficulty;
- }
- if (command === 'BattleScenarioResult' || command === 'BattleDungeonResult' || command === 'BattleDimensionHoleDungeonResult') {
- //proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV RUN RESULT: ${resp}` })
- for (var key in req) {
- this.log("info", `IVV REQ: ${key}: ${req[key]}`);
- }
- for (var key in resp) {
- this.log("info", `IVV RES: ${key}: ${resp[key]}`);
- }
- this.parse_normal(req, resp);
- }
- if (command === 'BattleRiftOfWorldsRaidResult') {
- this.parse_raid_rift(req, resp);
- }
- if (command === 'BattleRiftDungeonResult') {
- this.parse_elemental_rift(req, resp);
- }
- }
- catch (e) {
- proxy.log({ type: 'error', source: 'plugin', name: this.pluginName, message: `An unexpected error occured: ${e.message}` });
- }
- });
- },
- /**
- * Parses a reward item (no runes!).
- *
- * @param crate The crate object.
- * @return array of {item, unit, pieces, quantity, shapeshifting}
- */
- getItem(crate) {
- item = 0;
- unit = 0;
- pieces = 0;
- quantity = 0;
- shapeshifting = 0;
- if (crate.random_scroll && (crate.random_scroll.item_master_id === 1 || crate.random_scroll.item_master_id === 8 || crate.random_scroll.item_master_id === 2)){
- // 1: Unknown scroll
- // 2: Mystical Scroll
- // 8: Summoning Stones
- item = crate.random_scroll.item_master_id;
- quantity = crate.random_scroll.item_quantity;
- }
- if (crate.costume_point) {
- shapeshifting = crate.costume_point;
- }
- if (crate.rune_upgrade_stone) {
- item = 'Power Stone'; // TODO: Do they exist?
- quantity = crate.rune_upgrade_stone.item_quantity;
- }
- if (crate.unit_info) {
- unit = crate.unit_info.unit_master_id;
- }
- if (crate.material) {
- item = crate.material.item_master_id;
- quantity = crate.material.item_quantity;
- }
- if (crate.summon_pieces) {
- pieces = crate.summon_pieces.item_master_id;
- quantity = crate.summon_pieces.item_quantity;
- }
- if (crate.craft_stuff) {
- item = crate.craft_stuff.item_master_id;
- quantity = crate.craft_stuff.item_quantity;
- }
- drop = {item, unit, pieces, quantity, shapeshifting}
- return drop;
- },
- /**
- * TODO! Unaddapted.
- * Parses a rift reward item (no runes!).
- *
- * @param crate The crate object.
- * @return array of {item, unit, pieces, quantity}
- */
- getItemRift(item, entry) {
- if (item.type === 8) {
- const rune = item.info;
- entry.drop = 'Rune';
- entry.grade = `${rune.class}*`;
- entry.sell_value = rune.sell_value;
- entry.set = gMapping.rune.sets[rune.set_id];
- entry.slot = rune.slot_no;
- entry.efficiency = gMapping.getRuneEfficiency(rune).current;
- entry.rarity = gMapping.rune.class[rune.sec_eff.length];
- entry.main_stat = gMapping.getRuneEffect(rune.pri_eff);
- entry.prefix_stat = gMapping.getRuneEffect(rune.prefix_eff);
- rune.sec_eff.forEach((substat, i) => {
- entry[`sub${i + 1}`] = gMapping.getRuneEffect(substat);
- });
- }
- if (item.info.craft_type_id) {
- enhancement = this.getEnchantVals(item.info.craft_type_id, item.info.craft_type);
- entry.drop = enhancement.drop;
- entry.sell_value = item.sell_value;
- entry.set = enhancement.set;
- entry.main_stat = enhancement.type;
- entry.sub1 = enhancement.min;
- entry.sub2 = enhancement.max;
- }
- return entry;
- },
- /**
- * TODO! Will I need this.
- * Saves run data to a file in CSV format.
- *
- */
- saveToFile(entry, filename, headers, proxy) {
- const csvData = [];
- const self = this;
- fs.ensureFile(path.join(config.Config.App.filesPath, filename), err => {
- if (err) {
- return;
- }
- csv
- .fromPath(path.join(config.Config.App.filesPath, filename), { ignoreEmpty: true, headers, renameHeaders: true })
- .on('data', data => {
- csvData.push(data);
- })
- .on('end', () => {
- csvData.push(entry);
- csv.writeToPath(path.join(config.Config.App.filesPath, filename), csvData, { headers }).on('finish', () => {
- proxy.log({ type: 'success', source: 'plugin', name: self.pluginName, message: `Saved run data to ${filename}` });
- });
- });
- });
- },
- /**
- * Parses a battle data.
- * Valid for scenario, dungeons and Dimensional Hole.
- *
- * @param req The request
- * @param resp The response.
- */
- parse_normal(req, resp) {
- const { command } = req;
- const { wizard_id: wizardID, wizard_name: wizardName } = resp.wizard_info;
- const run = {};
- const run_party = {};
- const run_k_party = {};
- log = true;
- if (command === 'BattleDungeonResult') {
- //for (var key in req) {
- // this.log("DEBUG", `IVV DUNGEON REQ: ${key}: ${req[key]}`);
- //}
- if (req.dungeon_id > 10000){
- // Hall of Heroes or unknown
- log = false;
- }
- run.area = req.dungeon_id;
- run.stage = req.stage_id;
- run.difficulty = 0
- // TODO: Read request
- run.helper = 0;
- }
- if (command === 'BattleScenarioResult') {
- //for (var key in this.temp[wizardID]) {
- // this.log("DEBUG", `IVV TEMP: ${key}: ${this.temp[wizardID][key]}`);
- //}
- //for (var key in req) {
- // this.log("DEBUG", `IVV REQ: ${key}: ${req[key]}`);
- //}
- run.helper = this.temp[wizardID].helper;
- run.area = this.temp[wizardID].area;
- run.stage = this.temp[wizardID].stage;
- run.difficulty = this.temp[wizardID].difficulty;
- }
- if (command === 'BattleDimensionHoleDungeonResult') {
- //if (gMapping.dungeon[resp.dungeon_id]) {
- // run.dungeon = `${gMapping.dungeon[resp.dungeon_id]} Level ${resp.difficulty}`;
- //}
- //for (var key in req) {
- // this.log("DEBUG", `IVV DIMENSONALE REQ: ${key}: ${req[key]}`);
- //}
- run.area = resp.dungeon_id;
- run.stage = resp.difficulty;
- run.difficulty = 0
- run.helper = 0;
- }
- run.uid = wizardID;
- run.win = resp.win_lose; // 1/0 2 is lost in scenario
- run.dtime = dateFormat(new Date(), 'yyyy-mm-dd HH:MM:ss');
- const reward = resp.reward ? resp.reward : {};
- run.time = req.clear_time ? req.clear_time : 0;
- run.mana = reward.mana ? reward.mana : 0;
- run.energy = reward.energy ? reward.energy : 0;
- run.crystal = reward.crystal ? reward.crystal : 0;
-
- // TODO: GET
- //run.helper = 0;
- run.rune = {};
- run.unit = 0;
- run.unit_pieces = {};
- run.sd = 0;
- run.item = {};
- run.shapeshifting = 0;
- if (reward.crate) {
- run.mana = reward.crate.mana ? run.mana + reward.crate.mana : run.mana;
- run.energy = reward.crate.energy ? run.energy + reward.crate.energy : run.energy;
- run.crystal = reward.crate.crystal ? run.crystal + reward.crate.crystal : run.crystal;
- if (reward.crate.rune) {
- const rune = reward.crate.rune;
- //for (var key in rune) {
- // this.proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV RUNE: ${key}: ${rune[key]}` })
- //}
- run.rune.id = rune.rune_id;
- run.rune.grade = rune.class;
- run.rune.value = rune.sell_value;
- run.rune.set = rune.set_id;
- run.rune.slot = rune.slot_no;
- run.rune.efficiency = gMapping.getRuneEfficiency(rune).current;
- run.rune.quality = rune.rank;
- run.rune.main = rune.pri_eff[0];
- run.rune.main_value = rune.pri_eff[1];
- if (rune.prefix_eff){
- run.rune.innate = rune.prefix_eff[0];
- run.rune.innate_value = rune.prefix_eff[1];
- }
- run.rune['substat_1'] = 0;
- run.rune['substat_1_value'] = 0;
- run.rune['substat_2'] = 0;
- run.rune['substat_2_value'] = 0;
- run.rune['substat_3'] = 0;
- run.rune['substat_3_value'] = 0;
- run.rune['substat_4'] = 0;
- run.rune['substat_4_value'] = 0;
- rune.sec_eff.forEach((substat, i) => {
- run.rune[`substat_${i + 1}`] = substat[0];
- run.rune[`substat_${i + 1}_value`] = substat[1];
- });
- }
- else {
- for (var key in reward.crate) {
- this.proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV ITEM: ${key}: ${reward.crate[key]}` })
- }
- drop = this.getItem(reward.crate);
- if (drop.unit){
- run.unit.id = drop.unit;
- }
- if (drop.pieces){
- run.unit_pieces.id = drop.pieces;
- run.unit_pieces.quantity = drop.quantity;
- }
- if (drop.item){
- run.item.id = drop.item;
- run.item.quantity = drop.quantity;
- }
- run.shapeshifting = drop.shapeshifting;
- }
- }
- if (resp.instance_info) {
- run.sd = resp.instance_info;
- }
- if (resp.unit_list && resp.unit_list.length > 0) {
- resp.unit_list.forEach((unit, i) => {
- run_party[i] = unit.unit_master_id;
- run_k_party[i] = unit.unit_id;
- });
- }
- json_rune = '[';
- if (run.rune.id != undefined){
- json_rune += '{';
- json_rune += `"id": "${run.rune.id}", `;
- json_rune += `"stars": "${run.rune.grade}", `;
- json_rune += `"type": "${run.rune.set}", `;
- json_rune += `"slot": "${run.rune.slot}", `;
- json_rune += `"efficiency": "${run.rune.efficiency}", `;
- json_rune += `"quality": "${run.rune.quality}", `;
- // TODO: Get
- json_rune += `"ancient": 0, `;
- json_rune += `"value": "${run.rune.value}", `;
- json_rune += `"main_stat": "${run.rune.main}", `;
- json_rune += `"main_stat_value": "${run.rune.main_value}", `;
- json_rune += `"innate_stat": "${run.rune.innate}", `;
- json_rune += `"innate_stat_value": "${run.rune.innate_value}", `;
- json_rune += `"substat_1": "${run.rune.substat_1}", `;
- json_rune += `"substat_1_value": "${run.rune.substat_1_value}", `;
- json_rune += `"substat_2": "${run.rune.substat_2}", `;
- json_rune += `"substat_2_value": "${run.rune.substat_2_value}", `;
- json_rune += `"substat_3": "${run.rune.substat_3}", `;
- json_rune += `"substat_3_value": "${run.rune.substat_3_value}", `;
- json_rune += `"substat_4": "${run.rune.substat_4}", `;
- json_rune += `"substat_4_value": "${run.rune.substat_4_value}"`;
- json_rune += '}';
- }
- json_rune = json_rune + "]";
- json_item = '[';
- if (run.item.id != undefined){
- json_item += '{';
- json_item += `"id": "${run.item.id}", `;
- json_item += `"quantity": "${run.item.quantity}"`;
- json_item += '}';
- }
- json_item = json_item + "]";
- json_unit_pieces = '[';
- if (run.unit_pieces.length > 0){
- json_unit_pieces += '{';
- json_unit_pieces += `"id": "${run.unit_pieces.id}", `;
- json_unit_pieces += `"quantity": "${run.unit_pieces.quantity}"`;
- json_unit_pieces += '}';
- }
- json_unit_pieces = json_unit_pieces + "]";
- json_party = '[';
- resp.unit_list.forEach((unit, i) => {
- json_party = json_party + '{"unit_id": ' + run_party[i] + ', "unit_master_id": ' + run_k_party[i] + '},';
- });
- json_party = json_party.slice(0, -1) + "]";
- json = `{`;
- json += `"uid": "${run.uid}", `;
- json += `"dtime": "${run.dtime}", `;
- json += `"area": "${run.area}", `;
- json += `"stage": "${run.stage}", `;
- json += `"difficulty": "${run.difficulty}", `;
- json += `"win": "${run.win}", `;
- json += `"time": "${run.time}", `;
- json += `"mana": "${run.mana}", `;
- json += `"energy": "${run.energy}", `;
- json += `"crystal": "${run.crystal}", `;
- json += `"rune": ${json_rune}, `;
- json += `"sd": ${run.sd}, `;
- json += `"item": ${json_item}, `;
- json += `"unit": ${run.unit}, `;
- json += `"unit_pieces": ${json_unit_pieces}, `;
- json += `"shapeshifting": ${run.shapeshifting}, `;
- json += `"party": ${json_party}, `;
- json += `"helper": "${run.helper}"`;
- json += `}`;
- this.log('DEBUG', `json: ${json}`)
- //const filename = sanitize(`${wizardName}-${wizardID}-runs.csv`);
- //const filename = sanitize(`IVV-${wizardName}-${wizardID}-runs.csv`);
- //this.saveToFile(entry, filename, headers, proxy);
-
- // Make the request
- //var inspect = require('eyespect').inspector();
- var request = require('request')
- var postData = {
- name: 'data',
- value: json
- }
- var querystring = require('querystring');
- var http = require('http');
- var fs = require('fs');
- var post_data = querystring.stringify({
- 'data' : json
- });
- // An object of options to indicate where to post to
- var post_options = {
- host: '192.168.1.101',//this.target_host,
- port: this.target_port,
- path: this.target_url,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Content-Length': Buffer.byteLength(post_data)
- }
- };
- // Set up the request
- var resp = ""
- var post_req = http.request(post_options, function(res) {
- res.setEncoding('utf8');
- res.on('data', function (chunk) {
- resp = chunk;
- });
- });
-
- // post the data
- post_req.write(post_data);
- post_req.end();
-
-
- },
- /**
- * TODO Unaddapted.
- * Parses a battle data.
- * Valid for Rift Raids.
- *
- * @param req The request
- * @param resp The response.
- */
- parse_raid_rift(req, resp) {
- const { wizard_id: wizardID, wizard_name: wizardName } = resp.wizard_info;
- let run = {};
- if (gMapping.dungeon[req.dungeon_id]) {
- run.dungeon = `${gMapping.elemental_rift_dungeon[req.dungeon_id]}`;
- isElemental = true;
- }
- //const winLost = resp.win_lose === 1 ? 'Win' : 'Did not kill';
- run.dtime = dateFormat(new Date(), 'yyyy-mm-dd HH:MM:ss');
- //run.result = winLost;
- run.win = resp.win_lose;
- run.rune = {};
- run.unit = 0;
- run.unit_pieces = {};
- run.sd = 0;
- run.item = {};
- run.shapeshifting = 0;
- run.time = req.clear_time ? req.clear_time : 0;
- const reward = resp.reward ? resp.reward : {};
- if (resp.win_lose === 1) {
- // No crate: Mana of shapeshifting stones
- if (!reward.crate) {
- const reward = resp.battle_reward_list.find(value => value.wizard_id === resp.wizard_info.wizard_id).reward_list[0];
- if (reward.item_master_id === 6) {
- run.shapeshifting = reward.item_quantity;
- }
- else {
- run.mana = reward.item_quantity;
- }
- }
- // Rune craft item
- else if (reward.crate.changestones) {
- const item = {
- info: {
- craft_type: reward.crate.changestones[0].craft_type,
- craft_type_id: reward.crate.changestones[0].craft_type_id
- },
- sell_value: reward.crate.changestones[0].sell_value
- };
- run.drop= this.getItemRift(item, run);
- }
- // Rune
- else if (reward.crate.rune) {
- const rune = reward.crate.rune;
- //for (var key in rune) {
- // this.proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV RUNE: ${key}: ${rune[key]}` })
- //}
- run.rune.id = rune.rune_id;
- run.rune.grade = rune.class;
- run.rune.value = rune.sell_value;
- run.rune.set = rune.set_id;
- run.rune.slot = rune.slot_no;
- run.rune.efficiency = gMapping.getRuneEfficiency(rune).current;
- run.rune.quality = rune.rank;
- run.rune.main = rune.pri_eff[0];
- run.rune.main_value = rune.pri_eff[1];
- if (rune.prefix_eff){
- run.rune.innate = rune.prefix_eff[0];
- run.rune.innate_value = rune.prefix_eff[1];
- }
- rune.sec_eff.forEach((substat, i) => {
- run.rune[`substat_${i + 1}`] = substat[0];
- run.rune[`substat_${i + 1}_value`] = substat[1];
- });
- }
- // Unit (Rainbowmon)
- else if (reward.crate.unit_info && reward.crate.unit_info.unit_master_id > 0) {
- run.unit.id = reward.crate.unit_info.unit_master_id;
- }
- // Item
- else if (!run.drop && resp.reward.crate) {
- //run.drop = this.getItem(reward.resp.reward.crate);
- if (resp.reward.crate.random_scroll && (resp.reward.crate.random_scroll.item_master_id === 1 || resp.reward.crate.random_scroll.item_master_id === 8 || resp.reward.crate.random_scroll.item_master_id === 2)){
- // 1: Unknown scroll
- // 2: Mystical Scroll
- // 8: Summoning Stones
- run.item.id = resp.reward.crate.random_scroll.item_master_id;
- run.item.quantity = resp.reward.crate.random_scroll.item_quantity;
- }
- //if (resp.reward.crate.costume_point) {
- // shapeshifting = resp.reward.crate.costume_point;
- //}
- //if (resp.reward.crate.rune_upgrade_stone) {
- // item = 'Power Stone'; // TODO: Do they exist?
- // quantity = resp.reward.crate.rune_upgrade_stone.item_quantity;
- //}
- //if (resp.reward.crate.unit_info) {
- // unit = resp.reward.crate.unit_info.unit_master_id;
- //}
- if (resp.reward.crate.material) {
- item = resp.reward.crate.material.item_master_id;
- quantity = resp.reward.crate.material.item_quantity;
- }
- //if (resp.reward.crate.summon_pieces) {
- // pieces = resp.reward.crate.summon_pieces.item_master_id;
- // quantity = resp.reward.crate.summon_pieces.item_quantity;
- //}
- if (resp.reward.crate.craft_stuff) {
- item = resp.reward.crate.craft_stuff.item_master_id;
- quantity = resp.reward.crate.craft_stuff.item_quantity;
- }
- }
- else {
- run.drop = 'unknown';
- }
- }
- if (resp.unit_list && resp.unit_list.length > 0) {
- resp.unit_list.forEach((unit, i) => {
- run_party[i] = unit.unit_master_id;
- run_k_party[i] = unit.unit_id;
- });
- }
- //const filename = sanitize(`${wizardName}-${wizardID}-raid-runs.csv`);
- //this.saveToFile(run. filename, headers, proxy);
- },
- /**
- * TODO Unaddapted.
- * Parses a battle data.
- * Valid for Rift Dungeons.
- *
- * @param req The request
- * @param resp The response.
- */
- parse_elemental_rift(req, resp) {
- const { wizard_id: wizardID, wizard_name: wizardName } = resp.wizard_info;
- let entry = {};
- if (gMapping.dungeon[req.dungeon_id]) {
- entry.dungeon = `${gMapping.elemental_rift_dungeon[req.dungeon_id]}`;
- isElemental = true;
- }
- const winLost = req.battle_result === 1 ? 'Win' : 'Did not kill';
- entry.date = dateFormat(new Date(), 'yyyy-mm-dd HH:MM');
- entry.result = winLost;
- if (resp.item_list && resp.item_list.length > 0) {
- resp.item_list.forEach((item, i) => {
- if (item.is_boxing !== 1 || item.id === 2001) {
- entry[`item${i + 1}`] = `${gMapping.craftMaterial[item.id]} x${item.quantity}`;
- } else {
- if (item.id === 2) {
- entry.drop = 'Mystical Scroll';
- }
- if (item.id === 8) {
- entry.drop = `Summoning Stones x${item.item_quantity}`;
- }
- if (item.info && item.info.unit_master_id > 0) {
- entry.drop = `${gMapping.getMonsterName(item.info.unit_master_id)} ${item.class}`;
- }
- if ((item.info && item.info.craft_type_id) || item.type === 8) {
- entry = this.getItemRift(item, entry);
- }
- }
- });
- }
- if (resp.unit_list && resp.unit_list.length > 0) {
- resp.unit_list.forEach((unit, i) => {
- entry[`team${i + 1}`] = gMapping.getMonsterName(unit.unit_master_id);
- });
- }
- json_rune = '[';
- if (run.rune.length() > 0){
- json_rune += `"id": "${run.rune.id}", `;
- json_rune += `"grade": "${run.rune.grade}", `;
- json_rune += `"set": "${run.rune.set}", `;
- json_rune += `"slot": "${run.rune.slot}", `;
- json_rune += `"efficiency": "${run.rune.efficiency}", `;
- json_rune += `"quality": "${run.rune.quality}", `;
- json_rune += `"value": "${run.rune.value}", `;
- json_rune += `"main_stat": "${run.rune.main}", `;
- json_rune += `"main_stat_value": "${run.rune.main_value}", `;
- json_rune += `"innate_stat": "${run.rune.innate}", `;
- json_rune += `"innate_stat_value": "${run.rune.innate_value}", `;
- json_rune += `"substat_1": "${run.rune.substat_1}", `;
- json_rune += `"substat_1_value": "${run.rune.substat_1_value}", `;
- json_rune += `"substat_2": "${run.rune.substat_2}", `;
- json_rune += `"substat_2_value": "${run.rune.substat_2_value}", `;
- json_rune += `"substat_3": "${run.rune.substat_3}", `;
- json_rune += `"substat_4_value": "${run.rune.substat_3_value}", `;
- json_rune += `"substat_4": "${run.rune.substat_4}", `;
- json_rune += `"substat_4_value": "${run.rune.substat_4_value}", `;
- }
- json_rune = json_party.slice(0, -1) + "]";
- json_item = '[';
- if (run.item.length() > 0){
- json_item += `"id": "${run.item.id}", `;
- json_item += `"quantity": "${run.item.quantity}", `;
- }
- json_item = json_party.slice(0, -1) + "]";
- json_unit_pieces = '[';
- if (run.unit_pieces.length() > 0){
- json_unit_pieces += `"id": "${run.unit_pieces.id}", `;
- json_unit_pieces += `"quantity": "${run.unit_pieces.quantity}", `;
- }
- json_unit_pieces = json_party.slice(0, -1) + "]";
- json_party = '[';
- resp.unit_list.forEach((unit, i) => {
- json_party = json_party + '{"unit_id": ' + run_party[i] + ', "unit_master_id": ' + run_k_party[i] + '},';
- });
- json_party = json_party.slice(0, -1) + "]";
- //this.log('DEBUG', `IVV json_party: ${json_party}`)
- json = `{`;
- json += `"dtime": "${run.dtime}", `;
- json += `"area": "${run.dungeon}", `;
- json += `"stage": "${run.stage}", `;
- json += `"difficulty": "${run.difficulty}", `;
- json += `"win": "${run.win}", `;
- json += `"time": "${run.time}", `;
- json += `"mana": "${run.mana}", `;
- json += `"energy": "${run.energy}", `;
- json += `"crystal": "${run.crystal}", `;
- json += `"rune": ${json_rune}, `;
- json += `"sd": ${run.sd}, `;
- json += `"item": ${json_item}, `;
- json += `"unit": ${run.unit}, `;
- json += `"unit_pieces": ${json_unit_pieces}, `;
- json += `"sapeshifting": ${run.sapeshifting}, `;
- json += `"party": ${json_party}`;
- json += `}`;
- this.log('DEBUG', `json: ${json}`)
- },
- /**
- * TODO ???
- */
- getEnchantVals(craftID, craftType) {
- const map = {};
- const typeNumber = Number(craftID.toString().slice(-4, -2));
- map.set = gMapping.rune.sets[Number(craftID.toString().slice(0, -4))];
- map.grade = gMapping.rune.quality[Number(craftID.toString().slice(-1))];
- map.type = gMapping.rune.effectTypes[typeNumber];
- if (craftType === 2) {
- map.min = gMapping.grindstone[typeNumber].range[Number(craftID.toString().slice(-1))].min;
- map.max = gMapping.grindstone[typeNumber].range[Number(craftID.toString().slice(-1))].max;
- map.drop = 'Grindstone';
- } else {
- map.min = gMapping.enchanted_gem[typeNumber].range[Number(craftID.toString().slice(-1))].min;
- map.max = gMapping.enchanted_gem[typeNumber].range[Number(craftID.toString().slice(-1))].max;
- map.drop = 'Enchanted Gem';
- }
- return map;
- },
- /**
- * Prints a messageto the SWEX output.
- *
- * @param type Log type. Debug type will be printed depending on config.
- * @param msg The message to log.
- */
- log(type, msg){
- //if (type != "debug" || this.config.Config.Plugins[this.pluginName].debug == true){
- this.proxy.log({ type: type, source: 'plugin', name: this.pluginName, message: msg });
- //}
- }
- };
|