1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
//Source.cpp
typedef pair<int,int> key ; // dungeon_level,moster_level pair
map< key, Monsters > look_up ;
ostream& operator << ( ostream& stm, const key& k )
{ return stm << '(' << k.first << ',' << k.second << ')' ; }
ostream& operator << ( ostream& stm, const Monsters& m )
{
return stm << "monster{" << m.Damage << ',' << m.PowerUp << ',' << m.Monster_Strength
<< ',' << m.hp << ',' << m.lvl << ',' << m.money << ',' << m.money << '}' ;
}
int main()
{
// initialize look_up
{
Monsters m11 = { 23, 2, 5, 8, 19, 7, 9 } ; /* monster 1,1*/
look_up[ key(1,1) ] = m11 ;
Monsters m12 = { 5, 7, 15, 2, 8, 15, 6 } ;
look_up[ key(1,2) ] = m12 ;
Monsters m13 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,3) ] = m13 ;
Monsters m14 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,4) ] = m14 ;
Monsters m15 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,5) ] = m15 ;
Monsters m16 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,6) ] = m16 ;
Monsters m17 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,7) ] = m17 ;
Monsters m18 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,8) ] = m18 ;
Monsters m19 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,9) ] = m19 ;
Monsters m110 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,10) ] = m110 ;
Monsters m111 = { 1, 3, 11, 9, 17, 6, 1 } ;
look_up[ key(1,11) ] = m111 ;
}
//key k(1,8);
//cout << k << '\n' ;
typedef map< key, Monsters >::iterator iterator_t ;
for( iterator_t iter = look_up.begin() ; iter != look_up.end() ; ++iter ){
cout << "key: " << iter->first << " => data: " << iter->second << '\n' ;
cout << iter -> first;
}
|