⚙️ Beállítások
-
- {/* Pontszám */}
-
-
- updateField('points', parseInt(e.target.value) || 0)}
- className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-success)] focus:border-transparent outline-none transition-all duration-200"
- min="0"
- max="1000"
- />
-
+
+
+
+ {/* Pontszám */}
+
+
+
+
- {/* Időlimit */}
+ {/* Időlimit */}
+
+
+
+
+
+ {/* Karakterlimit (csak szöveges válasznál) */}
+ {card.subType === 'text' && (
+
+
+
+
+ )}
+
+
+ {/* Magyarázat */}
+
+
+
+
+
+
+ {/* Hamarosan elérhető felület */}
+
+
+
+ 🚧 Hamarosan elérhető
+
+
+
+
+
+
+ {/* Következmények (helyes válasz esetén) */}
+
+
+ 🎯 Következmények (helyes válasz esetén)
+
+
+
+ {/* Consequence Type */}
+
+ {consequenceTypes.find(t => t.value === (card.consequence?.type ?? 0))?.description}
+
- {/* Karakterlimit (csak szöveges válasznál) */}
- {card.subType === 'text' && (
+ {/* Consequence Value - csak ha előre/hátra lépés */}
+ {(card.consequence?.type === 0 || card.consequence?.type === 1) && (
updateField('characterLimit', parseInt(e.target.value) || 0)}
+ value={card.consequence?.value ?? 1}
+ onChange={(e) => updateConsequence('value', parseInt(e.target.value) || 1)}
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-success)] focus:border-transparent outline-none transition-all duration-200"
- min="10"
- max="500"
+ min="1"
+ max="10"
/>
)}
+
- {/* Magyarázat */}
-
-
-
diff --git a/SerpentRace_Frontend/src/components/PopUp/DeckInfoPopUp.jsx b/SerpentRace_Frontend/src/components/PopUp/DeckInfoPopUp.jsx
index 9d5ed97f..1db050ea 100644
--- a/SerpentRace_Frontend/src/components/PopUp/DeckInfoPopUp.jsx
+++ b/SerpentRace_Frontend/src/components/PopUp/DeckInfoPopUp.jsx
@@ -32,7 +32,7 @@ export default function DeckInfoPopUp({ deck, onClose }) {
const deckTypes = {
"Luck": { label: "Szerencse", color: "var(--color-luck)" },
"Question": { label: "Kérdés", color: "var(--color-question)" },
- "Fun": { label: "Szórakozás", color: "var(--color-fun)" }
+ "Fun": { label: "Joker", color: "var(--color-fun)" }
}
const currentDeckType = deckTypes[deck.type] || { label: deck.type, color: "var(--color-success)" }
diff --git a/SerpentRace_Frontend/src/index.css b/SerpentRace_Frontend/src/index.css
index a73bc306..e6db465c 100644
--- a/SerpentRace_Frontend/src/index.css
+++ b/SerpentRace_Frontend/src/index.css
@@ -31,7 +31,7 @@
/* Deck típus színek */
--color-luck: #5fa985; /* zöld, mint a success */
--color-question: #4f7be6; /* új kék, illik az oldalhoz */
- --color-fun: #e15b64; /* piros, mint az error */
+ --color-fun: #FFD700; /* citromsárga a joker kártyákhoz */
/* Háttérszínek */
--color-background: #181d23;
diff --git a/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx b/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx
index c7d30afa..5226cc2e 100644
--- a/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx
+++ b/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx
@@ -8,7 +8,7 @@ import DeckHeader from "../../components/DeckCreator/DeckHeader.jsx"
import CardsList from "../../components/DeckCreator/CardsList.jsx"
import CardEditor from "../../components/DeckCreator/CardEditor.jsx"
import { createDeck } from '../../api/deckApi'
-import { notifySuccess, notifyError } from "../../components/Toastify/toastifyServices"
+import { notifySuccess, notifyError, notifyWarning } from "../../components/Toastify/toastifyServices"
export default function DeckCreator() {
const { deckId } = useParams() // URL-ből deck ID (új deck esetén undefined)
@@ -17,8 +17,8 @@ export default function DeckCreator() {
// Deck alapadatok
const [deck, setDeck] = useState({
id: null,
- name: "Új Deck",
- type: "Question", // Question, Luck, Fun
+ name: "Új Pakli",
+ type: "QUESTION", // QUESTION, LUCK, JOKER - backend formátum
privacy: "private", // private, public
description: "",
cards: []
@@ -27,17 +27,17 @@ export default function DeckCreator() {
// UI állapotok
const [selectedCard, setSelectedCard] = useState(null)
const [isCreatingCard, setIsCreatingCard] = useState(false)
- const [newCardType, setNewCardType] = useState(null) // task, joker, luck
+ const [newCardType, setNewCardType] = useState(null)
- // Betöltés (később API-ból)
+ // Betöltés API-ból
useEffect(() => {
if (deckId) {
loadDeck(deckId)
} else {
setDeck({
id: null,
- name: "Új Deck",
- type: "Question",
+ name: "Új Pakli",
+ type: "QUESTION",
privacy: "private",
description: "",
cards: []
@@ -45,55 +45,25 @@ export default function DeckCreator() {
}
}, [deckId])
- const loadDeck = async (id) => {
- // Mock deck betöltés
- const mockDeck = {
- id: id,
- name: "Quiz Night",
- type: "Question",
- privacy: "public",
- description: "Szórakoztató kvíz este",
- cards: [
- {
- id: 1,
- type: "task",
- subType: "quiz",
- question: "Mi Magyarország fővárosa?",
- options: ["Budapest", "Debrecen", "Szeged", "Pécs"],
- correctAnswer: 0,
- points: 10,
- timeLimit: 30,
- explanation: "Budapest 1873 óta Magyarország fővárosa."
- },
- {
- id: 2,
- type: "task",
- subType: "truefalse",
- statement: "A Duna Magyarország leghosszabb folyója.",
- isTrue: false,
- points: 5,
- timeLimit: 15,
- explanation: "A Tisza a leghosszabb folyó Magyarországon."
- }
- ]
- }
- setDeck(mockDeck)
- }
-
const handleDeckUpdate = (updates) => {
setDeck(prev => ({ ...prev, ...updates }))
}
const handleSaveDeck = async () => {
try {
- console.log("Deck mentése:", deck)
-
+ // Konvertálás: Frontend string -> Backend enum number
+ const typeMapping = {
+ 'LUCK': 0,
+ 'JOKER': 1,
+ 'QUESTION': 2
+ }
+
const payload = {
name: deck.name,
- type: (deck.type || 'Question').toString().toUpperCase(),
+ type: typeMapping[deck.type] ?? 2, // Alapértelmezett: QUESTION
ctype: deck.privacy === 'public' ? 'PUBLIC' : 'PRIVATE',
description: deck.description || '',
- cards: deck.cards.map(c => ({ ...c, text: c.question || c.statement || c.text || '' }))
+ cards: deck.cards
}
const saved = await createDeck(payload)
@@ -131,28 +101,64 @@ export default function DeckCreator() {
}
const handleSaveCard = (cardData) => {
- if (isCreatingCard) {
- // Új kártya hozzáadása
- const newCard = {
+ try {
+ // Biztosítjuk az alapértelmezett consequence értékeket
+ const defaultConsequence = { type: 0, value: 1 }
+ const defaultWrongConsequence = { type: 1, value: 1 }
+
+ const updatedCard = {
...cardData,
- id: Date.now(), // Temporary ID
+ id: isCreatingCard ? Date.now() : cardData.id,
+ consequence: cardData.consequence || defaultConsequence,
+ // wrongConsequence csak QUESTION és JOKER típusoknál
+ ...(cardData.type === 'QUESTION' || cardData.type === 'JOKER'
+ ? { wrongConsequence: cardData.wrongConsequence || defaultWrongConsequence }
+ : {}
+ )
}
- setDeck(prev => ({
- ...prev,
- cards: [...prev.cards, newCard]
- }))
+
+ let wasInvalidCardDeleted = false
+
+ setDeck(prev => {
+ // Ellenőrizzük, vannak-e nem megfelelő típusú kártyák
+ const invalidCards = prev.cards.filter(card => card.type !== prev.type)
+
+ // Ha új kártyát mentünk megfelelő típussal és vannak nem megfelelők
+ if (isCreatingCard && cardData.type === prev.type && invalidCards.length > 0) {
+ wasInvalidCardDeleted = true
+
+ return {
+ ...prev,
+ cards: [
+ ...prev.cards.filter(card => card.type === prev.type),
+ updatedCard
+ ]
+ }
+ }
+
+ // Alap mentési logika
+ return {
+ ...prev,
+ cards: isCreatingCard
+ ? [...prev.cards, updatedCard]
+ : prev.cards.map(card => card.id === updatedCard.id ? updatedCard : card)
+ }
+ })
+
+ setSelectedCard(updatedCard)
setIsCreatingCard(false)
setNewCardType(null)
- setSelectedCard(newCard)
- } else {
- // Meglévő kártya frissítése
- setDeck(prev => ({
- ...prev,
- cards: prev.cards.map(card =>
- card.id === cardData.id ? cardData : card
- )
- }))
- setSelectedCard(cardData)
+
+ // Csak egy értesítés
+ if (wasInvalidCardDeleted) {
+ const invalidCount = deck.cards.filter(card => card.type !== deck.type).length
+ notifyWarning(`Kártya mentve! ${invalidCount} db nem megfelelő típusú kártya törlésre került.`)
+ } else {
+ notifySuccess('Kártya sikeresen mentve!')
+ }
+ } catch (error) {
+ console.error('Kártya mentési hiba:', error)
+ notifyError('Hiba történt a kártya mentése során')
}
}
@@ -188,6 +194,7 @@ export default function DeckCreator() {
{
setIsCreatingCard(false)