我出玩法,你出实现。 (你:豆包)
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cmath>
#include <utility>
#include <sstream>
#include <climits>
using namespace std;
template <typename T>
string int_to_string(const T& value) {
ostringstream oss;
oss << value;
return oss.str();
}
int getIntInput(int minValue, int maxValue, const string& prompt = "请输入: ") {
int input;
while (true) {
cout << prompt;
if (!(cin >> input)) {
cin.clear();
while (cin.get() != '\n') continue;
cout << "错误:请输入有效的数字!" << endl;
} else if (input < minValue || input > maxValue) {
while (cin.get() != '\n') continue;
cout << "错误:请输入" << minValue << "到" << maxValue << "之间的数字!" << endl;
} else {
while (cin.get() != '\n') continue;
return input;
}
}
}
enum Difficulty {
DIFFICULTY_EASY,
DIFFICULTY_NORMAL,
DIFFICULTY_HARD
};
enum Specialization {
SPECIALIZATION_NONE,
SPECIALIZATION_ENGINE_PROGRAMMING,
SPECIALIZATION_GAMEPLAY_PROGRAMMING,
SPECIALIZATION_AI_PROGRAMMING,
SPECIALIZATION_NETWORK_PROGRAMMING,
SPECIALIZATION_LEVEL_DESIGN,
SPECIALIZATION_UI_DESIGN,
SPECIALIZATION_CHARACTER_DESIGN,
SPECIALIZATION_ENVIRONMENT_DESIGN,
SPECIALIZATION_STORY_WRITING,
SPECIALIZATION_SYSTEM_DESIGN,
SPECIALIZATION_BALANCE_DESIGN,
SPECIALIZATION_QUEST_DESIGN,
SPECIALIZATION_FUNCTIONAL_TESTING,
SPECIALIZATION_PERFORMANCE_TESTING,
SPECIALIZATION_COMPATIBILITY_TESTING,
SPECIALIZATION_SECURITY_TESTING
};
enum Platform {
PLATFORM_PC,
PLATFORM_CONSOLE,
PLATFORM_MOBILE
};
class GameCompany;
class GameProject;
class Competitor;
class GameEngine;
class Employee;
class BranchOffice;
class GameEngine {
private:
string name;
int version;
int quality;
int developmentCost;
bool isCompleted;
int progress;
vector<Employee*> assignedEmployees;
public:
GameEngine(string n) : name(n), version(1), quality(0),
developmentCost(0), isCompleted(false), progress(0) {}
string getName() const { return name; }
int getVersion() const { return version; }
int getQuality() const { return quality; }
bool getIsCompleted() const { return isCompleted; }
int getProgress() const { return progress; }
int getDevelopmentCost() const { return developmentCost; }
void assignEmployee(Employee* emp);
void developMonth(double difficultyMultiplier);
void upgrade();
void displayInfo() const;
};
class Employee {
private:
string name;
string role;
int skillLevel;
int salary;
int productivity;
int experience;
int fatigue;
int morale;
Specialization specialization;
int loyalty;
bool isAssigned;
public:
Employee(string n, string r, int sl, double salaryMultiplier)
: name(n), role(r), skillLevel(sl), experience(0), fatigue(0), morale(70),
specialization(SPECIALIZATION_NONE), loyalty(50 + rand() % 30), isAssigned(false) {
salary = static_cast<int>((skillLevel * 1000 + (rand() % 500)) * salaryMultiplier);
productivity = skillLevel * 10 + (rand() % 20);
}
string getName() const { return name; }
string getRole() const { return role; }
int getSkillLevel() const { return skillLevel; }
int getSalary() const { return salary; }
int getProductivity() const;
int getExperience() const { return experience; }
int getFatigue() const { return fatigue; }
int getMorale() const { return morale; }
Specialization getSpecialization() const { return specialization; }
int getLoyalty() const { return loyalty; }
bool getIsAssigned() const { return isAssigned; }
void setAssigned(bool assigned) { isAssigned = assigned; }
void workMonth();
void restMonth();
void levelUp(double salaryMultiplier);
void chooseSpecialization();
void giveBonus(int amount);
bool willQuit(double difficultyMultiplier) const;
void displayInfo() const;
};
class GameProject {
private:
string name;
string genre;
Platform platform;
int developmentProgress;
int totalCost;
int expectedSales;
int actualSales;
double rating;
int marketingBudget;
bool isDLC;
bool isSequel;
string originalGameName;
double originalGameRating;
GameEngine* usedEngine;
int gameplay;
int graphics;
int story;
int sound;
int optimization;
vector<Employee*> assignedEmployees;
map<string, int> dlcSales;
public:
GameProject(string n, string g, Platform p, GameEngine* engine = NULL)
: name(n), genre(g), platform(p), developmentProgress(0),
totalCost(0), expectedSales(0), actualSales(0), rating(0.0),
marketingBudget(0), isDLC(false), isSequel(false),
originalGameName(""), originalGameRating(0.0), usedEngine(engine),
gameplay(5), graphics(5), story(5), sound(5), optimization(5) {}
static GameProject* createDLC(string dlcName, GameProject* originalGame);
static GameProject* createSequel(string sequelName, GameProject* originalGame);
string getName() const { return name; }
string getGenre() const { return genre; }
Platform getPlatform() const { return platform; }
int getProgress() const { return developmentProgress; }
int getTotalCost() const { return totalCost; }
double getRating() const { return rating; }
int getActualSales() const { return actualSales; }
int getMarketingBudget() const { return marketingBudget; }
bool getIsDLC() const { return isDLC; }
bool getIsSequel() const { return isSequel; }
string getOriginalGameName() const { return originalGameName; }
GameEngine* getUsedEngine() const { return usedEngine; }
int getProfit() const;
int getPricePerCopy() const;
void setFocus(int gp, int gr, int st, int so, int op);
void setMarketingBudget(int budget);
void assignEmployee(Employee* emp);
void developMonth(double difficultyMultiplier);
void finishGame(double marketTrend, int competitionLevel, double difficultyMultiplier);
void displayProjectInfo() const;
void displayGameResult() const;
};
class Competitor {
private:
string name;
int strength;
int money;
vector<GameProject*> currentProjects;
double difficultyMultiplier;
public:
Competitor(string n, int s, double dm)
: name(n), strength(s), money(500000 + s * 10000), difficultyMultiplier(dm) {}
string getName() const { return name; }
int getStrength() const { return strength; }
const vector<GameProject*>& getCurrentProjects() const { return currentProjects; }
void developMonth();
~Competitor();
};
class BranchOffice {
private:
string location;
int level;
int capacity;
vector<Employee*> employees;
public:
BranchOffice(string loc) : location(loc), level(1), capacity(5) {}
string getLocation() const { return location; }
int getLevel() const { return level; }
int getCapacity() const { return capacity; }
const vector<Employee*>& getEmployees() const { return employees; }
void upgrade();
bool addEmployee(Employee* emp);
};
class GameCompany {
private:
string name;
int money;
int month;
int reputation;
int officeLevel;
int maxEmployees;
bool isPublic;
double stockPrice;
int sharesOutstanding;
Difficulty difficulty;
double difficultyMultiplier;
double salaryMultiplier;
vector<Employee*> employees;
vector<GameProject*> currentProjects;
vector<GameProject*> completedGames;
vector<GameEngine*> engines;
vector<Employee*> employeePool;
vector<BranchOffice*> branches;
vector<Competitor*> competitors;
map<string, double> genreTrends;
int nextGameShowMonth;
public:
GameCompany(string n, Difficulty diff);
~GameCompany();
string getName() const { return name; }
int& getMoney() { return money; }
int getMoney() const { return money; }
int getMonth() const { return month; }
int getReputation() const { return reputation; }
int getOfficeLevel() const { return officeLevel; }
int getMaxEmployees() const { return maxEmployees; }
bool getIsPublic() const { return isPublic; }
double getStockPrice() const { return stockPrice; }
Difficulty getDifficulty() const { return difficulty; }
double getDifficultyMultiplier() const { return difficultyMultiplier; }
double getSalaryMultiplier() const { return salaryMultiplier; }
vector<Employee*>& getEmployees() { return employees; }
const vector<Employee*>& getEmployees() const { return employees; }
vector<GameProject*>& getCurrentProjects() { return currentProjects; }
const vector<GameProject*>& getCurrentProjects() const { return currentProjects; }
const vector<GameProject*>& getCompletedGames() const { return completedGames; }
const vector<GameEngine*>& getEngines() const { return engines; }
const vector<Employee*>& getEmployeePool() const { return employeePool; }
const vector<BranchOffice*>& getBranches() const { return branches; }
const vector<Competitor*>& getCompetitors() const { return competitors; }
double getGenreTrend(string genre) const;
void initializeMarketTrends();
void initializeCompetitors();
void generateEmployeePool();
bool hireEmployee(int index);
bool fireEmployee(int index);
bool startNewProject(string gameName, string genre, Platform platform, GameEngine* engine = NULL);
bool startEngineDevelopment(string engineName);
bool upgradeOffice();
bool openBranch(string location);
bool acquireStudio(string studioName, int cost);
bool goPublic();
void advanceMonth();
void updateMarketTrends();
void holdGameShow();
void checkEmployeeQuits();
void displayEmployeePool() const;
void displayEmployees() const;
void displayMarketTrends() const;
};
class GameDevCompanyGame {
private:
GameCompany* company;
bool running;
public:
GameDevCompanyGame();
~GameDevCompanyGame();
void start();
void showTutorial();
void mainLoop();
void displayMainMenu();
void viewCompanyStatus();
void employeeManagementMenu();
void hireEmployeeMenu();
void fireEmployeeMenu();
void giveBonusMenu();
void projectManagementMenu();
void startNewProjectMenu();
void manageCurrentProjectsMenu();
void adjustGameFocus(GameProject* project);
void assignEmployeesToProject(GameProject* project);
void setMarketingBudget(GameProject* project);
void createDLCMenu();
void createSequelMenu();
void engineDevelopmentMenu();
void startNewEngineMenu();
void manageEnginesMenu();
void assignEmployeesToEngine(GameEngine* engine);
void upgradeEngineMenu();
void marketAndMarketingMenu();
void viewCompetitors();
void companyDevelopmentMenu();
void openBranchMenu();
void acquireStudioMenu();
void nextMonth();
void viewGameHistory();
};
void GameEngine::assignEmployee(Employee* emp) {
assignedEmployees.push_back(emp);
}
void GameEngine::developMonth(double difficultyMultiplier) {
if (isCompleted) return;
int totalProductivity = 0;
for (size_t i = 0; i < assignedEmployees.size(); ++i) {
Employee* emp = assignedEmployees[i];
if (emp->getSpecialization() == SPECIALIZATION_ENGINE_PROGRAMMING)
totalProductivity += emp->getProductivity() * 2;
else
totalProductivity += emp->getProductivity();
developmentCost += static_cast<int>(emp->getSalary() * difficultyMultiplier);
}
int progressGain = totalProductivity / 15;
progress += progressGain;
developmentCost += static_cast<int>(10000 * difficultyMultiplier);
if (progress >= 100) {
isCompleted = true;
quality = 50 + rand() % 30;
int totalSkill = 0;
for (size_t i = 0; i < assignedEmployees.size(); ++i)
totalSkill += assignedEmployees[i]->getSkillLevel();
quality += totalSkill;
quality = min(100, quality);
}
}
void GameEngine::upgrade() {
version++;
isCompleted = false;
progress = 0;
developmentCost = 0;
quality += 10;
}
void GameEngine::displayInfo() const {
cout << "引擎名称: " << name << " v" << version << endl;
cout << "开发进度: " << progress << "%" << endl;
cout << "已投入成本: " << developmentCost << "元" << endl;
if (isCompleted) cout << "引擎质量: " << quality << "/100" << endl;
cout << "分配员工: " << assignedEmployees.size() << "人" << endl;
}
int Employee::getProductivity() const {
double fatigueModifier = 1.0 - (fatigue / 200.0);
double moraleModifier = 0.5 + (morale / 200.0);
return static_cast<int>(productivity * fatigueModifier * moraleModifier);
}
void Employee::workMonth() {
fatigue += 15 + rand() % 10;
morale -= 5 + rand() % 5;
if (fatigue > 80) morale -= 10;
if (morale < 30) loyalty -= 5;
experience += 10 + rand() % 10;
}
void Employee::restMonth() {
fatigue = max(0, fatigue - 30);
morale = min(100, morale + 15);
}
void Employee::levelUp(double salaryMultiplier) {
skillLevel++;
experience = 0;
salary = static_cast<int>((skillLevel * 1000 + rand() % 500) * salaryMultiplier);
productivity = skillLevel * 10 + rand() % 20;
morale += 20;
loyalty += 10;
cout << "^_^ " << name << " 升级了!现在是 " << skillLevel << " 级!" << endl;
if (skillLevel == 5 && specialization == SPECIALIZATION_NONE)
chooseSpecialization();
}
void Employee::chooseSpecialization() {
cout << name << " 可以选择专精方向了!" << endl;
cout << "请为 " << name << " (" << role << ") 选择专精:" << endl;
vector<pair<Specialization, string> > options;
if (role == "程序员") {
options.push_back(make_pair(SPECIALIZATION_ENGINE_PROGRAMMING, "引擎编程"));
options.push_back(make_pair(SPECIALIZATION_GAMEPLAY_PROGRAMMING, "游戏性编程"));
options.push_back(make_pair(SPECIALIZATION_AI_PROGRAMMING, "AI编程"));
options.push_back(make_pair(SPECIALIZATION_NETWORK_PROGRAMMING, "网络编程"));
} else if (role == "设计师") {
options.push_back(make_pair(SPECIALIZATION_LEVEL_DESIGN, "关卡设计"));
options.push_back(make_pair(SPECIALIZATION_UI_DESIGN, "UI设计"));
options.push_back(make_pair(SPECIALIZATION_CHARACTER_DESIGN, "角色设计"));
options.push_back(make_pair(SPECIALIZATION_ENVIRONMENT_DESIGN, "环境设计"));
} else if (role == "策划") {
options.push_back(make_pair(SPECIALIZATION_STORY_WRITING, "剧情策划"));
options.push_back(make_pair(SPECIALIZATION_SYSTEM_DESIGN, "系统策划"));
options.push_back(make_pair(SPECIALIZATION_BALANCE_DESIGN, "数值策划"));
options.push_back(make_pair(SPECIALIZATION_QUEST_DESIGN, "任务策划"));
} else if (role == "测试") {
options.push_back(make_pair(SPECIALIZATION_FUNCTIONAL_TESTING, "功能测试"));
options.push_back(make_pair(SPECIALIZATION_PERFORMANCE_TESTING, "性能测试"));
options.push_back(make_pair(SPECIALIZATION_COMPATIBILITY_TESTING, "兼容性测试"));
options.push_back(make_pair(SPECIALIZATION_SECURITY_TESTING, "安全测试"));
}
for (size_t i = 0; i < options.size(); ++i)
cout << i+1 << ". " << options[i].second << endl;
int choice = getIntInput(1, options.size());
specialization = options[choice-1].first;
cout << name << " 选择了 " << options[choice-1].second << " 专精!" << endl;
productivity += 20;
}
void Employee::giveBonus(int amount) {
morale += amount / 1000;
loyalty += amount / 2000;
morale = min(100, morale);
loyalty = min(100, loyalty);
}
bool Employee::willQuit(double difficultyMultiplier) const {
return loyalty < 20 && (rand() % 100) < static_cast<int>(30 * difficultyMultiplier);
}
void Employee::displayInfo() const {
string specStr = "无";
if (specialization != SPECIALIZATION_NONE) {
vector<pair<Specialization, string> > specMap;
specMap.push_back(make_pair(SPECIALIZATION_ENGINE_PROGRAMMING, "引擎编程"));
specMap.push_back(make_pair(SPECIALIZATION_GAMEPLAY_PROGRAMMING, "游戏性编程"));
specMap.push_back(make_pair(SPECIALIZATION_AI_PROGRAMMING, "AI编程"));
specMap.push_back(make_pair(SPECIALIZATION_NETWORK_PROGRAMMING, "网络编程"));
specMap.push_back(make_pair(SPECIALIZATION_LEVEL_DESIGN, "关卡设计"));
specMap.push_back(make_pair(SPECIALIZATION_UI_DESIGN, "UI设计"));
specMap.push_back(make_pair(SPECIALIZATION_CHARACTER_DESIGN, "角色设计"));
specMap.push_back(make_pair(SPECIALIZATION_ENVIRONMENT_DESIGN, "环境设计"));
specMap.push_back(make_pair(SPECIALIZATION_STORY_WRITING, "剧情策划"));
specMap.push_back(make_pair(SPECIALIZATION_SYSTEM_DESIGN, "系统策划"));
specMap.push_back(make_pair(SPECIALIZATION_BALANCE_DESIGN, "数值策划"));
specMap.push_back(make_pair(SPECIALIZATION_QUEST_DESIGN, "任务策划"));
specMap.push_back(make_pair(SPECIALIZATION_FUNCTIONAL_TESTING, "功能测试"));
specMap.push_back(make_pair(SPECIALIZATION_PERFORMANCE_TESTING, "性能测试"));
specMap.push_back(make_pair(SPECIALIZATION_COMPATIBILITY_TESTING, "兼容性测试"));
specMap.push_back(make_pair(SPECIALIZATION_SECURITY_TESTING, "安全测试"));
for (size_t i = 0; i < specMap.size(); ++i)
if (specMap[i].first == specialization) { specStr = specMap[i].second; break; }
}
cout << left << setw(12) << name
<< setw(10) << role
<< setw(8) << skillLevel
<< setw(10) << salary
<< setw(12) << getProductivity()
<< setw(8) << fatigue
<< setw(8) << morale
<< setw(12) << specStr
<< setw(8) << loyalty << endl;
}
GameProject* GameProject::createDLC(string dlcName, GameProject* originalGame) {
GameProject* dlc = new GameProject(dlcName, originalGame->getGenre(), originalGame->getPlatform());
dlc->isDLC = true;
dlc->originalGameName = originalGame->getName();
dlc->originalGameRating = originalGame->getRating();
dlc->usedEngine = originalGame->usedEngine;
dlc->totalCost = originalGame->getTotalCost() / 4;
return dlc;
}
GameProject* GameProject::createSequel(string sequelName, GameProject* originalGame) {
GameProject* sequel = new GameProject(sequelName, originalGame->getGenre(), originalGame->getPlatform());
sequel->isSequel = true;
sequel->originalGameName = originalGame->getName();
sequel->originalGameRating = originalGame->getRating();
sequel->usedEngine = originalGame->usedEngine;
sequel->rating = originalGame->getRating() / 2;
return sequel;
}
int GameProject::getProfit() const {
int revenue = actualSales * getPricePerCopy();
double platformCut = 0.3;
if (platform == PLATFORM_MOBILE) platformCut = 0.5;
revenue = static_cast<int>(revenue * (1 - platformCut));
return revenue - totalCost - marketingBudget;
}
int GameProject::getPricePerCopy() const {
if (isDLC) return 20;
if (platform == PLATFORM_PC) return 60;
if (platform == PLATFORM_CONSOLE) return 70;
if (platform == PLATFORM_MOBILE) return 10;
return 60;
}
void GameProject::setFocus(int gp, int gr, int st, int so, int op) {
gameplay = max(0, min(10, gp));
graphics = max(0, min(10, gr));
story = max(0, min(10, st));
sound = max(0, min(10, so));
optimization = max(0, min(10, op));
}
void GameProject::setMarketingBudget(int budget) {
marketingBudget = budget;
}
void GameProject::assignEmployee(Employee* emp) {
assignedEmployees.push_back(emp);
emp->setAssigned(true);
}
void GameProject::developMonth(double difficultyMultiplier) {
int totalProductivity = 0;
for (size_t i = 0; i < assignedEmployees.size(); ++i) {
Employee* emp = assignedEmployees[i];
double bonus = 1.0;
if (emp->getRole() == "程序员" &&
(emp->getSpecialization() == SPECIALIZATION_GAMEPLAY_PROGRAMMING ||
emp->getSpecialization() == SPECIALIZATION_AI_PROGRAMMING)) bonus = 1.5;
else if (emp->getRole() == "设计师" &&
(emp->getSpecialization() == SPECIALIZATION_LEVEL_DESIGN ||
emp->getSpecialization() == SPECIALIZATION_CHARACTER_DESIGN)) bonus = 1.5;
else if (emp->getRole() == "策划" &&
(emp->getSpecialization() == SPECIALIZATION_STORY_WRITING ||
emp->getSpecialization() == SPECIALIZATION_SYSTEM_DESIGN)) bonus = 1.5;
else if (emp->getRole() == "测试" &&
(emp->getSpecialization() == SPECIALIZATION_FUNCTIONAL_TESTING ||
emp->getSpecialization() == SPECIALIZATION_PERFORMANCE_TESTING)) bonus = 1.5;
totalProductivity += static_cast<int>(emp->getProductivity() * bonus);
totalCost += static_cast<int>(emp->getSalary() * difficultyMultiplier);
emp->workMonth();
}
double engineBonus = 1.0;
if (usedEngine && usedEngine->getIsCompleted())
engineBonus = 1.0 + (usedEngine->getQuality() / 200.0);
double typeBonus = 1.0;
if (isDLC) typeBonus = 2.0;
if (isSequel) typeBonus = 1.3;
int progressGain = static_cast<int>(totalProductivity * engineBonus * typeBonus / 10);
int eventRoll = rand() % 100;
if (eventRoll < 10) {
cout << "! 《" << name << "》遇到技术难题!开发进度减缓。" << endl;
progressGain /= 2;
} else if (eventRoll > 90) {
cout << "^_^ 《" << name << "》灵感爆发!开发进度大幅提升。" << endl;
progressGain *= 2;
}
developmentProgress = min(100, developmentProgress + progressGain);
totalCost += static_cast<int>(5000 * difficultyMultiplier);
}
void GameProject::finishGame(double marketTrend, int competitionLevel, double difficultyMultiplier) {
double baseRating = 50.0;
int totalSkill = 0;
for (size_t i = 0; i < assignedEmployees.size(); ++i)
totalSkill += assignedEmployees[i]->getSkillLevel();
baseRating += totalSkill * 2.0;
if (usedEngine && usedEngine->getIsCompleted())
baseRating += usedEngine->getQuality() / 5.0;
if (genre == "动作游戏")
baseRating += gameplay * 3.0 + graphics * 2.0 + optimization * 2.0;
else if (genre == "角色扮演")
baseRating += story * 3.0 + gameplay * 2.0 + sound * 2.0;
else if (genre == "策略游戏")
baseRating += gameplay * 3.0 + story * 2.0 + optimization * 2.0;
else if (genre == "休闲游戏")
baseRating += gameplay * 2.0 + graphics * 2.0 + sound * 2.0 + optimization * 2.0;
else
baseRating += gameplay * 2.0 + graphics * 2.0 + story * 2.0;
if (isSequel) baseRating += originalGameRating / 3.0;
if (isDLC) baseRating += originalGameRating / 2.0;
baseRating += (rand() % 20 - 10) / 1.0;
baseRating /= difficultyMultiplier;
baseRating = max(0.0, min(100.0, baseRating));
int temp = static_cast<int>(baseRating * 10);
rating = temp / 10.0;
double baseSales = rating * 1000.0;
if (platform == PLATFORM_PC) baseSales *= 1.2;
if (platform == PLATFORM_CONSOLE) baseSales *= 1.0;
if (platform == PLATFORM_MOBILE) baseSales *= 2.0;
baseSales *= marketTrend;
baseSales *= (1.0 - competitionLevel / 100.0);
baseSales *= (1.0 + marketingBudget / 100000.0);
if (isSequel) baseSales *= 1.5;
if (isDLC) baseSales *= 0.4;
double piracyRate = (100.0 - rating) / 200.0;
if (platform == PLATFORM_PC) piracyRate *= 1.5;
if (platform == PLATFORM_MOBILE) piracyRate *= 0.5;
expectedSales = static_cast<int>(baseSales);
actualSales = static_cast<int>(expectedSales * (1.0 - piracyRate) * (0.8 + (rand() % 40) / 100.0));
for (size_t i = 0; i < assignedEmployees.size(); ++i)
assignedEmployees[i]->setAssigned(false);
}
void GameProject::displayProjectInfo() const {
string platformStr;
if (platform == PLATFORM_PC) platformStr = "PC";
if (platform == PLATFORM_CONSOLE) platformStr = "主机";
if (platform == PLATFORM_MOBILE) platformStr = "手机";
cout << "游戏名称: " << name << " (" << genre << " - " << platformStr << ")" << endl;
if (isDLC) cout << "类型: DLC (原作: " << originalGameName << ")" << endl;
if (isSequel) cout << "类型: 续作 (原作: " << originalGameName << ")" << endl;
cout << "开发进度: " << developmentProgress << "%" << endl;
cout << "已投入成本: " << totalCost << "元" << endl;
cout << "营销预算: " << marketingBudget << "元" << endl;
if (usedEngine)
cout << "使用引擎: " << usedEngine->getName() << " v" << usedEngine->getVersion() << endl;
cout << "当前侧重点: " << endl;
cout << " 游戏性: " << gameplay << "/10" << endl;
cout << " 画面: " << graphics << "/10" << endl;
cout << " 剧情: " << story << "/10" << endl;
cout << " 音效: " << sound << "/10" << endl;
cout << " 优化: " << optimization << "/10" << endl;
cout << "分配员工: " << assignedEmployees.size() << "人" << endl;
}
void GameProject::displayGameResult() const {
string platformStr;
if (platform == PLATFORM_PC) platformStr = "PC";
if (platform == PLATFORM_CONSOLE) platformStr = "主机";
if (platform == PLATFORM_MOBILE) platformStr = "手机";
cout << "=====================================" << endl;
cout << "游戏《" << name << "》开发完成!" << endl;
cout << "=====================================" << endl;
cout << "游戏类型: " << genre << " (" << platformStr << ")" << endl;
cout << "游戏评分: " << fixed << setprecision(1) << rating << "/100" << endl;
if (rating >= 90.0) cout << "评价: 神作!媒体和玩家一致好评!" << endl;
else if (rating >= 75.0) cout << "评价: 优秀作品,获得广泛认可。" << endl;
else if (rating >= 60.0) cout << "评价: 中规中矩,表现平平。" << endl;
else if (rating >= 40.0) cout << "评价: 差强人意,有不少缺点。" << endl;
else cout << "评价: 灾难级作品,口碑崩盘!" << endl;
cout << "实际销量: " << actualSales << "份" << endl;
cout << "每份价格: " << getPricePerCopy() << "元" << endl;
cout << "总收入: " << actualSales * getPricePerCopy() << "元" << endl;
cout << "开发成本: " << totalCost << "元" << endl;
cout << "营销成本: " << marketingBudget << "元" << endl;
cout << "净利润: " << getProfit() << "元" << endl;
if (getProfit() > 0) cout << "$ 恭喜!游戏盈利了!" << endl;
else cout << ":( 遗憾!游戏亏损了..." << endl;
cout << "=====================================" << endl;
}
void Competitor::developMonth() {
if (currentProjects.size() < 2 && (rand() % 100) < static_cast<int>(20 * difficultyMultiplier)) {
string genres[] = {"动作游戏", "角色扮演", "策略游戏", "休闲游戏"};
string names[] = {"星际冒险", "魔法王国", "战争前线", "城市建设", "海底世界"};
Platform platforms[] = {PLATFORM_PC, PLATFORM_CONSOLE, PLATFORM_MOBILE};
string gameName = names[rand() % 5] + " " + int_to_string(rand() % 10);
string genre = genres[rand() % 4];
Platform platform = platforms[rand() % 3];
GameProject* project = new GameProject(gameName, genre, platform);
currentProjects.push_back(project);
cout << "* 竞争对手 " << name << " 宣布开发新游戏《" << gameName << "》!" << endl;
}
for (vector<GameProject*>::iterator it = currentProjects.begin(); it != currentProjects.end();) {
GameProject* proj = *it;
int progressGain = static_cast<int>((strength / 10 + rand() % 10) * difficultyMultiplier);
proj->developMonth(difficultyMultiplier);
if (proj->getProgress() >= 100) {
proj->finishGame(1.0, 0, difficultyMultiplier);
cout << "-> 竞争对手 " << name << " 的游戏《" << proj->getName() << "》上市了!" << endl;
cout << " 评分: " << fixed << setprecision(1) << proj->getRating() << "/100" << endl;
money += proj->getProfit();
strength += static_cast<int>(proj->getRating() / 10);
strength = min(100, strength);
delete proj;
it = currentProjects.erase(it);
} else ++it;
}
}
Competitor::~Competitor() {
for (size_t i = 0; i < currentProjects.size(); ++i)
delete currentProjects[i];
}
void BranchOffice::upgrade() {
level++;
capacity += 5;
cout << location << " 分公司升级到 " << level << " 级!员工容量增加到 " << capacity << " 人。" << endl;
}
bool BranchOffice::addEmployee(Employee* emp) {
if (employees.size() >= capacity) {
cout << "分公司员工已满!" << endl;
return false;
}
employees.push_back(emp);
return true;
}
GameCompany::GameCompany(string n, Difficulty diff)
: name(n), month(1), reputation(50), officeLevel(1), maxEmployees(10),
isPublic(false), stockPrice(10.0), sharesOutstanding(1000000),
difficulty(diff), nextGameShowMonth(6) {
switch (difficulty) {
case DIFFICULTY_EASY:
money = 200000;
difficultyMultiplier = 0.7;
salaryMultiplier = 0.8;
break;
case DIFFICULTY_NORMAL:
money = 100000;
difficultyMultiplier = 1.0;
salaryMultiplier = 1.0;
break;
case DIFFICULTY_HARD:
money = 50000;
difficultyMultiplier = 1.5;
salaryMultiplier = 1.2;
break;
}
generateEmployeePool();
initializeMarketTrends();
initializeCompetitors();
}
GameCompany::~GameCompany() {
for (size_t i = 0; i < employees.size(); ++i) delete employees[i];
for (size_t i = 0; i < currentProjects.size(); ++i) delete currentProjects[i];
for (size_t i = 0; i < completedGames.size(); ++i) delete completedGames[i];
for (size_t i = 0; i < engines.size(); ++i) delete engines[i];
for (size_t i = 0; i < employeePool.size(); ++i) delete employeePool[i];
for (size_t i = 0; i < branches.size(); ++i) delete branches[i];
for (size_t i = 0; i < competitors.size(); ++i) delete competitors[i];
}
double GameCompany::getGenreTrend(string genre) const {
map<string, double>::const_iterator it = genreTrends.find(genre);
if (it != genreTrends.end()) return it->second;
return 1.0;
}
void GameCompany::initializeMarketTrends() {
genreTrends["动作游戏"] = 1.0;
genreTrends["角色扮演"] = 1.0;
genreTrends["策略游戏"] = 1.0;
genreTrends["休闲游戏"] = 1.0;
}
void GameCompany::initializeCompetitors() {
competitors.push_back(new Competitor("电子艺界", static_cast<int>(70 * difficultyMultiplier), difficultyMultiplier));
competitors.push_back(new Competitor("动视暴雪", static_cast<int>(75 * difficultyMultiplier), difficultyMultiplier));
competitors.push_back(new Competitor("育碧", static_cast<int>(65 * difficultyMultiplier), difficultyMultiplier));
competitors.push_back(new Competitor("任天堂", static_cast<int>(85 * difficultyMultiplier), difficultyMultiplier));
}
void GameCompany::generateEmployeePool() {
string roles[] = {"程序员", "设计师", "策划", "测试"};
string firstNames[] = {"张", "李", "王", "刘", "陈", "杨", "黄", "赵", "周", "吴"};
string lastNames[] = {"伟", "芳", "娜", "强", "磊", "敏", "静", "丽", "勇", "军"};
for (int i = 0; i < 5; i++) {
string name = firstNames[rand() % 10] + lastNames[rand() % 10];
string role = roles[rand() % 4];
int skill = 1 + rand() % 7;
employeePool.push_back(new Employee(name, role, skill, salaryMultiplier));
}
}
bool GameCompany::hireEmployee(int index) {
if (index < 0 || index >= (int)employeePool.size()) return false;
Employee* emp = employeePool[index];
if (employees.size() >= (size_t)maxEmployees) {
cout << "总部员工已满!请升级办公室或开设分公司。" << endl;
return false;
}
if (money >= emp->getSalary() * 3) {
employees.push_back(emp);
employeePool.erase(employeePool.begin() + index);
money -= emp->getSalary();
cout << "成功招募 " << emp->getName() << "!" << endl;
return true;
} else {
cout << "资金不足,无法招募该员工!" << endl;
return false;
}
}
bool GameCompany::fireEmployee(int index) {
if (index < 0 || index >= (int)employees.size()) return false;
Employee* emp = employees[index];
if (emp->getIsAssigned()) {
cout << "该员工正在参与项目,无法解雇!" << endl;
return false;
}
for (size_t i = 0; i < employees.size(); ++i)
employees[i]->giveBonus(-500);
reputation -= 5;
cout << "已解雇 " << emp->getName() << "。" << endl;
delete emp;
employees.erase(employees.begin() + index);
return true;
}
bool GameCompany::startNewProject(string gameName, string genre, Platform platform, GameEngine* engine) {
if (currentProjects.size() >= 3) {
cout << "当前项目过多,无法同时开发更多游戏!" << endl;
return false;
}
GameProject* project = new GameProject(gameName, genre, platform, engine);
currentProjects.push_back(project);
cout << "成功启动项目《" << gameName << "》!" << endl;
return true;
}
bool GameCompany::startEngineDevelopment(string engineName) {
GameEngine* engine = new GameEngine(engineName);
engines.push_back(engine);
cout << "成功启动引擎开发项目:" << engineName << "!" << endl;
return true;
}
bool GameCompany::upgradeOffice() {
int cost = static_cast<int>(officeLevel * 100000 * difficultyMultiplier);
if (money >= cost) {
money -= cost;
officeLevel++;
maxEmployees += 5;
reputation += 5;
cout << "办公室升级到 " << officeLevel << " 级!员工容量增加到 " << maxEmployees << " 人。" << endl;
return true;
} else {
cout << "资金不足!升级需要 " << cost << " 元。" << endl;
return false;
}
}
bool GameCompany::openBranch(string location) {
int cost = static_cast<int>(500000 * difficultyMultiplier);
if (money >= cost) {
money -= cost;
branches.push_back(new BranchOffice(location));
reputation += 10;
cout << "在 " << location << " 成功开设分公司!" << endl;
return true;
} else {
cout << "资金不足!开设分公司需要 " << cost << " 元。" << endl;
return false;
}
}
bool GameCompany::acquireStudio(string studioName, int cost) {
int actualCost = static_cast<int>(cost * difficultyMultiplier);
if (money >= actualCost) {
money -= actualCost;
reputation += 20;
int numEmployees = 3 + rand() % 5;
for (int i = 0; i < numEmployees; i++) {
string roles[] = {"程序员", "设计师", "策划", "测试"};
string name = studioName + "员工" + int_to_string(i+1);
string role = roles[rand() % 4];
int skill = 3 + rand() % 5;
employees.push_back(new Employee(name, role, skill, salaryMultiplier));
}
cout << "成功收购 " << studioName << "!获得 " << numEmployees << " 名员工。" << endl;
return true;
} else {
cout << "资金不足!收购需要 " << actualCost << " 元。" << endl;
return false;
}
}
bool GameCompany::goPublic() {
if (isPublic) { cout << "公司已经上市!" << endl; return false; }
if (reputation < 70) { cout << "公司声誉不足!需要至少70点声誉才能上市。" << endl; return false; }
if (completedGames.size() < 5) { cout << "完成游戏数量不足!需要至少完成5款游戏才能上市。" << endl; return false; }
isPublic = true;
money += static_cast<int>(10000000 / difficultyMultiplier);
cout << "^_^ 公司成功上市!获得融资 " << static_cast<int>(10000000 / difficultyMultiplier) << " 元!" << endl;
cout << "当前股价: " << stockPrice << " 元" << endl;
return true;
}
void GameCompany::advanceMonth() {
month++;
cout << "=====================================" << endl;
cout << "第 " << month << " 个月开始" << endl;
cout << "=====================================" << endl;
int totalSalary = 0;
for (size_t i = 0; i < employees.size(); ++i)
totalSalary += employees[i]->getSalary();
money -= totalSalary;
cout << "支付员工工资: " << totalSalary << "元" << endl;
for (size_t i = 0; i < employees.size(); ++i)
if (!employees[i]->getIsAssigned())
employees[i]->restMonth();
for (vector<GameProject*>::iterator it = currentProjects.begin(); it != currentProjects.end();) {
GameProject* proj = *it;
proj->developMonth(difficultyMultiplier);
if (proj->getProgress() >= 100) {
int competitionLevel = 0;
for (size_t i = 0; i < competitors.size(); ++i) {
Competitor* comp = competitors[i];
const vector<GameProject*>& compProjs = comp->getCurrentProjects();
for (size_t j = 0; j < compProjs.size(); ++j) {
GameProject* cp = compProjs[j];
if (cp->getGenre() == proj->getGenre() && cp->getProgress() > 70)
competitionLevel += comp->getStrength() / 10;
}
}
competitionLevel = min(50, competitionLevel);
proj->finishGame(getGenreTrend(proj->getGenre()), competitionLevel, difficultyMultiplier);
proj->displayGameResult();
money += proj->getProfit();
reputation += static_cast<int>((proj->getRating() - 50.0) / 10.0);
reputation = max(0, min(100, reputation));
if (isPublic) {
stockPrice *= (1.0 + (proj->getRating() - 50.0) / 100.0);
cout << "股价变动: " << fixed << setprecision(2) << stockPrice << " 元" << endl;
}
completedGames.push_back(proj);
it = currentProjects.erase(it);
} else ++it;
}
for (size_t i = 0; i < engines.size(); ++i) {
GameEngine* engine = engines[i];
if (!engine->getIsCompleted()) {
engine->developMonth(difficultyMultiplier);
if (engine->getIsCompleted()) {
cout << "^_^ 引擎 " << engine->getName() << " 开发完成!质量: " << engine->getQuality() << "/100" << endl;
reputation += 10;
}
}
}
for (size_t i = 0; i < competitors.size(); ++i)
competitors[i]->developMonth();
updateMarketTrends();
if (month == nextGameShowMonth) {
holdGameShow();
nextGameShowMonth += 6;
}
for (vector<Employee*>::iterator it = employees.begin(); it != employees.end();) {
Employee* emp = *it;
if (emp->getExperience() >= emp->getSkillLevel() * 100)
emp->levelUp(salaryMultiplier);
if (emp->willQuit(difficultyMultiplier)) {
cout << "T_T " << emp->getName() << " 对公司不满,跳槽了!" << endl;
delete emp;
it = employees.erase(it);
reputation -= 5;
} else ++it;
}
employeePool.clear();
generateEmployeePool();
if (money < 0) {
cout << "=====================================" << endl;
cout << "公司破产!游戏结束!经营了 " << month << " 个月。" << endl;
cout << "=====================================" << endl;
exit(0);
}
cout << "本月结束,当前资金: " << money << "元" << endl;
cout << "公司声誉: " << reputation << "/100" << endl;
}
void GameCompany::updateMarketTrends() {
for (map<string, double>::iterator it = genreTrends.begin(); it != genreTrends.end(); ++it) {
double change = (rand() % 20 - 10) / 100.0;
it->second += change;
it->second = max(0.5, min(2.0, it->second));
}
if (rand() % 100 < 10) {
string genres[] = {"动作游戏", "角色扮演", "策略游戏", "休闲游戏"};
string hot = genres[rand() % 4];
genreTrends[hot] = 2.0;
cout << "^ 市场趋势:" << hot << " 非常流行!" << endl;
}
}
void GameCompany::holdGameShow() {
cout << "=====================================" << endl;
cout << "# 全球游戏展会!" << endl;
cout << "=====================================" << endl;
for (size_t i = 0; i < currentProjects.size(); ++i) {
GameProject* p = currentProjects[i];
int exp = p->getProgress() / 2 + reputation / 2;
cout << "《" << p->getName() << "》获得曝光!" << endl;
p->setMarketingBudget(p->getMarketingBudget() + exp * 1000);
}
if (!completedGames.empty() && rand() % 100 < 30) {
GameProject* best = completedGames[0];
for (size_t i = 0; i < completedGames.size(); ++i)
if (completedGames[i]->getRating() > best->getRating())
best = completedGames[i];
if (best->getRating() >= 75) {
cout << "* 恭喜!《" << best->getName() << "》获年度最佳游戏!" << endl;
reputation += 15;
if (isPublic) stockPrice *= 1.2;
}
}
}
void GameCompany::displayEmployeePool() const {
cout << "=====================================" << endl;
cout << "可招募员工" << endl;
cout << "=====================================" << endl;
cout << left << setw(4) << "编号" << setw(12) << "姓名" << setw(10) << "职位" << setw(8) << "技能" << setw(10) << "月薪" << setw(12) << "生产力" << setw(8) << "忠诚度" << endl;
for (int i = 0; i < (int)employeePool.size(); i++) {
cout << left << setw(4) << i+1;
employeePool[i]->displayInfo();
}
}
void GameCompany::displayEmployees() const {
cout << "=====================================" << endl;
cout << "公司员工" << endl;
cout << "=====================================" << endl;
cout << left << setw(4) << "编号" << setw(12) << "姓名" << setw(10) << "职位" << setw(8) << "技能" << setw(10) << "月薪" << setw(12) << "生产力" << setw(8) << "疲劳" << setw(8) << "士气" << setw(12) << "专精" << setw(8) << "忠诚度" << endl;
for (int i = 0; i < (int)employees.size(); i++) {
cout << left << setw(4) << i+1;
employees[i]->displayInfo();
}
}
void GameCompany::displayMarketTrends() const {
cout << "=====================================" << endl;
cout << "市场趋势" << endl;
cout << "=====================================" << endl;
for (map<string, double>::const_iterator it = genreTrends.begin(); it != genreTrends.end(); ++it) {
cout << left << setw(15) << it->first;
if (it->second > 1.5) cout << "* 非常热门" << endl;
else if (it->second > 1.2) cout << "^ 热门" << endl;
else if (it->second > 0.8) cout << "-> 平稳" << endl;
else cout << "v 低迷" << endl;
}
}
GameDevCompanyGame::GameDevCompanyGame() : running(true) {
srand((unsigned int)time(NULL));
}
GameDevCompanyGame::~GameDevCompanyGame() {
delete company;
}
void GameDevCompanyGame::start() {
cout << "=====================================" << endl;
cout << " 游戏开发公司 修复版" << endl;
cout << "=====================================" << endl;
cout << "1.查看教程 2.直接开始:";
int tc = getIntInput(1,2);
if (tc ==1) showTutorial();
cout << "\n选择难度:1简单 2普通 3困难:";
int dc = getIntInput(1,3);
Difficulty d;
if (dc ==1) d=DIFFICULTY_EASY;
else if(dc==2) d=DIFFICULTY_NORMAL;
else d=DIFFICULTY_HARD;
cout << "公司名:";
string name;
getline(cin,name);
company = new GameCompany(name,d);
mainLoop();
}
void GameDevCompanyGame::showTutorial() {
cout << "\n====教程====\n经营公司,开发游戏,赚钱壮大!\n按回车继续...\n";
cin.ignore(); cin.get();
}
void GameDevCompanyGame::mainLoop() {
while(running) {
displayMainMenu();
int c=getIntInput(0,8);
switch(c){
case 1: viewCompanyStatus(); break;
case 2: employeeManagementMenu(); break;
case 3: projectManagementMenu(); break;
case 4: engineDevelopmentMenu(); break;
case 5: marketAndMarketingMenu(); break;
case 6: companyDevelopmentMenu(); break;
case 7: nextMonth(); break;
case 8: viewGameHistory(); break;
case 0: running=false; cout<<"再见\n"; break;
}
}
}
void GameDevCompanyGame::displayMainMenu() {
cout<<"\n====主菜单 第"<<company->getMonth()<<"月====\n";
cout<<"资金:"<<company->getMoney()<<" 声誉:"<<company->getReputation()<<"\n";
cout<<"1公司状态 2员工 3项目 4引擎 5市场 6发展 7下月 8历史 0退出\n";
}
void GameDevCompanyGame::viewCompanyStatus() {
cout<<"\n====公司====\n";
cout<<"名:"<<company->getName()<<" 月:"<<company->getMonth()<<"\n";
cout<<"资金:"<<company->getMoney()<<" 声誉:"<<company->getReputation()<<"\n";
company->displayEmployees();
}
void GameDevCompanyGame::employeeManagementMenu() {
while(1){
cout<<"\n====员工管理====\n1查看 2招募 3解雇 4奖金 0返回\n";
int c=getIntInput(0,4);
if(c==0)break;
if(c==1)company->displayEmployees();
if(c==2)hireEmployeeMenu();
if(c==3)fireEmployeeMenu();
if(c==4)giveBonusMenu();
}
}
void GameDevCompanyGame::hireEmployeeMenu() {
company->displayEmployeePool();
int c=getIntInput(0,company->getEmployeePool().size(),"选员工(0返回):");
if(c==0)return;
company->hireEmployee(c-1);
}
void GameDevCompanyGame::fireEmployeeMenu() {
if(company->getEmployees().empty()){cout<<"无人\n";return;}
company->displayEmployees();
int c=getIntInput(0,company->getEmployees().size(),"解雇谁(0返回):");
if(c==0)return;
company->fireEmployee(c-1);
}
void GameDevCompanyGame::giveBonusMenu() {
if(company->getEmployees().empty()){cout<<"无人\n";return;}
company->displayEmployees();
int c=getIntInput(0,company->getEmployees().size(),"发奖金给谁(0返回):");
if(c==0)return;
int a=getIntInput(0,company->getMoney(),"金额:");
company->getEmployees()[c-1]->giveBonus(a);
company->getMoney()-=a;
}
void GameDevCompanyGame::projectManagementMenu() {
while(1){
cout<<"\n====项目====\n1新项目 2管理 3DLC 4续作 0返回\n";
int c=getIntInput(0,4);
if(c==0)break;
if(c==1)startNewProjectMenu();
if(c==2)manageCurrentProjectsMenu();
if(c==3)createDLCMenu();
if(c==4)createSequelMenu();
}
}
void GameDevCompanyGame::startNewProjectMenu() {
cout<<"\n新项目\n游戏名:";
string n; getline(cin,n);
cout<<"类型:1动作2角色扮演3策略4休闲:";
int g=getIntInput(1,4);
string gen;
if(g==1)gen="动作游戏"; else if(g==2)gen="角色扮演"; else if(g==3)gen="策略游戏"; else gen="休闲游戏";
cout<<"平台1PC2主机3手机:";
int p=getIntInput(1,3);
Platform pf;
if(p==1)pf=PLATFORM_PC; else if(p==2)pf=PLATFORM_CONSOLE; else pf=PLATFORM_MOBILE;
GameEngine* e=NULL;
if(!company->getEngines().empty()){
cout<<"引擎0不用:";
for(int i=0;i<(int)company->getEngines().size();i++)
cout<<i+1<<company->getEngines()[i]->getName()<<" ";
int ec=getIntInput(0,company->getEngines().size());
if(ec>0)e=company->getEngines()[ec-1];
}
company->startNewProject(n,gen,pf,e);
}
void GameDevCompanyGame::manageCurrentProjectsMenu() {
const vector<GameProject*>& ps=company->getCurrentProjects();
if(ps.empty()){cout<<"无项目\n";return;}
cout<<"\n项目列表:\n";
for(int i=0;i<(int)ps.size();i++)
cout<<i+1<<ps[i]->getName()<<" "<<ps[i]->getProgress()<<"%\n";
int c=getIntInput(0,ps.size(),"选项目(0返回):");
if(c==0)return;
GameProject* p=ps[c-1];
while(1){
cout<<"\n项目管理\n1侧重 2分配 3营销 0返回\n";
int o=getIntInput(0,3);
if(o==0)break;
if(o==1)adjustGameFocus(p);
if(o==2)assignEmployeesToProject(p);
if(o==3)setMarketingBudget(p);
}
}
void GameDevCompanyGame::adjustGameFocus(GameProject* project) {
int gp=getIntInput(0,10,"游戏性:");
int gr=getIntInput(0,10,"画面:");
int st=getIntInput(0,10,"剧情:");
int so=getIntInput(0,10,"音效:");
int op=getIntInput(0,10,"优化:");
project->setFocus(gp,gr,st,so,op);
}
void GameDevCompanyGame::assignEmployeesToProject(GameProject* project) {
const vector<Employee*>& es=company->getEmployees();
if(es.empty()){cout<<"无人\n";return;}
vector<int> ids;
for(int i=0;i<(int)es.size();i++)
if(!es[i]->getIsAssigned())ids.push_back(i);
if(ids.empty()){cout<<"全忙\n";return;}
cout<<"可分配:\n";
for(int i=0;i<(int)ids.size();i++)
cout<<i+1<<es[ids[i]]->getName()<<" "<<es[ids[i]]->getRole()<<"\n";
while(1){
int c=getIntInput(0,ids.size(),"分配(0结束):");
if(c==0)break;
project->assignEmployee(es[ids[c-1]]);
break;
}
}
void GameDevCompanyGame::setMarketingBudget(GameProject* project) {
int b=getIntInput(0,INT_MAX,"预算:");
project->setMarketingBudget(b);
}
void GameDevCompanyGame::createDLCMenu() {
const vector<GameProject*>& g=company->getCompletedGames();
if(g.empty()){cout<<"无已完成游戏\n";return;}
for(int i=0;i<(int)g.size();i++)
cout<<i+1<<g[i]->getName()<<"\n";
int c=getIntInput(0,g.size(),"选游戏(0返回):");
if(c==0)return;
cout<<"DLC名:";string n;getline(cin,n);
GameProject* d=GameProject::createDLC(n,g[c-1]);
company->getCurrentProjects().push_back(d);
}
void GameDevCompanyGame::createSequelMenu() {
const vector<GameProject*>& g=company->getCompletedGames();
if(g.empty()){cout<<"无\n";return;}
for(int i=0;i<(int)g.size();i++)
cout<<i+1<<g[i]->getName()<<"\n";
int c=getIntInput(0,g.size(),"选(0返回):");
if(c==0)return;
cout<<"续作名:";string n;getline(cin,n);
GameProject* s=GameProject::createSequel(n,g[c-1]);
company->getCurrentProjects().push_back(s);
}
void GameDevCompanyGame::engineDevelopmentMenu() {
while(1){
cout<<"\n====引擎====\n1新建 2管理 3升级 0返回\n";
int c=getIntInput(0,3);
if(c==0)break;
if(c==1)startNewEngineMenu();
if(c==2)manageEnginesMenu();
if(c==3)upgradeEngineMenu();
}
}
void GameDevCompanyGame::startNewEngineMenu() {
cout<<"引擎名:";string n;getline(cin,n);
company->startEngineDevelopment(n);
}
void GameDevCompanyGame::manageEnginesMenu() {
const vector<GameEngine*>& es=company->getEngines();
if(es.empty()){cout<<"无\n";return;}
for(int i=0;i<(int)es.size();i++)
cout<<i+1<<es[i]->getName()<<" "<<es[i]->getProgress()<<"%\n";
int c=getIntInput(0,es.size(),"选(0返回):");
if(c==0)return;
GameEngine* e=es[c-1];
while(1){
cout<<"\n1分配员工 0返回\n";
int o=getIntInput(0,1);
if(o==0)break;
assignEmployeesToEngine(e);
}
}
void GameDevCompanyGame::assignEmployeesToEngine(GameEngine* engine) {
const vector<Employee*>& es=company->getEmployees();
vector<int> ids;
for(int i=0;i<(int)es.size();i++)
if(!es[i]->getIsAssigned() && es[i]->getRole()=="程序员")
ids.push_back(i);
if(ids.empty()){cout<<"无可用程序员\n";return;}
for(int i=0;i<(int)ids.size();i++)
cout<<i+1<<es[ids[i]]->getName()<<"\n";
int c=getIntInput(0,ids.size(),"分配(0结束):");
if(c==0)return;
engine->assignEmployee(es[ids[c-1]]);
es[ids[c-1]]->setAssigned(true);
}
void GameDevCompanyGame::upgradeEngineMenu() {
const vector<GameEngine*>& es=company->getEngines();
vector<int> ids;
for(int i=0;i<(int)es.size();i++)
if(es[i]->getIsCompleted())ids.push_back(i);
if(ids.empty()){cout<<"无可升级\n";return;}
for(int i=0;i<(int)ids.size();i++)
cout<<i+1<<es[ids[i]]->getName()<<"\n";
int c=getIntInput(0,ids.size(),"选(0返回):");
if(c==0)return;
es[ids[c-1]]->upgrade();
}
void GameDevCompanyGame::marketAndMarketingMenu() {
while(1){
cout<<"\n====市场====\n1趋势 2对手 0返回\n";
int c=getIntInput(0,2);
if(c==0)break;
if(c==1)company->displayMarketTrends();
if(c==2)viewCompetitors();
}
}
void GameDevCompanyGame::viewCompetitors() {
const vector<Competitor*>& cs=company->getCompetitors();
for(int i=0;i<(int)cs.size();i++){
cout<<cs[i]->getName()<<" 实力:"<<cs[i]->getStrength()<<"\n";
}
}
void GameDevCompanyGame::companyDevelopmentMenu() {
while(1){
cout<<"\n====发展====\n1升级办公室 2开分公司 3收购 4上市 0返回\n";
int c=getIntInput(0,4);
if(c==0)break;
if(c==1)company->upgradeOffice();
if(c==2)openBranchMenu();
if(c==3)acquireStudioMenu();
if(c==4)company->goPublic();
}
}
void GameDevCompanyGame::openBranchMenu() {
cout<<"城市1北京2上海3深圳4洛杉矶5东京:";
int c=getIntInput(0,5);
if(c==0)return;
string loc;
if(c==1)loc="北京";else if(c==2)loc="上海";else if(c==3)loc="深圳";else if(c==4)loc="洛杉矶";else loc="东京";
company->openBranch(loc);
}
void GameDevCompanyGame::acquireStudioMenu() {
cout<<"1小50万 2中200万 3大500万:";
int c=getIntInput(0,3);
if(c==0)return;
int cost;string name;
if(c==1){cost=500000;name="小型工作室";}
else if(c==2){cost=2000000;name="中型工作室";}
else {cost=5000000;name="大型工作室";}
company->acquireStudio(name,cost);
}
void GameDevCompanyGame::nextMonth() {
company->advanceMonth();
}
void GameDevCompanyGame::viewGameHistory() {
const vector<GameProject*>& g=company->getCompletedGames();
if(g.empty()){cout<<"无\n";return;}
for(int i=0;i<(int)g.size();i++){
cout<<i+1<<g[i]->getName()<<" 评分"<<fixed<<setprecision(1)<<g[i]->getRating()<<"\n";
}
}
int main() {
GameDevCompanyGame game;
game.start();
return 0;
}