- Added a few cards
- Creature attacks, blocks, is re-ordered in blocking list events
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-07-12 12:27:55 +00:00
parent feedb16eae
commit ab445c9758
19 changed files with 280 additions and 148 deletions
+3 -1
View File
@@ -9,7 +9,9 @@ CardDescriptor::CardDescriptor(): MTGCardInstance(){
int CardDescriptor::init(){
int result = MTGCardInstance::init();
initAttackersDefensers();
attacker = 0;
defenser = NULL;
banding = NULL;
return result;
}
+52 -35
View File
@@ -27,7 +27,8 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to):
owner = NULL;
if (_belongs_to) owner = _belongs_to->library->owner;
lastController = owner;
initAttackersDefensers();
defenser = NULL;
banding = NULL;
life=toughness;
LOG("==Creating MTGCardInstance Successful==");
@@ -242,8 +243,8 @@ int MTGCardInstance::triggerRegenerate(){
int MTGCardInstance::initAttackersDefensers(){
attacker = 0;
defenser = NULL;
setAttacker(0);
setDefenser(NULL);
banding = NULL;
blockers.clear();
return 1;
@@ -403,26 +404,38 @@ void MTGCardInstance::unband(){
return ;
}
int MTGCardInstance::setAttacker(int value){
Targetable * previousTarget = NULL;
Targetable * target = NULL;
Player * p = controller()->opponent();
if (value) target = p;
if (attacker) previousTarget = p;
attacker = value;
WEvent * e = NEW WEventCreatureAttacker(this,previousTarget, target);
GameObserver::GetInstance()->receiveEvent(e);
delete e;
return 1;
}
int MTGCardInstance::toggleAttacker(){
//TODO more controls ?
if (canAttack()){
if (!attacker){
attacker = 1;
tap();
GameObserver * g = GameObserver::GetInstance();
if (!attacker){
if (!basicAbilities[Constants::VIGILANCE]) tap();
setAttacker(1);
return 1;
}else{
//Banding needs to be debugged...
/*MTGCardInstance * bandingPartner = getNextPartner();
if (bandingPartner){
if (banding) unband();
if (!bandingPartner->banding) bandingPartner->banding = bandingPartner;
banding = bandingPartner->banding;
return 1;
}else{
MTGCardInstance * bandingPartner = getNextPartner();
if (bandingPartner){
if (banding) unband();
if (!bandingPartner->banding) bandingPartner->banding = bandingPartner;
banding = bandingPartner->banding;
return 1;
}else{
attacker = 0;
untap();
return 1;
}
}
}else{*/
untap();
setAttacker(0);
return 1;
//}
}
return 0;
}
@@ -465,14 +478,9 @@ int MTGCardInstance::moveBlockerInRow(MTGCardInstance * blocker){
if (it2 == blockers.end()) it2 = blockers.begin();
blockers.splice( it2, blockers, it1 ); // move a before b, invalidates a
char buffer[512];
OutputDebugString("===Outputing blockers\n");
for (it1 = blockers.begin(); it1 != blockers.end(); it1++){
MTGCardInstance * c = *it1;
sprintf(buffer, "%p-", c);
OutputDebugString(buffer);
}
OutputDebugString("\n===End Outputing blockers\n");
WEvent* e = NEW WEventCreatureBlockerRank(blocker,*it2,this);
GameObserver::GetInstance()->receiveEvent(e);
delete(e);
return 1;
}
@@ -510,15 +518,24 @@ MTGCardInstance * MTGCardInstance::getNextOpponent(MTGCardInstance * previous){
return NULL;
}
int MTGCardInstance::setDefenser(MTGCardInstance * opponent){
GameObserver * g = GameObserver::GetInstance();
if (defenser) defenser->blockers.remove(this);
WEvent * e = NEW WEventCreatureBlocker(this, defenser, opponent);
defenser = opponent;
if (defenser){
defenser->blockers.push_back(this);
}
g->blockersSorted = false;
g->receiveEvent(e);
delete e;
return 1;
}
int MTGCardInstance::toggleDefenser(MTGCardInstance * opponent){
if (canBlock()){
if (canBlock(opponent)){
if (defenser) defenser->blockers.remove(this);
defenser = opponent;
if (defenser){
defenser->blockers.push_back(this);
}
GameObserver::GetInstance()->blockersSorted = false;
setDefenser(opponent);
return 1;
}
}
+1 -2
View File
@@ -116,8 +116,7 @@ void MTGAttackRule::Update(float dt){
int MTGAttackRule::reactToClick(MTGCardInstance * card){
if (!isReactingToClick(card)) return 0;
card->attacker = 1;
if (!card->basicAbilities[Constants::VIGILANCE]) card->tap();
card->toggleAttacker();
return 1;
}
+1
View File
@@ -50,6 +50,7 @@ JQuad * Player::getIcon(){
Player * Player::opponent(){
GameObserver * game = GameObserver::GetInstance();
if (!game) return NULL;
for (int i= 0; i < 2; i++){
if (game->players[i] != this) return game->players[i];
}
+1 -1
View File
@@ -354,7 +354,7 @@ int TestSuite::assertGame(){
for (int j = 0; j < 4; j++){
MTGGameZone * zone = playerZones[j];
if (zone->nb_cards != endState.playerData[i].zones[j].nbitems){
sprintf(result, "<span class=\"error\">==Card number not the same in %i==</span><br />",j);
sprintf(result, "<span class=\"error\">==Card number not the same in %i==, expected %i, got %i</span><br />",j, endState.playerData[i].zones[j].nbitems, zone->nb_cards);
Log(result);
error++;
return 0;
+3 -1
View File
@@ -13,7 +13,9 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness)
model = this;
owner = source->owner;
belongs_to=source->controller()->game;
initAttackersDefensers();
attacker = 0;
defenser = NULL;
banding = NULL;
mCache = source->mCache;
}
+11 -1
View File
@@ -24,4 +24,14 @@ WEventPhaseChange::WEventPhaseChange(Phase * _from, Phase * _to):WEvent(CHANGE_P
to = _to;
}
WEventCardTap::WEventCardTap(MTGCardInstance * card, bool before, bool after):WEvent(), card(card),before(before), after(after){}
WEventCardTap::WEventCardTap(MTGCardInstance * card, bool before, bool after)
:WEventCardUpdate(card), before(before), after(after){}
WEventCreatureAttacker::WEventCreatureAttacker(MTGCardInstance * card,Targetable * before, Targetable * after)
:WEventCardUpdate(card), before(before), after(after){}
WEventCreatureBlocker::WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to)
:WEventCardUpdate(card), before(before), after(after){}
WEventCreatureBlockerRank::WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker)
:WEventCardUpdate(card), exchangeWith(exchangeWith), attacker(attacker){}