MediaWiki:Gadget-idle-data.js

From Idle Clans wiki
Revision as of 13:43, 28 May 2024 by Uraxys (talk | contribs) (ES5)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
;(function($, mw, idleClans) {
var data = {
	/**
	 * Automatically generated experience table for levels 1 to 120, shouldn't
	 * be manually modified.
	 */
	EXP_TABLE: [ 0 /* Level 1 */,
			      75,      150,      226,      302,      378,      455,      607,      759,      911,     1063,
			    1216,     1369,     1522,     1826,     2130,     2434,     2738,     3042,     3347,     3652,
			    4257,     4863,     5469,     6075,     6681,     7287,     7894,     9101,    10308,    11516,
			   12724,    13932,    15140,    16348,    18757,    21166,    23575,    25985,    28395,    30805,
			   33215,    38025,    42836,    47647,    52458,    57270,    62082,    66894,    76506,    86118,
			   95731,   105344,   114957,   124571,   134185,   153399,   172613,   191827,   211042,   230257,
			  249472,   268688,   307104,   345520,   383936,   422352,   460769,   499186,   537603,   614421,
			  691239,   768057,   844875,   921693,   998512,  1075331,  1228950,  1382570,  1536190,  1689810,
			 1843430,  1997050,  2150671,  2457892,  2765113,  3072335,  3379557,  3686779,  3994001,  4301223,
			 4915646,  5530069,  6144492,  6758916,  7373340,  7987764,  8602188,  9831012, 11059837, 12288662,
			13517487, 14746313, 15975139, 17203965, 19661591, 22119217, 24576844, 27034471, 29492098, 31949726,
			34407354, 39322582, 44237810, 49153038, 54068267, 58983496, 63898725, 68813955, 78644385, 88474815
	],

	/**
	 * Get the experience required for a specific level.
	 *
	 * @param   {number} level
	 *          The level to get the experience for, will be clamped to the
	 *          range of 1 to 120.
	 *
	 * @returns {number}
	 *          The experience required for the specified level.
	 */
	getExperienceForLevel: function(level) {
		level = Math.max(1, Math.min(120, level));
		return this.EXP_TABLE[level - 1];
	},

	/**
	 * Get the level for a specific amount of experience.
	 *
	 * @param   {number} xp
	 *          The amount of experience to get the level for, will be clamped
	 *          to the range of 0 to the maximum experience for level 120.
	 *
	 * @returns {number}
	 *          The level for the specified amount of experience.
	 */
	getLevelForExperience: function(xp) {
		if (xp <= 0) return 1;
		if (xp >= this.EXP_TABLE[this.EXP_TABLE.length - 1]) return 120;

		for (var i = this.EXP_TABLE.length - 1; i >= 0; i--) {
			if (this.EXP_TABLE[i] <= xp) {
				return i + 1;
			}
		}
	},

	/*
	 * Boosts
	 */

	boosts: {
		/*
		 * Values are in percentages, so a value of 0.05 means a 5% boost, 0.5
		 * is a 50% boost, etc.
		 */

		experience: {
			/**
			 * Clan house boost for each tier, starting at tier 0 (no house) and
			 * ending at tier 6 (maxed clan house).
			 */
			CLAN_HOUSE: [0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3],

			/**
			 * The personal house boost for each tier, starting at tier 0 (no house)
			 * and ending at tier 5 (maxed house).
			 */
			PERSONAL_HOUSE: [0, 0.05, 0.1, 0.15, 0.2, 0.25],

			/**
			 * The boost gained from the daily ad boost.
			 */
			DAILY_AD: 0.3,
		},

		speed: {
			/**
			 * The skill item boost for each tier, starting at tier 0 (no item)
			 * and ending at tier 7 (godlike item).
			 */
			SKILL_ITEM: [0, 0.04, 0.06, 0.08, 0.1, 0.12, 0.15, 0.2],

			/**
			 * The skill cape boost for each tier, starting at tier 0 (no cape) and
			 * ending at tier 4 (maxed skill cape).
			 */
			SKILL_CAPE: [0, 0.05, 0.1, 0.15, 0.2],

			/**
			 * The enchantment speed boost for each scroll tier, starting at tier 0
			 * (common) and ending at tier 2 (exceptional).
			 */
			ENCHANTMENTS: [0.015, 0.03, 0.05],

			/**
			 * Get the speed boost for a specific enchantment scroll tier.
			 *
			 * @param   {number} tier
			 *          The tier of the enchantment scroll.
			 * @param   {boolean} ancientKnowledge
			 *          If we're using the ancient knowledge boost.
			 *
			 * @returns {number}
			 *          The speed boost for the specified enchantment scroll tier,
			 *          or NaN if the tier is out of range.
			 */
			getEnchantmentBoost: function(tier, ancientKnowledge) {
				if (tier < 0 || tier > 2) return NaN;

				var boost = this.ENCHANTMENTS[tier];
				if (ancientKnowledge)
					boost *= this.other.POTION_OF_ANCIENT_KNOWLEDGE;

				return boost;
			},
		},

		other: {
			/**
			 * The boost Potion of Ancient Knowledge gives to enchantment scrolls.
			 */
			POTION_OF_ANCIENT_KNOWLEDGE: 1.5,

			/**
			 * How long the daily ad boost lasts in hours.
			 */
			DAILY_AD_HOURS: 2,

			/**
			 * How many times you can claim the daily ad boost per day.
			 */
			DAILY_AD_AMOUNT: 4,
		}

	},

	/*
	 * Skills
	 */

	tasks: {
		COOKING: [
			{ name: "Piranha",      levelReq: 1,    exp: 10,    time: 3     },
			{ name: "Perch",        levelReq: 10,   exp: 16,    time: 3.5   },
			{ name: "Mackerel",     levelReq: 15,   exp: 20,    time: 4     },
			{ name: "Cod",          levelReq: 20,   exp: 26,    time: 4.5   },
			{ name: "Trout",        levelReq: 25,   exp: 33,    time: 5     },
			{ name: "Salmon",       levelReq: 30,   exp: 40,    time: 6     },
			{ name: "Carp",         levelReq: 40,   exp: 56,    time: 7.5   },
			{ name: "Zander",       levelReq: 50,   exp: 80,    time: 10    },
			{ name: "Pufferfish",   levelReq: 60,   exp: 105,   time: 12.5  },
			{ name: "Anglerfish",   levelReq: 70,   exp: 155,   time: 17.5  },
			{ name: "Tuna",         levelReq: 85,   exp: 331.5, time: 26.2  },

			{ name: "Meat",         levelReq: 10,   exp: 30,    time: 3     },
			{ name: "Giant Meat",   levelReq: 30,   exp: 60,    time: 4     },
			{ name: "Quality Meat", levelReq: 60,   exp: 120,   time: 6     },
			{ name: "Superior Meat",levelReq: 90,   exp: 250,   time: 10    },

			{ name: "Potato Soup",  levelReq: 20,   exp: 40,    time: 2.5   },
			{ name: "Meat Burger",  levelReq: 20,   exp: 75,    time: 4     },
			{ name: "Cod Soup",     levelReq: 40,   exp: 150,   time: 5.5   },
			{ name: "Blueberry Pie",levelReq: 50,   exp: 200,   time: 6     },
			{ name: "Salmon Salad", levelReq: 60,   exp: 250,   time: 7     },
			{ name: "Porcini Soup", levelReq: 70,   exp: 400,   time: 8     },
			{ name: "Beef Stew",    levelReq: 80,   exp: 550,   time: 9     },
			{ name: "Power Pizza",  levelReq: 95,   exp: 750,   time: 10    }
		],

		/**
		 * Get the task in a given skill by either the name or the index of the
		 * task.
		 *
		 * @param   {string} skill
		 *          The skill to get the task for.
		 * @param   {string|number} task
		 *          The name of the task to get.
		 *
		 * @returns {{name: string, levelReq: number, exp: number, time: number}|null}
		 *          The task with the specified name, or null if no task was found.
		 */
		getTask: function(skill, task) {
			var tasks = this[skill.toUpperCase()];
			if (!tasks) return null;

			// Check if the task is a number
			if (typeof task === "number") {
				if (task < 0 || task >= tasks.length) return null;
				return tasks[task];
			}

			// It must be a string.
			for (var i = 0; i < tasks.length; i++) {
				if (tasks[i].name.toLowerCase() === task.toLowerCase())
					return tasks[i];
			}

			return null;
		}
	}
};

// Add the data object to the idleClans object.
idleClans.data = data;

})(window.jQuery, window.mw, window.idleClans = window.idleClans || {});