本文整理汇总了C++中Hero::get_money方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::get_money方法的具体用法?C++ Hero::get_money怎么用?C++ Hero::get_money使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hero
的用法示例。
在下文中一共展示了Hero::get_money方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Buy
void Market::Buy(void){
Hero* h;
int itemchoice,c=0,choice,i,tlvl,tmn;
h=heroes->chooseHero("use for buying"); //choose Hero
tlvl=h->get_level();
tmn=h->get_money();
cout<<"Type 1 to see available weapons\n 2 to see available armors\n 3 to see available potions\n 4 to see available spells.\n(More items will appear while you gain level and money)\nInput : ";
cin>>choice;
while(choice<1||choice>4){
cout<<"Invalid Input.Type again : ";
cin>>choice;
}
list<Weapon*>::iterator it;
list<Armor*>::iterator ita;
list<Potion*>::iterator itb;
list<Spell*>::iterator itc;
switch(choice){
case 1: //buy weapons
for ( i=0,it=weapon_list.begin() ; it!= weapon_list.end(); ++it ){ //print only the items which the hero is able to buy
if( (*(*it)).able(tlvl,tmn) ){
cout<<++i<<" : ";
(*(*it)).printItem();
}
}
if(i==0){cout<<"No weapons can be bought with your money and level\nincrease them and return."<<endl;break;}
cout<<"Type the number of the weapon you want to buy or 0 to exit : "<<endl;
cin>>itemchoice;
while(itemchoice<0 || itemchoice>i){
cout<<"Wrong Input.Type again : ";
cin>>itemchoice;
}
for ( it=weapon_list.begin() ; it!= weapon_list.end(); ++it ){ //search list for the item choosen by input from those
if((*(*it)).able(tlvl,tmn) ){ //that the player can buy
c++;
if(c==itemchoice)
break;
}
}
if(h->add_to_bag( (*it) )){
h->pay_for_item( (*it)->getprice() );
}
break;
case 2: //buy armor
for ( i=0,ita=armor_list.begin() ; ita != armor_list.end(); ++ita ){
if( (*(*ita)).able(tlvl,tmn) ){
cout<<++i<<" : ";
(*(*ita)).printItem();
}
}
if(i==0){cout<<"No armors can be bought with your money and level\nincrease them and return."<<endl;break;}
cout<<"Type the number of the armor you want to buy or 0 to exit : "<<endl;
cin>>itemchoice;
while(itemchoice<0 || itemchoice>i){
cout<<"Wrong Input.Type again : ";
cin>>itemchoice;
}
for ( ita=armor_list.begin() ; ita!= armor_list.end(); ++ita ){
if((*(*ita)).able(tlvl,tmn) ){
c++;
if(c==itemchoice)
break;
}
}
if(h->add_to_bag( (*ita) )){
h->pay_for_item( (*ita)->getprice() );
}
break;
case 3: //buy potions
for ( i=0,itb=potion_list.begin() ; itb != potion_list.end(); ++itb ){
if( (*(*itb)).able(tlvl,tmn) ){
cout<<++i<<" : ";
(*(*itb)).printItem();
}
}
if(i==0){cout<<"No armors can be bought with your money and level\nincrease them and return."<<endl;break;}
cout<<"Type the number of the armor you want to buy or 0 to exit : "<<endl;
cin>>itemchoice;
while(itemchoice<0 || itemchoice>i){
//.........这里部分代码省略.........