示例#1
0
/* monthly - lets the player choose a special edition for the guardian */
int choosespecialedition(char &clearformess)
{
   int page=0;

   //char havetype[LOOTNUM];
   //for(int l=0;l<LOOTNUM;l++)havetype[l]=0;
   vector<bool> havetype(loottype.size(),false);
   vector<int> loottypeindex;

   //FIND ALL LOOT TYPES
   for(int loc=0;loc<location.size();loc++)
   {
      if(location[loc]->renting==RENTING_NOCONTROL)continue;

      for(int l=0;l<location[loc]->loot.size();l++)
      {
         if(!location[loc]->loot[l]->is_loot())continue;
         //Temporary, maybe put special edition definition into an xml file. -XML
         if(location[loc]->loot[l]->get_itemtypename()!="LOOT_CEOPHOTOS"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_CEOLOVELETTERS"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_CEOTAXPAPERS"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_INTHQDISK"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_CORPFILES"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_JUDGEFILES"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_RESEARCHFILES"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_PRISONFILES"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_CABLENEWSFILES"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_AMRADIOFILES"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_SECRETDOCUMENTS"&&
            location[loc]->loot[l]->get_itemtypename()!="LOOT_POLICERECORDS")continue;

         if(!havetype[getloottype(location[loc]->loot[l]->get_itemtypename())])
         {
            loottypeindex.push_back(getloottype(location[loc]->loot[l]->get_itemtypename()));
            havetype[getloottype(location[loc]->loot[l]->get_itemtypename())]=true;
         }
      }
   }
   for(int sq=0;sq<squad.size();sq++)
   {
      for(int l=0;l<squad[sq]->loot.size();l++)
      {
         if(!squad[sq]->loot[l]->is_loot())continue;

         if(squad[sq]->loot[l]->get_itemtypename()!="LOOT_CEOPHOTOS"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_CEOLOVELETTERS"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_CEOTAXPAPERS"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_INTHQDISK"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_CORPFILES"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_JUDGEFILES"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_RESEARCHFILES"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_PRISONFILES"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_CABLENEWSFILES"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_AMRADIOFILES"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_SECRETDOCUMENTS"&&
            squad[sq]->loot[l]->get_itemtypename()!="LOOT_POLICERECORDS")continue;

         if(!havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())])
         {
            loottypeindex.push_back(getloottype(squad[sq]->loot[l]->get_itemtypename()));
            havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())]=true;
         }
      }
   }

   if(loottypeindex.size()==0)return -1;

   clearformess=1;
   
   //PICK ONE
   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(0,0);
      addstr("Do you want to run a special edition?");

      int x=1,y=10;
      char str[200],str2[200];

      for(int l=page*18;l<loottypeindex.size()&&l<page*18+18;l++)
      {
         str[0]=l-page*18+'A';
         str[1]='\x0';
         strcat(str," - ");
         strcat(str,loottype[loottypeindex[l]]->get_name().c_str());

         move(y,x);
         addstr(str);

         x+=26;
         if(x>53)
         {
            x=1;
            y++;
         }
      }

      //PAGE UP
      if(page>0)
      {
         move(17,1);
         addprevpagestr();
      }
      //PAGE DOWN
      if((page+1)*18<loottype.size())
      {
         move(17,53);
         addnextpagestr();
      }

      move(24,1);
      addstr("X - Not in this month's Liberal Guardian");

      refresh();

      int c=getch();
      translategetch(c);

      if(c>='a'&&c<='r')
      {
         int slot=c-'a'+page*18;

         if(slot>=0&&slot<loottypeindex.size())
         {
            //DELETE THE ITEM
            for(int loc=0;loc<location.size();loc++)
            {
               if(location[loc]->renting==RENTING_NOCONTROL)continue;

               for(int l=0;l<location[loc]->loot.size();l++)
               {
                  if(!location[loc]->loot[l]->is_loot())continue;

                  if(getloottype(location[loc]->loot[l]->get_itemtypename())==loottypeindex[slot])
                  {
                     location[loc]->loot[l]->decrease_number(1);
                     if(location[loc]->loot[l]->get_number()==0)
                     {
                        delete location[loc]->loot[l];
                        location[loc]->loot.erase(location[loc]->loot.begin() + l);
                     }
                     return loottypeindex[slot];
                  }
               }
            }
            for(int sq=0;sq<squad.size();sq++)
            {
               for(int l=0;l<squad[sq]->loot.size();l++)
               {
                  if(!squad[sq]->loot[l]->is_loot())continue;

                  if(getloottype(squad[sq]->loot[l]->get_itemtypename())==loottypeindex[slot])
                  {
                     squad[sq]->loot[l]->decrease_number(1);
                     if(squad[sq]->loot[l]->get_number()==0)
                     {
                        delete squad[sq]->loot[l];
                        squad[sq]->loot.erase(squad[sq]->loot.begin() + l);
                     }
                     return loottypeindex[slot];
                  }
               }
            }

            //WHOOPS!
            return loottypeindex[slot];
         }
      }

      if(c=='x')
      {
         return -1;
      }

      //PAGE UP
      if((c==interface_pgup||c==KEY_UP||c==KEY_LEFT)&&page>0)page--;
      //PAGE DOWN
      if((c==interface_pgdn||c==KEY_DOWN||c==KEY_RIGHT)&&(page+1)*18<loottype.size())page++;

   }while(1);

   return -1;
}
/* monthly - lets the player choose a special edition for the guardian */
int choosespecialedition(char &clearformess)
{
   //Temporary, maybe put special edition definition into an xml file. -XML
	static const string document_types[] =
	{  // This list MUST be in alphabetical order for binary_search() to work right
      "LOOT_AMRADIOFILES",
      "LOOT_CABLENEWSFILES",
      "LOOT_CCS_BACKERLIST",
      "LOOT_CEOLOVELETTERS",
      "LOOT_CEOPHOTOS",
      "LOOT_CEOTAXPAPERS",
      "LOOT_CORPFILES",
      "LOOT_INTHQDISK",
      "LOOT_JUDGEFILES",
      "LOOT_POLICERECORDS",
      "LOOT_PRISONFILES",
      "LOOT_RESEARCHFILES",
      "LOOT_SECRETDOCUMENTS"
	};
	static const vector<string> dox(document_types,document_types+len(document_types));

   int page=0;

   //char havetype[LOOTNUM];
   //for(int l=0;l<LOOTNUM;l++)havetype[l]=0;
   vector<bool> havetype(len(loottype),false);
   vector<int> loottypeindex;

   //FIND ALL LOOT TYPES
   for(int loc=0;loc<len(location);loc++)
   {
      if(location[loc]->renting==RENTING_NOCONTROL) continue;

      consolidateloot(location[loc]->loot);
      for(int l=0;l<len(location[loc]->loot);l++)
      {
         if(!location[loc]->loot[l]->is_loot()) continue;
         if(!binary_search(dox.begin(),dox.end(),location[loc]->loot[l]->get_itemtypename())) continue;

         if(!havetype[getloottype(location[loc]->loot[l]->get_itemtypename())])
         {
            loottypeindex.push_back(getloottype(location[loc]->loot[l]->get_itemtypename()));
            havetype[getloottype(location[loc]->loot[l]->get_itemtypename())]=true;
         }
      }
   }
   for(int sq=0;sq<len(squad);sq++)
   {
      consolidateloot(squad[sq]->loot);
      for(int l=0;l<len(squad[sq]->loot);l++)
      {
         if(!squad[sq]->loot[l]->is_loot()) continue;
         if(!binary_search(dox.begin(),dox.end(),squad[sq]->loot[l]->get_itemtypename())) continue;

         if(!havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())])
         {
            loottypeindex.push_back(getloottype(squad[sq]->loot[l]->get_itemtypename()));
            havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())]=true;
         }
      }
   }

   if(!len(loottypeindex)) return -1;

   clearformess=1;

   //PICK ONE
   while(true)
   {
      music.play(MUSIC_NEWSPAPER);
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(0,0);
      addstr("Do you want to run a special edition?");

      int x=1,y=10;
      char str[200];

      for(int l=page*18;l<len(loottypeindex)&&l<page*18+18;l++)
      {
         str[0]=l-page*18+'A';
         str[1]='\x0';
         strcat(str," - ");
         strcat(str,loottype[loottypeindex[l]]->get_name());

         move(y,x);
         addstr(str);

         x+=26;
         if(x>53) x=1,y++;
      }

      //PAGE UP
      if(page>0)
      {
         move(17,1);
         addprevpagestr();
      }
      //PAGE DOWN
      if((page+1)*18<len(loottype))
      {
         move(17,53);
         addnextpagestr();
      }

      move(24,1);
      addstr("Enter - Not in this month's Liberal Guardian");

      int c=getkey();

      if(c>='a'&&c<='r')
      {
         int slot=c-'a'+page*18;

         if(slot>=0&&slot<len(loottypeindex))
         {
            //DELETE THE ITEM
            for(int loc=0;loc<len(location);loc++)
            {
               if(location[loc]->renting==RENTING_NOCONTROL) continue;

               for(int l=0;l<len(location[loc]->loot);l++)
               {
                  if(!location[loc]->loot[l]->is_loot()) continue;

                  if(getloottype(location[loc]->loot[l]->get_itemtypename())==loottypeindex[slot])
                  {
                     location[loc]->loot[l]->decrease_number(1);
                     if(location[loc]->loot[l]->empty())
                     	delete_and_remove(location[loc]->loot,l);
                     return loottypeindex[slot];
                  }
               }
            }
            for(int sq=0;sq<len(squad);sq++)
            {
               for(int l=0;l<len(squad[sq]->loot);l++)
               {
                  if(!squad[sq]->loot[l]->is_loot()) continue;

                  if(getloottype(squad[sq]->loot[l]->get_itemtypename())==loottypeindex[slot])
                  {
                     squad[sq]->loot[l]->decrease_number(1);
                     if(squad[sq]->loot[l]->empty())
                        delete_and_remove(squad[sq]->loot,l);
                     return loottypeindex[slot];
                  }
               }
            }

            //WHOOPS!
            return loottypeindex[slot];
         }
      }

      if(c=='x'||c==ENTER||c==ESC||c==SPACEBAR) return -1;

      //PAGE UP
      if((c==interface_pgup||c==KEY_UP||c==KEY_LEFT)&&page>0) page--;
      //PAGE DOWN
      if((c==interface_pgdn||c==KEY_DOWN||c==KEY_RIGHT)&&(page+1)*18<len(loottype)) page++;

   }

   return -1;
}
示例#3
0
int Shop::fenceselect(squadst& customers) const
{
   int ret=0;

   consolidateloot(location[customers.squad[0]->base]->loot);

   int page=0;

   vector<int> selected(location[customers.squad[0]->base]->loot.size(),0);

   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(0,0);
      addstr("What will you sell?");

      if (ret > 0)
      {
         move(0,30);
         addstr("Estimated Liberal Amount: $");
         addstr(tostring(ret).c_str());
      }

      printparty();

      int x = 1, y = 10;
      std::string outstr;
      std::string itemstr;

      for (int l = page * 18;
           l < (int)location[customers.squad[0]->base]->loot.size() && l < page * 18 + 18;
           l++)
      {
         if (selected[l])
            set_color(COLOR_GREEN,COLOR_BLACK,1);
         else
            set_color(COLOR_WHITE,COLOR_BLACK,0);
         itemstr = location[customers.squad[0]->base]->loot[l]->equip_title();
         if (location[customers.squad[0]->base]->loot[l]->get_number() > 1)
         {
            if(selected[l] > 0)
            {
               itemstr += " " + tostring(selected[l]) + "/";
            }
            else
               itemstr += " x";
            itemstr += tostring(location[customers.squad[0]->base]->loot[l]->get_number());
         }

         outstr = static_cast<char>(l - page * 18 + 'A');
         outstr += " - " + itemstr;

         move(y,x);
         addstr(outstr.c_str());

         x += 26;
         if (x > 53)
         {
            x = 1;
            y++;
         }
      }

      //PAGE UP
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      if (page > 0)
      {
         move(17,1);
         addprevpagestr();
      }
      //PAGE DOWN
      if((page + 1) * 18 < (int)location[customers.squad[0]->base]->loot.size())
      {
         move(17,53);
         addnextpagestr();
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(23,1);
      addstr("Press a letter to select an item to sell.");
      move(24,1);
      addstr("Enter - Done");

      refresh();

      int c = getch();
      translategetch(c);

      if (c >= 'a' && c <= 'r')
      {
         int slot = c - 'a' + page * 18;

         if(slot >= 0 && slot < (int)location[customers.squad[0]->base]->loot.size())
         {
            if (selected[slot])
            {
               ret -= location[customers.squad[0]->base]->loot[slot]->get_fencevalue() * selected[slot];
               selected[slot] = 0;
            }
            else
            {
               if (!location[customers.squad[0]->base]->loot[slot]->is_good_for_sale())
               {
                  printparty();

                  move(8,15);
                  set_color(COLOR_WHITE,COLOR_BLACK,1);
                  addstr(" You can't sell damaged goods.");

                  refresh();
                  getch();
               }
               else
               {
                  if (location[customers.squad[0]->base]->loot[slot]->get_number() > 1)
                  {
                     selected[slot] = 1;

                     printparty();

                     move(8,15);
                     set_color(COLOR_WHITE,COLOR_BLACK,1);
                     addstr("       How many?          ");

                     refresh();

                     char str[100];

                     keypad(stdscr,FALSE);
                     raw_output(FALSE);
                     echo();
                     curs_set(1);
                     mvgetstr(8,32,str);
                     curs_set(0);
                     noecho();
                     raw_output(TRUE);
                     keypad(stdscr,TRUE);

                     selected[slot] = atoi(str);
                     if (selected[slot] < 0)
                        selected[slot] = 0;
                     else if (selected[slot] > location[customers.squad[0]->base]->loot[slot]->get_number())
                        selected[slot]=location[customers.squad[0]->base]->loot[slot]->get_number();
                  }
                  else
                     selected[slot]=1;
                  ret += location[customers.squad[0]->base]->loot[slot]->get_fencevalue() * selected[slot];
               }
            }
         }
      }

      if(c == 'x'||c==10||c==ESC)
         break;

      //PAGE UP
      if((c == interface_pgup || c == KEY_UP || c == KEY_LEFT) && page > 0)
         page--;
      //PAGE DOWN
      if((c == interface_pgdn || c == KEY_DOWN || c == KEY_RIGHT)
         && (page + 1) * 18 < (int)location[customers.squad[0]->base]->loot.size())
         page++;

   } while (true);

   for(int l = location[customers.squad[0]->base]->loot.size() - 1; l >= 0; l--)
   {
      if(selected[l] > 0)
      {
         location[customers.squad[0]->base]->loot[l]->decrease_number(selected[l]);
         if(location[customers.squad[0]->base]->loot[l]->get_number() <= 0)
            delete_and_remove(location[customers.squad[0]->base]->loot,l);
      }
   }

   return ret;
}