#include "fightWidgetRowWidget.h"

QString FightWidgetRow::getNameQString() const {
	return QString::fromUtf8(name_.c_str());
}

QString FightWidgetRow::getNameAndIDQString() const {
	return QString::fromUtf8(name_.c_str()) + " (" + QString::number(id_) + ")";
}

std::string FightWidgetRow::getName() const {
	return name_;
}

EFortressType FightWidgetRow::getFortressType() const {
	return fortressType_;
}

id_t FightWidgetRow::getId() const {
	return id_;
}
	
bool FightWidgetRow::canBuild() const {
	return canBuild_;
}

QString FightWidgetRow::getRealmNameQString() const {
	return QString::fromUtf8(realmName_.c_str());
}

std::string FightWidgetRow::getRealmName() const {
	return realmName_;
}

std::string FightWidgetRow::getPlanetName() const {
	return planetName_;
}

bool FightWidgetRow::isShip() const {
	return fortressType_ == FORTRESS_TYPE_SHIP;
}

bool FightWidgetRow::isOwned() const {
	return isOwned_;
}

void FightWidgetRow::setShellIconEnabled(bool enabled) {
	this->shellIconEnabled_ = enabled;
}

bool FightWidgetRow::getShellIconEnabled() {
	return shellIconEnabled_;
}

FightWidgetRow::FightWidgetRow(const SimpleItem & item, EFortressType fortressType, bool isOwned) {
	this->fortressType_ = fortressType;
	this->isOwned_ = isOwned;
	this->name_ = item.name;
	this->realmName_ = item.realmName;
	this->id_ = item.id;

	this->planetName_ = "";
	this->canBuild_ = false;
	this->isShell_ = item.isShell;
} 

FightWidgetRow::FightWidgetRow(const FortressInRangeData & item, EFortressType fortressType) {
	this->fortressType_ = fortressType;		
	this->name_ = item.name;
	this->realmName_ = item.realmName;
	this->id_ = item.id;

	this->isOwned_ = false;
	this->planetName_ = "";
	this->canBuild_ = false;

	// Fortress is shell if it is not constructed
	this->isShell_ = item.isShell;
} 

FightWidgetRow::FightWidgetRow(const fortress_class_simple_data & item, EFortressType fortressType) {
	this->fortressType_ = fortressType;		
	this->name_ = item.name;
	this->id_ = item.id;

	this->isOwned_ = false;
	this->realmName_ = "";
	this->planetName_ = "";
	this->canBuild_ = false;

	// Fortress class is never shell
	this->isShell_ = false;
}

FightWidgetRow::FightWidgetRow(const fortress_build_information & item, EFortressType fortressType) {
	this->fortressType_ = fortressType;
	this->name_ = item.fortressName;
	this->id_ = item.fortressId;

	this->planetName_ = item.planetToBuildABaseName;
	this->canBuild_ = item.isTherePlanetToBuildABase && item.fortressTitan >= item.requiredTitan;

	this->isOwned_ = true;
	this->realmName_ = "";	

	// Our fortress will never be shell, if it was shell, it would not be controlled, so not ours
	this->isShell_ = false;
} 

bool FightWidgetRow::isShell() const {
	return isShell_;
}

FightWidgetRow::FightWidgetRow(const fortress_attack_information & item, EFortressType fortressType, bool isOwned) {
	this->fortressType_ = fortressType;
	this->name_ = item.fortressFightData.name;
	this->id_ = item.fortressFightData.id;

	this->planetName_ = "";	
	this->canBuild_ = false;
	this->isOwned_ = isOwned;
	this->realmName_ = "";	

	// Our fortress will never be shell, if it was shell, it would not be controlled, so not ours
	this->isShell_ = false;
} 