forked from profectus/Profectus
Made setupFeatures use more accurate types
This commit is contained in:
parent
269b40b821
commit
d30cc8688f
2 changed files with 22 additions and 23 deletions
|
@ -92,11 +92,10 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (layer.upgrades) {
|
if (layer.upgrades) {
|
||||||
setupFeatures<
|
setupFeatures<NonNullable<RawLayer["upgrades"]>, NonNullable<Layer["upgrades"]>, Upgrade>(
|
||||||
RawGridFeatures<GridFeatures<Upgrade>, Upgrade>,
|
layer.id,
|
||||||
GridFeatures<Upgrade>,
|
layer.upgrades
|
||||||
Upgrade
|
);
|
||||||
>(layer.id, layer.upgrades);
|
|
||||||
setRowCol(layer.upgrades);
|
setRowCol(layer.upgrades);
|
||||||
for (const id in layer.upgrades.data) {
|
for (const id in layer.upgrades.data) {
|
||||||
layer.upgrades.data[id].bought = function() {
|
layer.upgrades.data[id].bought = function() {
|
||||||
|
@ -190,8 +189,8 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
}
|
}
|
||||||
if (layer.achievements) {
|
if (layer.achievements) {
|
||||||
setupFeatures<
|
setupFeatures<
|
||||||
RawGridFeatures<GridFeatures<Achievement>, Achievement>,
|
NonNullable<RawLayer["achievements"]>,
|
||||||
GridFeatures<Achievement>,
|
NonNullable<Layer["achievements"]>,
|
||||||
Achievement
|
Achievement
|
||||||
>(layer.id, layer.achievements);
|
>(layer.id, layer.achievements);
|
||||||
setRowCol(layer.achievements);
|
setRowCol(layer.achievements);
|
||||||
|
@ -209,8 +208,8 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
}
|
}
|
||||||
if (layer.challenges) {
|
if (layer.challenges) {
|
||||||
setupFeatures<
|
setupFeatures<
|
||||||
RawGridFeatures<GridFeatures<Challenge>, Challenge>,
|
NonNullable<RawLayer["challenges"]>,
|
||||||
GridFeatures<Challenge>,
|
NonNullable<Layer["challenges"]>,
|
||||||
Challenge
|
Challenge
|
||||||
>(layer.id, layer.challenges);
|
>(layer.id, layer.challenges);
|
||||||
setRowCol(layer.challenges);
|
setRowCol(layer.challenges);
|
||||||
|
@ -301,11 +300,10 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (layer.buyables) {
|
if (layer.buyables) {
|
||||||
setupFeatures<
|
setupFeatures<NonNullable<RawLayer["buyables"]>, NonNullable<Layer["buyables"]>, Buyable>(
|
||||||
RawGridFeatures<GridFeatures<Buyable>, Buyable>,
|
layer.id,
|
||||||
GridFeatures<Buyable>,
|
layer.buyables
|
||||||
Buyable
|
);
|
||||||
>(layer.id, layer.buyables);
|
|
||||||
setRowCol(layer.buyables);
|
setRowCol(layer.buyables);
|
||||||
setDefault(layer.buyables, "respec", undefined, false);
|
setDefault(layer.buyables, "respec", undefined, false);
|
||||||
setDefault(
|
setDefault(
|
||||||
|
@ -353,8 +351,8 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
}
|
}
|
||||||
if (layer.clickables) {
|
if (layer.clickables) {
|
||||||
setupFeatures<
|
setupFeatures<
|
||||||
RawGridFeatures<GridFeatures<Clickable>, Clickable>,
|
NonNullable<RawLayer["clickables"]>,
|
||||||
GridFeatures<Clickable>,
|
NonNullable<Layer["clickables"]>,
|
||||||
Clickable
|
Clickable
|
||||||
>(layer.id, layer.clickables);
|
>(layer.id, layer.clickables);
|
||||||
setRowCol(layer.clickables);
|
setRowCol(layer.clickables);
|
||||||
|
@ -375,10 +373,11 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (layer.milestones) {
|
if (layer.milestones) {
|
||||||
setupFeatures<RawFeatures<Features<Milestone>, Milestone>, Features<Milestone>, Milestone>(
|
setupFeatures<
|
||||||
layer.id,
|
NonNullable<RawLayer["milestones"]>,
|
||||||
layer.milestones
|
NonNullable<Layer["milestones"]>,
|
||||||
);
|
Milestone
|
||||||
|
>(layer.id, layer.milestones);
|
||||||
for (const id in layer.milestones.data) {
|
for (const id in layer.milestones.data) {
|
||||||
layer.milestones.data[id].earned = function() {
|
layer.milestones.data[id].earned = function() {
|
||||||
return (
|
return (
|
||||||
|
@ -416,7 +415,7 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (layer.grids) {
|
if (layer.grids) {
|
||||||
setupFeatures<RawFeatures<Features<Grid>, Grid>, Features<Grid>, Grid>(
|
setupFeatures<NonNullable<RawLayer["grids"]>, NonNullable<Layer["grids"]>, Grid>(
|
||||||
layer.id,
|
layer.id,
|
||||||
layer.grids
|
layer.grids
|
||||||
);
|
);
|
||||||
|
|
4
src/typings/layer.d.ts
vendored
4
src/typings/layer.d.ts
vendored
|
@ -37,7 +37,7 @@ export interface RawLayer extends RawFeature<Layer> {
|
||||||
subtabs?: Record<string, RawFeature<Subtab>>;
|
subtabs?: Record<string, RawFeature<Subtab>>;
|
||||||
microtabs?: Record<string, RawMicrotabFamily>;
|
microtabs?: Record<string, RawMicrotabFamily>;
|
||||||
upgrades?: RawGridFeatures<NonNullable<Layer["upgrades"]>, Upgrade>;
|
upgrades?: RawGridFeatures<NonNullable<Layer["upgrades"]>, Upgrade>;
|
||||||
startData?: () => Record<string, any>;
|
startData?: () => Record<string, State>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Layer extends Feature {
|
export interface Layer extends Feature {
|
||||||
|
@ -115,7 +115,7 @@ export interface Layer extends Feature {
|
||||||
activeSubtab?: Subtab | undefined;
|
activeSubtab?: Subtab | undefined;
|
||||||
microtabs?: Record<string, MicrotabFamily>;
|
microtabs?: Record<string, MicrotabFamily>;
|
||||||
upgrades?: GridFeatures<Upgrade>;
|
upgrades?: GridFeatures<Upgrade>;
|
||||||
startData?: () => Record<string, any>;
|
startData?: () => Record<string, State>;
|
||||||
click?: () => void;
|
click?: () => void;
|
||||||
automate?: () => void;
|
automate?: () => void;
|
||||||
reset: (force?: boolean) => void;
|
reset: (force?: boolean) => void;
|
||||||
|
|
Loading…
Reference in a new issue