diff --git a/Kemkas.Web/frontend/src/second-edition/components/LevelUps.tsx b/Kemkas.Web/frontend/src/second-edition/components/LevelUps.tsx index 364017a..55017bc 100644 --- a/Kemkas.Web/frontend/src/second-edition/components/LevelUps.tsx +++ b/Kemkas.Web/frontend/src/second-edition/components/LevelUps.tsx @@ -7,7 +7,9 @@ import {arraySetN} from "../../util"; import {Osztaly2E} from "../domain-models/osztaly2E"; import KalozKritikus from "./KalozKritikus"; import HarcosFegyverSpecializacio from "./HarcosFegyverSpec"; -import {BasicOsztalySelector2E} from "./OsztalySelector2E"; + +import MultiClassOsztalySelector2E from "./MultiClassOsztalySelector2E"; +import {getClassLevels} from "../domain-models/szintlepes"; function LevelUp(props: { szint: number, @@ -30,22 +32,30 @@ function LevelUp(props: { changeOsztaly } = props - const harcosSzint = karakter.szintlepesek.filter(x => x.osztaly === Osztaly2E.Harcos).length - const kalozSzint = karakter.szintlepesek.filter(x => x.osztaly === Osztaly2E.Tengeresz).length + const classLevels = getClassLevels(karakter.szintlepesek) + + const harcosSzint = classLevels[Osztaly2E.Harcos] + const kalozSzint = classLevels[Osztaly2E.Tengeresz] const specialization = karakter.szintlepesek[szint-1].harcosFegyver const krit = karakter.szintlepesek[szint-1].kalozKritikus - + return
{szint}. Szint
- - {szint % 4 === 0 - && } + {osztaly !== Osztaly2E.Druida && + } + {szint % 4 === 0 && + } } - {osztaly === Osztaly2E.Tengeresz && kalozSzint % 3 === 0 && !!krit && + {osztaly === Osztaly2E.Tengeresz && kalozSzint % 3 === 0 && x.kalozKritikus)} changeKrit={changeKalozKritikus} szint={kalozSzint} diff --git a/Kemkas.Web/frontend/src/second-edition/components/MultiClassOsztalySelector2E.tsx b/Kemkas.Web/frontend/src/second-edition/components/MultiClassOsztalySelector2E.tsx new file mode 100644 index 0000000..022ab6a --- /dev/null +++ b/Kemkas.Web/frontend/src/second-edition/components/MultiClassOsztalySelector2E.tsx @@ -0,0 +1,54 @@ +import {Faj2E, SzintKorlatokFajokra} from "../domain-models/faj2E"; +import {Osztaly2E, OsztalyLabel} from "../domain-models/osztaly2E"; +import React from "react"; + +function MultiClassOsztalySelector2E(props: { + faj: Faj2E, + osztaly: Osztaly2E, + changeOsztaly: (o: Osztaly2E) => void + osztalySzint: number +}) { + const {faj, osztaly, changeOsztaly, osztalySzint} = props + + return <> +
+
+
+ +
+ +
+
+
+
+
+ + {osztalySzint} +
+
+
+ +} + +export default MultiClassOsztalySelector2E \ No newline at end of file diff --git a/Kemkas.Web/frontend/src/second-edition/components/OsztalySelector2E.tsx b/Kemkas.Web/frontend/src/second-edition/components/OsztalySelector2E.tsx index f8f6cb5..b6d06be 100644 --- a/Kemkas.Web/frontend/src/second-edition/components/OsztalySelector2E.tsx +++ b/Kemkas.Web/frontend/src/second-edition/components/OsztalySelector2E.tsx @@ -8,16 +8,21 @@ import { } from "../domain-models/osztaly2E"; import {Faj2E, SzintKorlatokFajokra} from "../domain-models/faj2E"; -export function BasicOsztalySelector2E(props: {faj: Faj2E, osztaly: Osztaly2E, changeOsztaly: (osztaly: Osztaly2E) => void}) { - const {faj, osztaly, changeOsztaly} = props; +function OsztalySelector2E(props: { + currentFaj: Faj2E, + currentOsztaly: Osztaly2E, + changeOsztaly: (newOsztaly: Osztaly2E) => void +}) { + const {currentFaj, currentOsztaly, changeOsztaly} = props; + return <>
-
- -} - -function OsztalySelector2E(props: { - currentFaj: Faj2E, - currentOsztaly: Osztaly2E, - changeOsztaly: (newOsztaly: Osztaly2E) => void -}) { - const {currentFaj, currentOsztaly, changeOsztaly} = props; - - return <> -
diff --git a/Kemkas.Web/frontend/src/second-edition/domain-models/szintlepes.ts b/Kemkas.Web/frontend/src/second-edition/domain-models/szintlepes.ts index 5688de9..89436e8 100644 --- a/Kemkas.Web/frontend/src/second-edition/domain-models/szintlepes.ts +++ b/Kemkas.Web/frontend/src/second-edition/domain-models/szintlepes.ts @@ -56,8 +56,7 @@ export function LevelUp(karakter: Karakter2E, changeKarakter: (input: Karakter2E szintlepes.kalozKritikus = AllowedFegyver(Osztaly2E.Tengeresz).filter(specializationFilter)[0].Id } } - console.log(`picked harcos specializacio ${szintlepes.harcosFegyver}`) - console.log(`picked kaloz krit ${szintlepes.kalozKritikus}`) + changeKarakter({...karakter, szint, szintlepesek: [...karakter.szintlepesek, szintlepes]}) } @@ -68,4 +67,33 @@ export function LevelDown(karakter: Karakter2E, changeKarakter: (input: Karakter else { console.error(`Can't level down character: ${karakter}`) } +} + +export type ClassLevels = { + [key in Osztaly2E]: number; +}; + +const defaultClassLevels: ClassLevels = { + [Osztaly2E.Amazon]: 0, + [Osztaly2E.Barbar]: 0, + [Osztaly2E.Ijasz]: 0, + [Osztaly2E.Harcos]: 0, + [Osztaly2E.Tengeresz]: 0, + + [Osztaly2E.Tolvaj]: 0, + [Osztaly2E.Pap]: 0, + + [Osztaly2E.Varazslo]: 0, + [Osztaly2E.Illuzionista]: 0, + + [Osztaly2E.Dalnok]: 0, + [Osztaly2E.Druida]: 0, + [Osztaly2E.Vandor]: 0, +} + +export function getClassLevels(szintlepesek: Szintlepes[]) : ClassLevels { + return szintlepesek.map(x => x.osztaly).reduce((classLevels, osztaly) => { + classLevels[osztaly]++ + return classLevels + }, {...defaultClassLevels}) } \ No newline at end of file