Add more code to units to help distinguish between types and visual values
This commit is contained in:
parent
ea426c70c6
commit
9fc5f33de8
8 changed files with 67 additions and 29 deletions
|
@ -1,15 +1,30 @@
|
|||
#include "unitv.h"
|
||||
|
||||
// V unit
|
||||
class CUnitV
|
||||
: public CUnit<'V'>
|
||||
#include <map> // for std::map
|
||||
|
||||
CUnitV::CUnitV()
|
||||
: dir(dir_t::S)
|
||||
{
|
||||
public:
|
||||
CUnitV() = default;
|
||||
virtual ~CUnitV() = default;
|
||||
|
||||
private:
|
||||
}
|
||||
|
||||
// V also has a direction
|
||||
char dir;
|
||||
};
|
||||
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() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue