Sfoglia il codice sorgente

* it's possible to exchange stacks between heroes
* fixed bugs with displaying stacks health
* 'T' hotkey opens marketplace window

Michał W. Urbańczyk 16 anni fa
parent
commit
824061e185
3 ha cambiato i file con 33 aggiunte e 3 eliminazioni
  1. 18 0
      client/CAdvmapInterface.cpp
  2. 8 3
      client/GUIClasses.cpp
  3. 7 0
      server/CGameHandler.cpp

+ 18 - 0
client/CAdvmapInterface.cpp

@@ -1561,6 +1561,24 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
 				LOCPLINT->openTownWindow(static_cast<const CGTownInstance*>(selection));
 			return;
 		}
+	case SDLK_t:
+		{
+			//act on key down if marketplace windows is not already opened
+			if(key.state != SDL_PRESSED  ||  dynamic_cast<CMarketplaceWindow*>(LOCPLINT->topInt())) return;
+
+			//check if we have aby marketplace
+			std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo();
+			size_t i = 0;
+			for(; i<towns.size(); i++)
+				if(vstd::contains(towns[i]->builtBuildings, 14))
+					break;
+
+			if(i != towns.size()) //if any town has marketplace, open window
+				LOCPLINT->pushInt(new CMarketplaceWindow); 
+			else //if not - complain
+				LOCPLINT->showInfoDialog("No available marketplace!", std::vector<SComponent*>(), soundBase::sound_todo);
+			return;
+		}
 	default: 
 		return;
 	}

+ 8 - 3
client/GUIClasses.cpp

@@ -67,6 +67,8 @@ static StackState* getStackState(const CGObjectInstance *obj, int pos, bool town
 	if(!h) return NULL;
 
 	StackState *pom = new StackState();
+	pom->shotsLeft = -1;
+	pom->healthBonus = h->valOfBonuses(HeroBonus::STACK_HEALTH);
 	pom->currentHealth = 0;
 	pom->attackBonus = h->getPrimSkillLevel(0);
 	pom->defenseBonus = h->getPrimSkillLevel(1);
@@ -2033,8 +2035,8 @@ CCreInfoWindow::CCreInfoWindow(int Cid, int Type, int creatureCount, StackState
 	if(c->shots)
 	{
 		printAt(CGI->generaltexth->allTexts[198],155,86,GEOR13,zwykly,bitmap);
-		if(State)
-			sprintf(pom,"%d(%d)",c->shots,State->shotsLeft);
+		if(State  &&  State->shotsLeft >= 0)
+			sprintf(pom,"%d (%d)",c->shots,State->shotsLeft);
 		else
 			SDL_itoa(c->shots,pom,10);
 		printToWR(pom,276,99,GEOR13,zwykly,bitmap);
@@ -2053,7 +2055,10 @@ CCreInfoWindow::CCreInfoWindow(int Cid, int Type, int creatureCount, StackState
 
 	//health
 	printAt(CGI->generaltexth->allTexts[388],155,124,GEOR13,zwykly,bitmap);
-	SDL_itoa(c->hitPoints + State->healthBonus,pom,10);
+	if(State  &&  State->healthBonus)
+		sprintf(pom,"%d (%d)",c->hitPoints, c->hitPoints + State->healthBonus);
+	else
+		SDL_itoa(c->hitPoints,pom,10);
 	printToWR(pom,276,137,GEOR13,zwykly,bitmap);
 
 	//remaining health

+ 7 - 0
server/CGameHandler.cpp

@@ -2656,6 +2656,13 @@ bool CGameHandler::isAllowedExchange( int id1, int id2 )
 		if(t->visitingHero == o1  ||  t->garrisonHero == o1)
 			return true;
 	}
+	if(o1->ID == HEROI_TYPE && o2->ID == HEROI_TYPE
+		&& distance(o1->pos, o2->pos) < 2) //hero stands on the same tile or on the neighbouring tiles
+	{
+		//TODO: it's workaround, we should check if first hero visited second and player hasn't closed exchange window
+		//(to block moving stacks for free [without visiting] beteen heroes)
+		return true;
+	}
 
 	return false;
 }