* Remove ^M's.
* Re-indent automatically.
* Remove whitespace at the end of lines.
This commit is contained in:
jean.chalard
2008-11-12 13:45:42 +00:00
parent 6ad6f9b668
commit c97dd1f260
116 changed files with 18073 additions and 18073 deletions

View File

@@ -1,131 +1,131 @@
#include "../include/debug.h"
#include "../include/CardDescriptor.h"
CardDescriptor::CardDescriptor(): MTGCardInstance(){
init();
mode = CD_AND;
}
int CardDescriptor::init(){
return MTGCardInstance::init();
}
MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
int found = 1;
for (int i = 0; i< nb_types; i++){
found = 0;
if (card->hasSubtype(types[i])){
found = 1;
break;
}
}
if (!found) return NULL;
for (int i = 0; i< MTG_NB_COLORS; i++){
found = 0;
if (colors[i] == 1 && card->hasColor(i)){
found = 1;
break;
}
}
if (!found) return NULL;
return card;
}
MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card){
#ifdef WIN32
OutputDebugString("Match AND\n");
#endif
MTGCardInstance * match = card;
for (int i = 0; i< nb_types; i++){
if (!card->hasSubtype(types[i])){
#ifdef WIN32
OutputDebugString(card->name.c_str());
OutputDebugString("Subtype No Match\n");
#endif
match = NULL;
}
}
for (int i = 0; i< MTG_NB_COLORS; i++){
if ((colors[i] == 1 && !card->hasColor(i))||(colors[i] == -1 && card->hasColor(i))){
match = NULL;
#ifdef WIN32
OutputDebugString(card->name.c_str());
OutputDebugString("Color No Match\n");
#endif
}
}
return match;
}
MTGCardInstance * CardDescriptor::match(MTGCardInstance * card){
MTGCardInstance * match = card;
if (mode == CD_AND){
match = match_and(card);
}else{
match=match_or(card);
}
//Abilities
for (int j = 0; j < NB_BASIC_ABILITIES; j++){
if ((basicAbilities[j] == 1 && !card->basicAbilities[j]) || (basicAbilities[j] == -1 && card->basicAbilities[j])){
match = NULL;
}
}
if ((tapped == -1 && card->isTapped()) || (tapped == 1 && !card->isTapped())){
match = NULL;
}
if (attacker == 1){
if ((int)defenser == 1){
if (!card->attacker && !card->defenser) match = NULL;
}else{
if (!card->attacker) match = NULL;
}
}else if (attacker == -1){
if ((int)defenser == -1){
if (card->attacker || card->defenser) match = NULL;
}else{
if (card->attacker) match = NULL;
}
}else{
if ((int)defenser == -1){
if (card->defenser) match = NULL;
}else if ((int)defenser == 1){
if (!card->defenser) match = NULL;
}else{
// we don't care about the attack/blocker state
}
}
return match;
}
MTGCardInstance * CardDescriptor::match(MTGGameZone * zone){
return (nextmatch(zone, NULL));
}
MTGCardInstance * CardDescriptor::nextmatch(MTGGameZone * zone, MTGCardInstance * previous){
int found = 0;
if (NULL == previous) found = 1;
for(int i=0; i < zone->nb_cards; i++){
if(found && match(zone->cards[i])){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf,"Card Descriptor MATCH!: %s \n" ,(zone->cards[i])->getName());
OutputDebugString(buf);
#endif
return zone->cards[i];
}
if (zone->cards[i] == previous){
found = 1;
}
}
return NULL;
}
#include "../include/debug.h"
#include "../include/CardDescriptor.h"
CardDescriptor::CardDescriptor(): MTGCardInstance(){
init();
mode = CD_AND;
}
int CardDescriptor::init(){
return MTGCardInstance::init();
}
MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
int found = 1;
for (int i = 0; i< nb_types; i++){
found = 0;
if (card->hasSubtype(types[i])){
found = 1;
break;
}
}
if (!found) return NULL;
for (int i = 0; i< MTG_NB_COLORS; i++){
found = 0;
if (colors[i] == 1 && card->hasColor(i)){
found = 1;
break;
}
}
if (!found) return NULL;
return card;
}
MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card){
#ifdef WIN32
OutputDebugString("Match AND\n");
#endif
MTGCardInstance * match = card;
for (int i = 0; i< nb_types; i++){
if (!card->hasSubtype(types[i])){
#ifdef WIN32
OutputDebugString(card->name.c_str());
OutputDebugString("Subtype No Match\n");
#endif
match = NULL;
}
}
for (int i = 0; i< MTG_NB_COLORS; i++){
if ((colors[i] == 1 && !card->hasColor(i))||(colors[i] == -1 && card->hasColor(i))){
match = NULL;
#ifdef WIN32
OutputDebugString(card->name.c_str());
OutputDebugString("Color No Match\n");
#endif
}
}
return match;
}
MTGCardInstance * CardDescriptor::match(MTGCardInstance * card){
MTGCardInstance * match = card;
if (mode == CD_AND){
match = match_and(card);
}else{
match=match_or(card);
}
//Abilities
for (int j = 0; j < NB_BASIC_ABILITIES; j++){
if ((basicAbilities[j] == 1 && !card->basicAbilities[j]) || (basicAbilities[j] == -1 && card->basicAbilities[j])){
match = NULL;
}
}
if ((tapped == -1 && card->isTapped()) || (tapped == 1 && !card->isTapped())){
match = NULL;
}
if (attacker == 1){
if ((int)defenser == 1){
if (!card->attacker && !card->defenser) match = NULL;
}else{
if (!card->attacker) match = NULL;
}
}else if (attacker == -1){
if ((int)defenser == -1){
if (card->attacker || card->defenser) match = NULL;
}else{
if (card->attacker) match = NULL;
}
}else{
if ((int)defenser == -1){
if (card->defenser) match = NULL;
}else if ((int)defenser == 1){
if (!card->defenser) match = NULL;
}else{
// we don't care about the attack/blocker state
}
}
return match;
}
MTGCardInstance * CardDescriptor::match(MTGGameZone * zone){
return (nextmatch(zone, NULL));
}
MTGCardInstance * CardDescriptor::nextmatch(MTGGameZone * zone, MTGCardInstance * previous){
int found = 0;
if (NULL == previous) found = 1;
for(int i=0; i < zone->nb_cards; i++){
if(found && match(zone->cards[i])){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf,"Card Descriptor MATCH!: %s \n" ,(zone->cards[i])->getName());
OutputDebugString(buf);
#endif
return zone->cards[i];
}
if (zone->cards[i] == previous){
found = 1;
}
}
return NULL;
}