@rpg-engine/long-bow 0.8.93 → 0.8.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.8.93",
3
+ "version": "0.8.95",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -84,7 +84,7 @@
84
84
  "dependencies": {
85
85
  "@capacitor/core": "^6.1.0",
86
86
  "@rollup/plugin-image": "^2.1.1",
87
- "@rpg-engine/shared": "^0.10.41",
87
+ "@rpg-engine/shared": "^0.10.42",
88
88
  "dayjs": "^1.11.2",
89
89
  "font-awesome": "^4.7.0",
90
90
  "fs-extra": "^10.1.0",
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  CharacterClass,
3
3
  getLevelFromSP,
4
+ getLevelFromXP,
4
5
  getSPForLevelExponential,
5
6
  getSkillConstants,
7
+ getXPForLevel,
6
8
  } from '@rpg-engine/shared';
7
9
  import React from 'react';
8
10
  import styled from 'styled-components';
@@ -32,7 +34,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
32
34
  skillName,
33
35
  skillKey,
34
36
  characterClass,
35
- level,
37
+ // level prop kept in interface for API compatibility, but calculated from skillPoints
36
38
  skillPoints: currentSkillPoints,
37
39
 
38
40
  texturePath,
@@ -45,12 +47,14 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
45
47
  // Use CharacterClass.None as default if skillKey is provided but characterClass is not
46
48
  const effectiveClass = characterClass ?? CharacterClass.None;
47
49
 
48
- // Calculate the effective level based on actual SP (handles data inconsistencies)
50
+ // Calculate the effective level based on actual SP/XP (handles data inconsistencies)
49
51
  const calculateEffectiveLevel = (): number => {
50
52
  if (!skillKey) {
51
- return level; // Fallback to stored level for general "Level" display
53
+ // Character level: uses cubic formula (level³ * 3)
54
+ return Math.max(1, getLevelFromXP(currentSkillPoints));
52
55
  }
53
56
 
57
+ // Skills: use exponential formula with class-based constants
54
58
  const { A, b, c } = getSkillConstants(skillKey, effectiveClass);
55
59
  const actualLevel = Math.floor(getLevelFromSP(currentSkillPoints, A, b, c));
56
60
  return Math.max(1, actualLevel); // Minimum level is always 1 in our system
@@ -58,12 +62,23 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
58
62
 
59
63
  const effectiveLevel = calculateEffectiveLevel();
60
64
 
61
- // Calculate progress based on actual SP position
65
+ // Calculate progress based on actual SP/XP position
62
66
  const calculateProgress = (): number => {
63
- // Use exponential formula for all skill progress calculations
64
- // For character XP (when skillKey is not provided), use default constants
65
- const skillName = skillKey ?? 'level';
66
- const { A, b, c } = getSkillConstants(skillName, effectiveClass);
67
+ // Character level uses cubic XP formula, skills use exponential SP formula
68
+ if (!skillKey) {
69
+ // Character level: uses cubic formula (level³ * 3)
70
+ const actualLevel = Math.max(1, getLevelFromXP(currentSkillPoints));
71
+ const currentLevelXP = getXPForLevel(actualLevel);
72
+ const nextLevelXP = getXPForLevel(actualLevel + 1);
73
+
74
+ const range = nextLevelXP - currentLevelXP;
75
+ const progressInLevel = currentSkillPoints - currentLevelXP;
76
+
77
+ return Math.min(99.99, Math.max(0, (progressInLevel / Math.max(1, range)) * 100));
78
+ }
79
+
80
+ // Skills: use exponential formula with class-based constants
81
+ const { A, b, c } = getSkillConstants(skillKey, effectiveClass);
67
82
 
68
83
  // Get the actual calculated level (might be 0 for magic)
69
84
  const actualLevel = Math.floor(getLevelFromSP(currentSkillPoints, A, b, c));
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  ISkill,
3
3
  ISkillDetails,
4
- getSPForLevel,
5
4
  getSPForLevelExponential,
6
5
  getSkillConstants,
7
6
  CharacterClass,
@@ -115,13 +114,11 @@ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
115
114
  continue;
116
115
  }
117
116
 
118
- // Calculate skillPointsToNextLevel using exponential formula if characterClass available
117
+ // Calculate skillPointsToNextLevel using exponential formula with character class
119
118
  const calcSkillPointsToNextLevel = (): number => {
120
- if (characterClass) {
121
- const { A, b, c } = getSkillConstants(key, characterClass);
122
- return Math.round(getSPForLevelExponential(skillDetails.level + 1, A, b, c));
123
- }
124
- return Math.round(getSPForLevel(skillDetails.level + 1));
119
+ const effectiveClass = characterClass ?? CharacterClass.None;
120
+ const { A, b, c } = getSkillConstants(key, effectiveClass);
121
+ return Math.round(getSPForLevelExponential(skillDetails.level + 1, A, b, c));
125
122
  };
126
123
 
127
124
  output.push(
@@ -28,7 +28,7 @@ const SKILL_NAMES: Record<string, string> = {
28
28
  shielding: 'shielding',
29
29
  fishing: 'fishing',
30
30
  cooking: 'cooking',
31
- firstAid: 'first aid',
31
+ fistFighting: 'fist fighting',
32
32
  };
33
33
 
34
34
  const getSkillName = (attribute: string): string => {