all repos — stealth-developers @ 1e972fbe77bc187b7bec4f6158641ece3cf7f98f

apps/api/src/lib/widgets/meow.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
import {
	AddWidgetPreviewHeroBuilder,
	MiniProfileContainedStatBuilder,
	WidgetBottomCollectionBuilder,
	WidgetPayloadBuilder,
	WidgetTopHeroBuilder,
	customString,
} from "./builders";
import { ASSETS } from "./constants";

export function generateWidget(values: {
	kills: string;
	deaths: string;
	level: string;
	matchesWon: string;
}) {
	const { kills, deaths, level, matchesWon } = values;
	if (!kills || !deaths || !level || !matchesWon) throw new Error("Missing values");

	return new WidgetPayloadBuilder("Ground War")
		.widgetTop(
			new WidgetTopHeroBuilder()
				.setHeroImage(ASSETS.hero.image)
				.setTitle(customString("text", "Ground War"))
				.addSubtitle(customString("text", "sub 1"))
				.addSubtitle(customString("text", "sub 2"))
				.build(),
		)
		.widgetBottom(
			new WidgetBottomCollectionBuilder()
				.addItem(ASSETS.hero.image, customString("text", "Kills"), customString("text", kills))
				.addItem(ASSETS.hero.image, customString("text", "Deaths"), customString("text", deaths))
				.addItem(ASSETS.hero.image, customString("text", "Level"), customString("text", level))
				.addItem(
					ASSETS.hero.image,
					customString("text", "Matches Won"),
					customString("text", matchesWon),
				)
				.build(),
		)
		.addWidgetPreview(new AddWidgetPreviewHeroBuilder().setHeroImage(ASSETS.hero.image).build())
		.miniProfile(
			new MiniProfileContainedStatBuilder()
				.setStat(customString("text", "Ground War"))
				.setContainedImage(ASSETS.hero.image)
				.build(),
		)
		.build();
}