1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

- Initializing movement points (t.#16)

- minor improvements
This commit is contained in:
Michał W. Urbańczyk 2007-10-03 18:53:49 +00:00
parent 8421c901a4
commit 7b3c270dfc
5 changed files with 38 additions and 4 deletions

@ -302,7 +302,7 @@ void CHeroList::draw()
if (pom>25) pom=25;
if (pom<0) pom=0;
blitAtWR(mobile->ourImages[pom].bitmap,posmobx,posmoby+i*32); //move point
pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->mana)/10;
pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->mana)/5; //bylo: .../10;
if (pom>25) pom=25;
if (pom<0) pom=0;
blitAtWR(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana

@ -8,7 +8,38 @@
#include "mapHandler.h"
#include "CGameState.h"
#include "CGameInterface.h"
int CCallback::lowestSpeed(CHeroInstance * chi)
{
int min = 150;
for ( std::map<int,std::pair<CCreature*,int> >::iterator i = chi->army.slots.begin();
i!=chi->army.slots.end(); i++ )
{
if (min>(*i).second.first->speed)
min = (*i).second.first->speed;
}
return min;
}
int CCallback::valMovePoints(CHeroInstance * chi)
{
int ret = 1270+70*lowestSpeed(chi);
if (ret>2000)
ret=2000;
//TODO: additional bonuses (but they aren't currently stored in chi)
return ret;
}
void CCallback::newTurn()
{
//std::map<int, PlayerState>::iterator i = gs->players.begin() ;
for ( std::map<int, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
{
for (int j=0;j<(*i).second.heroes.size();j++)
{
(*i).second.heroes[j]->movement = valMovePoints((*i).second.heroes[j]);
}
}
}
bool CCallback::moveHero(int ID, int3 destPoint, int idtype)
{
if(ID<0 || ID>CGI->heroh->heroInstances.size())

@ -12,12 +12,14 @@ struct HeroMoveDetails
class CCallback
{
private:
int player;
void newTurn();
CCallback(CGameState * GS, int Player):gs(GS),player(Player){};
CGameState * gs;
int lowestSpeed(CHeroInstance * chi); //speed of the slowest stack
int valMovePoints(CHeroInstance * chi);
protected:
CGameState * gs;
int player;
public:
bool moveHero(int ID, int3 destPoint, int idtype=0);//idtype: 0-position in vector; 1-ID of hero

@ -674,7 +674,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
LOCPLINT->adventureInt->update(); //updating screen
CGI->screenh->updateScreen();
SDL_framerateDelay(mainFPSmng); //for animation purposes
}
} //for(int i=1; i<32; i+=4)
//main moving done
//finishing move
if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl

@ -394,6 +394,7 @@ int _tmain(int argc, _TCHAR* argv[])
while(1) //main game loop, one execution per turn
{
cgi->consoleh->cb->newTurn();
for (int i=0;i<cgi->playerint.size();i++)
{
cgi->state->currentPlayer=cgi->playerint[i]->playerID;