mirror of
https://github.com/YouHaveTrouble/GuildMaster.git
synced 2026-05-11 22:16:59 +00:00
download news once per hour
This commit is contained in:
+15
@@ -49,6 +49,7 @@ import {version} from "../package.json"
|
||||
:adventurers="adventurers"
|
||||
:quests="missives"
|
||||
:adventurerForHire="adventurerForHire"
|
||||
:news="news"
|
||||
@finalizeQuest="finalizeQuest($event)"
|
||||
@wipeSave="resetSave()"
|
||||
@recruitActionTaken="recruitAction($event)"
|
||||
@@ -84,6 +85,7 @@ export default defineComponent({
|
||||
guild: new Guild(1, 500),
|
||||
gameTickTask: null as null | number,
|
||||
gameSaveTask: null as null | number,
|
||||
news: "" as string,
|
||||
lastQuestGot: {
|
||||
S: null as null | number,
|
||||
A: null as null | number,
|
||||
@@ -264,6 +266,13 @@ export default defineComponent({
|
||||
if (!confirm("You are about to wipe your save file. Are you sure?")) return;
|
||||
window.localStorage.removeItem("savedGame");
|
||||
window.location.reload();
|
||||
},
|
||||
async updateNews() {
|
||||
const result = await fetch("https://raw.githubusercontent.com/YouHaveTrouble/GuildMaster/master/news.txt").catch(() => {
|
||||
return null;
|
||||
});
|
||||
if (result === null) return;
|
||||
this.news = await result.text();
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
@@ -282,6 +291,12 @@ export default defineComponent({
|
||||
loadAdventurersForHire(),
|
||||
]);
|
||||
|
||||
this.updateNews().then(() => {
|
||||
setInterval(() => {
|
||||
this.updateNews();
|
||||
}, 1000 * 60 * 60);
|
||||
});
|
||||
|
||||
this.quests = promises[0] as { [key: string]: { [key: string]: Quest } };
|
||||
this.adventurersDatabase = promises[1] as Array<Adventurer>;
|
||||
console.debug("Game data loaded!")
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<h1>Guild Master</h1>
|
||||
<h3>Adventurer's guild management game</h3>
|
||||
<small>v{{ version }}</small>
|
||||
<p class="news">{{ news }}</p>
|
||||
</section>
|
||||
<section class="upgrades panel pinned-paper">
|
||||
<div class="nail top-left">
|
||||
@@ -56,6 +57,10 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
props: {
|
||||
news: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
guild: {
|
||||
type: Object as PropType<Guild>,
|
||||
default: () => new Guild(1, 0) as Guild,
|
||||
@@ -80,6 +85,11 @@ main {
|
||||
}
|
||||
}
|
||||
|
||||
.news {
|
||||
max-width: 75%;
|
||||
color: #ab0707;
|
||||
}
|
||||
|
||||
.coffer {
|
||||
text-align: center;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user