U137935.古墓摸金
通过率:0%
时间限制:1.00s
内存限制:128MB
输入格式
输入输出样例
输入#1
cout << "【"; if(drop.rarity == ItemRarity::COLORFUL) { printRainbowText(drop.name); } else { setConsoleColor(getRarityColor(drop.rarity)); cout << drop.name; resetConsoleColor(); } cout << "】价值" << drop.value << endl; if(drop.rarity == ItemRarity::RED || drop.rarity == ItemRarity::COLORFUL) { addToCollection(drop.name); } player.bag.emplace_back(drop); } else { cout << "敌人没有掉落任何东西。\n"; } return 1; } void fullHeal(GamePlayer& p) { p.hp = p.maxHp; cout << "\n战斗结束,你休整完毕,血量已完全回满!\n"; } void showBag(const GamePlayer& p) { cout << "\n====背包内变卖宝物====\n"; if(p.bag.empty()) { cout << "背包空空,还没有宝物\n"; return; } long long sum = 0; for(auto& item : p.bag) { printRarityTag(item.rarity); cout << " "; if(item.rarity == ItemRarity::COLORFUL) { printRainbowText(item.name); } else { setConsoleColor(getRarityColor(item.rarity)); cout << item.name; resetConsoleColor(); } cout << " 价值:" << item.value << "\n"; sum += item.value; } cout << "背包总财宝价值:" << sum << "\n"; } long long calcBagTotal(const GamePlayer& p) { long long sum = 0; for(auto& i : p.bag) sum += i.value; return sum; } // 执行一局探险,返回本局带出财富 long long runOneExplore() { clearScreen(); cout << "\n========开始新一局摸金探险========\n"; GamePlayer hero = createPlayer(); showPlayerInfo(hero); cout << "\n按回车键,正式进入古墓......"; cin.ignore(); cin.get(); clearScreen(); while(true) { if(hero.hp <= 0) { clearScreen(); cout << "\n=========本局结算=========\n"; cout << "你倒在了古墓之中,探险失败!\n"; long long full = calcBagTotal(hero); long long finalScore = (long long)(full * 0.4); cout << "死亡仅可带出40%财富,实际带出:" << finalScore << "\n"; return finalScore; } cout << "\n========【古墓探索】========\n"; cout << "等级:"<<hero.level<<" | HP:"<<hero.hp<<"/"<<hero.maxHp<<" | EXP:"<<hero.exp<<"/"<<hero.expNeed<<"\n"; cout << "1.继续向前探索\n2.查看背包\n3.选择撤离结束本局\n"; int sel; cin >> sel; cin.ignore(); if(sel == 3) { clearScreen(); cout << "\n=========本局结算=========\n"; cout << "你选择安全撤离古墓!\n"; long long finalScore = calcBagTotal(hero); cout << "成功撤离,带出全部财宝:" << finalScore << "\n"; return finalScore; } if(sel ==2) { showBag(hero); cout << "\n按回车键返回探索界面......"; cin.get(); clearScreen(); continue; } bool meetEnemy = (randDouble() > 0.5); if(meetEnemy) { int res = battle(hero, getRandomEnemy()); if(res == 0) { continue; } fullHeal(hero); cout << "\n按回车键回到探索菜单......"; cin.get(); clearScreen(); } else { openContainer(hero, getRandomContainer()); cout << "\n按回车键继续探索......"; cin.get(); clearScreen(); } } }输出#1
输入解题思路,AI测评打分。不知道怎么写?