mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-04-24 14:56:52 -05:00
commit
f5e2f0d3bc
|
|
@ -1,6 +1,9 @@
|
||||||
# Site Config
|
# Site Config
|
||||||
SITE_URL=https://splatoon3.ink
|
SITE_URL=https://splatoon3.ink
|
||||||
|
|
||||||
|
# Load data from Splatoon3.ink during development
|
||||||
|
VITE_DATA_FROM=https://splatoon3.ink
|
||||||
|
|
||||||
# Nintendo API
|
# Nintendo API
|
||||||
NINTENDO_TOKEN=
|
NINTENDO_TOKEN=
|
||||||
|
|
||||||
|
|
|
||||||
91
app/social/generators/SplatfestStatus.mjs
Normal file
91
app/social/generators/SplatfestStatus.mjs
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
import StatusGenerator from "./StatusGenerator.mjs";
|
||||||
|
import Media from "../Media.mjs";
|
||||||
|
import { useUSSplatfestsStore, STATUS_ACTIVE, STATUS_PAST } from '../../../src/stores/splatfests.mjs';
|
||||||
|
import { useTimeStore } from "../../../src/stores/time.mjs";
|
||||||
|
|
||||||
|
export default class SplatfestStatus extends StatusGenerator
|
||||||
|
{
|
||||||
|
key = 'splatfest';
|
||||||
|
name = 'Splatfest';
|
||||||
|
|
||||||
|
async getFestival() {
|
||||||
|
await this.preparePinia();
|
||||||
|
let store = useUSSplatfestsStore();
|
||||||
|
|
||||||
|
return store.upcomingFestival
|
||||||
|
|| store.activeFestival
|
||||||
|
|| store.recentFestival;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getState() {
|
||||||
|
let festival = await this.getFestival();
|
||||||
|
|
||||||
|
let startTime = Date.parse(festival?.startTime);
|
||||||
|
let now = useTimeStore().now;
|
||||||
|
let hoursAway = (startTime - now) / (1000 * 60 * 60);
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case !festival:
|
||||||
|
return null;
|
||||||
|
case festival.status === STATUS_PAST:
|
||||||
|
return 'ended';
|
||||||
|
case festival.status === STATUS_ACTIVE:
|
||||||
|
return 'active';
|
||||||
|
case hoursAway <= 24:
|
||||||
|
return 'upcoming:1d';
|
||||||
|
case hoursAway <= 72:
|
||||||
|
return 'upcoming:3d';
|
||||||
|
default:
|
||||||
|
return 'upcoming';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDataTime() {
|
||||||
|
let festival = await this.getFestival();
|
||||||
|
let state = await this.getState();
|
||||||
|
|
||||||
|
if (!festival || !state) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${festival.id}:${state}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async shouldPost(client) {
|
||||||
|
let currentId = await this.getDataTime();
|
||||||
|
|
||||||
|
let cachedId = await this.lastPostCache(client).getData();
|
||||||
|
|
||||||
|
return currentId && currentId !== cachedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
async _getStatus() {
|
||||||
|
let festival = await this.getFestival();
|
||||||
|
let state = await this.getState();
|
||||||
|
|
||||||
|
if (!festival || !state) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case 'upcoming':
|
||||||
|
return `You can now vote in the next global Splatfest: ${festival.title} #splatfest #splatoon3`;
|
||||||
|
case 'upcoming:3d':
|
||||||
|
return `Reminder: The next global Splatfest starts in 3 DAYS! ${festival.title} #splatfest #splatoon3`
|
||||||
|
case 'upcoming:1d':
|
||||||
|
return `Reminder: The next global Splatfest starts in 24 HOURS! ${festival.title} #splatfest #splatoon3`
|
||||||
|
case 'active':
|
||||||
|
return `The global Splatfest is NOW OPEN! ${festival.title} #splatfest #splatoon3`
|
||||||
|
case 'ended':
|
||||||
|
return `The global Splatfest is now closed. Results are usually posted within 2 hours! #splatfest #splatoon3`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param {ScreenshotHelper} screenshotHelper */
|
||||||
|
async _getMedia(screenshotHelper) {
|
||||||
|
let media = new Media;
|
||||||
|
media.file = await screenshotHelper.capture('splatfest');
|
||||||
|
|
||||||
|
return media;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import RegularGearStatus from "./generators/RegularGearStatus.mjs";
|
||||||
import SalmonRunGearStatus from "./generators/SalmonRunGearStatus.mjs";
|
import SalmonRunGearStatus from "./generators/SalmonRunGearStatus.mjs";
|
||||||
import SalmonRunStatus from "./generators/SalmonRunStatus.mjs";
|
import SalmonRunStatus from "./generators/SalmonRunStatus.mjs";
|
||||||
import SchedulesStatus from "./generators/SchedulesStatus.mjs";
|
import SchedulesStatus from "./generators/SchedulesStatus.mjs";
|
||||||
|
import SplatfestStatus from "./generators/SplatfestStatus.mjs";
|
||||||
import SplatfestResultsStatus from "./generators/SplatfestResultsStatus.mjs";
|
import SplatfestResultsStatus from "./generators/SplatfestResultsStatus.mjs";
|
||||||
import StatusGeneratorManager from "./StatusGeneratorManager.mjs"
|
import StatusGeneratorManager from "./StatusGeneratorManager.mjs"
|
||||||
|
|
||||||
|
|
@ -16,6 +17,7 @@ function defaultStatusGenerators() {
|
||||||
new RegularGearStatus,
|
new RegularGearStatus,
|
||||||
new SalmonRunStatus,
|
new SalmonRunStatus,
|
||||||
new SalmonRunGearStatus,
|
new SalmonRunGearStatus,
|
||||||
|
new SplatfestStatus,
|
||||||
new SplatfestResultsStatus,
|
new SplatfestResultsStatus,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@
|
||||||
<img src="@/assets/img/twitter-white.png" width="20" height="20" class="inline" />
|
<img src="@/assets/img/twitter-white.png" width="20" height="20" class="inline" />
|
||||||
@splatoon3ink
|
@splatoon3ink
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<img src="@/assets/img/fediverse-white.svg" width="14" height="14" class="inline m-[3px]" />
|
||||||
|
@splatoon3ink@splatoon3.ink
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
splatoon3.ink
|
splatoon3.ink
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ function defineEndpointStore(id, endpoint, transform = null) {
|
||||||
isUpdating.value = true;
|
isUpdating.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let response = await fetch(endpoint);
|
let baseUrl = import.meta.env.VITE_DATA_FROM || '';
|
||||||
|
let response = await fetch(baseUrl + endpoint);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
|
|
|
||||||
|
|
@ -23,5 +23,9 @@ import SplatfestResultsBox from '@/components/SplatfestResultsBox.vue';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
const usSplatfests = useUSSplatfestsStore();
|
const usSplatfests = useUSSplatfestsStore();
|
||||||
|
|
||||||
const festival = computed(() => usSplatfests.activeFestival ?? usSplatfests.recentFestival);
|
const festival = computed(() =>
|
||||||
|
usSplatfests.upcomingFestival
|
||||||
|
?? usSplatfests.activeFestival
|
||||||
|
?? usSplatfests.recentFestival
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user