fix calcAttackDuration formula, refactor
This commit is contained in:
parent
2d446c7c4a
commit
05d038b09b
30
dist/bonusBarbarianVillageFinder.js
vendored
30
dist/bonusBarbarianVillageFinder.js
vendored
|
@ -202,36 +202,36 @@ exports.default = _default;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.formatVillageName = exports.formatVillageURL = exports.formatPlayerURL = exports.formatTribeURL = void 0;
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.buildVillageName = exports.buildVillageURL = exports.buildPlayerURL = exports.buildTribeURL = void 0;
|
||||
|
||||
const formatTribeURL = id => {
|
||||
const buildTribeURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_ally',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatTribeURL = formatTribeURL;
|
||||
exports.buildTribeURL = buildTribeURL;
|
||||
|
||||
const formatPlayerURL = id => {
|
||||
const buildPlayerURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_player',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
|
||||
const formatVillageURL = id => {
|
||||
const buildVillageURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_village',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatVillageURL = formatVillageURL;
|
||||
exports.buildVillageURL = buildVillageURL;
|
||||
|
||||
const formatVillageName = function formatVillageName() {
|
||||
const buildVillageName = function buildVillageName() {
|
||||
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
||||
|
@ -239,10 +239,10 @@ const formatVillageName = function formatVillageName() {
|
|||
return "".concat(n, " (").concat(x, "|").concat(y, ") ").concat(continent);
|
||||
};
|
||||
|
||||
exports.formatVillageName = formatVillageName;
|
||||
exports.buildVillageName = buildVillageName;
|
||||
|
||||
const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed / unitSpeed);
|
||||
const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
exports.calcAttackDuration = calcAttackDuration;
|
||||
|
@ -276,10 +276,14 @@ var _bonusBarbarianVillageFinder = _interopRequireDefault(require("./i18n/bonusB
|
|||
|
||||
var _getCurrentServer = _interopRequireDefault(require("./utils/getCurrentServer"));
|
||||
|
||||
var _tribalwars = require("./utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("./utils/tribalwars"));
|
||||
|
||||
var _math = require("./utils/math");
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
@ -360,7 +364,7 @@ const getBonuses = () => {
|
|||
};
|
||||
|
||||
const buildTableBodyHTML = villages => {
|
||||
return "\n <tbody>\n <tr>\n <th>\n ".concat(translations.village, "\n </th>\n <th>\n ").concat(translations.distance, "\n </th>\n <th>\n ").concat(translations.action, "\n </th>\n </tr>\n ").concat(Array.isArray(villages) ? villages.map(village => "<tr>\n <td>\n <a href=\"".concat((0, _tribalwars.formatVillageURL)(village.id), "\">\n ").concat((0, _tribalwars.formatVillageName)(village.name, village.x, village.y), "\n </a>\n </td>\n <td>\n ").concat(village.distance.toFixed(1), "\n </td>\n <td>\n <a href=\"#\" onclick=\"return TWMap.focusUserSpecified(").concat(village.x, ", ").concat(village.y, ")\">Center</a>\n </td>\n </tr>")).join('') : '', "\n </tbody>\n ");
|
||||
return "\n <tbody>\n <tr>\n <th>\n ".concat(translations.village, "\n </th>\n <th>\n ").concat(translations.distance, "\n </th>\n <th>\n ").concat(translations.action, "\n </th>\n </tr>\n ").concat(Array.isArray(villages) ? villages.map(village => "<tr>\n <td>\n <a href=\"".concat(twutils.buildVillageURL(village.id), "\">\n ").concat(twutils.buildVillageName(village.name, village.x, village.y), "\n </a>\n </td>\n <td>\n ").concat(village.distance.toFixed(1), "\n </td>\n <td>\n <a href=\"#\" onclick=\"return TWMap.focusUserSpecified(").concat(village.x, ", ").concat(village.y, ")\">Center</a>\n </td>\n </tr>")).join('') : '', "\n </tbody>\n ");
|
||||
};
|
||||
|
||||
const updateActualCoords = () => {
|
||||
|
|
30
dist/dailyAchievements.js
vendored
30
dist/dailyAchievements.js
vendored
|
@ -2999,36 +2999,36 @@ exports.setItem = setItem;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.formatVillageName = exports.formatVillageURL = exports.formatPlayerURL = exports.formatTribeURL = void 0;
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.buildVillageName = exports.buildVillageURL = exports.buildPlayerURL = exports.buildTribeURL = void 0;
|
||||
|
||||
const formatTribeURL = id => {
|
||||
const buildTribeURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_ally',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatTribeURL = formatTribeURL;
|
||||
exports.buildTribeURL = buildTribeURL;
|
||||
|
||||
const formatPlayerURL = id => {
|
||||
const buildPlayerURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_player',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
|
||||
const formatVillageURL = id => {
|
||||
const buildVillageURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_village',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatVillageURL = formatVillageURL;
|
||||
exports.buildVillageURL = buildVillageURL;
|
||||
|
||||
const formatVillageName = function formatVillageName() {
|
||||
const buildVillageName = function buildVillageName() {
|
||||
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
||||
|
@ -3036,10 +3036,10 @@ const formatVillageName = function formatVillageName() {
|
|||
return "".concat(n, " (").concat(x, "|").concat(y, ") ").concat(continent);
|
||||
};
|
||||
|
||||
exports.formatVillageName = formatVillageName;
|
||||
exports.buildVillageName = buildVillageName;
|
||||
|
||||
const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed / unitSpeed);
|
||||
const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
exports.calcAttackDuration = calcAttackDuration;
|
||||
|
@ -3163,7 +3163,7 @@ var _dailyAchievments = _interopRequireDefault(require("./i18n/dailyAchievments"
|
|||
|
||||
var _localStorage = require("./utils/localStorage");
|
||||
|
||||
var _tribalwars = require("./utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("./utils/tribalwars"));
|
||||
|
||||
var _getCurrentServer = _interopRequireDefault(require("./utils/getCurrentServer"));
|
||||
|
||||
|
@ -3173,6 +3173,10 @@ var _date = require("./utils/date");
|
|||
|
||||
var _twhelp = require("./utils/twhelp");
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
@ -3239,7 +3243,7 @@ const render = (_ref) => {
|
|||
dailyPlayerStatsOrderedByScoreSup,
|
||||
dailyPlayerStatsOrderedByVillages
|
||||
} = _ref;
|
||||
const html = "\n <div class=\"award-group-head\">".concat(translations.title, "</div>\n <div class=\"award-group-content\" style=\"text-align: center;\">\n <div style=\"padding: 10px;\">\n <h1 style=\"margin-bottom: 0px;\"><a href=\"").concat((0, _twhelp.buildURLToServerPage)((0, _getServerVersionCode.default)(SERVER), SERVER), "\">TWHelp</a></h1>\n <h3 style=\"margin-bottom: 10px; margin-top: 0;\">").concat(translations.devNote, "</h3>\n <h3 style=\"color: red;\"><strong>").concat(translations.warning, "</strong></h3>\n <p><strong>").concat(translations.aotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByScoreAtt.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat((0, _tribalwars.formatPlayerURL)(item.player.id), "\">").concat(item.player.name, " - ").concat(item.scoreAtt.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n <hr>\n <div style=\"padding: 10px;\">\n <p><strong>").concat(translations.dotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByScoreDef.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat((0, _tribalwars.formatPlayerURL)(item.player.id), "\">").concat(item.player.name, " - ").concat(item.scoreDef.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n <hr>\n <div style=\"padding: 10px;\">\n <p><strong>").concat(translations.sotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByScoreSup.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat((0, _tribalwars.formatPlayerURL)(item.player.id), "\">").concat(item.player.name, " - ").concat(item.scoreSup.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n <hr>\n <div style=\"padding: 10px;\">\n <p><strong>").concat(translations.gpotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByVillages.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat((0, _tribalwars.formatPlayerURL)(item.player.id), "\">").concat(item.player.name, " - ").concat(item.villages.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n </div>\n <div class=\"award-group-foot\"></div>\n ");
|
||||
const html = "\n <div class=\"award-group-head\">".concat(translations.title, "</div>\n <div class=\"award-group-content\" style=\"text-align: center;\">\n <div style=\"padding: 10px;\">\n <h1 style=\"margin-bottom: 0px;\"><a href=\"").concat((0, _twhelp.buildURLToServerPage)((0, _getServerVersionCode.default)(SERVER), SERVER), "\">TWHelp</a></h1>\n <h3 style=\"margin-bottom: 10px; margin-top: 0;\">").concat(translations.devNote, "</h3>\n <h3 style=\"color: red;\"><strong>").concat(translations.warning, "</strong></h3>\n <p><strong>").concat(translations.aotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByScoreAtt.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat(twutils.buildPlayerURL(item.player.id), "\">").concat(item.player.name, " - ").concat(item.scoreAtt.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n <hr>\n <div style=\"padding: 10px;\">\n <p><strong>").concat(translations.dotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByScoreDef.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat(twutils.buildPlayerURL(item.player.id), "\">").concat(item.player.name, " - ").concat(item.scoreDef.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n <hr>\n <div style=\"padding: 10px;\">\n <p><strong>").concat(translations.sotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByScoreSup.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat(twutils.buildPlayerURL(item.player.id), "\">").concat(item.player.name, " - ").concat(item.scoreSup.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n <hr>\n <div style=\"padding: 10px;\">\n <p><strong>").concat(translations.gpotd, "</strong></p>\n ").concat(dailyPlayerStatsOrderedByVillages.items.map((item, index) => "<span>".concat(index + 1, ". <a href=\"").concat(twutils.buildPlayerURL(item.player.id), "\">").concat(item.player.name, " - ").concat(item.villages.toLocaleString(), "</a></span>")).join('<br>'), "\n </div>\n </div>\n <div class=\"award-group-foot\"></div>\n ");
|
||||
|
||||
if (!container) {
|
||||
container = document.createElement('div');
|
||||
|
|
37
dist/extendedMapPopup.js
vendored
37
dist/extendedMapPopup.js
vendored
|
@ -424,36 +424,36 @@ exports.calcDistanceBetweenTwoPoints = calcDistanceBetweenTwoPoints;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.formatVillageName = exports.formatVillageURL = exports.formatPlayerURL = exports.formatTribeURL = void 0;
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.buildVillageName = exports.buildVillageURL = exports.buildPlayerURL = exports.buildTribeURL = void 0;
|
||||
|
||||
const formatTribeURL = id => {
|
||||
const buildTribeURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_ally',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatTribeURL = formatTribeURL;
|
||||
exports.buildTribeURL = buildTribeURL;
|
||||
|
||||
const formatPlayerURL = id => {
|
||||
const buildPlayerURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_player',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
|
||||
const formatVillageURL = id => {
|
||||
const buildVillageURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_village',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatVillageURL = formatVillageURL;
|
||||
exports.buildVillageURL = buildVillageURL;
|
||||
|
||||
const formatVillageName = function formatVillageName() {
|
||||
const buildVillageName = function buildVillageName() {
|
||||
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
||||
|
@ -461,10 +461,10 @@ const formatVillageName = function formatVillageName() {
|
|||
return "".concat(n, " (").concat(x, "|").concat(y, ") ").concat(continent);
|
||||
};
|
||||
|
||||
exports.formatVillageName = formatVillageName;
|
||||
exports.buildVillageName = buildVillageName;
|
||||
|
||||
const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed / unitSpeed);
|
||||
const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
exports.calcAttackDuration = calcAttackDuration;
|
||||
|
@ -616,7 +616,7 @@ function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
|
|||
var diff = (0, _index.default)(dirtyDateLeft, dirtyDateRight) / MILLISECONDS_IN_MINUTE;
|
||||
return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
|
||||
}
|
||||
},{"../differenceInMilliseconds/index.js":"H70G","../_lib/requiredArgs/index.js":"kK6Q"}],"ATOB":[function(require,module,exports) {
|
||||
},{"../differenceInMilliseconds/index.js":"H70G","../_lib/requiredArgs/index.js":"kK6Q"}],"kcC2":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
|
@ -628,7 +628,7 @@ var _differenceInMinutes = _interopRequireDefault(require("date-fns/differenceIn
|
|||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = (ennobledAt, speed) => {
|
||||
const calcLoyalty = (ennobledAt, speed) => {
|
||||
let loyalty = 25 + Math.abs((0, _differenceInMinutes.default)(ennobledAt, new Date())) * (speed / 60);
|
||||
|
||||
if (loyalty > 100) {
|
||||
|
@ -638,6 +638,7 @@ var _default = (ennobledAt, speed) => {
|
|||
return Math.floor(loyalty);
|
||||
};
|
||||
|
||||
var _default = calcLoyalty;
|
||||
exports.default = _default;
|
||||
},{"date-fns/differenceInMinutes":"oGJj"}],"HdqX":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
@ -660,7 +661,7 @@ var _localStorage = require("./utils/localStorage");
|
|||
|
||||
var _tribalwars = require("./utils/tribalwars");
|
||||
|
||||
var _countLoyalty = _interopRequireDefault(require("./utils/countLoyalty"));
|
||||
var _calcLoyalty = _interopRequireDefault(require("./utils/calcLoyalty"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
@ -675,7 +676,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|||
// @namespace https://github.com/tribalwarshelp/scripts
|
||||
// @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
|
||||
// @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
|
||||
// @version 0.6.4
|
||||
// @version 0.6.5
|
||||
// @description Extended map popup
|
||||
// @author Kichiyaki https://dawid-wysokinski.pl/
|
||||
// @match *://*/game.php*screen=map*
|
||||
|
@ -793,7 +794,7 @@ const renderAdditionalInfo = (id, data, _ref) => {
|
|||
|
||||
const units = getAvailableUnits(unitConfig);
|
||||
unitsEl.innerHTML = "\n <td colspan=\"2\">\n <table style=\"border: 1px solid #ded3b9; max-width: 450px;\"\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\">\n <tbody>\n <tr class=\"center\">\n ".concat(units.map(buildUnitHeader).join(''), "\n </tr>\n <tr class=\"center\">\n ").concat(units.map((unit, index) => {
|
||||
return buildUnitArrivalInfo((0, _tribalwars.calcAttackDuration)(distance, config.unitSpeed * config.speed, unit.speed), index);
|
||||
return buildUnitArrivalInfo((0, _tribalwars.calcAttackDuration)(distance, unit.speed), index);
|
||||
}).join(''), "\n </tr>\n </tbody>\n </table>\n </td>\n ");
|
||||
let lastEnnobledAt = parent.querySelector('#lastEnnobledAt');
|
||||
|
||||
|
@ -812,7 +813,7 @@ const renderAdditionalInfo = (id, data, _ref) => {
|
|||
parent.appendChild(loyalty);
|
||||
}
|
||||
|
||||
loyalty.innerHTML = "\n <td>\n ".concat(translations.possibleLoyalty, ":\n </td>\n <td>\n ").concat(ennoblement ? (0, _countLoyalty.default)(new Date(ennoblement.ennobledAt), config.speed) : 100, "\n </td>\n ");
|
||||
loyalty.innerHTML = "\n <td>\n ".concat(translations.possibleLoyalty, ":\n </td>\n <td>\n ").concat(ennoblement ? (0, _calcLoyalty.default)(new Date(ennoblement.ennobledAt), config.speed) : 100, "\n </td>\n ");
|
||||
let canSendNoble = parent.querySelector('#canSendNoble');
|
||||
|
||||
if (!canSendNoble) {
|
||||
|
@ -852,4 +853,4 @@ const createDisplayForVillageHandler = cfg => async (e, a, t) => {
|
|||
console.log('extended map popup', error);
|
||||
}
|
||||
})();
|
||||
},{"date-fns/addMinutes":"pfh4","./i18n/extendedMapPopup":"ddIN","./libs/requestCreator":"Ph2E","./utils/formatDate":"V6Mf","./utils/getCurrentServer":"DMkL","./utils/math":"XOOL","./utils/buildUnitImgURL":"KX6P","./utils/localStorage":"KWxH","./utils/tribalwars":"fHHP","./utils/countLoyalty":"ATOB"}]},{},["HdqX"], null)
|
||||
},{"date-fns/addMinutes":"pfh4","./i18n/extendedMapPopup":"ddIN","./libs/requestCreator":"Ph2E","./utils/formatDate":"V6Mf","./utils/getCurrentServer":"DMkL","./utils/math":"XOOL","./utils/buildUnitImgURL":"KX6P","./utils/localStorage":"KWxH","./utils/tribalwars":"fHHP","./utils/calcLoyalty":"kcC2"}]},{},["HdqX"], null)
|
46
dist/extendedPlayerProfile.js
vendored
46
dist/extendedPlayerProfile.js
vendored
|
@ -587,36 +587,36 @@ exports.default = _default;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.formatVillageName = exports.formatVillageURL = exports.formatPlayerURL = exports.formatTribeURL = void 0;
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.buildVillageName = exports.buildVillageURL = exports.buildPlayerURL = exports.buildTribeURL = void 0;
|
||||
|
||||
const formatTribeURL = id => {
|
||||
const buildTribeURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_ally',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatTribeURL = formatTribeURL;
|
||||
exports.buildTribeURL = buildTribeURL;
|
||||
|
||||
const formatPlayerURL = id => {
|
||||
const buildPlayerURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_player',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
|
||||
const formatVillageURL = id => {
|
||||
const buildVillageURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_village',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatVillageURL = formatVillageURL;
|
||||
exports.buildVillageURL = buildVillageURL;
|
||||
|
||||
const formatVillageName = function formatVillageName() {
|
||||
const buildVillageName = function buildVillageName() {
|
||||
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
||||
|
@ -624,10 +624,10 @@ const formatVillageName = function formatVillageName() {
|
|||
return "".concat(n, " (").concat(x, "|").concat(y, ") ").concat(continent);
|
||||
};
|
||||
|
||||
exports.formatVillageName = formatVillageName;
|
||||
exports.buildVillageName = buildVillageName;
|
||||
|
||||
const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed / unitSpeed);
|
||||
const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
exports.calcAttackDuration = calcAttackDuration;
|
||||
|
@ -653,7 +653,11 @@ var _showPopup = _interopRequireDefault(require("../utils/showPopup"));
|
|||
|
||||
var _formatDate = _interopRequireDefault(require("../utils/formatDate"));
|
||||
|
||||
var _tribalwars = require("../utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("../utils/tribalwars"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
@ -662,7 +666,7 @@ const translations = (0, _showEnnoblementsPopup.default)();
|
|||
|
||||
const getPlayerTd = (player, tribe) => {
|
||||
if (player) {
|
||||
return "<td><a href=\"".concat((0, _tribalwars.formatPlayerURL)(player.id), "\">").concat(player.name, " (").concat(tribe ? "<a href=\"".concat((0, _tribalwars.formatTribeURL)(tribe.id), "\">").concat(tribe.tag, "</a>") : '-', ")</a></td>");
|
||||
return "<td><a href=\"".concat(twutils.buildPlayerURL(player.id), "\">").concat(player.name, " (").concat(tribe ? "<a href=\"".concat(twutils.buildTribeURL(tribe.id), "\">").concat(tribe.tag, "</a>") : '-', ")</a></td>");
|
||||
}
|
||||
|
||||
return '<td>-</td>';
|
||||
|
@ -683,7 +687,7 @@ var _default = function _default(e, ennoblements) {
|
|||
let rowHTML = '<tr>' + "<td>".concat((0, _formatDate.default)(ennoblement.ennobledAt), "</td>");
|
||||
|
||||
if (ennoblement.village) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatVillageURL)(ennoblement.village.id), "\">").concat((0, _tribalwars.formatVillageName)(ennoblement.village.name, ennoblement.village.x, ennoblement.village.y), "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildVillageURL(ennoblement.village.id), "\">").concat(twutils.buildVillageName(ennoblement.village.name, ennoblement.village.x, ennoblement.village.y), "</a></td>");
|
||||
} else {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
@ -954,7 +958,11 @@ var _pagination = require("../utils/pagination");
|
|||
|
||||
var _formatDate = _interopRequireDefault(require("../utils/formatDate"));
|
||||
|
||||
var _tribalwars = require("../utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("../utils/tribalwars"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
@ -989,7 +997,7 @@ var _default = function _default(e, history, daily) {
|
|||
}), "</td>");
|
||||
|
||||
if (!tribe && history.tribe) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatTribeURL)(history.tribe.id), "\">").concat(history.tribe.tag, "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildTribeURL(history.tribe.id), "\">").concat(history.tribe.tag, "</a></td>");
|
||||
} else if (!tribe) {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
@ -1164,7 +1172,7 @@ var _getServerVersionCode = _interopRequireDefault(require("./utils/getServerVer
|
|||
|
||||
var _formatDate = _interopRequireDefault(require("./utils/formatDate"));
|
||||
|
||||
var _tribalwars = require("./utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("./utils/tribalwars"));
|
||||
|
||||
var twhelputils = _interopRequireWildcard(require("./utils/twhelp"));
|
||||
|
||||
|
@ -1415,13 +1423,13 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
let rowHTML = '<tr>' + "<td>".concat((0, _formatDate.default)(tribeChange.createdAt), "</td>");
|
||||
|
||||
if (tribeChange.newTribe) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatTribeURL)(tribeChange.newTribe.id), "\">").concat(tribeChange.newTribe.tag, "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildTribeURL(tribeChange.newTribe.id), "\">").concat(tribeChange.newTribe.tag, "</a></td>");
|
||||
} else {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
||||
if (tribeChange.oldTribe) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatTribeURL)(tribeChange.oldTribe.id), "\">").concat(tribeChange.oldTribe.tag, "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildTribeURL(tribeChange.oldTribe.id), "\">").concat(tribeChange.oldTribe.tag, "</a></td>");
|
||||
} else {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
|
534
dist/extendedTribeProfile.js
vendored
534
dist/extendedTribeProfile.js
vendored
|
@ -117,469 +117,7 @@ parcelRequire = (function (modules, cache, entry, globalName) {
|
|||
}
|
||||
|
||||
return newRequire;
|
||||
})({"d3m2":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = assertString;
|
||||
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
_typeof = function _typeof(obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
_typeof = function _typeof(obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function assertString(input) {
|
||||
var isString = typeof input === 'string' || input instanceof String;
|
||||
|
||||
if (!isString) {
|
||||
var invalidType;
|
||||
|
||||
if (input === null) {
|
||||
invalidType = 'null';
|
||||
} else {
|
||||
invalidType = _typeof(input);
|
||||
|
||||
if (invalidType === 'object' && input.constructor && input.constructor.hasOwnProperty('name')) {
|
||||
invalidType = input.constructor.name;
|
||||
} else {
|
||||
invalidType = "a ".concat(invalidType);
|
||||
}
|
||||
}
|
||||
|
||||
throw new TypeError("Expected string but received ".concat(invalidType, "."));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
},{}],"hxfi":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = merge;
|
||||
|
||||
function merge() {
|
||||
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
for (var key in defaults) {
|
||||
if (typeof obj[key] === 'undefined') {
|
||||
obj[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
},{}],"KGu6":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isFQDN;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
var _merge = _interopRequireDefault(require("./util/merge"));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
|
||||
var default_fqdn_options = {
|
||||
require_tld: true,
|
||||
allow_underscores: false,
|
||||
allow_trailing_dot: false
|
||||
};
|
||||
|
||||
function isFQDN(str, options) {
|
||||
(0, _assertString.default)(str);
|
||||
options = (0, _merge.default)(options, default_fqdn_options);
|
||||
/* Remove the optional trailing dot before checking validity */
|
||||
|
||||
if (options.allow_trailing_dot && str[str.length - 1] === '.') {
|
||||
str = str.substring(0, str.length - 1);
|
||||
}
|
||||
|
||||
var parts = str.split('.');
|
||||
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
if (parts[i].length > 63) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.require_tld) {
|
||||
var tld = parts.pop();
|
||||
|
||||
if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
|
||||
return false;
|
||||
} // disallow spaces && special characers
|
||||
|
||||
|
||||
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (var part, _i = 0; _i < parts.length; _i++) {
|
||||
part = parts[_i];
|
||||
|
||||
if (options.allow_underscores) {
|
||||
part = part.replace(/_/g, '');
|
||||
}
|
||||
|
||||
if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) {
|
||||
return false;
|
||||
} // disallow full-width chars
|
||||
|
||||
|
||||
if (/[\uff01-\uff5e]/.test(part)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (part[0] === '-' || part[part.length - 1] === '-') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
},{"./util/assertString":"d3m2","./util/merge":"hxfi"}],"NHAn":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isIP;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
/**
|
||||
11.3. Examples
|
||||
|
||||
The following addresses
|
||||
|
||||
fe80::1234 (on the 1st link of the node)
|
||||
ff02::5678 (on the 5th link of the node)
|
||||
ff08::9abc (on the 10th organization of the node)
|
||||
|
||||
would be represented as follows:
|
||||
|
||||
fe80::1234%1
|
||||
ff02::5678%5
|
||||
ff08::9abc%10
|
||||
|
||||
(Here we assume a natural translation from a zone index to the
|
||||
<zone_id> part, where the Nth zone of any scope is translated into
|
||||
"N".)
|
||||
|
||||
If we use interface names as <zone_id>, those addresses could also be
|
||||
represented as follows:
|
||||
|
||||
fe80::1234%ne0
|
||||
ff02::5678%pvc1.3
|
||||
ff08::9abc%interface10
|
||||
|
||||
where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
|
||||
to the 5th link, and "interface10" belongs to the 10th organization.
|
||||
* * */
|
||||
|
||||
|
||||
var ipv4Maybe = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
|
||||
var ipv6Block = /^[0-9A-F]{1,4}$/i;
|
||||
|
||||
function isIP(str) {
|
||||
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
(0, _assertString.default)(str);
|
||||
version = String(version);
|
||||
|
||||
if (!version) {
|
||||
return isIP(str, 4) || isIP(str, 6);
|
||||
} else if (version === '4') {
|
||||
if (!ipv4Maybe.test(str)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parts = str.split('.').sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
return parts[3] <= 255;
|
||||
} else if (version === '6') {
|
||||
var addressAndZone = [str]; // ipv6 addresses could have scoped architecture
|
||||
// according to https://tools.ietf.org/html/rfc4007#section-11
|
||||
|
||||
if (str.includes('%')) {
|
||||
addressAndZone = str.split('%');
|
||||
|
||||
if (addressAndZone.length !== 2) {
|
||||
// it must be just two parts
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!addressAndZone[0].includes(':')) {
|
||||
// the first part must be the address
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addressAndZone[1] === '') {
|
||||
// the second part must not be empty
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var blocks = addressAndZone[0].split(':');
|
||||
var foundOmissionBlock = false; // marker to indicate ::
|
||||
// At least some OS accept the last 32 bits of an IPv6 address
|
||||
// (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says
|
||||
// that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses,
|
||||
// and '::a.b.c.d' is deprecated, but also valid.
|
||||
|
||||
var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4);
|
||||
var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8;
|
||||
|
||||
if (blocks.length > expectedNumberOfBlocks) {
|
||||
return false;
|
||||
} // initial or final ::
|
||||
|
||||
|
||||
if (str === '::') {
|
||||
return true;
|
||||
} else if (str.substr(0, 2) === '::') {
|
||||
blocks.shift();
|
||||
blocks.shift();
|
||||
foundOmissionBlock = true;
|
||||
} else if (str.substr(str.length - 2) === '::') {
|
||||
blocks.pop();
|
||||
blocks.pop();
|
||||
foundOmissionBlock = true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < blocks.length; ++i) {
|
||||
// test for a :: which can not be at the string start/end
|
||||
// since those cases have been handled above
|
||||
if (blocks[i] === '' && i > 0 && i < blocks.length - 1) {
|
||||
if (foundOmissionBlock) {
|
||||
return false; // multiple :: in address
|
||||
}
|
||||
|
||||
foundOmissionBlock = true;
|
||||
} else if (foundIPv4TransitionBlock && i === blocks.length - 1) {// it has been checked before that the last
|
||||
// block is a valid IPv4 address
|
||||
} else if (!ipv6Block.test(blocks[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundOmissionBlock) {
|
||||
return blocks.length >= 1;
|
||||
}
|
||||
|
||||
return blocks.length === expectedNumberOfBlocks;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
},{"./util/assertString":"d3m2"}],"XMVV":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isURL;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
var _isFQDN = _interopRequireDefault(require("./isFQDN"));
|
||||
|
||||
var _isIP = _interopRequireDefault(require("./isIP"));
|
||||
|
||||
var _merge = _interopRequireDefault(require("./util/merge"));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
/*
|
||||
options for isURL method
|
||||
|
||||
require_protocol - if set as true isURL will return false if protocol is not present in the URL
|
||||
require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
|
||||
protocols - valid protocols can be modified with this option
|
||||
require_host - if set as false isURL will not check if host is present in the URL
|
||||
allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
|
||||
|
||||
*/
|
||||
|
||||
|
||||
var default_url_options = {
|
||||
protocols: ['http', 'https', 'ftp'],
|
||||
require_tld: true,
|
||||
require_protocol: false,
|
||||
require_host: true,
|
||||
require_valid_protocol: true,
|
||||
allow_underscores: false,
|
||||
allow_trailing_dot: false,
|
||||
allow_protocol_relative_urls: false
|
||||
};
|
||||
var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
|
||||
|
||||
function isRegExp(obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||
}
|
||||
|
||||
function checkHost(host, matches) {
|
||||
for (var i = 0; i < matches.length; i++) {
|
||||
var match = matches[i];
|
||||
|
||||
if (host === match || isRegExp(match) && match.test(host)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isURL(url, options) {
|
||||
(0, _assertString.default)(url);
|
||||
|
||||
if (!url || url.length >= 2083 || /[\s<>]/.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (url.indexOf('mailto:') === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
options = (0, _merge.default)(options, default_url_options);
|
||||
var protocol, auth, host, hostname, port, port_str, split, ipv6;
|
||||
split = url.split('#');
|
||||
url = split.shift();
|
||||
split = url.split('?');
|
||||
url = split.shift();
|
||||
split = url.split('://');
|
||||
|
||||
if (split.length > 1) {
|
||||
protocol = split.shift().toLowerCase();
|
||||
|
||||
if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
|
||||
return false;
|
||||
}
|
||||
} else if (options.require_protocol) {
|
||||
return false;
|
||||
} else if (url.substr(0, 2) === '//') {
|
||||
if (!options.allow_protocol_relative_urls) {
|
||||
return false;
|
||||
}
|
||||
|
||||
split[0] = url.substr(2);
|
||||
}
|
||||
|
||||
url = split.join('://');
|
||||
|
||||
if (url === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
split = url.split('/');
|
||||
url = split.shift();
|
||||
|
||||
if (url === '' && !options.require_host) {
|
||||
return true;
|
||||
}
|
||||
|
||||
split = url.split('@');
|
||||
|
||||
if (split.length > 1) {
|
||||
if (options.disallow_auth) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auth = split.shift();
|
||||
|
||||
if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
hostname = split.join('@');
|
||||
port_str = null;
|
||||
ipv6 = null;
|
||||
var ipv6_match = hostname.match(wrapped_ipv6);
|
||||
|
||||
if (ipv6_match) {
|
||||
host = '';
|
||||
ipv6 = ipv6_match[1];
|
||||
port_str = ipv6_match[2] || null;
|
||||
} else {
|
||||
split = hostname.split(':');
|
||||
host = split.shift();
|
||||
|
||||
if (split.length) {
|
||||
port_str = split.join(':');
|
||||
}
|
||||
}
|
||||
|
||||
if (port_str !== null) {
|
||||
port = parseInt(port_str, 10);
|
||||
|
||||
if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
host = host || ipv6;
|
||||
|
||||
if (options.host_whitelist && !checkHost(host, options.host_whitelist)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
},{"./util/assertString":"d3m2","./isFQDN":"KGu6","./isIP":"NHAn","./util/merge":"hxfi"}],"kK6Q":[function(require,module,exports) {
|
||||
})({"kK6Q":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
|
@ -1289,36 +827,36 @@ exports.default = _default;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.formatVillageName = exports.formatVillageURL = exports.formatPlayerURL = exports.formatTribeURL = void 0;
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.buildVillageName = exports.buildVillageURL = exports.buildPlayerURL = exports.buildTribeURL = void 0;
|
||||
|
||||
const formatTribeURL = id => {
|
||||
const buildTribeURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_ally',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatTribeURL = formatTribeURL;
|
||||
exports.buildTribeURL = buildTribeURL;
|
||||
|
||||
const formatPlayerURL = id => {
|
||||
const buildPlayerURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_player',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
|
||||
const formatVillageURL = id => {
|
||||
const buildVillageURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_village',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatVillageURL = formatVillageURL;
|
||||
exports.buildVillageURL = buildVillageURL;
|
||||
|
||||
const formatVillageName = function formatVillageName() {
|
||||
const buildVillageName = function buildVillageName() {
|
||||
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
||||
|
@ -1326,10 +864,10 @@ const formatVillageName = function formatVillageName() {
|
|||
return "".concat(n, " (").concat(x, "|").concat(y, ") ").concat(continent);
|
||||
};
|
||||
|
||||
exports.formatVillageName = formatVillageName;
|
||||
exports.buildVillageName = buildVillageName;
|
||||
|
||||
const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed / unitSpeed);
|
||||
const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
exports.calcAttackDuration = calcAttackDuration;
|
||||
|
@ -1355,7 +893,11 @@ var _showPopup = _interopRequireDefault(require("../utils/showPopup"));
|
|||
|
||||
var _formatDate = _interopRequireDefault(require("../utils/formatDate"));
|
||||
|
||||
var _tribalwars = require("../utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("../utils/tribalwars"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
@ -1364,7 +906,7 @@ const translations = (0, _showEnnoblementsPopup.default)();
|
|||
|
||||
const getPlayerTd = (player, tribe) => {
|
||||
if (player) {
|
||||
return "<td><a href=\"".concat((0, _tribalwars.formatPlayerURL)(player.id), "\">").concat(player.name, " (").concat(tribe ? "<a href=\"".concat((0, _tribalwars.formatTribeURL)(tribe.id), "\">").concat(tribe.tag, "</a>") : '-', ")</a></td>");
|
||||
return "<td><a href=\"".concat(twutils.buildPlayerURL(player.id), "\">").concat(player.name, " (").concat(tribe ? "<a href=\"".concat(twutils.buildTribeURL(tribe.id), "\">").concat(tribe.tag, "</a>") : '-', ")</a></td>");
|
||||
}
|
||||
|
||||
return '<td>-</td>';
|
||||
|
@ -1385,7 +927,7 @@ var _default = function _default(e, ennoblements) {
|
|||
let rowHTML = '<tr>' + "<td>".concat((0, _formatDate.default)(ennoblement.ennobledAt), "</td>");
|
||||
|
||||
if (ennoblement.village) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatVillageURL)(ennoblement.village.id), "\">").concat((0, _tribalwars.formatVillageName)(ennoblement.village.name, ennoblement.village.x, ennoblement.village.y), "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildVillageURL(ennoblement.village.id), "\">").concat(twutils.buildVillageName(ennoblement.village.name, ennoblement.village.x, ennoblement.village.y), "</a></td>");
|
||||
} else {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
@ -1581,7 +1123,11 @@ var _pagination = require("../utils/pagination");
|
|||
|
||||
var _formatDate = _interopRequireDefault(require("../utils/formatDate"));
|
||||
|
||||
var _tribalwars = require("../utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("../utils/tribalwars"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
@ -1616,7 +1162,7 @@ var _default = function _default(e, history, daily) {
|
|||
}), "</td>");
|
||||
|
||||
if (!tribe && history.tribe) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatTribeURL)(history.tribe.id), "\">").concat(history.tribe.tag, "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildTribeURL(history.tribe.id), "\">").concat(history.tribe.tag, "</a></td>");
|
||||
} else if (!tribe) {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
@ -1705,15 +1251,15 @@ exports.default = _default;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.formatPlayerURL = void 0;
|
||||
exports.buildPlayerURL = void 0;
|
||||
|
||||
const formatPlayerURL = function formatPlayerURL() {
|
||||
const buildPlayerURL = function buildPlayerURL() {
|
||||
let server = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
return "http://www.twstats.com/in/".concat(server, "/player/").concat(id);
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
},{}],"gvXE":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
|
@ -1771,8 +1317,6 @@ exports.buildVillageURL = buildVillageURL;
|
|||
},{}],"r4nF":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
var _isURL = _interopRequireDefault(require("validator/lib/isURL"));
|
||||
|
||||
var _differenceInDays = _interopRequireDefault(require("date-fns/differenceInDays"));
|
||||
|
||||
var _extendedTribeProfile = _interopRequireDefault(require("./i18n/extendedTribeProfile"));
|
||||
|
@ -1799,11 +1343,15 @@ var _formatDate = _interopRequireDefault(require("./utils/formatDate"));
|
|||
|
||||
var _getServerVersionCode = _interopRequireDefault(require("./utils/getServerVersionCode"));
|
||||
|
||||
var _twstats = require("./utils/twstats");
|
||||
var twstatsutils = _interopRequireWildcard(require("./utils/twstats"));
|
||||
|
||||
var _twhelp = require("./utils/twhelp");
|
||||
var twhelputils = _interopRequireWildcard(require("./utils/twhelp"));
|
||||
|
||||
var _tribalwars = require("./utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("./utils/tribalwars"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
@ -1942,10 +1490,10 @@ const extendMembersData = players => {
|
|||
|
||||
if (player) {
|
||||
[[player.scoreAtt, player.rankAtt], [player.scoreDef, player.rankDef], [player.scoreSup, player.rankSup], [player.scoreTotal, player.rankTotal], player.dailyGrowth, [{
|
||||
link: (0, _twhelp.buildPlayerURL)(VERSION, SERVER, player.id),
|
||||
link: twhelputils.buildPlayerURL(VERSION, SERVER, player.id),
|
||||
label: 'TWHelp'
|
||||
}, {
|
||||
link: (0, _twstats.formatPlayerURL)(SERVER, player.id),
|
||||
link: twstatsutils.buildPlayerURL(SERVER, player.id),
|
||||
label: 'TWStats'
|
||||
}]].forEach((data, index) => {
|
||||
let td = tr.children[5 + index];
|
||||
|
@ -2140,7 +1688,7 @@ const buildMembersGrowthTBody = stats => {
|
|||
tds.push("<td style=\"".concat(getMembersGrowthTdStyle(val), "\">").concat(val.toLocaleString(), "</td>"));
|
||||
}
|
||||
|
||||
return "<tr>\n <td>\n ".concat(player ? "<a href=\"".concat((0, _tribalwars.formatPlayerURL)(id), "\">").concat(player.name, "</a>") : '-', "\n </td>\n ").concat(tds.join(''), "\n <td style=\"").concat(getMembersGrowthTdStyle(total), "\"><strong>").concat(total.toLocaleString(), "</strong></td>\n </tr>");
|
||||
return "<tr>\n <td>\n ".concat(player ? "<a href=\"".concat(twutils.buildPlayerURL(id), "\">").concat(player.name, "</a>") : '-', "\n </td>\n ").concat(tds.join(''), "\n <td style=\"").concat(getMembersGrowthTdStyle(total), "\"><strong>").concat(total.toLocaleString(), "</strong></td>\n </tr>");
|
||||
}).join(''), "\n </tbody>\n ");
|
||||
};
|
||||
|
||||
|
@ -2210,7 +1758,7 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
let rowHTML = '<tr>' + "<td>".concat((0, _formatDate.default)(tribeChange.createdAt), "</td>");
|
||||
|
||||
if (tribeChange.player) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatPlayerURL)(tribeChange.player.id), "\">").concat(tribeChange.player.name, "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildPlayerURL(tribeChange.player.id), "\">").concat(tribeChange.player.name, "</a></td>");
|
||||
} else {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
@ -2361,7 +1909,7 @@ const wrapAction = action => {
|
|||
|
||||
const renderActions = () => {
|
||||
const linkToTWHelp = document.createElement('a');
|
||||
linkToTWHelp.href = (0, _twhelp.buildTribeURL)(VERSION, SERVER, TRIBE_ID);
|
||||
linkToTWHelp.href = twhelputils.buildTribeURL(VERSION, SERVER, TRIBE_ID);
|
||||
linkToTWHelp.innerHTML = translations.action.linkToTWHelp;
|
||||
actionContainer.appendChild(wrapAction(linkToTWHelp));
|
||||
const showEnnoblements = document.createElement('a');
|
||||
|
@ -2418,4 +1966,4 @@ const renderActions = () => {
|
|||
console.log('extended tribe profile', error);
|
||||
}
|
||||
})();
|
||||
},{"validator/lib/isURL":"XMVV","date-fns/differenceInDays":"mdVI","./i18n/extendedTribeProfile":"iFDG","./libs/requestCreator":"Ph2E","./utils/pagination":"fCHX","./common/renderTodaysStats":"yrCm","./common/showEnnoblementsPopup":"vNT1","./common/showHistoryPopup":"kEDU","./utils/showPopup":"chDM","./utils/getIDFromURL":"tQUs","./utils/getCurrentServer":"DMkL","./utils/localStorage":"KWxH","./utils/formatDate":"V6Mf","./utils/getServerVersionCode":"J1Ly","./utils/twstats":"Syko","./utils/twhelp":"gvXE","./utils/tribalwars":"fHHP"}]},{},["r4nF"], null)
|
||||
},{"date-fns/differenceInDays":"mdVI","./i18n/extendedTribeProfile":"iFDG","./libs/requestCreator":"Ph2E","./utils/pagination":"fCHX","./common/renderTodaysStats":"yrCm","./common/showEnnoblementsPopup":"vNT1","./common/showHistoryPopup":"kEDU","./utils/showPopup":"chDM","./utils/getIDFromURL":"tQUs","./utils/getCurrentServer":"DMkL","./utils/localStorage":"KWxH","./utils/formatDate":"V6Mf","./utils/getServerVersionCode":"J1Ly","./utils/twstats":"Syko","./utils/twhelp":"gvXE","./utils/tribalwars":"fHHP"}]},{},["r4nF"], null)
|
51
dist/extendedVillageProfile.js
vendored
51
dist/extendedVillageProfile.js
vendored
|
@ -308,36 +308,36 @@ exports.default = _default;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.formatVillageName = exports.formatVillageURL = exports.formatPlayerURL = exports.formatTribeURL = void 0;
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.buildVillageName = exports.buildVillageURL = exports.buildPlayerURL = exports.buildTribeURL = void 0;
|
||||
|
||||
const formatTribeURL = id => {
|
||||
const buildTribeURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_ally',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatTribeURL = formatTribeURL;
|
||||
exports.buildTribeURL = buildTribeURL;
|
||||
|
||||
const formatPlayerURL = id => {
|
||||
const buildPlayerURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_player',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
|
||||
const formatVillageURL = id => {
|
||||
const buildVillageURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_village',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatVillageURL = formatVillageURL;
|
||||
exports.buildVillageURL = buildVillageURL;
|
||||
|
||||
const formatVillageName = function formatVillageName() {
|
||||
const buildVillageName = function buildVillageName() {
|
||||
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
||||
|
@ -345,10 +345,10 @@ const formatVillageName = function formatVillageName() {
|
|||
return "".concat(n, " (").concat(x, "|").concat(y, ") ").concat(continent);
|
||||
};
|
||||
|
||||
exports.formatVillageName = formatVillageName;
|
||||
exports.buildVillageName = buildVillageName;
|
||||
|
||||
const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed / unitSpeed);
|
||||
const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
exports.calcAttackDuration = calcAttackDuration;
|
||||
|
@ -606,7 +606,7 @@ function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
|
|||
var diff = (0, _index.default)(dirtyDateLeft, dirtyDateRight) / MILLISECONDS_IN_MINUTE;
|
||||
return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
|
||||
}
|
||||
},{"../differenceInMilliseconds/index.js":"H70G","../_lib/requiredArgs/index.js":"kK6Q"}],"ATOB":[function(require,module,exports) {
|
||||
},{"../differenceInMilliseconds/index.js":"H70G","../_lib/requiredArgs/index.js":"kK6Q"}],"kcC2":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
|
@ -618,7 +618,7 @@ var _differenceInMinutes = _interopRequireDefault(require("date-fns/differenceIn
|
|||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = (ennobledAt, speed) => {
|
||||
const calcLoyalty = (ennobledAt, speed) => {
|
||||
let loyalty = 25 + Math.abs((0, _differenceInMinutes.default)(ennobledAt, new Date())) * (speed / 60);
|
||||
|
||||
if (loyalty > 100) {
|
||||
|
@ -628,6 +628,7 @@ var _default = (ennobledAt, speed) => {
|
|||
return Math.floor(loyalty);
|
||||
};
|
||||
|
||||
var _default = calcLoyalty;
|
||||
exports.default = _default;
|
||||
},{"date-fns/differenceInMinutes":"oGJj"}],"J1Ly":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
@ -785,7 +786,11 @@ var _showPopup = _interopRequireDefault(require("../utils/showPopup"));
|
|||
|
||||
var _formatDate = _interopRequireDefault(require("../utils/formatDate"));
|
||||
|
||||
var _tribalwars = require("../utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("../utils/tribalwars"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
@ -794,7 +799,7 @@ const translations = (0, _showEnnoblementsPopup.default)();
|
|||
|
||||
const getPlayerTd = (player, tribe) => {
|
||||
if (player) {
|
||||
return "<td><a href=\"".concat((0, _tribalwars.formatPlayerURL)(player.id), "\">").concat(player.name, " (").concat(tribe ? "<a href=\"".concat((0, _tribalwars.formatTribeURL)(tribe.id), "\">").concat(tribe.tag, "</a>") : '-', ")</a></td>");
|
||||
return "<td><a href=\"".concat(twutils.buildPlayerURL(player.id), "\">").concat(player.name, " (").concat(tribe ? "<a href=\"".concat(twutils.buildTribeURL(tribe.id), "\">").concat(tribe.tag, "</a>") : '-', ")</a></td>");
|
||||
}
|
||||
|
||||
return '<td>-</td>';
|
||||
|
@ -815,7 +820,7 @@ var _default = function _default(e, ennoblements) {
|
|||
let rowHTML = '<tr>' + "<td>".concat((0, _formatDate.default)(ennoblement.ennobledAt), "</td>");
|
||||
|
||||
if (ennoblement.village) {
|
||||
rowHTML += "<td><a href=\"".concat((0, _tribalwars.formatVillageURL)(ennoblement.village.id), "\">").concat((0, _tribalwars.formatVillageName)(ennoblement.village.name, ennoblement.village.x, ennoblement.village.y), "</a></td>");
|
||||
rowHTML += "<td><a href=\"".concat(twutils.buildVillageURL(ennoblement.village.id), "\">").concat(twutils.buildVillageName(ennoblement.village.name, ennoblement.village.x, ennoblement.village.y), "</a></td>");
|
||||
} else {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
@ -857,14 +862,18 @@ var _wait = _interopRequireDefault(require("./utils/wait"));
|
|||
|
||||
var _localStorage = require("./utils/localStorage");
|
||||
|
||||
var _countLoyalty = _interopRequireDefault(require("./utils/countLoyalty"));
|
||||
var _calcLoyalty = _interopRequireDefault(require("./utils/calcLoyalty"));
|
||||
|
||||
var _getServerVersionCode = _interopRequireDefault(require("./utils/getServerVersionCode"));
|
||||
|
||||
var _twhelp = require("./utils/twhelp");
|
||||
var twhelputils = _interopRequireWildcard(require("./utils/twhelp"));
|
||||
|
||||
var _showEnnoblementsPopup = _interopRequireDefault(require("./common/showEnnoblementsPopup"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
@ -1079,7 +1088,7 @@ const wrapAction = action => {
|
|||
|
||||
const renderActions = () => {
|
||||
const linkToTWHelp = document.createElement('a');
|
||||
linkToTWHelp.href = (0, _twhelp.buildVillageURL)((0, _getServerVersionCode.default)(SERVER), SERVER, VILLAGE_ID);
|
||||
linkToTWHelp.href = twhelputils.buildVillageURL((0, _getServerVersionCode.default)(SERVER), SERVER, VILLAGE_ID);
|
||||
linkToTWHelp.innerHTML = translations.action.linkToTWHelp;
|
||||
actionContainer.appendChild(wrapAction(linkToTWHelp));
|
||||
const showEnnoblementsPopup = document.createElement('a');
|
||||
|
@ -1142,7 +1151,7 @@ const renderAdditionalInfo = function renderAdditionalInfo() {
|
|||
renderTr({
|
||||
id: 'loyalty',
|
||||
title: "".concat(translations.possibleLoyalty, ":"),
|
||||
data: firstEnnoblement ? (0, _countLoyalty.default)(new Date(firstEnnoblement.ennobledAt), config.speed) : 100
|
||||
data: firstEnnoblement ? (0, _calcLoyalty.default)(new Date(firstEnnoblement.ennobledAt), config.speed) : 100
|
||||
});
|
||||
renderTr({
|
||||
id: 'ennobledAt',
|
||||
|
@ -1178,4 +1187,4 @@ const renderAdditionalInfo = function renderAdditionalInfo() {
|
|||
console.log('extended village profile', error);
|
||||
}
|
||||
})();
|
||||
},{"./libs/requestCreator":"Ph2E","./i18n/extendedVillageProfile":"LNef","./utils/pagination":"fCHX","./utils/getCurrentServer":"DMkL","./utils/getIDFromURL":"tQUs","./utils/buildUnitImgURL":"KX6P","./utils/formatDate":"V6Mf","./utils/wait":"oUdd","./utils/localStorage":"KWxH","./utils/countLoyalty":"ATOB","./utils/getServerVersionCode":"J1Ly","./utils/twhelp":"gvXE","./common/showEnnoblementsPopup":"vNT1"}]},{},["UdfQ"], null)
|
||||
},{"./libs/requestCreator":"Ph2E","./i18n/extendedVillageProfile":"LNef","./utils/pagination":"fCHX","./utils/getCurrentServer":"DMkL","./utils/getIDFromURL":"tQUs","./utils/buildUnitImgURL":"KX6P","./utils/formatDate":"V6Mf","./utils/wait":"oUdd","./utils/localStorage":"KWxH","./utils/calcLoyalty":"kcC2","./utils/getServerVersionCode":"J1Ly","./utils/twhelp":"gvXE","./common/showEnnoblementsPopup":"vNT1"}]},{},["UdfQ"], null)
|
46
dist/latestEnnoblements.js
vendored
46
dist/latestEnnoblements.js
vendored
|
@ -240,36 +240,36 @@ exports.default = _default;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.formatVillageName = exports.formatVillageURL = exports.formatPlayerURL = exports.formatTribeURL = void 0;
|
||||
exports.buildImgURL = exports.calcAttackDuration = exports.buildVillageName = exports.buildVillageURL = exports.buildPlayerURL = exports.buildTribeURL = void 0;
|
||||
|
||||
const formatTribeURL = id => {
|
||||
const buildTribeURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_ally',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatTribeURL = formatTribeURL;
|
||||
exports.buildTribeURL = buildTribeURL;
|
||||
|
||||
const formatPlayerURL = id => {
|
||||
const buildPlayerURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_player',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatPlayerURL = formatPlayerURL;
|
||||
exports.buildPlayerURL = buildPlayerURL;
|
||||
|
||||
const formatVillageURL = id => {
|
||||
const buildVillageURL = id => {
|
||||
return window.location.origin + TribalWars.buildURL('', {
|
||||
screen: 'info_village',
|
||||
id
|
||||
});
|
||||
};
|
||||
|
||||
exports.formatVillageURL = formatVillageURL;
|
||||
exports.buildVillageURL = buildVillageURL;
|
||||
|
||||
const formatVillageName = function formatVillageName() {
|
||||
const buildVillageName = function buildVillageName() {
|
||||
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
||||
|
@ -277,10 +277,10 @@ const formatVillageName = function formatVillageName() {
|
|||
return "".concat(n, " (").concat(x, "|").concat(y, ") ").concat(continent);
|
||||
};
|
||||
|
||||
exports.formatVillageName = formatVillageName;
|
||||
exports.buildVillageName = buildVillageName;
|
||||
|
||||
const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed / unitSpeed);
|
||||
const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
exports.calcAttackDuration = calcAttackDuration;
|
||||
|
@ -435,16 +435,20 @@ var _getCurrentServer = _interopRequireDefault(require("./utils/getCurrentServer
|
|||
|
||||
var _formatDate = _interopRequireDefault(require("./utils/formatDate"));
|
||||
|
||||
var _tribalwars = require("./utils/tribalwars");
|
||||
var twutils = _interopRequireWildcard(require("./utils/tribalwars"));
|
||||
|
||||
var _localStorage = require("./utils/localStorage");
|
||||
|
||||
var _twhelp = require("./utils/twhelp");
|
||||
var twhelputils = _interopRequireWildcard(require("./utils/twhelp"));
|
||||
|
||||
var _getServerVersionCode = _interopRequireDefault(require("./utils/getServerVersionCode"));
|
||||
|
||||
var _latestEnnoblements = _interopRequireDefault(require("./i18n/latestEnnoblements"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
@ -557,7 +561,7 @@ const handleFilterFormSubmit = (e, ennoblements) => {
|
|||
oldOwnerTribe: e.target[3].value
|
||||
});
|
||||
|
||||
document.querySelector("#".concat(TABLE_ID, " tbody")).innerHTML = formatEnnoblementRows(filterEnnoblements(ennoblements, filters)).join('');
|
||||
document.querySelector("#".concat(TABLE_ID, " tbody")).innerHTML = buildEnnoblementsRows(filterEnnoblements(ennoblements, filters)).join('');
|
||||
cacheFilters(filters);
|
||||
};
|
||||
|
||||
|
@ -568,17 +572,17 @@ const addEventListeners = function addEventListeners() {
|
|||
});
|
||||
};
|
||||
|
||||
const formatPlayerHTML = player => {
|
||||
return player && player.name ? "<a href=\"".concat((0, _tribalwars.formatPlayerURL)(player.id), "\">").concat(player.name, "</a> (").concat(player.tribe && player.tribe.tag ? "<a href=\"".concat((0, _tribalwars.formatTribeURL)(player.tribe.id), "\">").concat(player.tribe.tag, "</a>") : '-', ")") : '-';
|
||||
const getPlayerHTML = player => {
|
||||
return player && player.name ? "<a href=\"".concat(twutils.buildPlayerURL(player.id), "\">").concat(player.name, "</a> (").concat(player.tribe && player.tribe.tag ? "<a href=\"".concat(twutils.buildTribeURL(player.tribe.id), "\">").concat(player.tribe.tag, "</a>") : '-', ")") : '-';
|
||||
};
|
||||
|
||||
const formatVillageHTML = village => {
|
||||
return "<a href=\"".concat((0, _tribalwars.formatVillageURL)(village.id), "\">").concat((0, _tribalwars.formatVillageName)(village.name, village.x, village.y), "</a>");
|
||||
const getVillageHTML = village => {
|
||||
return "<a href=\"".concat(twutils.buildVillageURL(village.id), "\">").concat(twutils.buildVillageName(village.name, village.x, village.y), "</a>");
|
||||
};
|
||||
|
||||
const formatEnnoblementRows = ennoblements => {
|
||||
const buildEnnoblementsRows = ennoblements => {
|
||||
return ennoblements.reverse().map(ennoblement => {
|
||||
return "<tr>\n <td>".concat(formatVillageHTML(ennoblement.village), "</td>\n <td>").concat(formatPlayerHTML(ennoblement.newOwner), "</td>\n <td>").concat(formatPlayerHTML(ennoblement.oldOwner), "</td>\n <td>").concat((0, _formatDate.default)(ennoblement.ennobledAt), "</td>\n </tr>");
|
||||
return "<tr>\n <td>".concat(getVillageHTML(ennoblement.village), "</td>\n <td>").concat(getPlayerHTML(ennoblement.newOwner), "</td>\n <td>").concat(getPlayerHTML(ennoblement.oldOwner), "</td>\n <td>").concat((0, _formatDate.default)(ennoblement.ennobledAt), "</td>\n </tr>");
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -588,7 +592,7 @@ const renderLatestEnnoblements = function renderLatestEnnoblements() {
|
|||
|
||||
const prepared = _objectSpread(_objectSpread({}, DEFAULT_FILTER), filters);
|
||||
|
||||
const html = "\n <form style=\"margin-bottom: 15px\" id=\"".concat(FILTER_FORM_ID, "\">\n <h1 style=\"margin-bottom: 0px; text-align: center;\"><a href=\"").concat((0, _twhelp.buildURLToServerPage)((0, _getServerVersionCode.default)(SERVER), SERVER), "\">TWHelp</a></h1>\n <h3 style=\"margin-bottom: 10px; margin-top: 0;\">").concat(translations.devNote, "</h3>\n <h3 style=\"margin-bottom: 5px\">").concat(translations.filters, "</h3>\n <input type=\"text\" placeholder=\"").concat(translations.newOwner, "\" value=\"").concat(prepared.newOwner, "\" />\n <input type=\"text\" placeholder=\"").concat(translations.newOwnerTribe, "\" value=\"").concat(prepared.newOwnerTribe, "\" />\n <input type=\"text\" placeholder=\"").concat(translations.oldOwner, "\" value=\"").concat(prepared.oldOwner, "\" />\n <input type=\"text\" placeholder=\"").concat(translations.oldOwnerTribe, "\" value=\"").concat(prepared.oldOwnerTribe, "\" />\n <div>\n <button type=\"submit\">").concat(translations.apply, "</button>\n </div>\n </form>\n <table class=\"vis\" id=\"").concat(TABLE_ID, "\" style=\"width: 100%\">\n <thead>\n <tr>\n <th>").concat(translations.village, "</th>\n <th>").concat(translations.newOwner, "</th>\n <th>").concat(translations.oldOwner, "</th>\n <th>").concat(translations.date, "</th>\n </tr>\n </thead>\n <tbody>\n ").concat(formatEnnoblementRows(filterEnnoblements(ennoblements, prepared)).join(''), "\n </tbody>\n </table>\n ");
|
||||
const html = "\n <form style=\"margin-bottom: 15px\" id=\"".concat(FILTER_FORM_ID, "\">\n <h1 style=\"margin-bottom: 0px; text-align: center;\"><a href=\"").concat(twhelputils.buildURLToServerPage((0, _getServerVersionCode.default)(SERVER), SERVER), "\">TWHelp</a></h1>\n <h3 style=\"margin-bottom: 10px; margin-top: 0;\">").concat(translations.devNote, "</h3>\n <h3 style=\"margin-bottom: 5px\">").concat(translations.filters, "</h3>\n <input type=\"text\" placeholder=\"").concat(translations.newOwner, "\" value=\"").concat(prepared.newOwner, "\" />\n <input type=\"text\" placeholder=\"").concat(translations.newOwnerTribe, "\" value=\"").concat(prepared.newOwnerTribe, "\" />\n <input type=\"text\" placeholder=\"").concat(translations.oldOwner, "\" value=\"").concat(prepared.oldOwner, "\" />\n <input type=\"text\" placeholder=\"").concat(translations.oldOwnerTribe, "\" value=\"").concat(prepared.oldOwnerTribe, "\" />\n <div>\n <button type=\"submit\">").concat(translations.apply, "</button>\n </div>\n </form>\n <table class=\"vis\" id=\"").concat(TABLE_ID, "\" style=\"width: 100%\">\n <thead>\n <tr>\n <th>").concat(translations.village, "</th>\n <th>").concat(translations.newOwner, "</th>\n <th>").concat(translations.oldOwner, "</th>\n <th>").concat(translations.date, "</th>\n </tr>\n </thead>\n <tbody>\n ").concat(buildEnnoblementsRows(filterEnnoblements(ennoblements, prepared)).join(''), "\n </tbody>\n </table>\n ");
|
||||
(0, _showPopup.default)({
|
||||
e: {
|
||||
clientY: 60
|
||||
|
|
9
dist/mapCoordsPicker.js
vendored
9
dist/mapCoordsPicker.js
vendored
|
@ -247,10 +247,11 @@ const saveConfig = () => {
|
|||
};
|
||||
|
||||
const villageIDByCoords = (x, y) => {
|
||||
const village = TWMap.villages[parseInt("".concat(x).concat(y))];
|
||||
const xy = parseInt("".concat(x).concat(y), 10);
|
||||
const village = TWMap.villages[xy];
|
||||
|
||||
if (village) {
|
||||
return TWMap.villages[parseInt("".concat(x).concat(y))].id;
|
||||
return TWMap.villages[xy].id;
|
||||
}
|
||||
|
||||
return NaN;
|
||||
|
@ -362,7 +363,7 @@ const renderGroups = () => {
|
|||
renderForm(formsContainer);
|
||||
};
|
||||
|
||||
const exportVillagesHandler = () => {
|
||||
const handleExportVillages = () => {
|
||||
const groups = [];
|
||||
|
||||
for (let name in config.groups) {
|
||||
|
@ -376,7 +377,7 @@ const exportVillagesHandler = () => {
|
|||
const renderActions = () => {
|
||||
const exportVillages = document.createElement('button');
|
||||
exportVillages.innerHTML = translations.export;
|
||||
exportVillages.addEventListener('click', exportVillagesHandler);
|
||||
exportVillages.addEventListener('click', handleExportVillages);
|
||||
actionsContainer.appendChild(exportVillages);
|
||||
};
|
||||
|
||||
|
|
4
dist/quickbar/bonusBarbarianVillageFinder.js
vendored
4
dist/quickbar/bonusBarbarianVillageFinder.js
vendored
|
@ -5,9 +5,9 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel
|
|||
},{}],"DMkL":[function(require,module,exports) {
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=()=>window.location.host.split(".")[0];exports.default=e;
|
||||
},{}],"fHHP":[function(require,module,exports) {
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildImgURL=exports.calcAttackDuration=exports.formatVillageName=exports.formatVillageURL=exports.formatPlayerURL=exports.formatTribeURL=void 0;const o=o=>window.location.origin+TribalWars.buildURL("",{screen:"info_ally",id:o});exports.formatTribeURL=o;const t=o=>window.location.origin+TribalWars.buildURL("",{screen:"info_player",id:o});exports.formatPlayerURL=t;const r=o=>window.location.origin+TribalWars.buildURL("",{screen:"info_village",id:o});exports.formatVillageURL=r;const e=function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500;const e="K"+String(r)[0]+String(t)[0];return"".concat(o," (").concat(t,"|").concat(r,") ").concat(e)};exports.formatVillageName=e;const i=(o,t,r)=>Math.round(o*r/t);exports.calcAttackDuration=i;const a=o=>image_base+o;exports.buildImgURL=a;
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildImgURL=exports.calcAttackDuration=exports.buildVillageName=exports.buildVillageURL=exports.buildPlayerURL=exports.buildTribeURL=void 0;const i=i=>window.location.origin+TribalWars.buildURL("",{screen:"info_ally",id:i});exports.buildTribeURL=i;const o=i=>window.location.origin+TribalWars.buildURL("",{screen:"info_player",id:i});exports.buildPlayerURL=o;const e=i=>window.location.origin+TribalWars.buildURL("",{screen:"info_village",id:i});exports.buildVillageURL=e;const t=function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500;const t="K"+String(e)[0]+String(o)[0];return"".concat(i," (").concat(o,"|").concat(e,") ").concat(t)};exports.buildVillageName=t;const l=(i,o)=>Math.round(i*o);exports.calcAttackDuration=l;const r=i=>image_base+i;exports.buildImgURL=r;
|
||||
},{}],"XOOL":[function(require,module,exports) {
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.calcDistanceBetweenTwoPoints=void 0;const e=(e,t,s,o)=>{const c=e-s,n=t-o;return Math.sqrt(c*c+n*n)};exports.calcDistanceBetweenTwoPoints=e;
|
||||
},{}],"fvjy":[function(require,module,exports) {
|
||||
"use strict";var t=o(require("./libs/requestCreator")),e=o(require("./i18n/bonusBarbarianVillageFinder")),n=o(require("./utils/getCurrentServer")),r=require("./utils/tribalwars"),a=require("./utils/math");function o(t){return t&&t.__esModule?t:{default:t}}function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?c(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const l=(0,n.default)(),u="\n query villages($server: String!, $filter: VillageFilter, $sort: [String!], $offset: Int) {\n villages(server: $server, filter: $filter, offset: $offset, sort: $sort) {\n total\n items {\n id\n name\n bonus\n x\n y\n }\n }\n }\n",d="bonusBarbarianVillageFinderTable",f="actualCoords",b=(0,e.default)();let p=void 0;const y=(t,e)=>({query:u,variables:{server:l,sort:["id DESC"],filter:{bonus:t,playerID:[0]},offset:e}}),m=async e=>{const{villages:n}=await(0,t.default)(y(e,0));for(let r=n.length;r<n.total;r+=1e3){const r=await(0,t.default)(y(e,0));n.items=[...n.items,...r.villages.items]}return n},g=async t=>{t.preventDefault();const e=await m(parseInt(t.target[0].value)),n=TWMap.pos;e.items=e.items.map(t=>i(i({},t),{},{distance:(0,a.calcDistanceBetweenTwoPoints)(n[0],n[1],t.x,t.y)})).sort((t,e)=>t.distance-e.distance),document.querySelector("#"+d).innerHTML=h(e.items)},v=()=>{let t=[];for(let e in TWMap.bonus_data)t.push({value:e,text:TWMap.bonus_data[e].text});return t},h=t=>"\n <tbody>\n <tr>\n <th>\n ".concat(b.village,"\n </th>\n <th>\n ").concat(b.distance,"\n </th>\n <th>\n ").concat(b.action,"\n </th>\n </tr>\n ").concat(Array.isArray(t)?t.map(t=>'<tr>\n <td>\n <a href="'.concat((0,r.formatVillageURL)(t.id),'">\n ').concat((0,r.formatVillageName)(t.name,t.x,t.y),"\n </a>\n </td>\n <td>\n ").concat(t.distance.toFixed(1),'\n </td>\n <td>\n <a href="#" onclick="return TWMap.focusUserSpecified(').concat(t.x,", ").concat(t.y,')">Center</a>\n </td>\n </tr>')).join(""):"","\n </tbody>\n "),O=()=>{document.querySelector("#actualCoords").innerHTML="".concat(b.actualCoords,": <strong>").concat(TWMap.pos.join("|"),"</strong>")},j=()=>{const t='\n <p id="'.concat("actualCoords",'"></p>\n <form>\n <select>\n ').concat(v().map(t=>'<option value="'.concat(t.value,'">').concat(t.text,"</option>")).join(""),'\n </select>\n <button type="submit">').concat(b.searchBonusBarbarianVillages,'</button>\n </form>\n <table class="vis" style="width: 100%;" id="').concat(d,'">\n ').concat(h(),"\n </table>\n ");p||((p=document.createElement("div")).classList.add("containerBorder"),p.style.clear="both",document.querySelector("#map_big").appendChild(p)),p.innerHTML=t,p.querySelector("form").addEventListener("submit",g),O(),setInterval(O,1e3)};j();
|
||||
"use strict";var e=c(require("./libs/requestCreator")),t=c(require("./i18n/bonusBarbarianVillageFinder")),n=c(require("./utils/getCurrentServer")),r=i(require("./utils/tribalwars")),a=require("./utils/math");function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}function i(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=r?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,t&&t.set(e,n),n}function c(e){return e&&e.__esModule?e:{default:e}}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const f=(0,n.default)(),d="\n query villages($server: String!, $filter: VillageFilter, $sort: [String!], $offset: Int) {\n villages(server: $server, filter: $filter, offset: $offset, sort: $sort) {\n total\n items {\n id\n name\n bonus\n x\n y\n }\n }\n }\n",p="bonusBarbarianVillageFinderTable",b="actualCoords",y=(0,t.default)();let v=void 0;const g=(e,t)=>({query:d,variables:{server:f,sort:["id DESC"],filter:{bonus:e,playerID:[0]},offset:t}}),m=async t=>{const{villages:n}=await(0,e.default)(g(t,0));for(let r=n.length;r<n.total;r+=1e3){const r=await(0,e.default)(g(t,0));n.items=[...n.items,...r.villages.items]}return n},O=async e=>{e.preventDefault();const t=await m(parseInt(e.target[0].value)),n=TWMap.pos;t.items=t.items.map(e=>l(l({},e),{},{distance:(0,a.calcDistanceBetweenTwoPoints)(n[0],n[1],e.x,e.y)})).sort((e,t)=>e.distance-t.distance),document.querySelector("#"+p).innerHTML=j(t.items)},h=()=>{let e=[];for(let t in TWMap.bonus_data)e.push({value:t,text:TWMap.bonus_data[t].text});return e},j=e=>"\n <tbody>\n <tr>\n <th>\n ".concat(y.village,"\n </th>\n <th>\n ").concat(y.distance,"\n </th>\n <th>\n ").concat(y.action,"\n </th>\n </tr>\n ").concat(Array.isArray(e)?e.map(e=>'<tr>\n <td>\n <a href="'.concat(r.buildVillageURL(e.id),'">\n ').concat(r.buildVillageName(e.name,e.x,e.y),"\n </a>\n </td>\n <td>\n ").concat(e.distance.toFixed(1),'\n </td>\n <td>\n <a href="#" onclick="return TWMap.focusUserSpecified(').concat(e.x,", ").concat(e.y,')">Center</a>\n </td>\n </tr>')).join(""):"","\n </tbody>\n "),w=()=>{document.querySelector("#actualCoords").innerHTML="".concat(y.actualCoords,": <strong>").concat(TWMap.pos.join("|"),"</strong>")},P=()=>{const e='\n <p id="'.concat("actualCoords",'"></p>\n <form>\n <select>\n ').concat(h().map(e=>'<option value="'.concat(e.value,'">').concat(e.text,"</option>")).join(""),'\n </select>\n <button type="submit">').concat(y.searchBonusBarbarianVillages,'</button>\n </form>\n <table class="vis" style="width: 100%;" id="').concat(p,'">\n ').concat(j(),"\n </table>\n ");v||((v=document.createElement("div")).classList.add("containerBorder"),v.style.clear="both",document.querySelector("#map_big").appendChild(v)),v.innerHTML=e,v.querySelector("form").addEventListener("submit",O),w(),setInterval(w,1e3)};P();
|
||||
},{"./libs/requestCreator":"Ph2E","./i18n/bonusBarbarianVillageFinder":"MRps","./utils/getCurrentServer":"DMkL","./utils/tribalwars":"fHHP","./utils/math":"XOOL"}]},{},["fvjy"], null)
|
4
dist/quickbar/dailyAchievements.js
vendored
4
dist/quickbar/dailyAchievements.js
vendored
File diff suppressed because one or more lines are too long
10
dist/quickbar/extendedMapPopup.js
vendored
10
dist/quickbar/extendedMapPopup.js
vendored
File diff suppressed because one or more lines are too long
8
dist/quickbar/extendedPlayerProfile.js
vendored
8
dist/quickbar/extendedPlayerProfile.js
vendored
File diff suppressed because one or more lines are too long
24
dist/quickbar/extendedTribeProfile.js
vendored
24
dist/quickbar/extendedTribeProfile.js
vendored
File diff suppressed because one or more lines are too long
12
dist/quickbar/extendedVillageProfile.js
vendored
12
dist/quickbar/extendedVillageProfile.js
vendored
File diff suppressed because one or more lines are too long
4
dist/quickbar/latestEnnoblements.js
vendored
4
dist/quickbar/latestEnnoblements.js
vendored
File diff suppressed because one or more lines are too long
2
dist/quickbar/mapCoordsPicker.js
vendored
2
dist/quickbar/mapCoordsPicker.js
vendored
File diff suppressed because one or more lines are too long
2
dist/quickbar/warStatsGenerator.js
vendored
2
dist/quickbar/warStatsGenerator.js
vendored
File diff suppressed because one or more lines are too long
4
dist/warStatsGenerator.js
vendored
4
dist/warStatsGenerator.js
vendored
|
@ -338,7 +338,7 @@ var _getCurrentServer = _interopRequireDefault(require("./utils/getCurrentServer
|
|||
|
||||
var _getServerVersionCode = _interopRequireDefault(require("./utils/getServerVersionCode"));
|
||||
|
||||
var _twhelp = require("./utils/twhelp");
|
||||
var twhelputils = _interopRequireWildcard(require("./utils/twhelp"));
|
||||
|
||||
var _showPopup = _interopRequireWildcard(require("./utils/showPopup"));
|
||||
|
||||
|
@ -472,7 +472,7 @@ const handleFormSubmit = async e => {
|
|||
};
|
||||
|
||||
const showWarStatsForm = e => {
|
||||
const html = "\n <form>\n <h1 style=\"margin-bottom: 0px; text-align: center;\"><a href=\"".concat((0, _twhelp.buildURLToServerPage)((0, _getServerVersionCode.default)(SERVER), SERVER), "\">TWHelp</a></h1>\n <h3 style=\"margin-bottom: 10px; margin-top: 0;\">").concat(translations.devNote, "</h3>\n <div id=\"").concat(RESULT_CONTAINER_ID, "\">\n </div>\n <div style=\"margin-bottom: 10px;\">\n <div id=\"").concat(FROM_INPUT_ID, "\">\n <label>").concat(translations.from, ": </label>\n <input type=\"date\" required />\n <input type=\"time\" required />\n </div>\n <div id=\"").concat(TO_INPUT_ID, "\">\n <label>").concat(translations.to, ": </label>\n <input type=\"date\" required />\n <input type=\"time\" required />\n </div>\n </div>\n <div style=\"display: flex; justify-content: space-between; margin-bottom: 10px; min-width: 800px;\">\n <div>\n <h3>").concat(translations.sideOne, "</h3>\n <div id=\"").concat(SIDE_ONE_INPUT_CONTAINER_ID, "\">\n </div>\n <button id=\"").concat(SIDE_ONE_BUTTON_ID, "\" class=\"btn\" type=\"button\">").concat(translations.addTribe, "</button>\n </div>\n <div style=\"margin: 0 5px;\"></div>\n <div>\n <h3>").concat(translations.sideTwo, "</h3>\n <div id=\"").concat(SIDE_TWO_INPUT_CONTAINER_ID, "\">\n </div>\n <button id=\"").concat(SIDE_TWO_BUTTON_ID, "\" class=\"btn\" type=\"button\">").concat(translations.addTribe, "</button>\n </div>\n </div>\n <div style=\"text-align: center;\">\n <button class=\"btn\" type=\"submit\">").concat(translations.generateWarStats, "</button>\n </div>\n </form>\n ");
|
||||
const html = "\n <form>\n <h1 style=\"margin-bottom: 0px; text-align: center;\"><a href=\"".concat(twhelputils.buildURLToServerPage((0, _getServerVersionCode.default)(SERVER), SERVER), "\">TWHelp</a></h1>\n <h3 style=\"margin-bottom: 10px; margin-top: 0;\">").concat(translations.devNote, "</h3>\n <div id=\"").concat(RESULT_CONTAINER_ID, "\">\n </div>\n <div style=\"margin-bottom: 10px;\">\n <div id=\"").concat(FROM_INPUT_ID, "\">\n <label>").concat(translations.from, ": </label>\n <input type=\"date\" required />\n <input type=\"time\" required />\n </div>\n <div id=\"").concat(TO_INPUT_ID, "\">\n <label>").concat(translations.to, ": </label>\n <input type=\"date\" required />\n <input type=\"time\" required />\n </div>\n </div>\n <div style=\"display: flex; justify-content: space-between; margin-bottom: 10px; min-width: 800px;\">\n <div>\n <h3>").concat(translations.sideOne, "</h3>\n <div id=\"").concat(SIDE_ONE_INPUT_CONTAINER_ID, "\">\n </div>\n <button id=\"").concat(SIDE_ONE_BUTTON_ID, "\" class=\"btn\" type=\"button\">").concat(translations.addTribe, "</button>\n </div>\n <div style=\"margin: 0 5px;\"></div>\n <div>\n <h3>").concat(translations.sideTwo, "</h3>\n <div id=\"").concat(SIDE_TWO_INPUT_CONTAINER_ID, "\">\n </div>\n <button id=\"").concat(SIDE_TWO_BUTTON_ID, "\" class=\"btn\" type=\"button\">").concat(translations.addTribe, "</button>\n </div>\n </div>\n <div style=\"text-align: center;\">\n <button class=\"btn\" type=\"submit\">").concat(translations.generateWarStats, "</button>\n </div>\n </form>\n ");
|
||||
(0, _showPopup.default)({
|
||||
title: translations.warStatsGenerator,
|
||||
id: 'warStats',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import requestCreator from './libs/requestCreator';
|
||||
import getTranslations from './i18n/bonusBarbarianVillageFinder';
|
||||
import getCurrentServer from './utils/getCurrentServer';
|
||||
import { formatVillageURL, formatVillageName } from './utils/tribalwars';
|
||||
import * as twutils from './utils/tribalwars';
|
||||
import { calcDistanceBetweenTwoPoints } from './utils/math';
|
||||
|
||||
// ==UserScript==
|
||||
|
@ -116,8 +116,12 @@ const buildTableBodyHTML = (villages) => {
|
|||
.map(
|
||||
(village) => `<tr>
|
||||
<td>
|
||||
<a href="${formatVillageURL(village.id)}">
|
||||
${formatVillageName(village.name, village.x, village.y)}
|
||||
<a href="${twutils.buildVillageURL(village.id)}">
|
||||
${twutils.buildVillageName(
|
||||
village.name,
|
||||
village.x,
|
||||
village.y
|
||||
)}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -5,22 +5,19 @@ import {
|
|||
} from '../utils/pagination';
|
||||
import showPopup from '../utils/showPopup';
|
||||
import formatDate from '../utils/formatDate';
|
||||
import {
|
||||
formatTribeURL,
|
||||
formatPlayerURL as formatPlayerURLTribalWars,
|
||||
formatVillageName,
|
||||
formatVillageURL,
|
||||
} from '../utils/tribalwars';
|
||||
import * as twutils from '../utils/tribalwars';
|
||||
|
||||
const PAGINATION_CONTAINER_ID = 'ennoblementsPagination';
|
||||
const translations = getTranslations();
|
||||
|
||||
const getPlayerTd = (player, tribe) => {
|
||||
if (player) {
|
||||
return `<td><a href="${formatPlayerURLTribalWars(player.id)}">${
|
||||
return `<td><a href="${twutils.buildPlayerURL(player.id)}">${
|
||||
player.name
|
||||
} (${
|
||||
tribe ? `<a href="${formatTribeURL(tribe.id)}">${tribe.tag}</a>` : '-'
|
||||
tribe
|
||||
? `<a href="${twutils.buildTribeURL(tribe.id)}">${tribe.tag}</a>`
|
||||
: '-'
|
||||
})</a></td>`;
|
||||
}
|
||||
return '<td>-</td>';
|
||||
|
@ -61,9 +58,9 @@ export default (
|
|||
let rowHTML =
|
||||
'<tr>' + `<td>${formatDate(ennoblement.ennobledAt)}</td>`;
|
||||
if (ennoblement.village) {
|
||||
rowHTML += `<td><a href="${formatVillageURL(
|
||||
rowHTML += `<td><a href="${twutils.buildVillageURL(
|
||||
ennoblement.village.id
|
||||
)}">${formatVillageName(
|
||||
)}">${twutils.buildVillageName(
|
||||
ennoblement.village.name,
|
||||
ennoblement.village.x,
|
||||
ennoblement.village.y
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
getContainerStyles,
|
||||
} from '../utils/pagination';
|
||||
import formatDate from '../utils/formatDate';
|
||||
import { formatTribeURL } from '../utils/tribalwars';
|
||||
import * as twutils from '../utils/tribalwars';
|
||||
|
||||
const PAGINATION_CONTAINER_ID = 'historyPagination';
|
||||
const translations = getTranslations();
|
||||
|
@ -73,9 +73,9 @@ export default (
|
|||
day: '2-digit',
|
||||
})}</td>`;
|
||||
if (!tribe && history.tribe) {
|
||||
rowHTML += `<td><a href="${formatTribeURL(history.tribe.id)}">${
|
||||
history.tribe.tag
|
||||
}</a></td>`;
|
||||
rowHTML += `<td><a href="${twutils.buildTribeURL(
|
||||
history.tribe.id
|
||||
)}">${history.tribe.tag}</a></td>`;
|
||||
} else if (!tribe) {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import format from 'date-fns/format';
|
|||
import requestCreator from './libs/requestCreator';
|
||||
import getTranslations from './i18n/dailyAchievments';
|
||||
import { setItem, getItem } from './utils/localStorage';
|
||||
import { formatPlayerURL } from './utils/tribalwars';
|
||||
import * as twutils from './utils/tribalwars';
|
||||
import getCurrentServer from './utils/getCurrentServer';
|
||||
import getServerVersionCode from './utils/getServerVersionCode';
|
||||
import { inTZ } from './utils/date';
|
||||
|
@ -134,7 +134,7 @@ const render = ({
|
|||
${dailyPlayerStatsOrderedByScoreAtt.items
|
||||
.map(
|
||||
(item, index) =>
|
||||
`<span>${index + 1}. <a href="${formatPlayerURL(
|
||||
`<span>${index + 1}. <a href="${twutils.buildPlayerURL(
|
||||
item.player.id
|
||||
)}">${
|
||||
item.player.name
|
||||
|
@ -148,7 +148,7 @@ const render = ({
|
|||
${dailyPlayerStatsOrderedByScoreDef.items
|
||||
.map(
|
||||
(item, index) =>
|
||||
`<span>${index + 1}. <a href="${formatPlayerURL(
|
||||
`<span>${index + 1}. <a href="${twutils.buildPlayerURL(
|
||||
item.player.id
|
||||
)}">${
|
||||
item.player.name
|
||||
|
@ -162,7 +162,7 @@ const render = ({
|
|||
${dailyPlayerStatsOrderedByScoreSup.items
|
||||
.map(
|
||||
(item, index) =>
|
||||
`<span>${index + 1}. <a href="${formatPlayerURL(
|
||||
`<span>${index + 1}. <a href="${twutils.buildPlayerURL(
|
||||
item.player.id
|
||||
)}">${
|
||||
item.player.name
|
||||
|
@ -176,7 +176,7 @@ const render = ({
|
|||
${dailyPlayerStatsOrderedByVillages.items
|
||||
.map(
|
||||
(item, index) =>
|
||||
`<span>${index + 1}. <a href="${formatPlayerURL(
|
||||
`<span>${index + 1}. <a href="${twutils.buildPlayerURL(
|
||||
item.player.id
|
||||
)}">${
|
||||
item.player.name
|
||||
|
|
|
@ -7,14 +7,14 @@ import { calcDistanceBetweenTwoPoints } from './utils/math';
|
|||
import buildUnitImgURL from './utils/buildUnitImgURL';
|
||||
import { setItem, getItem } from './utils/localStorage';
|
||||
import { calcAttackDuration } from './utils/tribalwars';
|
||||
import countLoyalty from './utils/countLoyalty';
|
||||
import calcLoyalty from './utils/calcLoyalty';
|
||||
|
||||
// ==UserScript==
|
||||
// @name Extended map popup
|
||||
// @namespace https://github.com/tribalwarshelp/scripts
|
||||
// @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
|
||||
// @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
|
||||
// @version 0.6.4
|
||||
// @version 0.6.5
|
||||
// @description Extended map popup
|
||||
// @author Kichiyaki https://dawid-wysokinski.pl/
|
||||
// @match *://*/game.php*screen=map*
|
||||
|
@ -226,11 +226,7 @@ const renderAdditionalInfo = (id, data, { config, unitConfig }) => {
|
|||
${units
|
||||
.map((unit, index) => {
|
||||
return buildUnitArrivalInfo(
|
||||
calcAttackDuration(
|
||||
distance,
|
||||
config.unitSpeed * config.speed,
|
||||
unit.speed
|
||||
),
|
||||
calcAttackDuration(distance, unit.speed),
|
||||
index
|
||||
);
|
||||
})
|
||||
|
@ -273,7 +269,7 @@ const renderAdditionalInfo = (id, data, { config, unitConfig }) => {
|
|||
<td>
|
||||
${
|
||||
ennoblement
|
||||
? countLoyalty(new Date(ennoblement.ennobledAt), config.speed)
|
||||
? calcLoyalty(new Date(ennoblement.ennobledAt), config.speed)
|
||||
: 100
|
||||
}
|
||||
</td>
|
||||
|
|
|
@ -16,7 +16,7 @@ import getIDFromURL from './utils/getIDFromURL';
|
|||
import getCurrentServer from './utils/getCurrentServer';
|
||||
import getServerVersionCode from './utils/getServerVersionCode';
|
||||
import formatDate from './utils/formatDate';
|
||||
import { formatTribeURL } from './utils/tribalwars';
|
||||
import * as twutils from './utils/tribalwars';
|
||||
import * as twhelputils from './utils/twhelp';
|
||||
import { setItem, getItem } from './utils/localStorage';
|
||||
|
||||
|
@ -530,14 +530,14 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
let rowHTML =
|
||||
'<tr>' + `<td>${formatDate(tribeChange.createdAt)}</td>`;
|
||||
if (tribeChange.newTribe) {
|
||||
rowHTML += `<td><a href="${formatTribeURL(
|
||||
rowHTML += `<td><a href="${twutils.buildTribeURL(
|
||||
tribeChange.newTribe.id
|
||||
)}">${tribeChange.newTribe.tag}</a></td>`;
|
||||
} else {
|
||||
rowHTML += '<td>-</td>';
|
||||
}
|
||||
if (tribeChange.oldTribe) {
|
||||
rowHTML += `<td><a href="${formatTribeURL(
|
||||
rowHTML += `<td><a href="${twutils.buildTribeURL(
|
||||
tribeChange.oldTribe.id
|
||||
)}">${tribeChange.oldTribe.tag}</a></td>`;
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import isURL from 'validator/lib/isURL';
|
||||
import differenceInDays from 'date-fns/differenceInDays';
|
||||
import getTranslations from './i18n/extendedTribeProfile';
|
||||
import requestCreator from './libs/requestCreator';
|
||||
|
@ -17,9 +16,9 @@ import getCurrentServer from './utils/getCurrentServer';
|
|||
import { setItem, getItem } from './utils/localStorage';
|
||||
import formatDate from './utils/formatDate';
|
||||
import getServerVersionCode from './utils/getServerVersionCode';
|
||||
import { formatPlayerURL } from './utils/twstats';
|
||||
import { buildPlayerURL, buildTribeURL } from './utils/twhelp';
|
||||
import { formatPlayerURL as formatPlayerURLTribalWars } from './utils/tribalwars';
|
||||
import * as twstatsutils from './utils/twstats';
|
||||
import * as twhelputils from './utils/twhelp';
|
||||
import * as twutils from './utils/tribalwars';
|
||||
|
||||
// ==UserScript==
|
||||
// @name Extended tribe profile
|
||||
|
@ -304,8 +303,14 @@ const extendMembersData = (players) => {
|
|||
[player.scoreTotal, player.rankTotal],
|
||||
player.dailyGrowth,
|
||||
[
|
||||
{ link: buildPlayerURL(VERSION, SERVER, player.id), label: 'TWHelp' },
|
||||
{ link: formatPlayerURL(SERVER, player.id), label: 'TWStats' },
|
||||
{
|
||||
link: twhelputils.buildPlayerURL(VERSION, SERVER, player.id),
|
||||
label: 'TWHelp',
|
||||
},
|
||||
{
|
||||
link: twstatsutils.buildPlayerURL(SERVER, player.id),
|
||||
label: 'TWStats',
|
||||
},
|
||||
],
|
||||
].forEach((data, index) => {
|
||||
let td = tr.children[5 + index];
|
||||
|
@ -514,9 +519,7 @@ const buildMembersGrowthTBody = (stats) => {
|
|||
<td>
|
||||
${
|
||||
player
|
||||
? `<a href="${formatPlayerURLTribalWars(id)}">${
|
||||
player.name
|
||||
}</a>`
|
||||
? `<a href="${twutils.buildPlayerURL(id)}">${player.name}</a>`
|
||||
: '-'
|
||||
}
|
||||
</td>
|
||||
|
@ -641,7 +644,7 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
let rowHTML =
|
||||
'<tr>' + `<td>${formatDate(tribeChange.createdAt)}</td>`;
|
||||
if (tribeChange.player) {
|
||||
rowHTML += `<td><a href="${formatPlayerURLTribalWars(
|
||||
rowHTML += `<td><a href="${twutils.buildPlayerURL(
|
||||
tribeChange.player.id
|
||||
)}">${tribeChange.player.name}</a></td>`;
|
||||
} else {
|
||||
|
@ -851,7 +854,7 @@ const wrapAction = (action) => {
|
|||
|
||||
const renderActions = () => {
|
||||
const linkToTWHelp = document.createElement('a');
|
||||
linkToTWHelp.href = buildTribeURL(VERSION, SERVER, TRIBE_ID);
|
||||
linkToTWHelp.href = twhelputils.buildTribeURL(VERSION, SERVER, TRIBE_ID);
|
||||
linkToTWHelp.innerHTML = translations.action.linkToTWHelp;
|
||||
actionContainer.appendChild(wrapAction(linkToTWHelp));
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ import buildUnitImgURL from './utils/buildUnitImgURL';
|
|||
import formatDate from './utils/formatDate';
|
||||
import wait from './utils/wait';
|
||||
import { setItem, getItem } from './utils/localStorage';
|
||||
import countLoyalty from './utils/countLoyalty';
|
||||
import calcLoyalty from './utils/calcLoyalty';
|
||||
import getServerVersionCode from './utils/getServerVersionCode';
|
||||
import { buildVillageURL } from './utils/twhelp';
|
||||
import * as twhelputils from './utils/twhelp';
|
||||
import showEnnoblementsPopup from './common/showEnnoblementsPopup';
|
||||
|
||||
// ==UserScript==
|
||||
|
@ -339,7 +339,7 @@ const wrapAction = (action) => {
|
|||
|
||||
const renderActions = () => {
|
||||
const linkToTWHelp = document.createElement('a');
|
||||
linkToTWHelp.href = buildVillageURL(
|
||||
linkToTWHelp.href = twhelputils.buildVillageURL(
|
||||
getServerVersionCode(SERVER),
|
||||
SERVER,
|
||||
VILLAGE_ID
|
||||
|
@ -406,7 +406,7 @@ const renderAdditionalInfo = ({ config, ennoblements } = {}) => {
|
|||
id: 'loyalty',
|
||||
title: `${translations.possibleLoyalty}:`,
|
||||
data: firstEnnoblement
|
||||
? countLoyalty(new Date(firstEnnoblement.ennobledAt), config.speed)
|
||||
? calcLoyalty(new Date(firstEnnoblement.ennobledAt), config.speed)
|
||||
: 100,
|
||||
});
|
||||
renderTr({
|
||||
|
|
|
@ -2,14 +2,9 @@ import requestCreator from './libs/requestCreator';
|
|||
import showPopup from './utils/showPopup';
|
||||
import getCurrentServer from './utils/getCurrentServer';
|
||||
import formatDate from './utils/formatDate';
|
||||
import {
|
||||
formatTribeURL,
|
||||
formatPlayerURL,
|
||||
formatVillageURL,
|
||||
formatVillageName,
|
||||
} from './utils/tribalwars';
|
||||
import * as twutils from './utils/tribalwars';
|
||||
import { setItem, getItem } from './utils/localStorage';
|
||||
import { buildURLToServerPage } from './utils/twhelp';
|
||||
import * as twhelputils from './utils/twhelp';
|
||||
import getServerVersionCode from './utils/getServerVersionCode';
|
||||
import loadTranslations from './i18n/latestEnnoblements';
|
||||
|
||||
|
@ -150,7 +145,7 @@ const handleFilterFormSubmit = (e, ennoblements) => {
|
|||
};
|
||||
document.querySelector(
|
||||
`#${TABLE_ID} tbody`
|
||||
).innerHTML = formatEnnoblementRows(
|
||||
).innerHTML = buildEnnoblementsRows(
|
||||
filterEnnoblements(ennoblements, filters)
|
||||
).join('');
|
||||
cacheFilters(filters);
|
||||
|
@ -164,11 +159,11 @@ const addEventListeners = (ennoblements = []) => {
|
|||
});
|
||||
};
|
||||
|
||||
const formatPlayerHTML = (player) => {
|
||||
const getPlayerHTML = (player) => {
|
||||
return player && player.name
|
||||
? `<a href="${formatPlayerURL(player.id)}">${player.name}</a> (${
|
||||
? `<a href="${twutils.buildPlayerURL(player.id)}">${player.name}</a> (${
|
||||
player.tribe && player.tribe.tag
|
||||
? `<a href="${formatTribeURL(player.tribe.id)}">${
|
||||
? `<a href="${twutils.buildTribeURL(player.tribe.id)}">${
|
||||
player.tribe.tag
|
||||
}</a>`
|
||||
: '-'
|
||||
|
@ -176,20 +171,18 @@ const formatPlayerHTML = (player) => {
|
|||
: '-';
|
||||
};
|
||||
|
||||
const formatVillageHTML = (village) => {
|
||||
return `<a href="${formatVillageURL(village.id)}">${formatVillageName(
|
||||
village.name,
|
||||
village.x,
|
||||
village.y
|
||||
)}</a>`;
|
||||
const getVillageHTML = (village) => {
|
||||
return `<a href="${twutils.buildVillageURL(
|
||||
village.id
|
||||
)}">${twutils.buildVillageName(village.name, village.x, village.y)}</a>`;
|
||||
};
|
||||
|
||||
const formatEnnoblementRows = (ennoblements) => {
|
||||
const buildEnnoblementsRows = (ennoblements) => {
|
||||
return ennoblements.reverse().map((ennoblement) => {
|
||||
return `<tr>
|
||||
<td>${formatVillageHTML(ennoblement.village)}</td>
|
||||
<td>${formatPlayerHTML(ennoblement.newOwner)}</td>
|
||||
<td>${formatPlayerHTML(ennoblement.oldOwner)}</td>
|
||||
<td>${getVillageHTML(ennoblement.village)}</td>
|
||||
<td>${getPlayerHTML(ennoblement.newOwner)}</td>
|
||||
<td>${getPlayerHTML(ennoblement.oldOwner)}</td>
|
||||
<td>${formatDate(ennoblement.ennobledAt)}</td>
|
||||
</tr>`;
|
||||
});
|
||||
|
@ -202,7 +195,7 @@ const renderLatestEnnoblements = (ennoblements = [], filters = {}) => {
|
|||
};
|
||||
const html = `
|
||||
<form style="margin-bottom: 15px" id="${FILTER_FORM_ID}">
|
||||
<h1 style="margin-bottom: 0px; text-align: center;"><a href="${buildURLToServerPage(
|
||||
<h1 style="margin-bottom: 0px; text-align: center;"><a href="${twhelputils.buildURLToServerPage(
|
||||
getServerVersionCode(SERVER),
|
||||
SERVER
|
||||
)}">TWHelp</a></h1>
|
||||
|
@ -236,7 +229,7 @@ const renderLatestEnnoblements = (ennoblements = [], filters = {}) => {
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${formatEnnoblementRows(
|
||||
${buildEnnoblementsRows(
|
||||
filterEnnoblements(ennoblements, prepared)
|
||||
).join('')}
|
||||
</tbody>
|
||||
|
|
|
@ -37,9 +37,10 @@ const saveConfig = () => {
|
|||
};
|
||||
|
||||
const villageIDByCoords = (x, y) => {
|
||||
const village = TWMap.villages[parseInt(`${x}${y}`)];
|
||||
const xy = parseInt(`${x}${y}`, 10);
|
||||
const village = TWMap.villages[xy];
|
||||
if (village) {
|
||||
return TWMap.villages[parseInt(`${x}${y}`)].id;
|
||||
return TWMap.villages[xy].id;
|
||||
}
|
||||
return NaN;
|
||||
};
|
||||
|
@ -178,7 +179,7 @@ const renderGroups = () => {
|
|||
renderForm(formsContainer);
|
||||
};
|
||||
|
||||
const exportVillagesHandler = () => {
|
||||
const handleExportVillages = () => {
|
||||
const groups = [];
|
||||
|
||||
for (let name in config.groups) {
|
||||
|
@ -201,7 +202,7 @@ const exportVillagesHandler = () => {
|
|||
const renderActions = () => {
|
||||
const exportVillages = document.createElement('button');
|
||||
exportVillages.innerHTML = translations.export;
|
||||
exportVillages.addEventListener('click', exportVillagesHandler);
|
||||
exportVillages.addEventListener('click', handleExportVillages);
|
||||
actionsContainer.appendChild(exportVillages);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import differenceInMinutes from 'date-fns/differenceInMinutes';
|
||||
|
||||
export default (ennobledAt, speed) => {
|
||||
const calcLoyalty = (ennobledAt, speed) => {
|
||||
let loyalty =
|
||||
25 + Math.abs(differenceInMinutes(ennobledAt, new Date())) * (speed / 60);
|
||||
if (loyalty > 100) {
|
||||
|
@ -8,3 +8,5 @@ export default (ennobledAt, speed) => {
|
|||
}
|
||||
return Math.floor(loyalty);
|
||||
};
|
||||
|
||||
export default calcLoyalty;
|
|
@ -1,4 +1,4 @@
|
|||
export const formatTribeURL = (id) => {
|
||||
export const buildTribeURL = (id) => {
|
||||
return (
|
||||
window.location.origin +
|
||||
TribalWars.buildURL('', {
|
||||
|
@ -8,7 +8,7 @@ export const formatTribeURL = (id) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const formatPlayerURL = (id) => {
|
||||
export const buildPlayerURL = (id) => {
|
||||
return (
|
||||
window.location.origin +
|
||||
TribalWars.buildURL('', {
|
||||
|
@ -18,7 +18,7 @@ export const formatPlayerURL = (id) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const formatVillageURL = (id) => {
|
||||
export const buildVillageURL = (id) => {
|
||||
return (
|
||||
window.location.origin +
|
||||
TribalWars.buildURL('', {
|
||||
|
@ -28,13 +28,13 @@ export const formatVillageURL = (id) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const formatVillageName = (n = '', x = 500, y = 500) => {
|
||||
export const buildVillageName = (n = '', x = 500, y = 500) => {
|
||||
const continent = 'K' + String(y)[0] + String(x)[0];
|
||||
return `${n} (${x}|${y}) ${continent}`;
|
||||
};
|
||||
|
||||
export const calcAttackDuration = (distance, unitSpeed, baseSpeed) => {
|
||||
return Math.round((distance * baseSpeed) / unitSpeed);
|
||||
export const calcAttackDuration = (distance, baseSpeed) => {
|
||||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
export const buildImgURL = (img) => {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export const formatPlayerURL = (server = '', id = 0) => {
|
||||
export const buildPlayerURL = (server = '', id = 0) => {
|
||||
return `http://www.twstats.com/in/${server}/player/${id}`;
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import requestCreator from './libs/requestCreator';
|
|||
import getTranslations from './i18n/warStatsGenerator';
|
||||
import getServer from './utils/getCurrentServer';
|
||||
import getServerVersionCode from './utils/getServerVersionCode';
|
||||
import { buildURLToServerPage } from './utils/twhelp';
|
||||
import * as twhelputils from './utils/twhelp';
|
||||
import showPopup, { POPUP_SELECTOR } from './utils/showPopup';
|
||||
|
||||
// ==UserScript==
|
||||
|
@ -182,7 +182,7 @@ const handleFormSubmit = async (e) => {
|
|||
const showWarStatsForm = (e) => {
|
||||
const html = `
|
||||
<form>
|
||||
<h1 style="margin-bottom: 0px; text-align: center;"><a href="${buildURLToServerPage(
|
||||
<h1 style="margin-bottom: 0px; text-align: center;"><a href="${twhelputils.buildURLToServerPage(
|
||||
getServerVersionCode(SERVER),
|
||||
SERVER
|
||||
)}">TWHelp</a></h1>
|
||||
|
|
Reference in New Issue
Block a user