全部评论 1

  • //判断是否红色品质变卖物(>240000为红色)
    bool is_red_collectible(Item* item)
    {
    if(!item) return false;
    return item->type == ItemTypeCOLLECTIBLE && item->value > 240000;
    }
    //打印仓库内容
    void show_red_vault()
    {
    clear_screen();
    std
    cout << "=红色品质仓库=\n";
    stdcout << "仓库总金钱:" << red_vault.bank_money << "\n\n";
    if(red_vault.stored_red_collectibles.empty())
    {
    std
    cout << "仓库为空,还没有存入红色变卖物\n";
    }
    else
    {
    long long total_val = 0;
    for(size_t i =0;i<red_vault.stored_red_collectibles.size();i++)
    {
    auto it = red_vault.stored_red_collectibles[i];
    SetColor(4,0);
    stdcout << i+1 <<". "<< it->name << " |价值:" << it->value << "\n";
    SetColor(7,0);
    total_val += it->value;
    }
    std
    cout << "\n仓库物品总价值:" << total_val << "\n";
    }
    stdcout << "\n操作:\n";
    std
    cout << "输入序号出售该红色物品(90%折价);0 返回\n";
    stdcout << "请输入:";
    int opt;
    string_input_to_digit(opt);
    if(opt ==0)
    {
    return;
    }
    opt -=1;
    if(opt >=0 && opt < (int)red_vault.stored_red_collectibles.size())
    {
    Item* item = red_vault.stored_red_collectibles[opt];
    long long sell_price = (long long)std
    round(item->value * 0.9f);
    red_vault.bank_money += sell_price;
    stdcout << "出售【" << item->name << "】获得仓库金钱:" << sell_price << "\n";
    delete item;
    red_vault.stored_red_collectibles.erase(red_vault.stored_red_collectibles.begin()+opt);
    red_vault.save_to_file(VAULT_FILE);
    }
    else
    {
    std
    cout << "无效序号\n";
    }
    press_any_key();
    }

    3天前 来自 浙江

    0
    • userId_undefined
      AC
      回复
      AC

      //把玩家背包中变卖物处理:红色存入仓库;非红色变卖物自动换成仓库金钱;其他物品直接丢弃
      void store_player_red_to_vault()
      {
      stdvector<Item*> keep;
      for(auto item : player.inventory)
      {
      if(item->type == ItemType
      COLLECTIBLE)
      {
      if(is_red_collectible(item))
      {
      //红色品质存入仓库
      red_vault.stored_red_collectibles.push_back(new Item(*item));
      delete item;
      }
      else
      {
      //新增:非红色变卖物,直接出售,钱进仓库总金钱(黑市90%折价)
      long long sell_val = (long long)stdround(item->value * 0.9f);
      red_vault.bank_money += sell_val;
      delete item;
      }
      }
      else
      {
      //武器/防具/消耗品/弹药全部丢弃,不保留
      delete item;
      }
      }
      player.inventory.swap(keep);
      //重置玩家背包负载、变卖物价值
      player.current_load = 0;
      player.collectibles_value = 0;
      red_vault.save_to_file(VAULT_FILE);
      }
      void change_difficulty()
      {
      clear_screen();
      std
      cout << "=选择游戏难度=\n";
      stdcout << "1. 常规:敌人弱,物资爆率低,适合新手\n";
      std
      cout << "2. 机密:敌人属性中等,物资爆率中等\n";
      stdcout << "3. 绝密:敌人强力,精英更多,物资爆率大幅提高!\n";
      std
      cout << "请选择难度:";
      int sel;
      string_input_to_digit(sel);
      if(sel ==1)
      {
      current_difficulty = DifficultyNORMAL;
      std
      cout<<"已切换为【常规】难度\n";
      }
      else if(sel ==2)
      {
      current_difficulty = DifficultySECRET;
      std
      cout<<"已切换为【机密】难度\n";
      }
      else if(sel ==3)
      {
      current_difficulty = DifficultyTOP_SECRET;
      std
      cout<<"已切换为【绝密】难度\n";
      }
      else
      {
      std::cout<<"无效选择,难度不变\n";
      }
      press_any_key();
      }
      void handle_main_menu_input() {
      int choice;
      string_input_to_digit(choice);
      switch (choice) {
      case 1:
      start_game();
      break;
      //新增查看仓库分支
      case 2:
      show_red_vault();
      break;
      case 3:
      lobby_shop(); //新增大厅商店函数调用
      break;
      case 4:
      change_d

      3天前 来自 浙江

      0
    • userId_undefined
      AC
      回复
      AC

      ifficulty(); //修改难度
      break;
      case 5:
      lobby_select_melee();
      break;
      case 6:
      red_vault.save_to_file(VAULT_FILE);
      cleanup_game_session();
      clear_screen();
      stdcout << "正在退出游戏...\n";
      Sleep(600);
      std
      cout << "退出成功!\n";
      exit(EXIT_SUCCESS);
      default:
      stdcout << "无效的输入,请重试。\n";
      press_any_key();
      break;
      }
      }
      // 开始新游戏
      void start_game() {
      std
      cout << "请输入你的士兵代号: ";
      stdcin >> player.name;
      //修复:清除cin异常标记,再丢弃缓冲区剩余字符,防止卡死
      std
      cin.clear();
      stdcin.ignore(stdnumeric_limitsstd::streamsize::max(), '\n');

      //==== 注意!这里删除原来那一大段delete武器、清空背包代码!cleanup_game_session已经处理完!====
      player.health = player.max_health;
      player.exp = 0;
      player.level = 1;
      player.money = 0;
      player.kill_count = 0;
      player.collectibles_value = 0;
      player.reached_evac = false;
      player.temp_defense = 0;
      player.temp_crit = 0;
      current_area = AreaId::CORE;
      global_step = 0;
      local_step = 0;
      meet_sasa_event = false;
      
      // 初始化人机玩家
      bots.clear();
      bots.emplace_back("侦察兵甲", 60, 12, 30); // 30%概率出现
      bots.emplace_back("突击手乙", 80, 15, 25); // 25%概率出现
      bots.emplace_back("医疗兵丙", 50, 8, 20);  // 20%概率出现
      reset_bots();
      
      std::cout << "\n欢迎你," << player.name << "!你的任务是收集高价值物品并到达撤离点。\n";
          std::cout<<"本局难度:";
      if(current_difficulty == Difficulty::NORMAL) std::cout<<"【常规】敌人较弱,物资爆率较低\n";
      else if(current_difficulty == Difficulty::SECRET) std::cout<<"【机密】均衡难度\n";
      else if(current_difficulty == Difficulty::TOP_SECRET) std::cout<<"【绝密】敌人强悍,物资爆率提升!小心精英敌人!\n";
      std::cout << "探索区域寻找容器,从中获取变卖物,注意敌人巡逻!\n";
      std::cout << "武器系统:可拾取任意武器,装备时可选择替换已装备武器\n";
      std::cout << "每探索25步会遇到黑市商店,可买卖物品\n";
      std::cout << "前期(前20步)不会遇到精英敌人,放心探索!\n";
      
      //大厅商店购买的开局礼物给到玩家
      for(Item* gift : lobby_starting_gifts)
      {
          player.add_item(gift);
      }
      lobby_starting_gifts.clear(); //清空,下一局不会重复给
      
      press_any_key();
      current_state = GameState::EXPLORING;
      

      }
      // 重置人机玩家状态
      void reset_bots() {
      for (auto& bot : bots) {
      bot.reset();
      }
      }
      // 创建变卖物

      3天前 来自 浙江

      0
    • userId_undefined
      AC
      回复
      AC

      (保险箱仅产出中等价值及以上)
      void create_collectibles(stdvector<Item*>& items, int count, ContainerType container_type) {
      // 根据容器类型调整价值等级
      bool safe_only_mid_plus = (container_type == ContainerType
      SAFE || container_type == ContainerType::SMALL_SAFE);

      //====难度爆率修正====
      int top_mod = 0;
      int high_mod =0;
      if(current_difficulty == Difficulty::NORMAL)
      {
          top_mod = -20;
          high_mod = -50;
      }
      else if(current_difficulty == Difficulty::TOP_SECRET)
      {
          top_mod = +40;
          high_mod = +80;
      }
      //机密不修改
      
      // 价值概率(千分比)
      int top_chance = 0;
      int high_chance = 0;
      int mid_chance = 0;
      int low_chance = 0;
      int max_chance=0;
      if (container_type == ContainerType::SAFE) {
      	max_chance=800;
      	top_chance = 100;    // 7%
      	high_chance = 100;   // 18%
      	mid_chance = 0;    // 50%
      	low_chance = 0;      // 保险箱无低价值
      	top_chance += top_mod;
          high_chance += high_mod;
      } else if (container_type == ContainerType::SMALL_SAFE) {
      	max_chance = 700;
      	top_chance = 100;     // 3%
      	high_chance = 100;   // 17%
      	mid_chance = 100;    // 70%
      	low_chance = 0;      // 小保险箱无低价值top_chance += top_mod;
          high_chance += high_mod;
      } else if (container_type == ContainerType::MEDICAL_BOX) {
      	max_chance = 600;
      	top_chance = 200;     // 3%
      	high_chance = 100;   // 17%
      	mid_chance = 100;    // 70%
      	low_chance = 0;   // 医疗箱同普通容器
      	top_chance += top_mod;
          high_chance += high_mod;
      } else if (container_type == ContainerType::STORAGE_BOX_S) {
      	max_chance = 600;
      	top_chance = 200;     // 3%
      	high_chance = 100;   // 17%
      	mid_chance = 100;    // 70%
      	low_chance = 0; 	 //储物箱
      	top_chance += top_mod;
          high_chance += high_mod;
      } else if (container_type == ContainerType::SCATTERED || container_type == ContainerType::MANHOLE) {
      	max_chance = 600;
      	top_chance = 200;     // 3%
      	high_chance = 100;   // 17%
      	mid_chance = 100;    // 70%
      	low_chance = 0;    // 散落物 井盖
      	top_chance += top_mod;
          high_chance += high_mod;
      }else {
      	max_cha
      

      3天前 来自 浙江

      0

热门讨论