-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.cpp
53 lines (44 loc) · 890 Bytes
/
Card.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Lib.h"
#include "Card.h"
Card::Card(){}
Card::Card(CardInfo *c, Card *p)
{
info=c;insert(p);
}
Card::~Card()
{
if(info) delete info;
erase();
}
CardInfo Card::getCardInfo()
{
return *info;//TODO: Skills like 红颜
}
void Card::erase()
{
zone->size--;prev->next=next;next->prev=prev;
}
void Card::insert(Card *p)
{
zone=p->zone;zone->size++;prev=p;next=p->next;p->next=next->prev=this;
}
void Card::move(Card *p)
{
if(p!=this) {erase();insert(p);}
}
bool Card::isVisibleTo(Player *p)
{
bool res=zone->isVisibleTo(p);//TODO:face down
pair<Card*, Player*> data=make_pair(this,p);
game->applyStatics(visibilityValue,&res,&data);
return res;
}
string Card::toString(Player *p)
{
string res="";
if(isVisibleTo(p)) res+=getPhysicalCardInfo().toString();
else res+="hidden";
res+="@";
res+=zone->toString();
return res;
}