Skip to content

Feat/frontend api#10

Merged
Rikublender3d merged 3 commits intomainfrom
feat/frontend-api
Dec 13, 2025
Merged

Feat/frontend api#10
Rikublender3d merged 3 commits intomainfrom
feat/frontend-api

Conversation

@Rikublender3d
Copy link
Copy Markdown
Contributor

@Rikublender3d Rikublender3d commented Dec 13, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Battle system with enemy selection and turn-based combat mechanics
    • Solo mode for gameplay challenges
    • User account creation flow and settings management
    • Experience points (XP) tracking and display on home screen
    • Battle completion results with rewards and navigation options

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR restructures the app from a tab-based layout to a linear navigation flow, removes old tab/explore screens and legacy UI components, introduces a battle system with player vs. enemy gameplay, adds user account creation, and simplifies the root navigation with a refreshed set of screens and themed components.

Changes

Cohort / File(s) Summary
Navigation & Layout Restructuring
frontend/app/_layout.tsx, frontend/app/index.tsx
Root layout simplified: removed tab/modal route declarations, updated font paths; home screen now initializes user data, fetches XP, and routes to user creation or battle/settings screens.
Battle System
frontend/app/battle.tsx, frontend/app/battle-game.tsx, frontend/app/battle-result.tsx, frontend/components/battle/EnemyCard.tsx
New battle feature: enemy list screen, main battle game with HP tracking and attack sequences, result screen displaying win/loss; EnemyCard component for enemy selection.
User Management & Onboarding
frontend/app/create-user.tsx
New user creation screen: validates and submits display name via API, handles success/error states with alerts, redirects to home.
Settings & Exploration Screens
frontend/app/settings.tsx, frontend/app/solo.tsx
Two new screens: settings page with home navigation button; solo mode placeholder with future camera/motion logic.
Common UI Components
frontend/components/common/BackButton.tsx, frontend/components/common/ScreenHeader.tsx
New reusable components: back button (bottom-centered) and screen title header for consistent UI.
Themed Component Replacements
frontend/components/themed/Text.tsx, frontend/components/themed/TextInput.tsx, frontend/components/themed/index.ts
New simplified theme-aware wrappers: Text and TextInput with default DotGothic16-Regular font applied; re-exported via index.
API Utilities
frontend/utils/api.ts
Refactored API layer: renamed getUser→getUsers, added getCurrentUser helper, shifted error handling to return dummy data instead of throwing; affects user fetch, enemy list, and battle log creation.
Component Deletions
frontend/app/(tabs)/_layout.tsx, frontend/app/(tabs)/explore.tsx, frontend/app/modal.tsx, frontend/components/external-link.tsx, frontend/components/haptic-tab.tsx, frontend/components/hello-wave.tsx, frontend/components/parallax-scroll-view.tsx, frontend/components/themed-text.tsx, frontend/components/themed-view.tsx, frontend/components/ui/collapsible.tsx, frontend/components/ui/icon-symbol.*
Removed legacy tab routing, explore screen, modal screen, and old UI component library (ExternalLink, HapticTab, HelloWave, ParallaxScrollView, ThemedText, ThemedView, Collapsible, IconSymbol).

Sequence Diagram

sequenceDiagram
    participant User
    participant BattleGame as Battle Game Screen
    participant State as Game State
    participant API as API Layer
    participant Router as Router

    User->>BattleGame: Load battle screen
    BattleGame->>API: getCurrentUser()
    API-->>BattleGame: User data + max HP from level
    BattleGame->>State: Initialize: playerHP, enemyHP, log
    
    User->>BattleGame: Player attack button
    BattleGame->>State: Calculate random damage
    BattleGame->>State: Apply damage to enemyHP
    BattleGame->>State: Log attack action
    
    alt Enemy Defeated
        BattleGame->>API: createBattleLog(duration, damage)
        API-->>BattleGame: Log saved
        BattleGame->>State: Set gameOver, winner=player
        BattleGame->>Router: Navigate to battle-result (won=true)
    else Enemy Survives
        BattleGame->>State: Schedule enemy counterattack (delay)
        BattleGame->>State: Calculate enemy damage
        BattleGame->>State: Apply damage to playerHP
        BattleGame->>State: Log enemy attack
        
        alt Player Defeated
            BattleGame->>API: createBattleLog(duration, damage)
            API-->>BattleGame: Log saved
            BattleGame->>State: Set gameOver, winner=enemy
            BattleGame->>Router: Navigate to battle-result (won=false)
        else Continue Battle
            BattleGame->>State: Update UI with new HP values
        end
    end
    
    alt Flee Action
        User->>BattleGame: Flee button
        BattleGame->>Router: Navigate back to battle list
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Battle game logic (battle-game.tsx): HP management, attack sequencing with delays, and API integration require careful validation of damage calculations and state transitions
  • API refactoring (api.ts): Error handling shift from throwing to returning dummy data affects downstream error recovery behavior; verify all call sites handle the new return signatures correctly
  • Navigation restructuring (_layout.tsx, index.tsx): Confirm routing guards (user creation redirect) work as intended and no redirect loops occur
  • Component deprecation impact: Verify all deletions (ThemedText, ThemedView, etc.) are fully migrated to new implementations (Text, TextInput wrappers) with no orphaned imports

Possibly related PRs

  • feat:add-frontend-home #5: Directly modifies frontend/utils/api.ts with type definitions and implementations for getUser, getEnemies, and createBattleLog; this PR refactors those same functions with renamed exports and altered error handling.

Poem

🐰 A battle unfolds in the warren's grand hall,
From creation to combat—our game has it all!
Old paths cleared away, new adventures await,
With TabLayout gone and a bold, streamlined fate.
Hop forth to victory or retreat with great flair—
The battle begins, and the UI's so fair!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/frontend-api

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1deb7e7 and 5e64479.

📒 Files selected for processing (27)
  • frontend/app/(tabs)/_layout.tsx (0 hunks)
  • frontend/app/(tabs)/explore.tsx (0 hunks)
  • frontend/app/_layout.tsx (2 hunks)
  • frontend/app/battle-game.tsx (1 hunks)
  • frontend/app/battle-result.tsx (1 hunks)
  • frontend/app/battle.tsx (1 hunks)
  • frontend/app/create-user.tsx (1 hunks)
  • frontend/app/index.tsx (5 hunks)
  • frontend/app/modal.tsx (0 hunks)
  • frontend/app/settings.tsx (1 hunks)
  • frontend/app/solo.tsx (1 hunks)
  • frontend/components/battle/EnemyCard.tsx (1 hunks)
  • frontend/components/common/BackButton.tsx (1 hunks)
  • frontend/components/common/ScreenHeader.tsx (1 hunks)
  • frontend/components/external-link.tsx (0 hunks)
  • frontend/components/haptic-tab.tsx (0 hunks)
  • frontend/components/hello-wave.tsx (0 hunks)
  • frontend/components/parallax-scroll-view.tsx (0 hunks)
  • frontend/components/themed-text.tsx (0 hunks)
  • frontend/components/themed-view.tsx (0 hunks)
  • frontend/components/themed/Text.tsx (1 hunks)
  • frontend/components/themed/TextInput.tsx (1 hunks)
  • frontend/components/themed/index.ts (1 hunks)
  • frontend/components/ui/collapsible.tsx (0 hunks)
  • frontend/components/ui/icon-symbol.ios.tsx (0 hunks)
  • frontend/components/ui/icon-symbol.tsx (0 hunks)
  • frontend/utils/api.ts (5 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Rikublender3d Rikublender3d merged commit 11198f7 into main Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant