mirror of
https://git.haroon.hackclub.app/haroon/Battler-Generator.git
synced 2024-11-10 07:49:39 +00:00
fix part 3
This commit is contained in:
parent
fcd0787454
commit
7e50cb802e
4 changed files with 20 additions and 6 deletions
1
assets/communityvs/None.png
Symbolic link
1
assets/communityvs/None.png
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
assets/battlebgs/None.png
|
Before Width: | Height: | Size: 241 KiB After Width: | Height: | Size: 241 KiB |
19
index.ts
19
index.ts
|
@ -144,7 +144,14 @@ const opponents = {
|
||||||
text: "Master OG",
|
text: "Master OG",
|
||||||
colour: ["#FF0000", "#FFFFFF"]
|
colour: ["#FF0000", "#FFFFFF"]
|
||||||
},
|
},
|
||||||
[Opponents.Stik]: {
|
}
|
||||||
|
|
||||||
|
const communityOpponents = {
|
||||||
|
[Opponents.None]: {
|
||||||
|
text: "",
|
||||||
|
colour: ["#FFFFFF", "#FFFFFF"]
|
||||||
|
},
|
||||||
|
[CommunityOpponents.Stik]: {
|
||||||
text: "Stik",
|
text: "Stik",
|
||||||
colour: ["#FF0000", "#000000"]
|
colour: ["#FF0000", "#000000"]
|
||||||
}
|
}
|
||||||
|
@ -277,7 +284,7 @@ const server = createServer(async (req, res) => {
|
||||||
const canvas = createCanvas(1920, 1080);
|
const canvas = createCanvas(1920, 1080);
|
||||||
const context = canvas.getContext("2d");
|
const context = canvas.getContext("2d");
|
||||||
|
|
||||||
if (!validOpponents.includes(opts.opponent)) opts.opponent = CommunityOpponents.None
|
if (!validOpponents.includes(opts.opponent)) opts.opponent = Opponents.None
|
||||||
|
|
||||||
const SquadBackground = await loadImage(
|
const SquadBackground = await loadImage(
|
||||||
`./assets/communityvs/${opts.opponent}.png`,
|
`./assets/communityvs/${opts.opponent}.png`,
|
||||||
|
@ -291,9 +298,11 @@ const server = createServer(async (req, res) => {
|
||||||
|
|
||||||
context.textAlign = "center"
|
context.textAlign = "center"
|
||||||
|
|
||||||
context.font = applyText(canvas, opponents[opts.opponent].text, 875)
|
// @ts-ignore shut up
|
||||||
|
context.font = applyText(canvas, communityOpponents[opts.opponent].text, 875)
|
||||||
|
|
||||||
drawText([1450, 1000], opponents[opts.opponent].text, opponents[opts.opponent].colour[1], { colour: opponents[opts.opponent].colour[0], width: 20 }, context);
|
// @ts-ignore shut up
|
||||||
|
drawText([1450, 1000], communityOpponents[opts.opponent].text, communityOpponents[opts.opponent].colour[1], { colour: communityOpponents[opts.opponent].colour[0], width: 20 }, context);
|
||||||
|
|
||||||
context.font = applyText(canvas, opts.username, 675)
|
context.font = applyText(canvas, opts.username, 675)
|
||||||
|
|
||||||
|
@ -334,7 +343,7 @@ const server = createServer(async (req, res) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Generating ${opts.action} for ${opts.username}`)
|
console.log(`Generating ${opts.action}`)
|
||||||
|
|
||||||
// Image dimensions
|
// Image dimensions
|
||||||
const canvas = createCanvas(1920, 1080);
|
const canvas = createCanvas(1920, 1080);
|
||||||
|
|
4
types.ts
4
types.ts
|
@ -127,6 +127,10 @@ export enum Opponents {
|
||||||
Dicey2024 = "Dicey2024",
|
Dicey2024 = "Dicey2024",
|
||||||
CakeDay = "CakeDay",
|
CakeDay = "CakeDay",
|
||||||
MasterOG = "MasterOG",
|
MasterOG = "MasterOG",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum CommunityOpponents {
|
||||||
|
None = "None",
|
||||||
Stik = "Stik",
|
Stik = "Stik",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue