Skip to content

Commit

Permalink
reorganize layout and reduce menu
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonly committed Apr 27, 2016
1 parent 11e1387 commit 55db9ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Monopoly/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ namespace monopoly {
gs.message += "请输入步数(-9 ~ 9), 负号表示反向于前进方向: (输入 " + RED + "x" + NC + " 返回)";
gs.state = GS::step;
}
else if (strcmp(cmd, "i") == 0) {
Player &player = gs.currentPlayer();
gs.message += "玩家 " + gc.posSymbolMap[player.name] + "信息:";
gs.message += "\n现金: ¥" + to_string(player.cash);
gs.message += "\n存款: ¥" + to_string(player.deposit);
}
// else if (strcmp(cmd, "i") == 0) {
// Player &player = gs.currentPlayer();
// gs.message += "玩家 " + gc.posSymbolMap[player.name] + "信息:";
// gs.message += "\n现金: ¥" + to_string(player.cash);
// gs.message += "\n存款: ¥" + to_string(player.deposit);
// }
else if (strcmp(cmd, "r") == 0) {
gs.lastRoll = static_cast<int>(rand() % 6) + 1;
// gs.lastRoll = 5; // TODO: remove
Expand Down
22 changes: 20 additions & 2 deletions Monopoly/GameContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace monopoly {
Player& player = gs.currentPlayer();
Land& land = gs.board[player.x][player.y];
string posName;

if (land.landType == LandType::land) {
if (land.owner == "none") {
posName = "land";
Expand All @@ -113,10 +114,27 @@ namespace monopoly {
cout << "现在是玩家 " << player << " 的回合, "
<< PURPLE << (gs.currentPlayer().direction ? "" : "") << NC << "时针, "
<< "当前位置" << posSymbolMap[posName] << endl;

cout << "玩家信息: ";
cout << "现金¥" << player.cash << ", 存款¥" << player.deposit;
cout << " | 道具: ";

vector<Tool>::iterator it = player.tools.begin();
int i = 0;
for (; !player.tools.empty() && it != player.tools.end()-1; it++, i++) {
cout << i << "." << it->type << ", ";
}
if (!player.tools.empty()) {
cout << i << "." << it->type << endl;
}
else {
cout << "" << endl;
}

cout << "你可以做:" << endl
<< "t(tool) - 道具列表" << endl
// << "t(tool) - 道具列表" << endl
<< "s(step) - 查看前后若干步的具体信息" << endl
<< "i(info) - 查看玩家资产信息" << endl
// << "i(info) - 查看玩家资产信息" << endl
<< "r(roll) - 掷骰子" << endl
<< "gg(GG) - 是在下输了" << endl;
}
Expand Down
3 changes: 1 addition & 2 deletions Monopoly/Tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#include "Tool.hpp"

namespace monopoly {
Tool::Tool(string type) {
type = type;
Tool::Tool(string type): type(type) {
}

ostream& operator <<(ostream& os, Tool& tool) {
Expand Down

0 comments on commit 55db9ef

Please sign in to comment.