Esempio n. 1
0
void iPlayer::UpdateFogMap()
{
	m_FogMap.ResetFog();
	if (gSettings.ShowEnemyTurn() && PlayerType() == PT_HUMAN) {
		for (iGameWorld::iPLIt pit = gGame.Map().m_Players.First(); pit != gGame.Map().m_Players.End(); ++pit) {
			for (iHLIt hit=(*pit)->m_Heroes.First(); hit!=(*pit)->m_Heroes.End(); ++hit)
				m_FogMap.DiscoverMap((*hit)->Pos().x,(*hit)->Pos().y,(*hit)->Scouting());
			for (iCLIt cit=(*pit)->m_Cnsts.First(); cit!=(*pit)->m_Cnsts.End(); ++cit)
				m_FogMap.DiscoverMap((*cit)->Pos().x,(*cit)->Pos().y, (*cit)->Proto()->Scouting());
			for (iCtLIt ctit=(*pit)->m_Castles.First(); ctit!=(*pit)->m_Castles.End(); ++ctit) 
				m_FogMap.DiscoverMap((*ctit)->Pos().x,(*ctit)->Pos().y, (*ctit)->Scouting());
		}
	} else {
		for (iHLIt hit=m_Heroes.First(); hit!=m_Heroes.End(); ++hit)
			m_FogMap.DiscoverMap((*hit)->Pos().x,(*hit)->Pos().y,(*hit)->Scouting());
		for (iCLIt cit=m_Cnsts.First(); cit!=m_Cnsts.End(); ++cit)
			m_FogMap.DiscoverMap((*cit)->Pos().x,(*cit)->Pos().y, (*cit)->Proto()->Scouting());
		for (iCtLIt ctit=m_Castles.First(); ctit!=m_Castles.End(); ++ctit)
			m_FogMap.DiscoverMap((*ctit)->Pos().x,(*ctit)->Pos().y, (*ctit)->Scouting());
	}

	UpdateVisItems();
	m_bDirtPassMap = true;

	if (gSettings.ShowEnemyTurn() && PlayerType() != PT_HUMAN && gGame.Map().ActPlayer()) {
		gGame.Map().ActPlayer()->UpdateFogMap();
	}
}
Esempio n. 2
0
void iPlayer::UpdatePassMap()
{
	if (!m_bDirtPassMap) return;
	m_bDirtPassMap=false;
	bool bConstPass = (PlayerType() == PT_COMPUTER);

	check(m_pCurHero);
	sint32 mbonus = m_pCurHero->MoveCostBonus();
	
	m_passMap.CopyFrom(gGame.Map().m_PassMap);
	for (sint32 yy=0; yy<m_passMap.GetHeight(); ++yy){
		for (sint32 xx=0; xx<m_passMap.GetWidth(); ++xx){
			sint32 res;
			if (m_FogMap.IsInvisible(iPoint(xx,yy))) {
				res = -1;
			} else {
				iBaseMapObject* pObj = gGame.Map().m_CoverMap.GetAt(xx,yy);
				if (pObj && pObj->Pos() == iPoint(xx,yy) && (!pObj->Disap() || bConstPass || !m_FogMap.IsHidden(pObj->Pos()))) {
					res = -2;
				} else {
					res = m_passMap.GetAt(xx,yy);
				}
			}
			if (mbonus && res > SURF_MOVE_COST[STYPE_DIRT]) res -= (res-SURF_MOVE_COST[STYPE_DIRT]) * mbonus / 100;
			m_passMap.GetAt(xx,yy) = (sint8)res;
		}
	}
}
Esempio n. 3
0
void iPlayer::OnSelect(bool bNewWeek, bool bAfterLoad)
{
	check(PlayerType() == PT_HUMAN);

	// Show new week dialog
	if (bNewWeek) {
		iDlg_NewWeek dlg(&gApp.ViewMgr(), m_PlayerId, gGame.Map().WeekDesc());
		dlg.DoModal();
	}

	// show current day
	uint32 days = gGame.Map().m_CurDay-1;
	gGame.AddMsg(iFormat(_T("#F4B4%s: #F9F9%d  #F4B4%s: #F9F9%d  #F4B4%s: #F9F9%d"),gTextMgr[TRID_MONTH], days/28+1,gTextMgr[TRID_WEEK], (days%28)/7+1,gTextMgr[TRID_DAY],days%7+1));

	// update fog map
	UpdateFogMap();

	// Select current hero and castle
	if (!m_pCurHero && m_Heroes.Count()){
		m_pCurHero = *m_Heroes.First();
	}
	if (m_pCurHero) m_pCurHero->OnSelect();
	else if (m_pCurCastle) m_pCurCastle->OnSelect();

	// Process time events
	if (!bAfterLoad) gGame.Map().ProcessTimeEvents(this);
}
Esempio n. 4
0
 PlayerType PlayerTypes::getPlayerType(std::string name)
 {
   for ( int i = 0; i < PlayerTypes::Enum::MAX; ++i )
   {
     if ( name == playerTypeName[i] )
       return PlayerType(i);
   }
   return PlayerTypes::Unknown;
 }