mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
- Skeleton transformer implemented
This commit is contained in:
parent
88f0ee0682
commit
e4fcfd7044
@ -742,8 +742,17 @@ void CCastleInterface::buildingClicked(int building)
|
||||
break;
|
||||
}
|
||||
/*Necropolis*/ case 4: //Skeleton Transformer
|
||||
tlog4<<"Skeleton Transformer not handled\n";
|
||||
break;
|
||||
const CGHeroInstance *hero;
|
||||
if (town->visitingHero)
|
||||
hero = town->visitingHero;
|
||||
else if (town->garrisonHero)
|
||||
hero = town->garrisonHero;
|
||||
else
|
||||
hero = NULL;//no hero - will trade with town garrison
|
||||
|
||||
GH.pushInt ( new CTransformerWindow(hero, town) );
|
||||
break;
|
||||
|
||||
/*Dungeon*/ case 5: //Portal of Summoning
|
||||
tlog4<<"Portal of Summoning not handled\n";
|
||||
break;
|
||||
|
@ -18,6 +18,7 @@ class CResDataBar;
|
||||
class CStatusBar;
|
||||
class CTownList;
|
||||
class CRecruitmentWindow;
|
||||
class CTransformerWindow;
|
||||
class CCreaturePic;
|
||||
class CMinorResDataBar;
|
||||
|
||||
|
@ -5219,6 +5219,102 @@ void CPuzzleWindow::show(SDL_Surface * to)
|
||||
CMessage::drawBorder(LOCPLINT->playerID,to,828,628,pos.x-14,pos.y-15);
|
||||
}
|
||||
|
||||
void CTransformerWindow::CItem::showAll(SDL_Surface * to)
|
||||
{
|
||||
SDL_Surface * backgr = graphics->bigImgs[parent->army->getCreature(id)->idNumber];
|
||||
blitAt(backgr, pos.x, pos.y, to);
|
||||
printAtMiddle(boost::lexical_cast<std::string>(size),pos.x+28, pos.y+76,FONT_SMALL,zwykly,to);//stack size
|
||||
}
|
||||
|
||||
void CTransformerWindow::CItem::move()
|
||||
{
|
||||
if (left)
|
||||
pos.x += 289;
|
||||
else
|
||||
pos.x -= 289;
|
||||
left = !left;
|
||||
}
|
||||
|
||||
void CTransformerWindow::CItem::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(previousState && (!down))
|
||||
{
|
||||
move();
|
||||
parent->showAll(screen2);
|
||||
}
|
||||
}
|
||||
|
||||
CTransformerWindow::CItem::CItem(CTransformerWindow * _parent, int _size, int _id):
|
||||
parent(_parent), id(_id), size(_size)
|
||||
{
|
||||
used = LCLICK;
|
||||
left=true;
|
||||
pos.w = 58;
|
||||
pos.h = 64;
|
||||
|
||||
pos.x += 45 + (id%3)*83 + id/6*83;
|
||||
pos.y += 109 + (id/3)*98;
|
||||
}
|
||||
|
||||
CTransformerWindow::CItem::~CItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CTransformerWindow::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
printAtMiddleLoc( CGI->generaltexth->allTexts[485], 153, 29,FONT_SMALL, tytulowy,to);//holding area
|
||||
printAtMiddleLoc( CGI->generaltexth->allTexts[486], 153+295, 29,FONT_SMALL, tytulowy,to);//transformer
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[487], 153, 75,FONT_MEDIUM, 32,tytulowy,to);//move creatures to create skeletons
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[488], 153+295, 75,FONT_MEDIUM, 32,tytulowy,to);//creatures here will become skeletons
|
||||
}
|
||||
|
||||
void CTransformerWindow::makeDeal()
|
||||
{
|
||||
for (int i=0; i<items.size(); i++)
|
||||
if (!items[i]->left)
|
||||
LOCPLINT->cb->trade(town, CREATURE_UNDEAD, items[i]->id, 0, 0, hero);
|
||||
}
|
||||
|
||||
void CTransformerWindow::addAll()
|
||||
{
|
||||
for (int i=0; i<items.size(); i++)
|
||||
if (items[i]->left)
|
||||
items[i]->move();
|
||||
showAll(screen2);
|
||||
}
|
||||
|
||||
CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town):hero(_hero),town(_town)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
used = LCLICK;
|
||||
pos.x = screen->w/2 - 300;
|
||||
pos.y = screen->h/2 - 242;
|
||||
bg = new CPicture ("SKTRNBK.PCX");
|
||||
bg->colorizeAndConvert(LOCPLINT->playerID);
|
||||
pos.w = bg->bg->w;
|
||||
pos.h = bg->bg->h;
|
||||
|
||||
if (hero)
|
||||
army = hero;
|
||||
else
|
||||
army = town;
|
||||
|
||||
for (int i=0; i<7; i++ )
|
||||
if ( army->getCreature(i) )
|
||||
items.push_back(new CItem(this, army->getAmount(i), i));
|
||||
|
||||
all = new AdventureMapButton(CGI->generaltexth->zelp[590],boost::bind(&CTransformerWindow::addAll,this), 146,416,"ALTARMY.DEF",SDLK_a);
|
||||
convert= new AdventureMapButton(CGI->generaltexth->zelp[591],boost::bind(&CTransformerWindow::makeDeal,this), 269,416,"ALTSACR.DEF",SDLK_RETURN);
|
||||
cancel = new AdventureMapButton(CGI->generaltexth->zelp[592],boost::bind(&CGuiHandler::popIntTotally,&GH, this),392,416,"ICANCEL.DEF",SDLK_ESCAPE);
|
||||
}
|
||||
|
||||
CTransformerWindow::~CTransformerWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CShopWindow::swapItem (ui16 which, bool choose)
|
||||
{
|
||||
bool itemFound = false;
|
||||
|
@ -956,6 +956,38 @@ public:
|
||||
~CPuzzleWindow();
|
||||
};
|
||||
|
||||
class CTransformerWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
class CItem : public CIntObject
|
||||
{
|
||||
public:
|
||||
int id;//position of creature in hero army
|
||||
bool left;//position of the item
|
||||
int size; //size of creature stack
|
||||
CTransformerWindow * parent;
|
||||
|
||||
void move();
|
||||
void showAll(SDL_Surface * to);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
CItem(CTransformerWindow * _parent, int _size, int _id);
|
||||
~CItem();
|
||||
};
|
||||
|
||||
const CArmedInstance *army;//object with army for transforming (hero or town)
|
||||
const CGHeroInstance *hero;//only if we have hero in town
|
||||
const CGTownInstance *town;//market, town garrison is used if hero == NULL
|
||||
CPicture *bg; //background
|
||||
std::vector<CItem*> items;
|
||||
|
||||
AdventureMapButton *all, *convert, *cancel;
|
||||
void showAll(SDL_Surface * to);
|
||||
void makeDeal();
|
||||
void addAll();
|
||||
CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town); //c-tor
|
||||
~CTransformerWindow(); //d-tor
|
||||
};
|
||||
|
||||
class CShopWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
|
3
global.h
3
global.h
@ -109,7 +109,8 @@ const int WEEKLY_GROWTH = 10; //percent
|
||||
|
||||
enum EMarketMode
|
||||
{
|
||||
RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT, ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP,
|
||||
RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT,
|
||||
ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD,
|
||||
MARTKET_AFTER_LAST_PLACEHOLDER
|
||||
};
|
||||
|
||||
|
@ -1954,6 +1954,8 @@ bool CGTownInstance::allowsTrade(EMarketMode mode) const
|
||||
return (subID == 2 || subID == 5 || subID == 8) && vstd::contains(builtBuildings, 17);//artifact merchants
|
||||
case CREATURE_RESOURCE:
|
||||
return subID == 6 && vstd::contains(builtBuildings, 21); //Freelancer's guild
|
||||
case CREATURE_UNDEAD:
|
||||
return subID == 4 && vstd::contains(builtBuildings, 22);//Skeleton transformer
|
||||
default:
|
||||
assert(0);
|
||||
return false;
|
||||
|
@ -3185,6 +3185,36 @@ bool CGameHandler::sellCreatures(ui32 count, const IMarket *market, const CGHero
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameHandler::transformInUndead(const IMarket *market, const CGHeroInstance * hero, ui32 slot)
|
||||
{
|
||||
const CArmedInstance *army = NULL;
|
||||
if (hero)
|
||||
army = hero;
|
||||
else
|
||||
{
|
||||
army = dynamic_cast<const CGTownInstance *>(market->o);
|
||||
}
|
||||
if (!army)
|
||||
COMPLAIN_RET("Incorrect call to transform in undead!");
|
||||
tlog1<<"test2\n";
|
||||
if(!vstd::contains(army->Slots(), slot))
|
||||
COMPLAIN_RET("Army doesn't have any creature in that slot!");
|
||||
tlog1<<"test3\n";
|
||||
const CStackInstance &s = army->getStack(slot);
|
||||
int resCreature;//resulting creature - bone dragons or skeletons
|
||||
|
||||
if (s.hasBonusOfType(Bonus::KING1))
|
||||
resCreature = 68;
|
||||
else
|
||||
resCreature = 56;
|
||||
tlog1<<"test4\n";
|
||||
SetGarrisons sg;
|
||||
sg.garrs[army->id] = army->getArmy();
|
||||
sg.garrs[army->id].setCreature(slot, resCreature, s.count);
|
||||
sendAndApply(&sg);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameHandler::sendResources(ui32 val, ui8 player, ui32 r1, ui32 r2)
|
||||
{
|
||||
const PlayerState *p2 = gs->getPlayer(r2, false);
|
||||
|
@ -172,6 +172,7 @@ public:
|
||||
bool tradeResources(const IMarket *market, ui32 val, ui8 player, ui32 id1, ui32 id2);
|
||||
bool sendResources(ui32 val, ui8 player, ui32 r1, ui32 r2);
|
||||
bool sellCreatures(ui32 count, const IMarket *market, const CGHeroInstance * hero, ui32 slot, ui32 resourceID);
|
||||
bool transformInUndead(const IMarket *market, const CGHeroInstance * hero, ui32 slot);
|
||||
bool assembleArtifacts (si32 heroID, ui16 artifactSlot, bool assemble, ui32 assembleTo);
|
||||
bool buyArtifact( ui32 hid, si32 aid ); //for blacksmith and mage guild only -> buying for gold in common buildings
|
||||
bool buyArtifact( const IMarket *m, const CGHeroInstance *h, int rid, int aid); //for artifact merchant and black market -> buying for any resource in special building / advobject
|
||||
|
@ -156,6 +156,8 @@ bool TradeOnMarketplace::applyGh( CGameHandler *gh )
|
||||
if(!hero)
|
||||
COMPLAIN_AND_RETURN("Only hero can buy artifacts!");
|
||||
return gh->buyArtifact(m, hero, r1, r2);
|
||||
case CREATURE_UNDEAD:
|
||||
return gh->transformInUndead(m, hero, r1);
|
||||
default:
|
||||
COMPLAIN_AND_RETURN("Unknown exchange mode!");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user