資源簡介
大富翁游戲源代碼,使用vs2017編譯器,語言為c++,歡迎各位下載使用

代碼片段和文件信息
#include?“board.h“
#include?
board::board()
{
srand((unsigned?int)time(0));
for?(int?i?=?0;?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? {
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
評論
共有 條評論