2019-11-06 13:36:28 +00:00
|
|
|
#include "AllyCenter.h"
|
|
|
|
#include "Observer.h"
|
|
|
|
|
|
|
|
/*********** AllyCenter ****************/
|
|
|
|
AllyCenter::AllyCenter(){
|
2021-10-13 23:54:58 +00:00
|
|
|
printf("大吉大利,今晚吃鸡!\n");
|
2019-11-06 13:36:28 +00:00
|
|
|
}
|
|
|
|
|
2021-10-13 23:54:58 +00:00
|
|
|
// 加入玩家
|
2019-11-06 13:36:28 +00:00
|
|
|
void AllyCenter::join(Observer* player){
|
|
|
|
if (playerList.size() == 4){
|
2021-10-13 23:54:58 +00:00
|
|
|
printf("玩家已满!\n");
|
2019-11-06 13:36:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-13 23:54:58 +00:00
|
|
|
printf("玩家 %s 加入\n", player->getName().c_str());
|
2019-11-06 13:36:28 +00:00
|
|
|
playerList.push_back(player);
|
|
|
|
if (playerList.size() == 4){
|
2021-10-13 23:54:58 +00:00
|
|
|
printf("组队成功,不要怂,一起上!\n");
|
2019-11-06 13:36:28 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-13 23:54:58 +00:00
|
|
|
// 移除玩家
|
2019-11-06 13:36:28 +00:00
|
|
|
void AllyCenter::remove(Observer* player){
|
2021-10-13 23:54:58 +00:00
|
|
|
printf("玩家 %s 退出\n", player->getName().c_str());
|
2019-11-06 13:36:28 +00:00
|
|
|
//playerList.remove(player);
|
|
|
|
}
|
|
|
|
/*********** AllyCenter ****************/
|
|
|
|
|
|
|
|
|
|
|
|
/********** AllyCenterController *******/
|
|
|
|
AllyCenterController::AllyCenterController(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-13 23:54:58 +00:00
|
|
|
// 实现通知方法
|
2019-11-06 13:36:28 +00:00
|
|
|
void AllyCenterController::notify(INFO_TYPE infoType, std::string name){
|
|
|
|
switch (infoType){
|
|
|
|
case RESOURCE:
|
|
|
|
for each (Observer* obs in playerList){
|
|
|
|
if (obs->getName() != name){
|
|
|
|
((Player*)obs)->come();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HELP:
|
|
|
|
for each (Observer* obs in playerList){
|
|
|
|
if (obs->getName() != name){
|
|
|
|
((Player*)obs)->help();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Nothing\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/********** AllyCenterController *******/
|