Skip to content

Commit

Permalink
Merge branch 'amber' into builds
Browse files Browse the repository at this point in the history
  • Loading branch information
glaciyan authored Jan 4, 2022
2 parents aabfd85 + 5e15a5e commit a22b722
Show file tree
Hide file tree
Showing 53 changed files with 183 additions and 1,735 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dist-ssr
.vercel
src/version.ts
.obsidian
scripts/jsdata

# Logs
logs
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"license": "MIT",
"version": "2.1.2",
"scripts": {
"pre": "yarn genver",
"pre": "yarn gen:version",
"dev": "yarn pre && vite",
"build": "yarn pre && vue-tsc --noEmit && vite build",
"start": "vite preview",
"prod": "yarn build && yarn start",
"lint": "eslint ./src --ext .ts,.vue",
"genver": "node scripts/version.js",
"gen:version": "node scripts/version.js",
"gen:datakeys": "yarn data:tsc && node scripts/generate_key_types.js",
"data:tsc": "tsc src/lib/data/Characters.ts src/lib/data/Items.ts src/lib/data/ItemGroups.ts src/lib/data/Elements.ts src/lib/data/WeaponTypes.ts src/lib/data/DaysOfWeek.ts src/lib/data/ItemAvailability.ts src/lib/data/Travelers.ts --outdir scripts/jsdata",
"images:characters:build": "squoosh-cli --oxipng auto --webp auto --resize {width:240} -d public/images/characters/card",
"images:mugshot:build": "squoosh-cli --oxipng auto --webp auto --resize {width:100} -d public/images/characters/mugshot",
"images:items:build": "squoosh-cli --oxipng auto --webp auto --resize {width:40} -d public/images/materials",
Expand Down
Binary file added public/images/characters/mugshot/shenhe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/characters/mugshot/shenhe.webp
Binary file not shown.
Binary file added public/images/characters/mugshot/yun_jin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/characters/mugshot/yun_jin.webp
Binary file not shown.
Binary file added public/images/materials/unknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/materials/unknown.webp
Binary file not shown.
35 changes: 35 additions & 0 deletions scripts/generate_key_types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require("fs");

// run `yarn data:tsc` to create the required files
const Characters = require("./jsdata/data/Characters.js").Characters;
const Items = require("./jsdata/data/Items.js").Items;
const ItemGroups = require("./jsdata/data/ItemGroups.js").ItemGroups;
const Elements = require("./jsdata/data/Elements.js").Elements;
const DaysOfWeek = require("./jsdata/data/DaysOfWeek.js").DaysOfWeek;
const WeaponTypes = require("./jsdata/data/WeaponTypes.js").WeaponTypes;
const ItemAvailability = require("./jsdata/data/ItemAvailability.js").ItemAvailability;
const Travelers = require("./jsdata/data/Travelers.js").Travelers;

const generateFile = (object, name) => {
const keys = Object.keys(object);

fs.writeFileSync(
`./src/lib/data/keys/${name}.ts`,
`
type ${name} = ${keys.map((key) => `"${key}"`).join(" | ")};
export default ${name};`
);
};

const main = async () => {
generateFile(Characters, "CharactersKey");
generateFile(Items, "ItemsKey");
generateFile(ItemGroups, "ItemGroupsKey");
generateFile(Elements, "ElementsKey");
generateFile(DaysOfWeek, "DaysOfWeekKey");
generateFile(WeaponTypes, "WeaponTypesKey");
generateFile(ItemAvailability, "ItemAvailabilityKey");
generateFile(Travelers, "TravelersKey");
};

main();
12 changes: 12 additions & 0 deletions scripts/hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@
"name": "./src/lib/data/images/characters/mugshot/sayu.png",
"hash": "8375aa2331c5d1403ef38ae442ea6632d1fa6f55"
},
{
"name": "./src/lib/data/images/characters/mugshot/shenhe.png",
"hash": "3e16f232c7356554b9f23f2df9e31a4235df9426"
},
{
"name": "./src/lib/data/images/characters/mugshot/sucrose.png",
"hash": "eb431f785d030555d606b2b771d445872781bea4"
Expand Down Expand Up @@ -363,6 +367,10 @@
"name": "./src/lib/data/images/characters/mugshot/yoimiya.png",
"hash": "0876aa869ddafea13c02c6ebb92d2addc35c99db"
},
{
"name": "./src/lib/data/images/characters/mugshot/yun_jin.png",
"hash": "0a59d142859800bbfe0067effef5f7dff17d9d89"
},
{
"name": "./src/lib/data/images/characters/mugshot/zhongli.png",
"hash": "04622161a3e332773639ee11b7cae8f3df0f019e"
Expand Down Expand Up @@ -1115,6 +1123,10 @@
"name": "./src/lib/data/images/materials/tusk_of_monoceros_caeli.png",
"hash": "b215777a1ec5e0fa16c1c6b3c5f960a502ab6085"
},
{
"name": "./src/lib/data/images/materials/unknown.png",
"hash": "6f275fba8afd93c975104211327734a655384f98"
},
{
"name": "./src/lib/data/images/materials/vajrada_amethyst_chunk.png",
"hash": "01972c0cbfcec2e6d405074422f46b5ff9e4b1b1"
Expand Down
14 changes: 2 additions & 12 deletions src/components/BuildCharacter/TheCharacterDetailPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@ const elementTextColor = computed(() => `text-genshin-element-${props.character.
<template>
<aside class="flex flex-col bg-dark-700 px-6 pt-4 pb-6 relative">
<div aria-hidden="true" class="h-32 w-full opacity-50 inset-x-0 top-0 absolute">
<Image
class="h-full object-cover w-full"
type="characterCard"
:name="character.normalizedName"
width="240"
height="150"
/>
<Image class="h-full object-cover w-full" type="characterCard" :entity="character" width="240" height="150" />
</div>
<div class="relative">
<GPortrait
class="ring mb-6 ring-dark-700"
:normalizedName="character.normalizedName"
:rarity="character.rarity"
/>
<GPortrait class="ring mb-6 ring-dark-700" :character="character" />
<!-- Character details -->
<div>
<p class="font-bold text-light-important">{{ character.name }}</p>
Expand Down
17 changes: 9 additions & 8 deletions src/components/GImage.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<script setup lang="ts">
import { IBaseCharacter } from "~/lib/data/contracts/IBaseCharacter";
import { IItem } from "~/lib/data/contracts/IItem";
import { getCharacterImage } from "~/lib/data/util/getCharacterImage";
import { getItemImage } from "~/lib/data/util/getItemImage";
import { getWeaponImage } from "~/lib/data/util/getWeaponImage";
const props = defineProps<{
type: "characterMugshot" | "characterCard" | "item" | "weapon";
name: string;
type: "characterMugshot" | "characterCard" | "item";
entity: IBaseCharacter | IItem;
}>();
const src = computed(() => {
switch (props.type) {
case "characterCard":
return getCharacterImage(props.name, "card");
//@ts-expect-error type prop filters the case out where it can be an item
return getCharacterImage(props.entity, "card");
case "characterMugshot":
return getCharacterImage(props.name, "mugshot");
//@ts-expect-error type prop filters the case out where it can be an item
return getCharacterImage(props.entity, "mugshot");
case "item":
return getItemImage(props.name);
case "weapon":
return getWeaponImage(props.name);
return getItemImage(props.entity.normalizedName);
}
});
</script>
Expand Down
17 changes: 6 additions & 11 deletions src/components/GPortrait.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<script setup lang="ts">
import RarityStars from "./RarityStars.vue";
import Image from "./GImage.vue";
import { IBaseCharacter } from "~/lib/data/contracts/IBaseCharacter";
const props = defineProps<{ normalizedName: string; rarity?: number; weapon?: boolean }>();
const rounding = ["rounded-t-md", { "rounded-b-md": props.rarity === undefined }];
const props = defineProps<{ character: IBaseCharacter }>();
const rounding = ["rounded-t-md", { "rounded-b-md": props.character.rarity === undefined }];
</script>

<template>
<div class="rounded-md h-max bg-dark-500 w-[100px]">
<div :class="['bg-dark-500', rounding]">
<Image
:class="[rounding, { '': weapon }]"
:type="weapon ? 'weapon' : 'characterMugshot'"
:name="normalizedName"
width="100"
height="100"
/>
<Image :class="rounding" type="characterMugshot" :entity="character" width="100" height="100" />
</div>
<div v-if="rarity" class="rounded-b-md flex bg-dark-400 border-0 py-0.5 items-center justify-center">
<RarityStars :rarity="rarity" />
<div v-if="character.rarity" class="rounded-b-md flex bg-dark-400 border-0 py-0.5 items-center justify-center">
<RarityStars :rarity="character.rarity" />
</div>
</div>
</template>
2 changes: 1 addition & 1 deletion src/components/ItemCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const amount = computed(() => millify(props.itemWithAmount.amount));
<Image
:class="['h-full object-contain w-full', { 'filter grayscale': grayscale }]"
type="item"
:name="itemWithAmount.item.normalizedName"
:entity="itemWithAmount.item"
width="40"
height="40"
:alt="itemWithAmount.item.name"
Expand Down
12 changes: 6 additions & 6 deletions src/components/character/CharacterBuildPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ const edit = () => {
<div class="flex min-h-32 relative lg:w-50">
<div class="inset-x-0 top-0 absolute fading-out">
<Image
class="object-cover h-32 w-full opacity-50"
type="characterCard"
:name="character.normalizedName"
width="240"
height="150"
/>
class="object-cover h-32 w-full opacity-50"
type="characterCard"
:entity="character"
width="240"
height="150"
/>
</div>
<div class="p-6 relative <sm:p-4">
<p class="font-bold text-lg text-light-important mb-2">
Expand Down
2 changes: 1 addition & 1 deletion src/components/character/CharacterCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const isVisible = useIntersection(image);
v-if="isVisible"
class="h-full w-full"
type="characterCard"
:name="character.normalizedName"
:entity="character"
width="240"
height="150"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/levelSelector/SelectorAscensionLevel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { AscensionLevel } from "~/lib/types/AscensionLevel";
import AllLevels from "~/lib/data/Levels";
import AllLevels from "~/lib/data/util/Levels";
import AscensionCheckbox from "../CheckboxAscension.vue";
import CustomSelector from "../SelectorCustom.vue";
import AscensionLevelDisplay from "../AscensionLevelDisplay.vue";
Expand Down
15 changes: 0 additions & 15 deletions src/components/weapons/WeaponCard.vue

This file was deleted.

6 changes: 3 additions & 3 deletions src/lib/calculator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import AscensionCostTable from "./data/AscensionCostTable";
import AscensionCostTable from "./data/costTables/AscensionCostTable";
import { IBaseCharacter } from "./data/contracts/IBaseCharacter";
import { IStandardAscensionItems } from "./data/contracts/IStandardCharacterItems";
import { ItemWithAmount } from "./types/ItemWithAmount";
import { Items } from "./data/Items";
import LevelingCostTable from "./data/LevelingCostTable";
import TalentCostTable from "./data/TalentCostTable";
import LevelingCostTable from "./data/costTables/LevelingCostTable";
import TalentCostTable from "./data/costTables/TalentCostTable";
import { getAscensionStage } from "./level/getAscensionStage";
import getLevelingIndex from "./level/getLevelingIndex";
import { getStandardAscensionItems, getStandardTalentItems } from "./item/getStandardItems";
Expand Down
38 changes: 36 additions & 2 deletions src/lib/data/Characters.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
import { ICharacter } from "./contracts/ICharacter";
import { IdIndex } from "../types/UsingId";
import { Elements } from "./Elements";
import { ItemGroups } from "./ItemGroups";
import { Items } from "./Items";
import CharactersKey from "./keys/CharactersKey";
import { WeaponTypes } from "./WeaponTypes";

export const Characters: IdIndex<ICharacter> = {
export const Characters: { [key in CharactersKey]: ICharacter } = {
shenhe: {
noPic: true,
name: "Shenhe",
normalizedName: "shenhe",
element: Elements.cryo,
weaponType: WeaponTypes.polearm,
rarity: 5,
sub: "No Info",
constellation: "Crista Doloris",
description: "No Info",
local: Items.qingxin,
commonGroup: ItemGroups.nectar,
boss: Items.unknown,
gemGroup: ItemGroups.cryo_gem,
bookGroup: ItemGroups.prosperity,
weekly: Items.hellfire_butterfly,
},
yun_jin: {
noPic: true,
name: "Yun Jin",
normalizedName: "yun_jin",
element: Elements.geo,
weaponType: WeaponTypes.polearm,
rarity: 4,
sub: "No Info",
constellation: "Opera Grandis",
description: "No Info",
local: Items.glaze_lily,
commonGroup: ItemGroups.mask,
boss: Items.riftborn_regalia,
gemGroup: ItemGroups.geo_gem,
bookGroup: ItemGroups.diligence,
weekly: Items.ashen_heart,
},
itto: {
name: "Itto",
normalizedName: "itto",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/data/DaysOfWeek.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const DaysOfWeek = {
import { INamed } from "./contracts/INamed";
import DaysOfWeekKey from "./keys/DaysOfWeekKey";

export const DaysOfWeek: { [key in DaysOfWeekKey]: INamed } = {
monday: {
name: "Monday",
normalizedName: "mo",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/data/Elements.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IdIndex } from "../types/UsingId";
import { IElement } from "./contracts/IElement";
import ElementsKey from "./keys/ElementsKey";

export const Elements: IdIndex<IElement> = {
export const Elements: { [key in ElementsKey]: IElement } = {
pyro: {
name: "Pyro",
normalizedName: "pyro",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/data/ItemAvailability.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IItemAvailability } from "./contracts/IItemAvailability";
import { IdIndex } from "../types/UsingId";
import { ItemGroups as ig } from "./ItemGroups";
import { DaysOfWeek as dw } from "./DaysOfWeek";
import { ItemGroups as ig } from "./ItemGroups";
import ItemAvailabilityKey from "./keys/ItemAvailabilityKey";

export const ItemAvailability: IdIndex<IItemAvailability> = {
export const ItemAvailability: { [key in ItemAvailabilityKey]: IItemAvailability } = {
freedom: {
item: ig.freedom,
days: [dw.monday, dw.thursday, dw.sunday],
Expand Down
4 changes: 2 additions & 2 deletions src/lib/data/ItemGroups.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IdIndex } from "../types/UsingId";
import { IItemGroup } from "./contracts/IItemGroup";
import { Items } from "./Items";
import ItemGroupsKey from "./keys/ItemGroupsKey";

export const ItemGroups: IdIndex<IItemGroup> = {
export const ItemGroups: { [key in ItemGroupsKey]: IItemGroup } = {
unknown: { normalizedName: "unknown", itemIds: [Items.unknown, Items.unknown, Items.unknown, Items.unknown] },

sentinel_gear: {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/data/Items.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IdIndex } from "../types/UsingId";
import { IItem } from "./contracts/IItem";
import ItemsKey from "./keys/ItemsKey";

export const Items: IdIndex<IItem> = {
export const Items: { [key in ItemsKey]: IItem } = {
unknown: {
name: "Unknown Item",
normalizedName: "unknown",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/data/Travelers.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { ITraveler } from "./contracts/ITraveler";
import { IdIndex } from "../types/UsingId";
import { Elements } from "./Elements";
import { Traveler } from "./entities/Traveler";
import { generateTravelerTalentBooks } from "./util/generateTravelerTalentBooks";
import { ItemGroups } from "./ItemGroups";
import { Items } from "./Items";
import TravelersKey from "./keys/TravelersKey";
import { generateTravelerTalentBooks } from "./util/generateTravelerTalentBooks";

const mondstadtBooks = generateTravelerTalentBooks(ItemGroups.freedom, ItemGroups.resistance, ItemGroups.ballad);
const liyueBooks = generateTravelerTalentBooks(ItemGroups.prosperity, ItemGroups.diligence, ItemGroups.gold);
const inazumaBooks = generateTravelerTalentBooks(ItemGroups.transience, ItemGroups.elegance, ItemGroups.light);

export const Travelers: IdIndex<ITraveler> = {
export const Travelers: { [key in TravelersKey]: ITraveler } = {
traveler_electro: new Traveler({
element: Elements.electro,
talentBoss: Items.dragon_lords_crown,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/data/WeaponTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IdIndex } from "../types/UsingId";
import { IWeaponType } from "./contracts/IWeaponType";
import WeaponTypesKey from "./keys/WeaponTypesKey";

export const WeaponTypes: IdIndex<IWeaponType> = {
export const WeaponTypes: { [key in WeaponTypesKey]: IWeaponType } = {
bow: {
name: "Bow",
normalizedName: "bow",
Expand Down
Loading

0 comments on commit a22b722

Please sign in to comment.