资源简介
大富翁游戏源代码,使用vs2017编译器,语言为c++,欢迎各位下载使用

代码片段和文件信息
#include “board.h“
#include
board::board()
{
srand((unsigned int)time(0));
for (int i = 0; i < MAP_SIZE;++i)
{
m[i] = new square();
}
}
square* board::operator[](int pos)
{
return m[pos];
}
void board::display(player *p1player *p2string *msgstring *cmsg)
{/*display the information to console*/
/*print up side*/
display_up_side();
/*print left and right sides*/
display_lr_side(p1 p2 msg cmsg);
/*print bottom side*/
display_bottom_side();
}
string board::check_fine(int pos)
{
string msg;
player *owner = m[pos]->getowner();
if (pos<3)
pos += MAP_SIZE;
if (owner!=nullptr)
{//square have owner
if(m[(pos + 1) % MAP_SIZE] &&m[(pos + 1)%MAP_SIZE]->getowner()==owner)
{//2 consecutives squares have same owner
if (m[(pos + 2) % MAP_SIZE]&&m[(pos + 2) % MAP_SIZE]->getowner()==owner)
{//3 consecutives squares have same owner
m[pos]->setfine(0.2);
m[(pos + 1) % MAP_SIZE]->setfine(0.2);
m[(pos + 1) % MAP_SIZE]->setfine(0.2);
msg = “pos “+to_string(pos) + “ “ + to_string(pos + 1) + “ “ + to_string(pos + 2) + “ fine increase 20%“;
}
if (m[(pos - 1) % MAP_SIZE]&&m[(pos - 1) % MAP_SIZE]->getowner()==owner)
{//3 consecutives squares have same owner
m[(pos + 0) % MAP_SIZE]->setfine(0.2);
m[(pos + 1) % MAP_SIZE]->setfine(0.2);
m[(pos - 1) % MAP_SIZE]->setfine(0.2);
msg = “pos “ + to_string(pos-1) + “ “ + to_string(pos) + “ “ + to_string(pos + 1) + “ fine increase 20%“;
}
if (m[(pos + 2) % MAP_SIZE]&&m[(pos + 2) % MAP_SIZE]->getowner()!= owner &&m[(pos - 1) % MAP_SIZE]&&m[(pos - 1) % MAP_SIZE]->getowner()!= owner)
{
m[pos]->setfine(0.15);
m[(pos + 1) % MAP_SIZE]->setfine(0.15);
msg = “pos “ + to_string(pos) + “ “ + to_string(pos + 1) + “ fine increase 15%“;
}
}
if (m[(pos - 1) % MAP_SIZE]&&m[(pos - 1) % MAP_SIZE]->getowner() == owner)
{//2 consecutives squares have same owner
if (m[(pos - 2) % MAP_SIZE] &&m[(pos - 2) % MAP_SIZE]->getowner() == owner)
{//3 consecutives squares have same owner
m[pos]->setfine(0.2);
m[(pos - 1) % MAP_SIZE]->setfine(0.2);
m[(pos - 2) % MAP_SIZE]->setfine(0.2);
msg = “pos “ + to_string(pos - 2) + “ “ + to_string(pos - 1) + “ “ + to_string(pos) + “ fine increase 20%“;
}
if (m[(pos - 2) % MAP_SIZE]&&m[(pos - 2) % MAP_SIZE]->getowner() != owner &&m[(pos + 1) % MAP_SIZE]&& m[(pos + 1) % MAP_SIZE]->getowner() != owner)
{//2 consecutives squares have same owner
m[pos]->setfine(0.15);
m[(pos - 1) % MAP_SIZE]->setfine(0.15);
msg = “pos “ + to_string(pos-1) + “ “ + to_string(pos) + “ fine increase 15%“;
}
}
}
return msg;
}
board::~board()
{
for (int i = 0; i < MAP_SIZE;++i)
{
delete m[i];
}
}
void board::displayHelp(int line)
{
string help[8];
help[0] = “--------------------“;
help[1] = “| |“;
help[2] = “|price invest_flag|“;
help[3] = “| |“;
help[4] =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-02-28 19:24 大富翁(完成)\
文件 6848 2018-05-03 16:05 大富翁(完成)\board.cpp
文件 1040 2018-05-03 15:51 大富翁(完成)\board.h
文件 3872 2018-05-03 16:56 大富翁(完成)\game.cpp
文件 653 2018-05-03 15:51 大富翁(完成)\game.h
文件 1293 2018-05-03 16:59 大富翁(完成)\game.txt
文件 277 2018-05-03 14:47 大富翁(完成)\main.cpp
文件 161280 2018-05-03 16:56 大富翁(完成)\Monopoly.exe
文件 1429 2018-08-28 11:28 大富翁(完成)\Monopoly.sln
文件 7592 2018-08-28 10:00 大富翁(完成)\Monopoly.vcxproj
文件 1682 2018-05-02 22:35 大富翁(完成)\Monopoly.vcxproj.filters
文件 165 2018-08-28 09:59 大富翁(完成)\Monopoly.vcxproj.user
文件 1906 2018-05-03 15:58 大富翁(完成)\pla
文件 949 2018-05-03 15:51 大富翁(完成)\pla
文件 1783 2018-05-03 15:37 大富翁(完成)\square.cpp
文件 1117 2018-05-03 11:08 大富翁(完成)\square.h
相关资源
- 猜数字游戏 c语言代码
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- LINUX下命令行界面的C语言细胞游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 用C语言实现的一个打字游戏
- C语言版3D魔方游戏源代码
- 打飞机小游戏57466
- 俄罗斯方块游戏源码(Tetris)
- c++ 猜拳小游戏
- 扫雷游戏.cpp
- 杨中科游戏开发引擎
- 智商超高的中国象棋游戏源码(C++版
- c++ 扫雷游戏源码(控制台)
- C++跑跑卡丁车
- C++“倒忌时”小游戏
- XX游戏客户端源码
- c++小游戏源码.doc
- 基于ege图形的推箱子游戏
- C语言ege贪吃蛇游戏
- C++小游戏4款(源码)
- 推箱子小游戏源码
- 五子棋游戏源码(控制台)
- 猜数字游戏.sb3
- C++贪吃蛇控制台小游戏代码
- 扫雷游戏.cpp(较简单)
- MFC五子棋游戏
- VC++ 大富翁4_大富翁游戏源码
- c++常用游戏算法及数据结构设计
- c++的飞行鸟游戏
评论
共有 条评论