Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alboneon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Claesson
Alboneon
Commits
43a9d3a7
Verified
Commit
43a9d3a7
authored
2 years ago
by
Martin Claesson
Browse files
Options
Downloads
Patches
Plain Diff
fix(inventory):
#82
Fix carrying capacity for strength values > 29
Signed-off-by:
Martin Claesson
<
martin@claesson.co
>
parent
29690c31
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!62
fix(inventory): Fix coin conversion
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/library/__tests__/CharacterHelper.spec.ts
+40
-1
40 additions, 1 deletion
packages/library/__tests__/CharacterHelper.spec.ts
packages/library/helpers/CharacterHelpers.ts
+11
-1
11 additions, 1 deletion
packages/library/helpers/CharacterHelpers.ts
with
51 additions
and
2 deletions
packages/library/__tests__/CharacterHelper.spec.ts
+
40
−
1
View file @
43a9d3a7
import
{
calculateWeight
,
PathfinderCarryingCapacities
}
from
"
@alboneon/library/helpers/CharacterHelpers
"
import
{
calculateWeight
,
PathfinderCarryingCapacities
}
from
"
@alboneon/library/helpers/CharacterHelpers
"
import
{
Enums
}
from
"
@alboneon/library/types/Enums
"
import
{
Enums
}
from
"
@alboneon/library/types/Enums
"
import
GameSystem
=
Enums
.
GameSystem
;
import
GameSystem
=
Enums
.
GameSystem
;
import
{
describe
,
it
,
test
}
from
"
@jest/globals
"
import
{
expect
}
from
"
expect
"
test
(
"
Test Pathfinder Weights
"
,
()
=>
{
test
(
"
Test Pathfinder Weights
"
,
()
=>
{
[
Enums
.
Size
.
FINE
,
[
Enums
.
Size
.
FINE
,
...
@@ -25,6 +27,7 @@ test("Test Pathfinder Weights", () => {
...
@@ -25,6 +27,7 @@ test("Test Pathfinder Weights", () => {
})
})
PathfinderCarryingCapacities
[
Enums
.
CarryLoad
.
MEDIUM
].
forEach
((
expected
,
str
)
=>
{
PathfinderCarryingCapacities
[
Enums
.
CarryLoad
.
MEDIUM
].
forEach
((
expected
,
str
)
=>
{
try
{
try
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-ignore
expect
(
calculateWeight
(
str
,
Enums
.
GameSystem
.
Pathfinder
,
undefined
,
size
)).
toEqual
(
0
)
expect
(
calculateWeight
(
str
,
Enums
.
GameSystem
.
Pathfinder
,
undefined
,
size
)).
toEqual
(
0
)
}
catch
(
e
:
unknown
)
{
}
catch
(
e
:
unknown
)
{
...
@@ -34,7 +37,43 @@ test("Test Pathfinder Weights", () => {
...
@@ -34,7 +37,43 @@ test("Test Pathfinder Weights", () => {
})
})
})
})
})
})
it
(
"
should test pathfinder weights for > 29
"
,
async
function
()
{
[
Enums
.
Size
.
FINE
,
Enums
.
Size
.
DIMINUTIVE
,
Enums
.
Size
.
TINY
,
Enums
.
Size
.
SMALL
,
Enums
.
Size
.
MEDIUM
,
Enums
.
Size
.
LARGE
,
Enums
.
Size
.
HUGE
,
Enums
.
Size
.
GARGANTUAN
,
Enums
.
Size
.
COLOSSAL
]
.
forEach
((
size
)
=>
{
[
Enums
.
CarryLoad
.
LIGHT
,
Enums
.
CarryLoad
.
MEDIUM
,
Enums
.
CarryLoad
.
HEAVY
].
forEach
((
load
)
=>
{
expect
(
calculateWeight
(
30
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
20
]
*
4
*
size
)
expect
(
calculateWeight
(
31
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
21
]
*
4
*
size
)
expect
(
calculateWeight
(
32
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
22
]
*
4
*
size
)
expect
(
calculateWeight
(
33
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
23
]
*
4
*
size
)
expect
(
calculateWeight
(
34
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
24
]
*
4
*
size
)
expect
(
calculateWeight
(
35
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
25
]
*
4
*
size
)
expect
(
calculateWeight
(
36
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
26
]
*
4
*
size
)
expect
(
calculateWeight
(
37
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
27
]
*
4
*
size
)
expect
(
calculateWeight
(
38
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
28
]
*
4
*
size
)
expect
(
calculateWeight
(
39
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
29
]
*
4
*
size
)
expect
(
calculateWeight
(
40
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
20
]
*
16
*
size
)
expect
(
calculateWeight
(
41
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
21
]
*
16
*
size
)
expect
(
calculateWeight
(
42
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
22
]
*
16
*
size
)
expect
(
calculateWeight
(
43
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
23
]
*
16
*
size
)
expect
(
calculateWeight
(
44
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
24
]
*
16
*
size
)
expect
(
calculateWeight
(
45
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
25
]
*
16
*
size
)
expect
(
calculateWeight
(
46
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
26
]
*
16
*
size
)
expect
(
calculateWeight
(
47
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
27
]
*
16
*
size
)
expect
(
calculateWeight
(
48
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
28
]
*
16
*
size
)
expect
(
calculateWeight
(
49
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
29
]
*
16
*
size
)
expect
(
calculateWeight
(
50
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
20
]
*
64
*
size
)
expect
(
calculateWeight
(
60
,
Enums
.
GameSystem
.
Pathfinder
,
load
,
size
)).
toEqual
(
PathfinderCarryingCapacities
[
load
][
20
]
*
256
*
size
)
})
})
})
test
(
"
Test DND5E Weights
"
,
()
=>
{
test
(
"
Test DND5E Weights
"
,
()
=>
{
[
Enums
.
Size
.
FINE
,
[
Enums
.
Size
.
FINE
,
Enums
.
Size
.
DIMINUTIVE
,
Enums
.
Size
.
DIMINUTIVE
,
...
...
This diff is collapsed.
Click to expand it.
packages/library/helpers/CharacterHelpers.ts
+
11
−
1
View file @
43a9d3a7
...
@@ -113,7 +113,17 @@ export function calculateWeight(str: number, system: Enums.GameSystem, acceptedL
...
@@ -113,7 +113,17 @@ export function calculateWeight(str: number, system: Enums.GameSystem, acceptedL
return
0
return
0
}
}
if
(
system
===
Enums
.
GameSystem
.
Pathfinder
)
{
if
(
system
===
Enums
.
GameSystem
.
Pathfinder
)
{
if
(
str
<
PathfinderCarryingCapacities
[
acceptedLoad
].
length
)
{
return
PathfinderCarryingCapacities
[
acceptedLoad
][
str
]
*
size
return
PathfinderCarryingCapacities
[
acceptedLoad
][
str
]
*
size
}
let
localStr
=
str
-
20
let
modifier
=
1
while
(
localStr
>=
10
)
{
modifier
*=
4
localStr
-=
10
}
const
baseValue
=
(
str
%
10
+
20
)
return
PathfinderCarryingCapacities
[
acceptedLoad
][
baseValue
]
*
modifier
*
size
}
else
{
}
else
{
let
multiplier
=
0
let
multiplier
=
0
switch
(
acceptedLoad
)
{
switch
(
acceptedLoad
)
{
...
...
This diff is collapsed.
Click to expand it.
Semantic Release
@semantic-release
mentioned in commit
28936dfa
·
2 years ago
mentioned in commit
28936dfa
mentioned in commit 28936dfaa5aaffc11c9b6a4892d038cf6a7934fc
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment