fixed travel

This commit is contained in:
Anselme 2016-03-16 17:14:52 +01:00
parent 9c44781fd3
commit 98c3ff193d

View File

@ -142,10 +142,13 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat)
{
if(dir.compare("north") == 0 || dir.compare("n") == 0)
{
if(c->y == 0 || (repeat && terrainType != WORLDMAP[c->x][c->y-1]))
bool isDiff = repeat && terrainType != WORLDMAP[c->x][c->y-1];
if(c->y == 0 || (isDiff && dist != 0))
blocked = true;
else
{
if(isDiff)
blocked = true;
c->y -= 1;
++dist;
}
@ -153,10 +156,13 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat)
}
else if(dir.compare("south") == 0 || dir.compare("s") == 0)
{
if(c->y == 24 || (repeat && terrainType != WORLDMAP[c->x][c->y+1]))
bool isDiff = repeat && terrainType != WORLDMAP[c->x][c->y+1];
if(c->y == 24 || (isDiff && dist != 0))
blocked = true;
else
{
if(isDiff)
blocked = true;
c->y += 1;
++dist;
}
@ -164,10 +170,13 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat)
}
else if(dir.compare("west") == 0 || dir.compare("w") == 0)
{
if(c->x == 0 || (repeat && terrainType != WORLDMAP[c->x-1][c->y]))
bool isDiff = repeat && terrainType != WORLDMAP[c->x-1][c->y];
if(c->x == 0 || (isDiff && dist != 0))
blocked = true;
else
{
if(isDiff)
blocked = true;
c->x -= 1;
++dist;
}
@ -175,10 +184,13 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat)
}
else if(dir.compare("east") == 0 || dir.compare("e") == 0)
{
if(c->x == 24 || (repeat && terrainType != WORLDMAP[c->x+1][c->y]))
bool isDiff = repeat && terrainType != WORLDMAP[c->x+1][c->y];
if(c->x == 24 || (isDiff && dist != 0))
blocked = true;
else
{
if(isDiff)
blocked = true;
c->x += 1;
++dist;
}
@ -191,10 +203,12 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat)
if(blocked)
{
if(repeat && dist > 0)
if(repeat)
{
QString("%1 travels %2 during %3 hours through %4")
.arg(c->pseudo).arg(direction).arg(dist).arg(currentArea);
if(dist > 0)
return QString("%1 travels %2 during %3 hours through %4")
.arg(c->pseudo).arg(direction).arg(dist).arg(currentArea);
else {}
}
else
return QString("%1 cannot go %2, a hill is blocking his way").arg(c->pseudo).arg(direction);