本文整理汇总了C++中ActionList::AddAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionList::AddAction方法的具体用法?C++ ActionList::AddAction怎么用?C++ ActionList::AddAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionList
的用法示例。
在下文中一共展示了ActionList::AddAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Shop
void GameFlow::Shop()
{
ActionList actions;
actions.AddAction("[B] Buy");
actions.AddAction("[S] Sell");
actions.AddAction("[X] Leave");
Map->GetCharacter()->PrintInfo();
actions.PrintActions();
char action=GetUserInput(actions);
while(action!='X')
{
system("cls");
Map->GetCharacter()->PrintInfo();
//cout<<"Market:"<<endl;
if(action=='B')
{
//set the level of the items available
int highlevel=Map->GetCurrentTile()->GetLevel()+4;
int lowlevel=Map->GetCurrentTile()->GetLevel()-4;
if(lowlevel<1)
lowlevel=1;
double markup=3;
if(Map->GetCurrentTile()->GetContainer()->GetType()==TOWN)
{
Town* t=(Town*)Map->GetCurrentTile()->GetContainer();
if(t->GetSpecialty()=="Market")
{
markup=1.5;
if(Map->GetCharacter()->GetLevel()>highlevel)
highlevel+=(Map->GetCharacter()->GetLevel()-highlevel)/2;
}
}
else if(Map->GetCurrentTile()->GetContainer()->GetType()==CASTLE)
{
markup=2;
if(Map->GetCharacter()->GetLevel()>highlevel)
highlevel=Map->GetCharacter()->GetLevel();
}
//get the items from the level, adding them to possible items
map<string,Item> tempitemMap;
for(int i=lowlevel;i<=highlevel;i+=1)
{
vector<string> items=Item::ItemLevelMap[i];
for(unsigned int j=0;j<items.size();j+=1)
tempitemMap[items[j]]=Item::ItemMap[items[j]];
}
//add them to a vector
vector<Item> sellingItems;
map<string,Item>::iterator it=tempitemMap.begin();
while(it!=tempitemMap.end())
{
sellingItems.push_back(it->second);
it++;
}
int tag=0;
while(tag!=-1)
{
cout<<"Buying:"<<endl;
//print the items
for(unsigned int i=0;i<sellingItems.size();i+=1)
{
int price=(int)(sellingItems[i].GetWorth()*markup);
cout<<i<<". "<<sellingItems[i].GetName()<<" - "<<price<<"Qulz"<<endl;
}
//select item
string input;
cout<<"Enter the item number you wish to buy(-1 to exit): ";
cin>>input;
tag=Printer::StringToInt(input);
while((tag<(-1))||(tag>=(signed int)sellingItems.size()))
{
Printer::MoveBackLine();
Printer::ClearLine();
cout<<"Enter the item number you wish to buy(-1 to exit): ";
cin>>input;
tag=Printer::StringToInt(input);
}
//check to see if you can buy
if(tag!=-1)
{
if(Map->GetCharacter()->GetQulz()>=sellingItems[tag].GetWorth()*markup)
{
if(Map->GetCharacter()->AddItem(sellingItems[tag]))
{
Map->GetCharacter()->AddQulz((int)(-sellingItems[tag].GetWorth()*markup));
Printer::pout<<"#014You've purchased the "<<sellingItems[tag].GetName()<<endl;
}
}
else
{
Printer::pout<<"#014You don't have enough Qulz to purchase that item"<<endl;
}
system("pause");
system("cls");
Map->GetCharacter()->PrintInfo();
}
}//end while
system("cls");
//.........这里部分代码省略.........