aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-02-13 13:17:37 -0600
committermat <github@matdoes.dev>2022-02-13 13:17:37 -0600
commitf20cdf862a6c52b0088279656592bd710a0051c3 (patch)
tree72f70c340f093f2719560ae8b7d2bbaf0d51389f
parentaa4d561f1663c85e9dec8e3d2e76c14cbea997bb (diff)
downloadskyblock-api-f20cdf862a6c52b0088279656592bd710a0051c3.tar.gz
skyblock-api-f20cdf862a6c52b0088279656592bd710a0051c3.tar.bz2
skyblock-api-f20cdf862a6c52b0088279656592bd710a0051c3.zip
Update election.ts
-rw-r--r--src/cleaners/skyblock/election.ts32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/cleaners/skyblock/election.ts b/src/cleaners/skyblock/election.ts
index 78937ec..2a00d53 100644
--- a/src/cleaners/skyblock/election.ts
+++ b/src/cleaners/skyblock/election.ts
@@ -1,14 +1,6 @@
-
-const candidateColors = {
- barry: 'e',
- paul: '4',
- aatrox: 'a',
- foxy: '3',
- cole: 'e',
- marina: '5',
- diaz: '5',
- diana: '3',
-}
+const candidateColors = [
+ '4', 'a', '3', 'e', '5',
+]
export interface MayorPerk {
name: string
@@ -35,26 +27,26 @@ export interface ElectionData {
} | null
}
-function cleanCandidate(data: any): Candidate {
+function cleanCandidate(data: any, index: number): Candidate {
return {
name: data.name,
- perks: data.perks,
+ perks: data.perks.map(perk => ({
+ name: perk.name,
+ description: 'ยง7' + perk.description,
+ })),
votes: data.votes,
- color: candidateColors[data.name.toLowerCase()],
+ color: candidateColors[index],
}
}
export function cleanElectionResponse(data: any): ElectionData {
+ const previousCandidates = data.mayor.election.candidates.map(cleanCandidate)
return {
last_updated: data.lastUpdated / 1000,
previous: {
year: data.mayor.election.year,
- winner: cleanCandidate({
- name: data.mayor.name,
- perks: data.mayor.perks,
- votes: data.mayor.election.candidates.find(c => c.key === data.mayor.key).votes,
- }),
- candidates: data.mayor.election.candidates.map(cleanCandidate)
+ winner: data.mayor.name,
+ candidates: previousCandidates
},
current: data.current ? {
year: data.current.year,