2019-11-06 13:36:28 +00:00
|
|
|
|
#ifndef __OBSERVER_H__
|
|
|
|
|
#define __OBSERVER_H__
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
using namespace std;
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "AllyCenter.h"
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>۲<EFBFBD><DBB2><EFBFBD> Observer
|
|
|
|
|
class Observer
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-04-04 13:09:08 +00:00
|
|
|
|
virtual ~Observer(){}
|
2019-11-06 13:36:28 +00:00
|
|
|
|
Observer(){}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
virtual void call(INFO_TYPE infoType, AllyCenter* ac) = 0;
|
|
|
|
|
string getName(){
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
void setName(string iName){
|
|
|
|
|
this->name = iName;
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
string name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>
|
|
|
|
|
class Player :public Observer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Player(){
|
|
|
|
|
setName("none");
|
|
|
|
|
}
|
|
|
|
|
Player(string iName){
|
|
|
|
|
setName(iName);
|
|
|
|
|
}
|
|
|
|
|
// ʵ<><CAB5>
|
|
|
|
|
void call(INFO_TYPE infoType, AllyCenter* ac){
|
|
|
|
|
switch (infoType){
|
|
|
|
|
case RESOURCE:
|
|
|
|
|
printf("%s :<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n", getName().c_str());
|
|
|
|
|
break;
|
|
|
|
|
case HELP:
|
|
|
|
|
printf("%s :<3A>Ⱦ<EFBFBD><C8BE><EFBFBD>\n", getName().c_str());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("Nothing\n");
|
|
|
|
|
}
|
|
|
|
|
ac->notify(infoType, getName());
|
|
|
|
|
}
|
|
|
|
|
// ʵ<>־<EFBFBD><D6BE>巽<EFBFBD><E5B7BD>
|
|
|
|
|
void help(){
|
|
|
|
|
printf("%s:<3A><><EFBFBD><EFBFBD>ס<EFBFBD><D7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣡\n", getName().c_str());
|
|
|
|
|
}
|
|
|
|
|
void come(){
|
|
|
|
|
printf("%s:<3A>õģ<C3B5><C4A3><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>\n", getName().c_str());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|