import { Profession } from './profession';
import { Stat } from './stats';
import { SkillDefinition, Skill } from './skills';
+import { EquippedItemDetails } from './equipped';
+
+export function PermissionGuard(request: any): boolean {
+ const perms: Permission[] = ['admin', 'moderator', 'tester', 'archaeologist'];
+
+ return perms.includes(request);
+}
+
+export type Permission = 'admin' | 'moderator' | 'tester' | 'archaeologist';
export type Player = {
id: string,
hp: number;
city_id: number;
stat_points: number;
+ vigor: number;
+ permissions: Permission[]
}
export type PlayerWithSkills = Player & {
}
export function maxHp(constitution: number, playerLevel: number): number {
- return Math.ceil((constitution + (playerLevel * 1.3)) * 1.7);
+ return Math.ceil((constitution * 1.7) + (playerLevel * 1.3));
+}
+
+export function maxVigor(constitution: number, playerLevel: number): number {
+ return Math.ceil((constitution * 3.8) + (playerLevel * 1.5));
}
export function expToLevel(level: number): number {
}
}
+export function totalDefence(equippedItems: EquippedItemDetails[], player: Player, accountForVigor: boolean = true): number {
+ const vigorPercent = player.vigor / maxVigor(player.constitution, player.level);
+
+ const totalDefence = equippedItems.reduce((acc, curr) => {
+ let defence = curr.boosts.defence ?? 0;
+ return acc += defence;
+ }, 0);
+
+ if(accountForVigor) {
+ return Math.ceil(totalDefence * vigorPercent);
+ }
+ else {
+ return totalDefence;
+ }
+}
+
export type StatDisplay = {
id: Stat,
display: string;
abbrv: string;
+ description: string;
}
export const StatDef: Map<Stat, StatDisplay> = new Map<Stat, StatDisplay>();
StatDef.set(Stat.strength, {
id: Stat.strength,
display: 'Strength',
- abbrv: 'STR'
+ abbrv: 'STR',
+ description: 'Affects your melee damage'
});
StatDef.set(Stat.constitution, {
id: Stat.constitution,
display: 'Constitution',
- abbrv: 'CON'
+ abbrv: 'CON',
+ description: 'Affects your max HP and Vigor'
});
StatDef.set(Stat.dexterity, {
id: Stat.dexterity,
display: 'Dexterity',
- abbrv: 'DEX'
+ abbrv: 'DEX',
+ description: 'Affects you ability to dodge attacks double-hit'
});
StatDef.set(Stat.intelligence, {
id: Stat.intelligence,
display: 'Intelligence',
- abbrv: 'INT'
+ abbrv: 'INT',
+ description: 'Affects your magical damage'
});