Procházet zdrojové kódy

level 10 PvP requirement

jblanked před 8 měsíci
rodič
revize
a2459d424d
3 změnil soubory, kde provedl 20 přidání a 0 odebrání
  1. 3 0
      game/game.c
  2. 16 0
      game/player.c
  3. 1 0
      game/player.h

+ 3 - 0
game/game.c

@@ -192,6 +192,9 @@ static void game_stop(void *ctx)
         case GAME_END_TUTORIAL_INCOMPLETE:
         case GAME_END_TUTORIAL_INCOMPLETE:
             snprintf(message, sizeof(message), "The tutorial is not complete.\nPlease finish the tutorial to\nsave your game.\n\nHit BACK to exit.");
             snprintf(message, sizeof(message), "The tutorial is not complete.\nPlease finish the tutorial to\nsave your game.\n\nHit BACK to exit.");
             break;
             break;
+        case GAME_END_PVP_REQUIREMENT:
+            snprintf(message, sizeof(message), "You need to be level 10 to\nplay PvP.\n\nHit BACK to exit.");
+            break;
         };
         };
         easy_flipper_dialog("Game Over", message);
         easy_flipper_dialog("Game Over", message);
     }
     }

+ 16 - 0
game/player.c

@@ -136,6 +136,14 @@ void player_spawn(Level *level, GameManager *manager)
         pctx->elapsed_health_regen = 0;
         pctx->elapsed_health_regen = 0;
         pctx->max_health = 100 + ((pctx->level - 1) * 10); // 10 health per level
         pctx->max_health = 100 + ((pctx->level - 1) * 10); // 10 health per level
 
 
+        // level 10 level required for PvP
+        if (game_context->game_mode == GAME_MODE_PVP)
+        {
+            FURI_LOG_E(TAG, "Player level is not high enough for PvP");
+            game_context->end_reason = GAME_END_PVP_REQUIREMENT;
+            game_context->ended_early = true;
+        }
+
         // Set player username
         // Set player username
         if (!load_char("Flip-Social-Username", pctx->username, sizeof(pctx->username)))
         if (!load_char("Flip-Social-Username", pctx->username, sizeof(pctx->username)))
         {
         {
@@ -164,6 +172,14 @@ void player_spawn(Level *level, GameManager *manager)
     // Determine the player's level based on XP
     // Determine the player's level based on XP
     pctx->level = player_level_iterative_get(pctx->xp);
     pctx->level = player_level_iterative_get(pctx->xp);
 
 
+    // level 10 level required for PvP
+    if (game_context->game_mode == GAME_MODE_PVP && pctx->level < 10)
+    {
+        FURI_LOG_E(TAG, "Player level %ld is not high enough for PvP", pctx->level);
+        game_context->end_reason = GAME_END_PVP_REQUIREMENT;
+        game_context->ended_early = true;
+    }
+
     // Update strength and max health based on the new level
     // Update strength and max health based on the new level
     pctx->strength = 10 + (pctx->level * 1);           // 1 strength per level
     pctx->strength = 10 + (pctx->level * 1);           // 1 strength per level
     pctx->max_health = 100 + ((pctx->level - 1) * 10); // 10 health per level
     pctx->max_health = 100 + ((pctx->level - 1) * 10); // 10 health per level

+ 1 - 0
game/player.h

@@ -91,6 +91,7 @@ typedef enum
 {
 {
     GAME_END_MEMORY = 0,              // ran out of memory
     GAME_END_MEMORY = 0,              // ran out of memory
     GAME_END_TUTORIAL_INCOMPLETE = 1, // tutorial incomplete
     GAME_END_TUTORIAL_INCOMPLETE = 1, // tutorial incomplete
+    GAME_END_PVP_REQUIREMENT = 2,     // player level too low for pvp
 } GameEndReason;
 } GameEndReason;
 
 
 typedef struct
 typedef struct