Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getItemName(itemID) {
- var myUrl = "https://api.guildwars2.com/v2/items/" + escape(itemID);
- var jsonData = UrlFetchApp.fetch(myUrl);
- var jsonString = jsonData.getContentText();
- return jsonObject;
- }
- function getItemBuyValue(itemID, upd) {
- var myUrl = "https://api.guildwars2.com/v2/commerce/listings/" + escape(itemID);
- var jsonData = UrlFetchApp.fetch(myUrl);
- var jsonString = jsonData.getContentText();
- var jsonObject = JSON.parse(jsonString).result;
- var adjustedValue = (jsonObject.max_offer_unit_price / 100);
- Utilities.sleep(1000);
- return adjustedValue;
- }
- function GetItemSellValue(itemID) {
- var myUrl = "https://api.guildwars2.com/v2/commerce/listings/" + escape(itemID);
- var jsonData = UrlFetchApp.fetch(myUrl);
- var jsonString = jsonData.getContentText();
- var jsonObject = JSON.parse(jsonString).result;
- var adjustedValue = (jsonObject.min_sale_unit_price / 100 );
- Utilities.sleep(1000);
- return adjustedValue;
- }
- function SalePriceChangedLastHour(itemID) {
- var myUrl = "https://api.guildwars2.com/v2/commerce/listings/" + escape(itemID);
- var jsonData = UrlFetchApp.fetch(myUrl);
- var jsonString = jsonData.getContentText();
- var jsonObject = JSON.parse(jsonString).result;
- var adjustedValue = (jsonObject.sale_price_change_last_hour / 100);
- Utilities.sleep(1000);
- return adjustedValue;
- }
- function OfferPriceChangedLastHour(itemID) {
- var myUrl = "https://api.guildwars2.com/v2/commerce/listings/" + escape(itemID);
- var jsonData = UrlFetchApp.fetch(myUrl);
- var jsonString = jsonData.getContentText();
- var jsonObject = JSON.parse(jsonString).result;
- var adjustedValue = (jsonObject.offer_price_change_last_hour / 100);
- Utilities.sleep(1000);
- return adjustedValue;
- function formatAsGold(sellValue) {
- var n = sellValue;
- var s = "";
- if (sellValue < 0) {
- s = "-";
- n = Math.abs(n);
- }
- var gold = Math.floor(((n / 10000) % 100));
- var silver = Math.floor(((n / 100) % 100));
- var copper = Math.floor((n % 100)) + "c";
- if (gold == 0) {
- gold = "";
- } else {
- gold += "g ";
- }
- if (silver == 0) {
- silver = "";
- } else {
- silver += "s ";
- }
- return s + gold + silver + copper;
- }
- function getItemLastPriceChange(itemID) {
- var lastUpdate = getItemProperty(itemID, 'price_last_changed');
- return lastUpdate.substr(0,19); // shave off " UTC" part
- }
- }
- function calcSDStatus(supply, demand, threshold) {
- if (typeof threshold === "undefined") {
- threshold = 0.05;
- }
- //supply = 212;
- //demand = 541;
- var ratio = supply / demand;
- var lowerBound = (ratio - threshold);
- var upperBound = (ratio + threshold);
- var status;
- if (ratio == 1.0) {
- status = "Equilibrium";
- } else if (lowerBound < 1.0) {
- status = "In Demand";
- } else { // upperBound > 1.0
- status = "Saturated";
- }
- return status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement