mirror of
https://github.com/morbalint/kemkas.git
synced 2026-07-17 19:03:46 +00:00
fix picking specializations
This commit is contained in:
@@ -15,20 +15,22 @@ function HarcosFegyverSpecializacio(props: {
|
|||||||
szint
|
szint
|
||||||
} = props
|
} = props
|
||||||
const fegyver = GetFegyver(specialization)
|
const fegyver = GetFegyver(specialization)
|
||||||
const hasError = existingSpecializations.filter(x => x === specialization).length > (szint < 9 ? 1 : 2)
|
const pickableFegyverek = fegyverek.data.filter(f => f.Id === specialization || existingSpecializations.filter(x => x === f.Id).length < (szint < 9 ? 1 : 2))
|
||||||
|
const kozelharciPickable = pickableFegyverek.filter(f => f.Type === 'kozelharci')
|
||||||
|
const tavolsagiPickable = pickableFegyverek.filter(f => f.Type === 'lofegyver')
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<div className='row m-2'>
|
<div className='row m-2'>
|
||||||
<label className='col-md-2 col-sm-3 col-form-label' >Fegyver specializáció</label>
|
<label className='col-md-2 col-sm-3 col-form-label' >Fegyver specializáció</label>
|
||||||
<select className='col form-select' value={fegyver?.Id || defaultFegyverID} onChange={e => changeSpecialization(e.target.value)}>
|
<select className='col form-select' value={fegyver?.Id || defaultFegyverID} onChange={e => changeSpecialization(e.target.value)}>
|
||||||
<optgroup label="Közelharci">
|
<optgroup label="Közelharci">
|
||||||
{fegyverek.data.filter(f => f.Type === 'kozelharci').map(f => <option key={f.Id} value={f.Id}>{f.Name}</option>)}
|
{kozelharciPickable.map(f => <option key={`spec-${szint}-${f.Id}`} value={f.Id}>{f.Name}</option>)}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="Távolsági">
|
<optgroup label="Távolsági">
|
||||||
{fegyverek.data.filter(f => f.Type === 'lofegyver').map(f => <option key={f.Id} value={f.Id}>{f.Name}</option>)}
|
{tavolsagiPickable.map(f => <option key={`spec-${szint}-${f.Id}`} value={f.Id}>{f.Name}</option>)}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
{fegyver == null && <span className='form-field-error'>Ismeretlen fegyver: {specialization}</span>}
|
{fegyver == null && <span className='form-field-error'>Ismeretlen fegyver: {specialization}</span>}
|
||||||
{hasError && <span className='form-field-error'>Már {szint < 9 ? '' : 'kétszer is'} választottad ezt a fegyvert!</span>}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,20 +14,19 @@ function KalozKritikus(props: {
|
|||||||
changeKrit,
|
changeKrit,
|
||||||
szint
|
szint
|
||||||
} = props
|
} = props
|
||||||
const hasError = existingKrits.filter(x => x === kritFegyverId).length > (szint < 9 ? 1 : 2)
|
const fegyverek = AllowedFegyver(Osztaly.Kaloz, []).filter(f => f.Id === kritFegyverId || existingKrits.filter(x => x === f.Id).length < (szint < 9 ? 1 : 2))
|
||||||
const fegyverek = AllowedFegyver(Osztaly.Kaloz, [])
|
|
||||||
return <>
|
return <>
|
||||||
<div className='row m-2'>
|
<div className='row m-2'>
|
||||||
<label className='col-md-2 col-sm-3 col-form-label'>Kritikus</label>
|
<label className='col-md-2 col-sm-3 col-form-label'>Kritikus</label>
|
||||||
<select className='col form-select' value={kritFegyverId} onChange={e => changeKrit(e.target.value)}>
|
<select className='col form-select' value={kritFegyverId} onChange={e => changeKrit(e.target.value)}>
|
||||||
<optgroup label="Közelharci">
|
<optgroup label="Közelharci">
|
||||||
{fegyverek.filter(f => f.Type === 'kozelharci').map(f => <option key={f.Id} value={f.Id}>{f.Name}</option>)}
|
{fegyverek.filter(f => f.Type === 'kozelharci').map(f => <option key={f.Id} value={f.Id}>{f.Name}</option>)}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="Távolsági">
|
<optgroup label="Távolsági">
|
||||||
{fegyverek.filter(f => f.Type === 'lofegyver').map(f => <option key={f.Id} value={f.Id}>{f.Name}</option>)}
|
{fegyverek.filter(f => f.Type === 'lofegyver').map(f => <option key={f.Id} value={f.Id}>{f.Name}</option>)}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
{hasError && <span className='form-field-error'>Már {szint < 9 ? '' : 'kétszer is'} választottad ezt a fegyvert!</span>}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ function LevelUp(props: {
|
|||||||
|
|
||||||
const specializationIndex = Math.floor((szint-1) / 2)
|
const specializationIndex = Math.floor((szint-1) / 2)
|
||||||
const specialization = karakter.harcosSpecializaciok[specializationIndex]
|
const specialization = karakter.harcosSpecializaciok[specializationIndex]
|
||||||
console.log(specialization)
|
|
||||||
const kritIndex = kalozKritIndex(szint)
|
const kritIndex = kalozKritIndex(szint)
|
||||||
const krit = karakter.kalozKritikus[kritIndex]
|
const krit = karakter.kalozKritikus[kritIndex]
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import {TulajdonsagIDs, TulajdonsagokTotal} from "./tulajdonsag";
|
|||||||
import {KarakterInputs} from "./karakter";
|
import {KarakterInputs} from "./karakter";
|
||||||
import {GetFajDetails} from "./faj";
|
import {GetFajDetails} from "./faj";
|
||||||
import {Osztaly} from "./osztaly";
|
import {Osztaly} from "./osztaly";
|
||||||
|
import fegyverek from "./fegyver.json"
|
||||||
|
import {AllowedFegyver} from "./allowed-fegyver";
|
||||||
|
|
||||||
|
export function PickableSpecializationFilter(existingSpecilizations: string[], szint: number) {
|
||||||
|
return (fegyver: {Id: string}) => existingSpecilizations.filter(x => x === fegyver.Id).length < (szint < 9 ? 1 : 2)
|
||||||
|
}
|
||||||
|
|
||||||
export function LevelUp(karakter: KarakterInputs, changeKarakter: (input: KarakterInputs) => void) {
|
export function LevelUp(karakter: KarakterInputs, changeKarakter: (input: KarakterInputs) => void) {
|
||||||
const tulajdonsagokTotal = TulajdonsagokTotal(karakter)
|
const tulajdonsagokTotal = TulajdonsagokTotal(karakter)
|
||||||
@@ -24,11 +29,13 @@ export function LevelUp(karakter: KarakterInputs, changeKarakter: (input: Karakt
|
|||||||
}
|
}
|
||||||
let harcosSpecializaciok = karakter.harcosSpecializaciok
|
let harcosSpecializaciok = karakter.harcosSpecializaciok
|
||||||
if(karakter.osztaly === Osztaly.Harcos && szint % 2 === 1) {
|
if(karakter.osztaly === Osztaly.Harcos && szint % 2 === 1) {
|
||||||
harcosSpecializaciok = [...harcosSpecializaciok, "csatabard"]
|
const nextPickableFegyverId = fegyverek.data.filter(PickableSpecializationFilter(karakter.harcosSpecializaciok, karakter.szint))[0].Id
|
||||||
|
harcosSpecializaciok = [...harcosSpecializaciok, nextPickableFegyverId]
|
||||||
}
|
}
|
||||||
let kalozKritikus = karakter.kalozKritikus
|
let kalozKritikus = karakter.kalozKritikus
|
||||||
if(karakter.osztaly === Osztaly.Kaloz && szint % 3 === 0) {
|
if(karakter.osztaly === Osztaly.Kaloz && szint % 3 === 0) {
|
||||||
kalozKritikus = [...kalozKritikus, "szablya"]
|
const nextPickableFegyverId = AllowedFegyver(Osztaly.Kaloz, []).filter(PickableSpecializationFilter(karakter.kalozKritikus, szint))[0].Id
|
||||||
|
kalozKritikus = [...kalozKritikus, nextPickableFegyverId]
|
||||||
}
|
}
|
||||||
changeKarakter({...karakter, szint, hpRolls, tulajdonsagNovelesek, harcosSpecializaciok, kalozKritikus})
|
changeKarakter({...karakter, szint, hpRolls, tulajdonsagNovelesek, harcosSpecializaciok, kalozKritikus})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user