Skip to content

Commit

Permalink
Gods time cooldowns - #201
Browse files Browse the repository at this point in the history
  • Loading branch information
FrutyX authored Jan 23, 2025
2 parents 971620f + 7e3b6e2 commit e6deb86
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 4 deletions.
6 changes: 5 additions & 1 deletion source/core/locale/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ gca_languages['cs'] = {
// Item materials
base : "Základ",
prefix : "Prefix",
suffix : "Suffix"
suffix : "Suffix",

// Gods cooldowns
gods_cd_title : "Čekací doby bohů"
},

// Overview
Expand Down Expand Up @@ -400,6 +403,7 @@ gca_languages['cs'] = {
category_global$clear_arena_notifications : "Automaticky mazat notifikace útoků pro Arénu",
category_global$clear_ct_notifications : "Automaticky mazat notifikace útoků pro Circus Turma",
category_global$surprise_me : "Překvap mě.",
category_global$gods_cooldown : "Zobrazit zbývající časy bohů",
// Settings - Overview
category_overview$analyze_items : "Analyzuj hráčovo předměty",
category_overview$food_life_gain : "Zobrazit počet životů obdržený z jídla",
Expand Down
6 changes: 5 additions & 1 deletion source/core/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ gca_languages["en"] = {
// Item materials
base : "Base",
prefix : "Prefix",
suffix : "Suffix"
suffix : "Suffix",

// Gods cooldowns
gods_cd_title : "Gods cooldowns"
},

// Overview
Expand Down Expand Up @@ -413,6 +416,7 @@ gca_languages["en"] = {
category_global$clear_arena_notifications : "Automatically clear attack notifications for Arena",
category_global$clear_ct_notifications : "Automatically clear attack notifications for Circus Turma",
category_global$surprise_me : "Surprise me.",
category_global$gods_cooldown : "Show gods cooldowns",
// Settings - Overview
category_overview$analyze_items : "Analyze items stats (needed for training)",
category_overview$food_life_gain : "Show life gain from foods",
Expand Down
5 changes: 4 additions & 1 deletion source/core/source/gca.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ gca_options.data = {
"clear_ct_notifications" : false,

// Surprise Me?
"surprise_me" : false
"surprise_me" : false,

// Show gods cooldowns
"gods_cooldown" : false
},

// Overview Options
Expand Down
92 changes: 92 additions & 0 deletions source/core/source/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ var gca_global = {
// Attacked Timers
(gca_options.bool("global","attacked_timers") &&
this.display.attacked_timers.inject());

// Show gods cooldowns
(gca_options.bool("global","gods_cooldown") &&
this.display.showGodsCooldowns.inject());

// Quests Timer
(!this.isTraveling && gca_options.bool("main_menu","quest_timer") &&
Expand Down Expand Up @@ -2941,6 +2945,94 @@ var gca_global = {
this.globalArenaCooldownText.textContent = '0:' + minutes + ':' + seconds;
}
},

showGodsCooldowns : {
inject: async function() {
// URL
const url = gca_getPage.link({ mod: "gods" });

// Convert time
function formatCooldownTime(ms) {
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const remainingMinutes = minutes % 60;
const remainingSeconds = seconds % 60;
return `${hours}:${remainingMinutes < 10 ? '0' + remainingMinutes : remainingMinutes}:${remainingSeconds < 10 ? '0' + remainingSeconds : remainingSeconds}`;
}

try {
// GET URL
const response = await jQuery.get(url);

const godsContainer = jQuery(response);

// Gods IDs
const gods = ["vulcanus", "minerva", "diana", "mars", "merkur", "apollo"];

// Create wrapper
const wrapper = document.createElement('div');
wrapper.style.position = 'absolute';
wrapper.style.top = '200px';
wrapper.style.right = '-160px';
wrapper.style.maxWidth = '150px';
wrapper.style.zIndex = '9999';
wrapper.style.overflow = 'hidden';
wrapper.style.whiteSpace = 'normal';
wrapper.style.wordWrap = 'break-word';

// Title
const title = document.createElement('h2');
title.className = 'section-header';
title.style.cursor = 'pointer';
title.textContent = gca_locale.get("global", "gods_cd_title")
wrapper.appendChild(title);

// Section
const section = document.createElement('section');
section.style.display = 'block';

// List
const list = document.createElement('ul');
list.style.margin = '0';
list.style.padding = '0';
list.style.listStyle = 'none';

// Browse gods and cds
gods.forEach(god => {
const godElement = godsContainer.find(`#${god}`);
if (godElement.length) {
const godName = godElement.find(".god_name").text().trim();

// Cooldown from data-ticker-time-left
const cooldownElement = godElement.find(".ticker");
let cooldownTimeLeft = cooldownElement.attr("data-ticker-time-left");

// Check text
if (!cooldownTimeLeft) {
cooldownTimeLeft = cooldownElement.text().trim();
}

// Convert or show no cd
const formattedCooldown = cooldownTimeLeft ? formatCooldownTime(parseInt(cooldownTimeLeft)) : gca_locale.get("general", "no");

// Create list
const item = document.createElement('li');
item.innerHTML = `<strong>${godName}:</strong> ${formattedCooldown}`;
list.appendChild(item);
}
});

section.appendChild(list);
wrapper.appendChild(section);

// Insert on page
document.getElementById('content').appendChild(wrapper);
} catch (error) {
console.error("Error fetching gods data:", error);
}
}
},

// Events
event : {
Expand Down
5 changes: 4 additions & 1 deletion source/core/source/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,10 @@ var gca_settings = {
"clear_ct_notifications" : false,

// Surprise Me?
"surprise_me" : false
"surprise_me" : false,

// Show gods cooldowns
"gods_cooldown" : false
},

// Overview Options
Expand Down

0 comments on commit e6deb86

Please sign in to comment.