Every trivia session in TriviaPP puts the player through 10 Star Wars questions drawn from two sources: a curated bank of classic lore questions and dynamically generated challenges built from live SWAPI data. Questions appear one at a time. The player selects one of four options, receives instant feedback, and then moves to the next question. Once all 10 questions are answered the session ends, the score is saved to both local storage and Firebase Firestore, and a game-over screen is displayed with the final result.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dreancaste/TriviaPP/llms.txt
Use this file to discover all available pages before exploring further.
TriviaPP’s UI and all in-game text — questions, feedback messages, and labels — are written in Spanish.
Session Structure
Each game is exactly 10 questions long (totalQuestions = 10). A progress bar driven by progressValue = questionNumber / totalQuestions gives players a visual sense of how far through the session they are.
Correct answers are worth 100 points each, so a perfect game yields a maximum score of 1 000 points. After every answer the app displays a feedback message:
- Correct —
"¡Correcto, joven padawan!" - Incorrect —
"Incorrecto. La respuesta era: <correct answer>"— the right answer is revealed immediately.
Question Categories
Questions belong to one of four categories depending on how they are generated:| Category | Source | Description |
|---|---|---|
| Lore | Hardcoded array | Classic Star Wars knowledge — masters, planets, factions, and key saga events |
| Personajes | SWAPI /people page 1 | ”¿De qué planeta es [character]?” — homeworld lookup per character |
| Planetas | SWAPI /planets page 1 | ”¿Cuál es el clima de [planet]?” — climate translated from English to Spanish via MyMemory API |
| Películas | SWAPI /films | ”¿Quién dirigió la película ‘[film title]’?” — director drawn from all SWAPI films |
Question Generation Logic
TriviaService.generateQuestion() uses a 60 / 40 probability split on every call:
- 60 % of the time (
random < 0.6) it draws from the internalloreQuestionsarray — 19 hand-crafted questions covering masters, Sith names, planets, orders, and characters. - 40 % of the time it picks at random among three live-data generators:
generatePeopleQuestion(),generatePlanetQuestion(), andgenerateFilmQuestion(). Each generator fetches data from SWAPI at runtime and builds a question with four shuffled options usingbuildUniqueOptions().
usedQuestionKeys string array. Every question’s question string is stored in this array after it is served. Subsequent calls skip any question whose key is already present. If the entire loreQuestions bank is exhausted within a single session, usedQuestionKeys is automatically reset and the pool is re-used from the start. At the beginning of each new game TriviaService.resetUsedQuestions() clears the array entirely.
Scoring and State
TriviaPage tracks the full session state through the following properties:
| Property | Type | Purpose |
|---|---|---|
score | number | Running point total (increments by 100 per correct answer) |
questionNumber | number | 1-based index of the current question |
totalQuestions | number | Fixed at 10 |
correctCount | number | Count of correct answers in the session |
answered | boolean | Locks options after the player selects one |
selectedAnswer | string | The option the player tapped |
feedback | string | Message shown after an answer is submitted |
loading | boolean | true while a new question is being fetched |
gameFinished | boolean | true after the 10th question is answered |
TriviaQuestion model used throughout the service and page is:
Game End
When the player answers the 10th question,TriviaPage.finishGame() is called. It performs four write operations in sequence:
- History — a
HistoryItemobject (date, score, correct answers, total questions) is prepended to the local history array viaStorageService.addHistory(). - Local ranking — a
RankingItemobject (display name, score) is upserted into the local top-20 list viaStorageService.addRankingItem(). - Cumulative stats —
StorageService.updateStats(score, correctCount)incrementsgamesPlayed, accumulatescorrectAnswers, and updatesmaxScoreif the new score is a personal best. - Firebase —
RankingService.addScore(displayName, score)writes the entry to therankingcollection in Firestore with today’s ISO date (YYYY-MM-DD).
StorageService.getProfile().displayName, falling back to "Jugador" if no name has been set.
Haptic Feedback
If the player has enabled the vibration on error setting in their profile (profile.vibrateOnError === true), a heavy haptic impact fires every time a wrong answer is submitted:
@capacitor/haptics plugin and only produces physical feedback on a real device.