updates to concierge bot to support adding services and routes
This commit is contained in:
@@ -18,7 +18,7 @@ export interface Attribute {
|
||||
readonly tooltip_description?: LocalizedString;
|
||||
}
|
||||
|
||||
export const getAttribute = (id: number) => {
|
||||
export const getAttribute = (id: number): Attribute => {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.dogma_attributes[String(id)];
|
||||
if (!data) throw new Error(`Attribute ID ${id} not found in reference data`);
|
||||
|
||||
@@ -37,14 +37,21 @@ export interface Blueprint {
|
||||
};
|
||||
}
|
||||
|
||||
export function getBlueprint(blueprint_type_id: number) {
|
||||
export function getBlueprint(blueprint_type_id: number): Blueprint {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.blueprints[String(blueprint_type_id)];
|
||||
if (!data) throw new Error(`Blueprint Type ID ${blueprint_type_id} not found in reference data`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export function getManufacturingMaterials(blueprint: Blueprint) {
|
||||
export function getManufacturingMaterials(blueprint: Blueprint):
|
||||
| any[]
|
||||
| Promise<
|
||||
{
|
||||
type: Type;
|
||||
quantity: number;
|
||||
}[]
|
||||
> {
|
||||
const manufacturing = blueprint.activities[ActivityType.MANUFACTURING];
|
||||
if (!manufacturing) return [];
|
||||
|
||||
@@ -56,7 +63,14 @@ export function getManufacturingMaterials(blueprint: Blueprint) {
|
||||
);
|
||||
}
|
||||
|
||||
export function getManufacturingProducts(blueprint: Blueprint) {
|
||||
export function getManufacturingProducts(blueprint: Blueprint):
|
||||
| any[]
|
||||
| Promise<
|
||||
{
|
||||
type: Type;
|
||||
quantity: number;
|
||||
}[]
|
||||
> {
|
||||
const manufacturing = blueprint.activities[ActivityType.MANUFACTURING];
|
||||
if (!manufacturing) return [];
|
||||
|
||||
@@ -68,7 +82,14 @@ export function getManufacturingProducts(blueprint: Blueprint) {
|
||||
);
|
||||
}
|
||||
|
||||
export function getInventionMaterials(blueprint: Blueprint) {
|
||||
export function getInventionMaterials(blueprint: Blueprint):
|
||||
| any[]
|
||||
| Promise<
|
||||
{
|
||||
type: Type;
|
||||
quantity: number;
|
||||
}[]
|
||||
> {
|
||||
const invention = blueprint.activities[ActivityType.INVENTION];
|
||||
if (!invention) return [];
|
||||
|
||||
@@ -80,7 +101,14 @@ export function getInventionMaterials(blueprint: Blueprint) {
|
||||
);
|
||||
}
|
||||
|
||||
export function getInventionProducts(blueprint: Blueprint) {
|
||||
export function getInventionProducts(blueprint: Blueprint):
|
||||
| any[]
|
||||
| Promise<
|
||||
{
|
||||
type: Type;
|
||||
quantity: number;
|
||||
}[]
|
||||
> {
|
||||
const invention = blueprint.activities[ActivityType.INVENTION];
|
||||
if (!invention) return [];
|
||||
|
||||
@@ -92,7 +120,14 @@ export function getInventionProducts(blueprint: Blueprint) {
|
||||
);
|
||||
}
|
||||
|
||||
export function getInventionSkills(blueprint: Blueprint) {
|
||||
export function getInventionSkills(blueprint: Blueprint):
|
||||
| any[]
|
||||
| Promise<
|
||||
{
|
||||
type: Type;
|
||||
level: number;
|
||||
}[]
|
||||
> {
|
||||
const invention = blueprint.activities[ActivityType.INVENTION];
|
||||
if (!invention) return [];
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface Category {
|
||||
readonly icon_id?: number;
|
||||
}
|
||||
|
||||
export function getCategory(category_id: number) {
|
||||
export function getCategory(category_id: number): Category {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.categories[String(category_id)];
|
||||
if (!data) throw new Error(`Category ID ${category_id} not found in reference data`);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAttribute } from './attribute';
|
||||
import { getAttribute, type Attribute } from './attribute';
|
||||
import type { LocalizedString } from './shared-types';
|
||||
import { dataSets, loadModels } from './loadModels';
|
||||
|
||||
@@ -37,29 +37,29 @@ export interface Effect {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
export function getEffect(effect_id: number) {
|
||||
export function getEffect(effect_id: number): Effect {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.dogma_effects[String(effect_id)];
|
||||
if (!data) throw new Error(`Effect ID ${effect_id} not found in reference data`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export function getDischargeAttribute(effect: Effect) {
|
||||
export function getDischargeAttribute(effect: Effect): Attribute {
|
||||
return effect.discharge_attribute_id && getAttribute(effect.discharge_attribute_id);
|
||||
}
|
||||
|
||||
export function getFalloffAttribute(effect: Effect) {
|
||||
export function getFalloffAttribute(effect: Effect): Attribute {
|
||||
return effect.falloff_attribute_id && getAttribute(effect.falloff_attribute_id);
|
||||
}
|
||||
|
||||
export function getDurationAttribute(effect: Effect) {
|
||||
export function getDurationAttribute(effect: Effect): Attribute {
|
||||
return effect.duration_attribute_id && getAttribute(effect.duration_attribute_id);
|
||||
}
|
||||
|
||||
export function getRangeAttribute(effect: Effect) {
|
||||
export function getRangeAttribute(effect: Effect): Attribute {
|
||||
return effect.range_attribute_id && getAttribute(effect.range_attribute_id);
|
||||
}
|
||||
|
||||
export function getTrackingSpeedAttribute(effect: Effect) {
|
||||
export function getTrackingSpeedAttribute(effect: Effect): Attribute {
|
||||
return effect.tracking_speed_attribute_id && getAttribute(effect.tracking_speed_attribute_id);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface Group {
|
||||
readonly use_base_price: boolean;
|
||||
readonly type_ids?: number[];
|
||||
}
|
||||
export function getGroup(group_id: number) {
|
||||
export function getGroup(group_id: number): Group {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.groups[String(group_id)];
|
||||
if (!data) throw new Error(`Group ID ${group_id} not found in reference data`);
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface Icon {
|
||||
readonly file: string;
|
||||
}
|
||||
|
||||
export function getIcon(icon_id: number) {
|
||||
export function getIcon(icon_id: number): Icon {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.icons[String(icon_id)];
|
||||
if (!data) throw new Error(`Icon ID ${icon_id} not found in reference data`);
|
||||
@@ -33,9 +33,5 @@ export function getIconUrl(
|
||||
isBpc?: boolean;
|
||||
} = {},
|
||||
): string {
|
||||
return `https://images.evetech.net/types/${icon_id}/icon${
|
||||
isBp ? '/bp'
|
||||
: isBpc ? '/bpc'
|
||||
: ''
|
||||
}?size=${size}`;
|
||||
return `https://images.evetech.net/types/${icon_id}/icon${isBp ? '/bp' : isBpc ? '/bpc' : ''}?size=${size}`;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ const dataSets = {
|
||||
types: {} as Record<string, Type>,
|
||||
units: {} as Record<string, Unit>,
|
||||
};
|
||||
export async function loadModels() {
|
||||
export async function loadModels(): Promise<void> {
|
||||
dataSets.dogma_attributes = JSON.parse(fs.readFileSync(join(__dirname, '../data/reference-data/dogma_attributes.json')).toString());
|
||||
dataSets.blueprints = JSON.parse(fs.readFileSync(join(__dirname, '../data/reference-data/blueprints.json')).toString());
|
||||
dataSets.categories = JSON.parse(fs.readFileSync(join(__dirname, '../data/reference-data/categories.json')).toString());
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface MarketGroup {
|
||||
readonly has_types: boolean;
|
||||
}
|
||||
|
||||
export function getMarketGroup(market_group_id: number) {
|
||||
export function getMarketGroup(market_group_id: number): MarketGroup {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.market_groups[String(market_group_id)];
|
||||
if (!data) throw new Error(`Market group ID ${market_group_id} not found in reference data`);
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface MetaGroup {
|
||||
readonly icon_suffix?: string;
|
||||
}
|
||||
|
||||
export function getMetaGroup(meta_group_id: number) {
|
||||
export function getMetaGroup(meta_group_id: number): MetaGroup {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.meta_groups[String(meta_group_id)];
|
||||
if (!data) throw new Error(`Meta group ID ${meta_group_id} not found in reference data`);
|
||||
|
||||
@@ -16,7 +16,7 @@ export interface Region {
|
||||
readonly name: LocalizedString;
|
||||
}
|
||||
|
||||
export function getRegion(region_id: number) {
|
||||
export function getRegion(region_id: number): Region {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.regions[String(region_id)];
|
||||
if (!data) throw new Error(`Region ID ${region_id} not found in reference data`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { LocalizedString, TypeIDQuantity } from './shared-types';
|
||||
import { getType } from './type';
|
||||
import { getType, type Type } from './type';
|
||||
import { dataSets, loadModels } from './loadModels';
|
||||
|
||||
export interface Schematic {
|
||||
@@ -11,27 +11,33 @@ export interface Schematic {
|
||||
readonly pin_type_ids: number[];
|
||||
}
|
||||
|
||||
export function getSchematic(schematic_id: number) {
|
||||
export function getSchematic(schematic_id: number): Schematic {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.schematics[String(schematic_id)];
|
||||
if (!data) throw new Error(`Schematic ID ${schematic_id} not found in reference data`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export function getMaterialQuantities(schematic: Schematic) {
|
||||
export function getMaterialQuantities(schematic: Schematic): {
|
||||
type: Type;
|
||||
quantity: number;
|
||||
}[] {
|
||||
return Object.entries(schematic.materials).map(([type_id, { quantity }]) => ({
|
||||
type: getType(Number(type_id)),
|
||||
quantity,
|
||||
}));
|
||||
}
|
||||
|
||||
export function getProductQuantities(schematic: Schematic) {
|
||||
export function getProductQuantities(schematic: Schematic): {
|
||||
type: Type;
|
||||
quantity: number;
|
||||
}[] {
|
||||
return Object.entries(schematic.products).map(([type_id, { quantity }]) => ({
|
||||
type: getType(Number(type_id)),
|
||||
quantity,
|
||||
}));
|
||||
}
|
||||
|
||||
export function getPinTypes(schematic: Schematic) {
|
||||
export function getPinTypes(schematic: Schematic): Type[] {
|
||||
return schematic.pin_type_ids.map(getType);
|
||||
}
|
||||
|
||||
@@ -11,26 +11,26 @@ export interface Skill {
|
||||
readonly required_skills?: { [skill_type_id: string]: number }; // skill_type_id : level
|
||||
}
|
||||
|
||||
export function getSkill(type_id: number) {
|
||||
export function getSkill(type_id: number): Skill {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.skills[String(type_id)];
|
||||
if (!data) throw new Error(`Skill ID ${type_id} not found in reference data`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export function getPrimaryDogmaAttribute(skill: Skill) {
|
||||
export function getPrimaryDogmaAttribute(skill: Skill): Attribute {
|
||||
return getAttribute(skill.primary_dogma_attribute_id);
|
||||
}
|
||||
|
||||
export function getSecondaryDogmaAttribute(skill: Skill) {
|
||||
export function getSecondaryDogmaAttribute(skill: Skill): Attribute {
|
||||
return getAttribute(skill.secondary_dogma_attribute_id);
|
||||
}
|
||||
|
||||
export function getPrimaryCharacterAttribute(skill: Skill) {
|
||||
export function getPrimaryCharacterAttribute(skill: Skill): Attribute {
|
||||
return getAttribute(skill.primary_character_attribute_id);
|
||||
}
|
||||
|
||||
export function getSecondaryCharacterAttribute(skill: Skill) {
|
||||
export function getSecondaryCharacterAttribute(skill: Skill): Attribute {
|
||||
return getAttribute(skill.secondary_character_attribute_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import type { AttributeIDValue, BlueprintTypeIDActivity, EffectIDDefault, LocalizedString, MaterialIDQuantity } from './shared-types';
|
||||
import type {
|
||||
ActivityType,
|
||||
AttributeIDValue,
|
||||
BlueprintTypeIDActivity,
|
||||
EffectIDDefault,
|
||||
LocalizedString,
|
||||
MaterialIDQuantity,
|
||||
} from './shared-types';
|
||||
import { IconSize } from './icon';
|
||||
import { getUnit, type Unit } from './unit';
|
||||
import { CommonAttribute, getAttribute } from './attribute';
|
||||
import { getGroup } from './group';
|
||||
import { getMetaGroup } from './meta-group';
|
||||
import { CommonAttribute, getAttribute, type Attribute } from './attribute';
|
||||
import { getGroup, type Group } from './group';
|
||||
import { getMetaGroup, type MetaGroup } from './meta-group';
|
||||
import { dataSets, loadModels } from './loadModels';
|
||||
|
||||
interface Masteries {
|
||||
@@ -67,7 +74,7 @@ export interface Type {
|
||||
readonly is_blueprint?: boolean;
|
||||
}
|
||||
|
||||
export function getType(type_id: number) {
|
||||
export function getType(type_id: number): Type {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const data = dataSets.types[String(type_id)];
|
||||
if (!data) throw new Error(`Type ID ${type_id} not found in reference data`);
|
||||
@@ -114,7 +121,12 @@ export function getSkillBonuses(type: Type): {
|
||||
return skillBonuses;
|
||||
}
|
||||
|
||||
export function getRoleBonuses(type: Type) {
|
||||
export function getRoleBonuses(type: Type): {
|
||||
bonus: number;
|
||||
bonus_text: LocalizedString;
|
||||
importance: number;
|
||||
unit: Unit;
|
||||
}[] {
|
||||
if (!type.traits || !type.traits.role_bonuses) return [];
|
||||
return Object.values(type.traits.role_bonuses).map((bonus) => ({
|
||||
bonus: bonus.bonus,
|
||||
@@ -136,7 +148,7 @@ export function eveTycoonLink(type_id: number) {
|
||||
return `https://evetycoon.com/market/${type_id}`;
|
||||
}
|
||||
|
||||
export function getTypeAttributes(type: Type) {
|
||||
export function getTypeAttributes(type: Type): any[] {
|
||||
if (!type.dogma_attributes) return [];
|
||||
Object.keys(type.dogma_attributes).map((attribute_id) => ({
|
||||
attribute: getAttribute(Number(attribute_id)),
|
||||
@@ -144,7 +156,7 @@ export function getTypeAttributes(type: Type) {
|
||||
}));
|
||||
}
|
||||
|
||||
export function typeHasAnyAttribute(type: Type, attribute_ids: CommonAttribute[]) {
|
||||
export function typeHasAnyAttribute(type: Type, attribute_ids: CommonAttribute[]): boolean {
|
||||
if (!type.dogma_attributes) return false;
|
||||
for (const attribute_id of attribute_ids) {
|
||||
if (type.dogma_attributes[attribute_id]) return true;
|
||||
@@ -152,7 +164,10 @@ export function typeHasAnyAttribute(type: Type, attribute_ids: CommonAttribute[]
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getTypeSkills(type: Type) {
|
||||
export function getTypeSkills(type: Type): {
|
||||
skill: Type;
|
||||
level: number;
|
||||
}[] {
|
||||
if (!type.required_skills) return [];
|
||||
return Object.keys(type.required_skills).map((skill_type_id) => ({
|
||||
skill: getType(Number(skill_type_id)),
|
||||
@@ -160,7 +175,13 @@ export function getTypeSkills(type: Type) {
|
||||
}));
|
||||
}
|
||||
|
||||
export function typeGetAttribute(type: Type, attribute_id: number) {
|
||||
export function typeGetAttribute(
|
||||
type: Type,
|
||||
attribute_id: number,
|
||||
): {
|
||||
attribute: Attribute;
|
||||
value: number;
|
||||
} {
|
||||
if (!type.dogma_attributes || !type.dogma_attributes[attribute_id]) return null;
|
||||
return {
|
||||
attribute: getAttribute(attribute_id),
|
||||
@@ -168,7 +189,10 @@ export function typeGetAttribute(type: Type, attribute_id: number) {
|
||||
};
|
||||
}
|
||||
|
||||
export function getTypeBlueprints(type: Type) {
|
||||
export function getTypeBlueprints(type: Type): {
|
||||
blueprint: Type;
|
||||
activity: ActivityType;
|
||||
}[] {
|
||||
if (!type.produced_by_blueprints) return [];
|
||||
return Object.values(type.produced_by_blueprints).map((blueprint) => ({
|
||||
blueprint: getType(blueprint.blueprint_type_id),
|
||||
@@ -176,22 +200,25 @@ export function getTypeBlueprints(type: Type) {
|
||||
}));
|
||||
}
|
||||
|
||||
export function getTypeSchematics(type: Type) {
|
||||
export function getTypeSchematics(type: Type): Type[] {
|
||||
return type.produced_by_schematic_ids?.map((schematic_id) => getType(schematic_id)) ?? [];
|
||||
}
|
||||
|
||||
export function getTypeGroup(type: Type) {
|
||||
export function getTypeGroup(type: Type): Group {
|
||||
if (!type.group_id) return null;
|
||||
return getGroup(type.group_id);
|
||||
}
|
||||
|
||||
export function getTypeVariants(type: Type) {
|
||||
export function getTypeVariants(type: Type): {
|
||||
metaGroup: MetaGroup;
|
||||
types: Type[];
|
||||
}[] {
|
||||
return Object.entries(type.type_variations || {}).map(([meta_group_id, variant_ids]) => ({
|
||||
metaGroup: getMetaGroup(Number(meta_group_id)),
|
||||
types: variant_ids.map((type_id) => getType(type_id)),
|
||||
}));
|
||||
}
|
||||
|
||||
export function typeHasAttributes(type: Type) {
|
||||
export function typeHasAttributes(type: Type): boolean {
|
||||
return type.dogma_attributes && Object.keys(type.dogma_attributes).length > 0;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface Unit {
|
||||
readonly name: LocalizedString;
|
||||
}
|
||||
|
||||
export function getUnit(unit_id: number) {
|
||||
export function getUnit(unit_id: number): Unit {
|
||||
if (!dataSets.loaded) loadModels();
|
||||
const unit = dataSets.units[String(unit_id)];
|
||||
if (!unit) throw new Error(`Unit ID ${unit_id} not found in reference data`);
|
||||
@@ -61,6 +61,6 @@ export function renderUnit(unit: Unit, value: number, locale: string = 'en'): st
|
||||
}
|
||||
}
|
||||
|
||||
export function isUnitInversePercentage(unit: Unit) {
|
||||
export function isUnitInversePercentage(unit: Unit): boolean {
|
||||
return unit.unit_id == 108 || unit.unit_id == 111;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user