2021-03-31 06:45:21 +02:00
|
|
|
import { calculateIntelligenceBonus } from "../../PersonObjects/formulas/intelligence";
|
|
|
|
import { CONSTANTS } from "../../Constants";
|
|
|
|
|
|
|
|
export interface ICrime {
|
2021-09-05 01:09:30 +02:00
|
|
|
hacking_success_weight: number;
|
|
|
|
strength_success_weight: number;
|
|
|
|
defense_success_weight: number;
|
|
|
|
dexterity_success_weight: number;
|
|
|
|
agility_success_weight: number;
|
|
|
|
charisma_success_weight: number;
|
|
|
|
difficulty: number;
|
2021-03-31 06:45:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IPerson {
|
2021-11-05 22:12:52 +01:00
|
|
|
hacking: number;
|
2021-09-05 01:09:30 +02:00
|
|
|
strength: number;
|
|
|
|
defense: number;
|
|
|
|
dexterity: number;
|
|
|
|
agility: number;
|
|
|
|
charisma: number;
|
|
|
|
intelligence: number;
|
|
|
|
crime_success_mult: number;
|
2021-03-31 06:45:21 +02:00
|
|
|
}
|
|
|
|
|
2021-09-09 05:47:34 +02:00
|
|
|
export function calculateCrimeSuccessChance(crime: ICrime, person: IPerson): number {
|
2021-09-05 01:09:30 +02:00
|
|
|
let chance: number =
|
2021-11-05 22:12:52 +01:00
|
|
|
crime.hacking_success_weight * person.hacking +
|
2021-09-05 01:09:30 +02:00
|
|
|
crime.strength_success_weight * person.strength +
|
|
|
|
crime.defense_success_weight * person.defense +
|
|
|
|
crime.dexterity_success_weight * person.dexterity +
|
|
|
|
crime.agility_success_weight * person.agility +
|
|
|
|
crime.charisma_success_weight * person.charisma +
|
|
|
|
CONSTANTS.IntelligenceCrimeWeight * person.intelligence;
|
|
|
|
chance /= CONSTANTS.MaxSkillLevel;
|
|
|
|
chance /= crime.difficulty;
|
|
|
|
chance *= person.crime_success_mult;
|
|
|
|
chance *= calculateIntelligenceBonus(person.intelligence);
|
2021-03-31 06:45:21 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
return Math.min(chance, 1);
|
|
|
|
}
|