Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skill Calculation Error #115

Open
Doomcard10 opened this issue May 3, 2020 · 1 comment
Open

Skill Calculation Error #115

Doomcard10 opened this issue May 3, 2020 · 1 comment

Comments

@Doomcard10
Copy link

There's an error when calculating the costs for skills, and I've figured out exactly what's happening, but not entirely sure why. If a skill's total is 1-59, it calculates as normal, with it costing 1 CP per level in the skill. However, for a skill total of 60+, it counts it only as 1 CP for every skill point after 60.

For example, if you bring a skill to 65, the site only counts it as 5 CP being spent. Bringing the skill to 60 has the same effect as keeping it at a total of 0.

My theory for why this is happening is that perhaps an if-statement in the code has gone wrong? I'd guess you coded it so that it calculates differently for stats higher than 60, but maybe in detecting that you've caused it to ignore the first 59 points?

@EmperorArthur
Copy link
Collaborator

Okay, this may take me a bit. Partly because it's complicated, and partly because I'm in the middle of converting the code to Laravel. Which will massively increase maintainability, and should massively reduce your save file size. Let me see what I can do really quickly though.

Determining the final value is easy enough. That's done here. That calculation looks something like:

Aptitude = min(Aptitude + Aptitude Background Modifier + Aptitude Faction Modifier , Aptitude Maximum for Ego) + Aptitude Software Modifier + Aptitude Psi Sleight Modifier

Skill Ego Value = Base + Aptitude + Natural Language Bonus + Skill Trait Modifier + Skill Background Modifier + Skill Faction Modifier, Skill Maximum for Ego + Skill Software Modifier + Skill Psi Sleight Modifier.

Skill Morph Value = Skill Morph Modifier + Skill Ego Value

Now skill costs are calculated here. Importantly the total skill value for calculating costs looks something like:

Aptitude = min(Aptitude + Aptitude Background Modifier + Aptitude Faction Modifier , Aptitude Maximum for Ego)

Skill = Base + Aptitude + Skill Background Modifier + Skill Faction Modifier

We can see two things pretty clearly from this. First, there are a surprising number of bonuses that have to be managed under the hood to determine how much something costs. Second, if you have any bonuses from things like software or traits, those are applied after the amount of points put into the skill. That's because I couldn't find the correct answer to the order question in the rules and this is how the original creators did it years ago.

That may seem to have been what was causing the problem. On the other hand, there is a logic error in this piece of code:

$newLimit =  60 - $bonusValue;
$underLimitCost = $newLimit * 1;
$overLimitCost = $baseValue - $newLimit * 2;
return $underLimitCost + $overLimitCost;

Modified to add constants instead of config values.

Specifically, that second to last line should look like:

$overLimitCost = ($baseValue - $newLimit) * 2;

Fortunately, this is a relatively easy fix, so it shouldn't take long for me to test and deploy it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants