Add new creation method from a visual representation
This commit is contained in:
parent
8ade68101b
commit
7f639a6bf4
6 changed files with 72 additions and 16 deletions
game
|
@ -8,17 +8,18 @@ CUnitV::CUnitV()
|
|||
|
||||
}
|
||||
|
||||
|
||||
// Map of visual representation of unitv
|
||||
static const std::map< dir_t, unitVis_c > sk_visMap =
|
||||
{
|
||||
{dir_t::N,'^'},
|
||||
{dir_t::E,'>'},
|
||||
{dir_t::S,'v'},
|
||||
{dir_t::W,'<'},
|
||||
};
|
||||
|
||||
unitVis_c CUnitV::getVisual() const
|
||||
{
|
||||
// Map of visual representation of unitv
|
||||
static const std::map< dir_t, unitVis_c > sk_visMap =
|
||||
{
|
||||
{dir_t::N,'^'},
|
||||
{dir_t::E,'>'},
|
||||
{dir_t::S,'v'},
|
||||
{dir_t::W,'<'},
|
||||
};
|
||||
|
||||
std::map< dir_t, char >::const_iterator it = sk_visMap.find(dir);
|
||||
|
||||
if( it == sk_visMap.end() )
|
||||
|
@ -27,4 +28,21 @@ unitVis_c CUnitV::getVisual() const
|
|||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool CUnitV::setFromVisual( unitVis_c& vis )
|
||||
{
|
||||
std::map< dir_t, char >::const_iterator it;
|
||||
|
||||
for( it = sk_visMap.begin(); it != sk_visMap.end(); it++ )
|
||||
{
|
||||
if( it->second == vis )
|
||||
{
|
||||
dir == it->first;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// No matching direction to visual
|
||||
return false;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue