add pancel and pajzs VO to pdf

This commit is contained in:
2023-10-10 20:13:07 +00:00
parent 199127843b
commit 4d58cc2b6a
8 changed files with 112 additions and 22 deletions
+29 -3
View File
@@ -1,13 +1,14 @@
import pancel from "./pancel.json"
import pancelok from './pancel.json'
import pajzsok from './pajzs.json'
export type PancelType = keyof typeof pancel
export type PancelType = 'konnyu' | 'kozepes' | 'nehez'
export const PancelTypes: PancelType[] = ['konnyu', 'kozepes', 'nehez']
export interface Pancel {
ID: string,
Name: string,
Type: 'konnyu' | 'kozepes' | 'nehez'
Type: PancelType
VO: number,
Price: number,
}
@@ -55,4 +56,29 @@ export function PancelTypeLabel(type: PancelType): string {
result = 'Egyéb páncél'
}
return result
}
export function GetPancel(id?: string): Pancel | undefined {
if (id == null) {
return undefined
}
const filteredPancel = pancelok['pancel'].filter(p => p.ID === id) as Pancel[]
return filteredPancel.length > 0 ? filteredPancel[0] : undefined
}
export function MaxAbilityVO(p: PancelType) {
switch(p){
case 'konnyu': return 3;
case 'kozepes': return 2;
case 'nehez': return 1;
default: return 9999;
}
}
export function GetPajzs(id?: string): Pajzs | undefined {
if (id == null) {
return undefined
}
const filtered = pajzsok['pajzs'].filter(p => p.ID === id) as Pajzs[]
return filtered.length > 0 ? filtered[0] : undefined
}
+14 -4
View File
@@ -4,6 +4,7 @@ import {KarakterInputs} from "./karakter";
import {Modifier} from "./tulajdonsag";
import {CelzoTB, KozelharciTB} from "./tamadas_bonusz";
import {Faj} from "./faj";
import { GetPajzs, GetPancel, MaxAbilityVO } from "./felszereles";
export interface MasodlagosErtekekView {
HP: number
@@ -13,7 +14,7 @@ export interface MasodlagosErtekekView {
Mentok: Mentok
}
export type KarakterpickForMasodlagosErtekek = Pick<KarakterInputs, 'osztaly' | 'hpRolls' | 'tulajdonsagok' | 'szint' | 'faj'>
export type KarakterpickForMasodlagosErtekek = Pick<KarakterInputs, 'osztaly' | 'hpRolls' | 'tulajdonsagok' | 'szint' | 'faj' | 'felszereles'>
export function BaseHP(osztaly: Osztaly) {
let base = 4;
@@ -49,20 +50,29 @@ export function HP(karakter: Pick<KarakterInputs, 'osztaly' | 'tulajdonsagok' |
.reduce((sum, val) => sum + val, 0)
}
export function VO(karakter: Pick<KarakterInputs, 'tulajdonsagok' | 'faj' | 'osztaly' | 'szint'>): number {
let vo = 10 + Modifier(karakter.tulajdonsagok.t_ugy)
export function VO(karakter: Pick<KarakterInputs, 'tulajdonsagok' | 'faj' | 'osztaly' | 'szint' | 'felszereles'>): number {
const pancel = GetPancel(karakter.felszereles.pancelID)
const pancelVO = pancel?.VO ?? 0
const pajzsVO = GetPajzs(karakter.felszereles.pajzsID)?.VO ?? 0
let vo = 10 + pajzsVO + pancelVO
let abilityVO = Modifier(karakter.tulajdonsagok.t_ugy)
if (karakter.osztaly === Osztaly.Kaloz) {
vo += Math.floor(karakter.szint / 3)
}
if (karakter.osztaly === Osztaly.Amazon) {
if (karakter.tulajdonsagok.t_kar > karakter.tulajdonsagok.t_ugy) {
vo = 10 + Modifier(karakter.tulajdonsagok.t_kar)
abilityVO = Modifier(karakter.tulajdonsagok.t_kar)
}
vo += Math.floor(karakter.szint / 2)
}
if (karakter.faj === Faj.Felszerzet){
vo += 1
}
if (pancel) {
abilityVO = Math.min(MaxAbilityVO(pancel.Type), abilityVO)
}
vo += abilityVO
return vo
}
+28
View File
@@ -1,3 +1,6 @@
import { GetPancel, KarakterFelszereles, Pancel, PancelType } from "./felszereles";
import pancelok from './pancel.json'
export enum Osztaly {
Harcos = 'o_harcos',
Ijasz = 'o_ijasz',
@@ -10,6 +13,31 @@ export enum Osztaly {
Illuzionista = 'o_illuzionista',
}
export function OsztalyAllowedPancelTypes(o: Osztaly): PancelType[] {
switch (o) {
case Osztaly.Amazon: return ['konnyu'];
case Osztaly.Barbar: return ['konnyu', 'kozepes', 'nehez'];
case Osztaly.Pap: return ['konnyu', 'kozepes', 'nehez'];
case Osztaly.Illuzionista: return [];
case Osztaly.Varazslo: return [];
case Osztaly.Harcos: return ['konnyu', 'kozepes', 'nehez'];
case Osztaly.Ijasz: return ['konnyu', 'kozepes'];
case Osztaly.Kaloz: return ['konnyu', 'kozepes'];
case Osztaly.Tolvaj: return ['konnyu']
}
}
export function SetFelszerelesForChangedOsztaly(o: Osztaly, felszereles: KarakterFelszereles, changeFelszereles: (f: KarakterFelszereles) => void) {
const allowedPancelTypes = OsztalyAllowedPancelTypes(o)
const pancel = GetPancel(felszereles.pancelID)
if (pancel && !allowedPancelTypes.includes(pancel.Type)) {
changeFelszereles({...felszereles, pancelID: undefined})
}
if (allowedPancelTypes.length === 0 && !!felszereles.pajzsID){
changeFelszereles({...felszereles, pajzsID: undefined})
}
}
export function OsztalyLabel(osztaly: Osztaly) : string {
switch (osztaly) {
case Osztaly.Amazon: return 'Amazon';
+3 -7
View File
@@ -1,5 +1,5 @@
{
"konnyu": [
"pancel": [
{
"ID": "tomott",
"Name": "Tömött",
@@ -34,9 +34,7 @@
"Type": "konnyu",
"VO": 4,
"Price": 50
}
],
"kozepes": [
},
{
"ID": "pikkelyvert",
"Name": "Pikkelyvért",
@@ -57,9 +55,7 @@
"Type": "kozepes",
"VO": 5,
"Price": 100
}
],
"nehez": [
},
{
"ID": "racsvert",
"Name": "Rácsvért",