Erwan
- Added Dr Solomat's TEMPEST expansion - Added Sacrifice as part of the cost of activated abilities. Making it work as an extra cost for "put in play" still requires some work though. "Render" methods need to be written correctly - Added cards with sacrifice in the existing sets. Most of them need testing...
This commit is contained in:
118
projects/mtg/src/ExtraCost.cpp
Normal file
118
projects/mtg/src/ExtraCost.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "../include/ExtraCost.h"
|
||||
#include "../include/TargetChooser.h"
|
||||
#include "../include/MTGCardInstance.h"
|
||||
#include <JGE.h>
|
||||
|
||||
ExtraCost::ExtraCost( TargetChooser *_tc):tc(_tc){
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ExtraCost::setSource(MTGCardInstance * _source){
|
||||
source=_source;
|
||||
if (tc){ tc->source = _source;}
|
||||
return 1;
|
||||
}
|
||||
|
||||
SacrificeCost::SacrificeCost(TargetChooser *_tc):ExtraCost(_tc){
|
||||
target = NULL;
|
||||
if (!tc) OutputDebugString("Self Sacrifice\n");
|
||||
}
|
||||
|
||||
int SacrificeCost::setSource(MTGCardInstance * card){
|
||||
ExtraCost::setSource(card);
|
||||
if (!tc) target = card;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SacrificeCost::setPayment(MTGCardInstance * card){
|
||||
if (tc) {
|
||||
int result = tc->addTarget(card);
|
||||
if (result) {
|
||||
target = card;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SacrificeCost::isPaymentSet(){
|
||||
if (target) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SacrificeCost::doPay(){
|
||||
if(target){
|
||||
target->controller()->game->putInGraveyard(target);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SacrificeCost::Render(){
|
||||
//TODO : real stuff
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
|
||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||
char buffer[200];
|
||||
sprintf(buffer, "sacrifice");
|
||||
mFont->DrawString(buffer, 20 ,20, JGETEXT_LEFT);
|
||||
}
|
||||
|
||||
//
|
||||
//Container
|
||||
//
|
||||
ExtraCosts::ExtraCosts(){
|
||||
action = NULL;
|
||||
source = NULL;
|
||||
}
|
||||
|
||||
void ExtraCosts::Render(){
|
||||
//TODO cool window and stuff...
|
||||
for (int i=0; i < costs.size(); i++){
|
||||
costs[i]->Render();
|
||||
}
|
||||
}
|
||||
|
||||
int ExtraCosts::setAction(MTGAbility * _action, MTGCardInstance * _card){
|
||||
action = _action;
|
||||
source = _card;
|
||||
for (int i=0; i < costs.size(); i++){
|
||||
costs[i]->setSource(_card);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ExtraCosts::reset(){
|
||||
action = NULL;
|
||||
source = NULL;
|
||||
//TODO set all payments to "unset"
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ExtraCosts::tryToSetPayment(MTGCardInstance * card){
|
||||
for (int i=0; i < costs.size(); i++){
|
||||
if (int result = costs[i]->setPayment(card)) return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ExtraCosts::isPaymentSet(){
|
||||
for (int i=0; i < costs.size(); i++){
|
||||
if (!costs[i]->isPaymentSet()) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ExtraCosts::doPay(){
|
||||
int result = 0;
|
||||
for (int i=0; i < costs.size(); i++){
|
||||
result+=costs[i]->doPay();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
void ExtraCosts::Dump(){
|
||||
char buf[4096];
|
||||
OutputDebugString("=====\nDumping ExtraCosts=====\n");
|
||||
sprintf(buf, "NbElements : %i\n", costs.size());
|
||||
OutputDebugString(buf);
|
||||
}
|
||||
Reference in New Issue
Block a user