コード例 #1
0
void activatebulk(void)
{
   vector<Creature *> temppool = activatable_liberals();

   if(temppool.size()==0)return;

   int page=0;

   char str[80];

   int selectedactivity=0;

   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      printfunds(0,1,"Money: ");

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(0,0);
      addstr("Activate Uninvolved Liberals");
      move(1,0);
      addstr("----CODE NAME------------CURRENT ACTIVITY---------------------------------------");
      move(1,51);
      addstr("BULK ACTIVITY");

      if(selectedactivity==0)set_color(COLOR_WHITE,COLOR_BLACK,1);
      else set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(2,51);
      addstr("1 - Engaging in Liberal Activism");
      if(selectedactivity==1)set_color(COLOR_WHITE,COLOR_BLACK,1);
      else set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(3,51);
      addstr("2 - Legal Fundraising");
      if(selectedactivity==2)set_color(COLOR_WHITE,COLOR_BLACK,1);
      else set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(4,51);
      addstr("3 - Illegal Fundraising");
      if(selectedactivity==3)set_color(COLOR_WHITE,COLOR_BLACK,1);
      else set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(5,51);
      addstr("4 - Checking Polls");
      if(selectedactivity==4)set_color(COLOR_WHITE,COLOR_BLACK,1);
      else set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(6,51);
      addstr("5 - Stealing Cars");
      if(selectedactivity==5)set_color(COLOR_WHITE,COLOR_BLACK,1);
      else set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(7,51);
      addstr("6 - Community Service");

      int y=2;
      for(int p=page*19;p<temppool.size()&&p<page*19+19;p++)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         move(y,0);
         addch(y+'A'-2);addstr(" - ");
         addstr(temppool[p]->name);

         move(y,25);
         set_activity_color(temppool[p]->activity.type);
         getactivity(str,temppool[p]->activity);
         addstr(str);
         /*if(temppool[p]->activity.type==ACTIVITY_TROUBLE)
         {
         addstr(" ($");
         itoa(temppool[p]->activity.arg,num,10);
         addstr(num);
         addstr(")");
         }*/

         y++;
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(22,0);
      addstr("Press a Letter to Assign an Activity.  Press a Number to select an Activity.");
      move(23,0);
      addpagestr();

      refresh();

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

      //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)*19<temppool.size())page++;

      if(c>='a'&&c<='s')
      {
         int p=page*19+(int)(c-'a');
         if(p<temppool.size())
         {
            switch(selectedactivity)
            {
            case 0: //Activism
               if(temppool[p]->get_attribute(ATTRIBUTE_WISDOM,true)>7)
                  temppool[p]->activity.type=ACTIVITY_COMMUNITYSERVICE;
               else if(temppool[p]->get_attribute(ATTRIBUTE_WISDOM,true)>4)
                  temppool[p]->activity.type=ACTIVITY_TROUBLE;
               else
               {
                  if(temppool[p]->get_skill(SKILL_COMPUTERS)>2)
                     temppool[p]->activity.type=ACTIVITY_HACKING;
                  else if(temppool[p]->get_skill(SKILL_ART)>1)
                  {
                     temppool[p]->activity.type=ACTIVITY_GRAFFITI;
                     temppool[p]->activity.arg=-1;
                  }
                  else temppool[p]->activity.type=ACTIVITY_TROUBLE;
               }
               break;
            case 1: //Fundraising
               if(temppool[p]->get_skill(SKILL_ART)>1)
                  temppool[p]->activity.type=ACTIVITY_SELL_ART;
               else if(temppool[p]->get_skill(SKILL_MUSIC)>1)
                  temppool[p]->activity.type=ACTIVITY_SELL_MUSIC;
               else if(temppool[p]->get_skill(SKILL_TAILORING)>1)
                  temppool[p]->activity.type=ACTIVITY_SELL_TSHIRTS;
               else temppool[p]->activity.type=ACTIVITY_DONATIONS;
               break;
            case 2: //Illegal Fundraising
               if(temppool[p]->get_skill(SKILL_COMPUTERS)>1)
                  temppool[p]->activity.type=ACTIVITY_CCFRAUD;
#ifndef ZEROMORAL
                else if(temppool[p]->get_skill(SKILL_SEDUCTION)>1 && temppool[p]->age >=18)
#else
               else if(temppool[p]->get_skill(SKILL_SEDUCTION)>1)
#endif
                  temppool[p]->activity.type=ACTIVITY_PROSTITUTION;
               else
                  temppool[p]->activity.type=ACTIVITY_SELL_DRUGS;
               break;
            case 3: //Check polls
               temppool[p]->activity.type=ACTIVITY_POLLS;
               break;
            case 4: //Steal cars
               temppool[p]->activity.type=ACTIVITY_STEALCARS;
               break;
            case 5: //Volunteer
               temppool[p]->activity.type=ACTIVITY_COMMUNITYSERVICE;
               break;
            }
         }
      }
      if(c>='1'&&c<='6')
      {
         selectedactivity=c-'1';
      }

      if(c==10||c==ESC)break;
   }while(1);
コード例 #2
0
/* base - activate the uninvolved */
void activate(void)
{
   vector<Creature *> temppool = activatable_liberals();

   if(temppool.size()==0)return;

   sortliberals(temppool,activesortingchoice[SORTINGCHOICE_ACTIVATE]);

   int page=0;

   char str[80];
   char num[20];

   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);     
      printfunds(0,1,"Money: ");


      move(0,0);
      addstr("Activate Uninvolved Liberals");
      move(1,0);
      addstr("----CODE NAME------------SKILL---HEALTH---LOCATION------------------------------");
      move(1,57);
      addstr("ACTIVITY");

      int y=2;
      for(int p=page*19;p<temppool.size()&&p<page*19+19;p++)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         move(y,0);
         addch(y+'A'-2);addstr(" - ");
         addstr(temppool[p]->name);

         char bright=0;
         int skill=0;
         for(int sk=0;sk<SKILLNUM;sk++)
         {
            skill+=temppool[p]->get_skill(sk);
            if(temppool[p]->get_skill_ip(sk)>=100+(10*temppool[p]->get_skill(sk))&&
               temppool[p]->get_skill(sk)<temppool[p]->skill_cap(sk,true))bright=1;
         }

         set_color(COLOR_WHITE,COLOR_BLACK,bright);

         move(y,25);
         itoa(skill,num,10);
         addstr(num);

         printhealthstat(*temppool[p],y,33,TRUE);

         if(mode==REVIEWMODE_JUSTICE)set_color(COLOR_YELLOW,COLOR_BLACK,1);
         else set_color(COLOR_WHITE,COLOR_BLACK,0);
         move(y,42);
         addstr(location[temppool[p]->location]->getname(true));

         move(y,57);
         // Let's add some color here...
         set_activity_color(temppool[p]->activity.type);
         getactivity(str,temppool[p]->activity);
         addstr(str);

         y++;
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(22,0);
      addstr("Press a Letter to Assign an Activity.");
      move(23,0);
      addpagestr();
      addstr(" T to sort people.");
      move(24,0);
      addstr("Press Z to assign simple tasks in bulk.");

      refresh();

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

      //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)*19<temppool.size())page++;

      if(c>='a'&&c<='s')
      {
         int p=page*19+(int)(c-'a');
         if(p<temppool.size())
         {
            activate(temppool[p]);
         }
      }

      if(c=='t')
      {
         sorting_prompt(SORTINGCHOICE_ACTIVATE);
         sortliberals(temppool,activesortingchoice[SORTINGCHOICE_ACTIVATE],true);
      }

      if(c=='z')
      {
         activatebulk();
      }

      if(c==10||c==ESC)break;
   }while(1);
}
コード例 #3
0
/* base - activate sleepers */
void activate_sleepers(void)
{
    vector<Creature *> temppool;
    // Comb the pool of Liberals for sleeper agents
    for(int p=0; p<pool.size(); p++)
    {
        // Select only sleepers that can work
        if(pool[p]->alive==true&&
                pool[p]->flag & CREATUREFLAG_SLEEPER&&
                pool[p]->align==ALIGN_LIBERAL&&
                pool[p]->hiding==false&&
                pool[p]->clinic==false&&
                pool[p]->dating==false)
        {
            temppool.push_back(pool[p]);
        }
    }

    if(temppool.size()==0)return;

    sortliberals(temppool,activesortingchoice[SORTINGCHOICE_ACTIVATESLEEPERS]);

    int page=0;

    char str[80];

    do
    {
        erase();

        set_color(COLOR_WHITE,COLOR_BLACK,0);
        printfunds(0,1,"Money: ");


        move(0,0);
        addstr("Activate Sleeper Agents");
        makedelimiter(1,0);
        move(1,4);
        addstr("CODE NAME");
        move(1,25);
        addstr("JOB");
        move(1,42);
        addstr("SITE");
        move(1,57);
        addstr("ACTIVITY");

        int y=2;
        for(int p=page*9; p<temppool.size()&&p<page*9+9; p++)
        {
            set_color(COLOR_WHITE,COLOR_BLACK,0);
            move(y,0);
            addch((y-2)/2+'A');
            addstr(" - ");
            addstr(temppool[p]->name);

            move(y,25);
            getrecruitcreature(str,temppool[p]->type);
            addstr(str);

            move(y+1,6);
            addstr("Effectiveness: ");

            if(temppool[p]->infiltration > 0.8f)
            {
                set_color(COLOR_RED,COLOR_BLACK,1);
            }
            else if(temppool[p]->infiltration > 0.6f)
            {
                set_color(COLOR_MAGENTA,COLOR_BLACK,1);
            }
            else if(temppool[p]->infiltration > 0.4f)
            {
                set_color(COLOR_YELLOW,COLOR_BLACK,1);
            }
            else if(temppool[p]->infiltration > 0.2f)
            {
                set_color(COLOR_WHITE,COLOR_BLACK,1);
            }
            else if(temppool[p]->infiltration > 0.1f)
            {
                set_color(COLOR_WHITE,COLOR_BLACK,0);
            }
            else
            {
                set_color(COLOR_GREEN,COLOR_BLACK,0);
            }
            char num[10];
            itoa(static_cast<int>(temppool[p]->infiltration*100),num,10);
            addstr(num);
            addstr("%");

            move(y,42);
            set_color(COLOR_WHITE,COLOR_BLACK,0);
            addshortname(location[temppool[p]->worklocation]);

            move(y,57);
            // Let's add some color here...
            set_activity_color(temppool[p]->activity.type);
            getactivity(str,temppool[p]->activity);
            addstr(str);

            y+=2;
        }

        set_color(COLOR_WHITE,COLOR_BLACK,0);
        move(22,0);
        addstr("Press a Letter to Assign an Activity.");
        move(23,0);
        addpagestr();
        addstr(" T to sort people.");

        set_color(COLOR_WHITE,COLOR_BLACK,0);

        refresh();

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

        //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)*9<temppool.size())page++;

        if(c>='a'&&c<='s')
        {
            int p=page*9+(int)(c-'a');
            if(p<temppool.size())
            {
                activate_sleeper(temppool[p]);
            }
        }

        if(c=='t')
        {
            sorting_prompt(SORTINGCHOICE_ACTIVATESLEEPERS);
            sortliberals(temppool,activesortingchoice[SORTINGCHOICE_ACTIVATESLEEPERS],true);
        }

        if(c==10)break;
    } while(1);
}
コード例 #4
0
/* monthly - LCS finances report */
void fundreport(char &clearformess)
{
   if(disbanding) return;
   music.play(MUSIC_FINANCES);

   clearformess=true;

   int page=0;
   bool showledger=false;
   std::string num;
   static const char dotdotdot[]=". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ";

   int expenselines = 0;
   for(int i=0;i<EXPENSETYPENUM;i++)
      if (ledger.expense[i])
         expenselines++;

   while(true)
   {
      erase();

      int y=2,totalmoney=0,dailymoney=0,numpages=1;

      set_color(COLOR_WHITE,COLOR_BLACK,1);
      mvaddstr(0,0,"Liberal Crime Squad: Funding Report");

      for(int i=0;i<INCOMETYPENUM;i++)
      {
         if(ledger.income[i])
         {
            showledger=true;
            if(page==numpages-1)
            {
               set_color(COLOR_WHITE,COLOR_BLACK,0);
               mvaddstr(y,0,dotdotdot);
               set_color(COLOR_GREEN,COLOR_BLACK,0);
               num="+$"+tostring(ledger.income[i]);
               mvaddstr(y,60-len(num),num);
               if(ledger.dailyIncome[i])
                  num=" (+$"+tostring(ledger.dailyIncome[i])+")";
               else
               {
                  set_color(COLOR_WHITE,COLOR_BLACK,0);
                  num=" ($0)";
               }
               mvaddstr(y,73-len(num),num);
               set_color(COLOR_WHITE,COLOR_BLACK,0);
               switch(i)
               {
               case INCOME_BROWNIES: mvaddstr(y,0,"Brownies"); break;
               case INCOME_CARS: mvaddstr(y,0,"Car Sales"); break;
               case INCOME_CCFRAUD: mvaddstr(y,0,"Credit Card Fraud"); break;
               case INCOME_DONATIONS: mvaddstr(y,0,"Donations"); break;
               case INCOME_SKETCHES: mvaddstr(y,0,"Drawing Sales"); break;
               case INCOME_EMBEZZLEMENT: mvaddstr(y,0,"Embezzlement"); break;
               case INCOME_EXTORTION: mvaddstr(y,0,"Extortion"); break;
               case INCOME_HUSTLING: mvaddstr(y,0,"Hustling"); break;
               case INCOME_PAWN: mvaddstr(y,0,"Pawning Goods"); break;
               case INCOME_PROSTITUTION: mvaddstr(y,0,"Prostitution"); break;
               case INCOME_BUSKING: mvaddstr(y,0,"Street Music"); break;
               case INCOME_THIEVERY: mvaddstr(y,0,"Thievery"); break;
               case INCOME_TSHIRTS: mvaddstr(y,0,"T-Shirt Sales"); break;
               default: mvaddstr(y,0,"Other Income"); break;
               }
            }
            totalmoney+=ledger.income[i];
            dailymoney+=ledger.dailyIncome[i];

            if(++y>=23) y=2,numpages++;
         }
      }

      // If expenses are too long to fit on this page, start them on the next page so it isn't broken in half unnecessarily
      if(y+expenselines>=23 && y>2) y=2,numpages++;

      for(int i=0;i<EXPENSETYPENUM;i++)
      {
         if(ledger.expense[i])
         {
            showledger=true;
            if(page==numpages-1)
            {
               set_color(COLOR_WHITE,COLOR_BLACK,0);
               mvaddstr(y,0,dotdotdot);
               set_color(COLOR_RED,COLOR_BLACK,0);
               num="-$"+tostring(ledger.expense[i]);
               mvaddstr(y,60-len(num),num);
               if(ledger.dailyExpense[i])
                  num=" (-$"+tostring(ledger.dailyExpense[i])+")";
               else
               {
                  set_color(COLOR_WHITE,COLOR_BLACK,0);
                  num=" ($0)";
               }
               mvaddstr(y,73-len(num),num);
               set_color(COLOR_WHITE,COLOR_BLACK,0);
               switch(i)
               {
               case EXPENSE_TROUBLEMAKING: mvaddstr(y,0,"Activism"); break;
               case EXPENSE_CONFISCATED: mvaddstr(y,0,"Confiscated"); break;
               case EXPENSE_DATING: mvaddstr(y,0,"Dating"); break;
               case EXPENSE_SKETCHES: mvaddstr(y,0,"Drawing Materials"); break;
               case EXPENSE_FOOD: mvaddstr(y,0,"Groceries"); break;
               case EXPENSE_HOSTAGE: mvaddstr(y,0,"Hostage Tending"); break;
               case EXPENSE_LEGAL: mvaddstr(y,0,"Legal Fees"); break;
               case EXPENSE_MANUFACTURE: mvaddstr(y,0,"Manufacturing"); break;
               case EXPENSE_CARS: mvaddstr(y,0,"New Cars"); break;
               case EXPENSE_SHOPPING: mvaddstr(y,0,"Purchasing Goods"); break;
               case EXPENSE_RECRUITMENT: mvaddstr(y,0,"Recruitment"); break;
               case EXPENSE_RENT: mvaddstr(y,0,"Rent"); break;
               case EXPENSE_COMPOUND: mvaddstr(y,0,"Safehouse Investments"); break;
               case EXPENSE_TRAINING: mvaddstr(y,0,"Training"); break;
               case EXPENSE_TRAVEL: mvaddstr(y,0,"Travel"); break;
               case EXPENSE_TSHIRTS: mvaddstr(y,0,"T-Shirt Materials"); break;
               default: mvaddstr(y,0,"Other Expenses"); break;
               }
            }
            totalmoney-=ledger.expense[i];
            dailymoney-=ledger.dailyExpense[i];

            if(++y>=23) y=2,numpages++;
         }
      }

      if(showledger)
      {
         if(page==numpages-1) makedelimiter(y);

         if(++y>=23) y=2,numpages++;

         if(page==numpages-1)
         {
            set_color(COLOR_WHITE,COLOR_BLACK,1);
            mvaddstr(y,0,"Net Change This Month (Day):");
            if(totalmoney>0) { set_color(COLOR_GREEN,COLOR_BLACK,1); num="+"; }
            else if(totalmoney<0) { set_color(COLOR_RED,COLOR_BLACK,1); num="-"; }
            else { set_color(COLOR_WHITE,COLOR_BLACK,1); num=""; }
            num+="$"+tostring(abs(totalmoney));
            mvaddstr(y,60-len(num),num);
            if(dailymoney>0)
            {
               set_color(COLOR_GREEN,COLOR_BLACK,1);
               num=" (+$"+tostring(abs(dailymoney))+")";
            }
            else if(dailymoney<0)
            {
               set_color(COLOR_RED,COLOR_BLACK,1);
               num=" (-$"+tostring(abs(dailymoney))+")";
            }
            else
            {
               set_color(COLOR_WHITE,COLOR_BLACK,1);
               num=" ($0)";
            }
            mvaddstr(y,73-len(num),num);
         }

         if(++y>=23) y=2,numpages++;
      }

      if (y>2) y++; // Blank line between income/expenses and assets if not starting a new page
      if (y+7>=23) y=2, numpages++; //Start a new page if the liquid assets won't fit on the rest of the current page.
      // tally up liquid assets
      long weaponValue=0,armorValue=0,clipValue=0,lootValue=0;
      for(int j=0;j<len(location);j++)
         for(int i=0;i<len(location[j]->loot);i++)
         {
            Item* item=location[j]->loot[i];
            if(item->is_weapon()) weaponValue+=item->get_fencevalue()*item->get_number();
            if(item->is_armor()) armorValue+=item->get_fencevalue()*item->get_number();
            if(item->is_clip()) clipValue+=item->get_fencevalue()*item->get_number();
            if(item->is_loot()) lootValue+=item->get_fencevalue()*item->get_number();
         }

      if(page==numpages-1)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         mvaddstr(y,0,dotdotdot);
         mvaddstr(y,0,"Cash");
         set_color(ledger.get_funds()?COLOR_GREEN:COLOR_WHITE,COLOR_BLACK,0);
         num="$"+tostring(ledger.get_funds());
         mvaddstr(y,60-len(num),num);
      }

      if(++y>=23) y=2,numpages++;

      if(page==numpages-1)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         mvaddstr(y,0,dotdotdot);
         mvaddstr(y,0,"Tools and Weapons");
         set_color(weaponValue?COLOR_GREEN:COLOR_WHITE,COLOR_BLACK,0);
         num="$"+tostring(weaponValue);
         mvaddstr(y,60-len(num),num);
      }

      if(++y>=23) y=2,numpages++;

      if(page==numpages-1)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         mvaddstr(y,0,dotdotdot);
         mvaddstr(y,0,"Clothing and Armor");
         set_color(armorValue?COLOR_GREEN:COLOR_WHITE,COLOR_BLACK,0);
         num="$"+tostring(armorValue);
         mvaddstr(y,60-len(num),num);
      }

      if(++y>=23) y=2,numpages++;

      if(page==numpages-1)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         mvaddstr(y,0,dotdotdot);
         mvaddstr(y,0,"Ammunition");
         set_color(clipValue?COLOR_GREEN:COLOR_WHITE,COLOR_BLACK,0);
         num="$"+tostring(clipValue);
         mvaddstr(y,60-len(num),num);
      }

      if(++y>=23) y=2,numpages++;

      if(page==numpages-1)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         mvaddstr(y,0,dotdotdot);
         mvaddstr(y,0,"Miscellaneous Loot");
         set_color(lootValue?COLOR_GREEN:COLOR_WHITE,COLOR_BLACK,0);
         num="$"+tostring(lootValue);
         mvaddstr(y,60-len(num),num);
      }

      if(++y>=23) y=2,numpages++;

      if(page==numpages-1) makedelimiter(y);

      if(++y>=23) y=2,numpages++;

      if(page==numpages-1)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,1);
         mvaddstr(y,0,"Total Liquid Assets:");
         long netWorth=ledger.get_funds()+weaponValue+armorValue+clipValue+lootValue;
         set_color(netWorth?COLOR_GREEN:COLOR_WHITE,COLOR_BLACK,1);
         num="$"+tostring(netWorth);
         mvaddstr(y,60-len(num),num);
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      if(numpages>1)
      {
         mvaddstr(24,0,"Press Enter to reflect on the report.  ");
         addpagestr();

         while(true)
         {
            int c=getkey();

            if(c=='x'||c==ENTER||c==ESC||c==SPACEBAR)
            {
               music.play(MUSIC_PREVIOUS);
               return;
            }

            //PAGE UP
            if(c==interface_pgup||c==KEY_UP||c==KEY_LEFT) { page--; if(page<0) page=numpages-1; break; }
            //PAGE DOWN
            if(c==interface_pgdn||c==KEY_DOWN||c==KEY_RIGHT) { page++; if(page>=numpages) page=0; break; }
         }
      }
      else
      {
         mvaddstr(24,0,"Press any key to reflect on the report.");

         getkey();

         music.play(MUSIC_PREVIOUS);
         return;
      }
   }
}
コード例 #5
0
void Shop::maskselect(Creature &buyer) const
{
   short maskindex=-1;

   std::vector<unsigned> masktype;
   for(unsigned a=0;a<armortype.size();a++)
   {
      if (armortype[a]->is_mask() && !armortype[a]->is_surprise_mask())
         masktype.push_back(a);
   }

   unsigned page=0;

   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,1);
      move(0,0);
      addstr("Which mask will ");
      addstr(buyer.name);
      addstr(" buy?");
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(1,0);
      addstr("----PRODUCT NAME-----------------------DESCRIPTION------------------------------");

      int y=2;
      for(unsigned p=page*19 ; p < masktype.size() && p < page*19+19; p++)
      {
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         move(y,0);
         addch(y+'A'-2);addstr(" - ");
         addstr(armortype[masktype[p]]->get_name().c_str());
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         move(y,39);
         addstr(armortype[masktype[p]]->get_description().c_str());

         y++;
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(22,0);
      addstr("Press a Letter to select a Mask");
      move(23,0);
      addpagestr();
      move(24,0);
      addstr("Z - Surprise ");
      addstr(buyer.name);
      addstr(" With a Random Mask");

      refresh();

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

      //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)*19 < masktype.size())
         page++;

      if(c >= 'a' && c <= 's')
      {
         int p = page*19+(int)(c-'a');
         if(p < (int)masktype.size())
         {
            maskindex = masktype[p];
            break;
         }
      }
      if(c == 'z')
      {
         for (int i = 0; i < (int)armortype.size(); ++i)
         {
            if (armortype[i]->is_mask() && armortype[i]->is_surprise_mask())
               masktype.push_back(i);
         }
         maskindex = masktype[LCSrandom(masktype.size())];
         break;
      }

      if (c == 10)
         break;
   }while(1);

   if (maskindex != -1 && ledger.get_funds() >= 15)
   {
      Armor a = Armor(*armortype[maskindex]);
      buyer.give_armor(a, &location[buyer.base]->loot);
      ledger.subtract_funds(15,EXPENSE_SHOPPING);
   }
}
コード例 #6
0
void Shop::browse_fullscreen(squadst& customers, int& buyer) const
{
   unsigned page = 0;

   std::vector<ShopOption*> available_options = options_;
   available_options.erase (remove_if (available_options.begin(),
				       available_options.end(),
				       not1 (mem_fun (&ShopOption::display))),
			    available_options.end());


   do
   {
      erase();
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(0,0);
      addstr("What will ");
      addstr(customers.squad[buyer]->name);
      addstr(" buy?");
      move(1,0);
      addstr("----PRODUCT NAME-----------------------PRICE------------------------------------");
      int yline = 2;

      //Write wares and prices
      for(unsigned p = page * 19; p < available_options.size () && p < page * 19 + 19; p++)
      {
         if (available_options[p]->is_available())
            set_color(COLOR_WHITE,COLOR_BLACK,0);
         else
            set_color(COLOR_BLACK,COLOR_BLACK,1);
         move(yline,0);
         addch('A' + yline - 2);
         addstr(" - ");
         addstr(available_options[p]->get_description_fullscreen().c_str());
         ++yline;
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(22,0);
      addstr("Press a Letter to select an option"); //allow customize "option"? -XML
      move(23,0);
      addpagestr();
      move(24,0);
      addstr(("Enter - " + std::string(customers.squad[buyer]->name) + " " + exit_).c_str());

      refresh();

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

      //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) * 19 < available_options.size())
         page++;

      if (c >= 'a' && c <= 's')
      {
         int p = page * 19 + static_cast<int>(c-'a');
         if (p < (int)available_options.size() && available_options[p]->is_available())
            available_options[p]->choose(customers, buyer);
         break;
      }

      if (c == 10)
         break;
   } while (true);
}