Armor  ICharacter::unequipArmor()
		{
			Armor returnArmor = armor;

			updateStats(-armor.getStrength(), -armor.getDexterity(), -armor.getConstitution(), -armor.getIntelligence(), -armor.getWisdom(), -armor.getCharisma());

			this -> armor = Armor(0, 0, 0, 0, 0, 0);

			return returnArmor;
		}
Exemple #2
0
void ArcherArmor::ArcherArmor_shop()
{
	soldier_armor = {//name, damage, price
			{1, Armor("Meito Ichimonji", 4, 150, 1)},
			{2, Armor("Shusui", 10, 230, 2)},
			{3, Armor("Apocalypse", 16, 300, 3)},
			{4, Armor("Blade of Scars", 24, 550, 4)},
			{5, Armor("Ragnarok", 32, 610, 5)},
			{6, Armor("Eternal Darkness", 40, 690, 6)},
			{7, Armor("Masamune", 52, 750, 7)},
			{8, Armor("Soul Calibur", 60, 900, 8)}
		};
}
void MageArmor::MageArmor_Shop(Hero& hero)
{
     /*this->mage_armor = {//name, damage, price
        {1, Armor("Colossus", 4, 150, 1)},
        {2, Armor("Eternal Vanguard", 10, 230, 2)},
        {3, Armor("Prism", 16, 300, 3)},
        {4, Armor("Valkyrie", 24, 550, 4)},
        {5, Armor("Trident", 32, 610, 5)},
        {6, Armor("Eclipse", 40, 690, 6)},
        {7, Armor("Lunar Spirit", 52, 750, 7)},
        {8, Armor("Astral Inducer", 60, 900, 8)}
    };*/
	
	this->init_map_values();//Inherits init_map_values from mainshop
	
	this->mage_armor = {//name, damage, price
        {1, Armor("Colossus",         map_effect_array[0], map_price_array[0],map_sellValue_array[0], 1)},
        {2, Armor("Eternal Vanguard", map_effect_array[1], map_price_array[1],map_sellValue_array[1], 2)},
        {3, Armor("Prism",            map_effect_array[2], map_price_array[2],map_sellValue_array[2], 3)},
        {4, Armor("Valkyrie",		  map_effect_array[3], map_price_array[3],map_sellValue_array[3], 4)},
        {5, Armor("Trident",		  map_effect_array[4], map_price_array[4],map_sellValue_array[4], 5)},
        {6, Armor("Eclipse",		  map_effect_array[5], map_price_array[5],map_sellValue_array[5], 6)},
        {7, Armor("Lunar Spirit",	  map_effect_array[6], map_price_array[6],map_sellValue_array[6], 7)},
        {8, Armor("Astral Inducer",   map_effect_array[7], map_price_array[7],map_sellValue_array[7], 8)}
    };
    
    //Able to check private data of hero i.e My_class because its a friend
	//check class
	if (hero.My_class != "Mage")
	{
		cout << "\nNote: You can only buy from this category if you are of a mage class\n";
		cout << "...\nSorry, you are not of type mage class, therefore you cannot buy mage related items.\n";
        MainShop::mainShop(hero);
        return;
	}
    
    //this->getMageArmor();
    this->getMageArmor();//DISPLAYS THE armor MAP
    
	cout << "Select what you would like to buy, or enter 9 to quit!\n";
	cin >> choice;
	switch (choice)
	{
        case 1:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 1)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {//Add a function-if you already have a armor, you cannot buy it again
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 2:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 2)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 3:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 3)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 4:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 4)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 5:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 5)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 6:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 6)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 7:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 7)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 8:
            for (map <int, Armor>::iterator iter = mage_armor.begin(); iter != mage_armor.end(); iter++)
            {
                if(iter->first == 8)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_armor(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< armor_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this armor\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->MageArmor_Shop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 9: cout << "Exiting Armor shop...\n";
            break;
            
        default:
            cout << "Error! You have entered an invalid answer\nPlease try again" << endl;
            this->MageArmor_Shop(hero);
	}
}
Exemple #4
0
void doship(shiptype *ship, int update)
{
    racetype *Race;
    shiptype *ship2;

    /*ship is active */
    ship->active = 1;

    if(!ship->owner) ship->alive = 0;

    if (ship->alive) {
        /* repair radiation */
        if (ship->rad) {
            ship->active = 1;
            /* irradiated ships are immobile.. */
            /* kill off some people */
            /* check to see if ship is active */
            if(success(ship->rad))
                ship->active = 0;
            if(update) {
                ship->popn = round_rand(ship->popn * .80);
                ship->troops = round_rand(ship->troops * .80);
                if (ship->rad >= (int)REPAIR_RATE)
                    ship->rad -= int_rand(0,(int)REPAIR_RATE);
                else
                    ship->rad -= int_rand(0,(int)ship->rad);
            }
        } else
            ship->active = 1;

        if(!ship->popn && Max_crew(ship) && !ship->docked)
            ship->whatdest = LEVEL_UNIV;

        if (ship->whatorbits != LEVEL_UNIV
                && Stars[ship->storbits]->nova_stage>0) {
            /* damage ships from supernovae */
            /* Maarten: modified to take into account MOVES_PER_UPDATE */
            ship->damage += 5 * Stars[ship->storbits]->nova_stage /
                            ((Armor(ship)+1) * segments);
            if (ship->damage >= 100) {
                kill_ship((int)(ship->owner), ship);
                return;
            }
        }

        if(ship->type==OTYPE_FACTORY && !ship->on) {
            Race = races[ship->owner-1];
            ship->tech = Race->tech;
        }

        if(ship->active)
            Moveship(ship, update, 1, 0);

        ship->size = ship_size(ship);	/* for debugging */

        if(ship->whatorbits==LEVEL_SHIP) {
            (void)getship(&ship2, (int)ship->destshipno);
            if(ship2->owner != ship->owner) {
                ship2->owner = ship->owner;
                ship2->governor = ship->governor;
                putship(ship2);
            }
            free(ship2);
            /* just making sure */
        } else if(ship->whatorbits != LEVEL_UNIV &&
                  (ship->popn || ship->type == OTYPE_PROBE)) {
            /* Though I have often used TWCs for exploring, I don't think it is right */
            /* to be able to map out worlds with this type of junk. Either a manned ship, */
            /* or a probe, which is designed for this kind of work.  Maarten */
            StarsInhab[ship->storbits] = 1;
            setbit(Stars[ship->storbits]->inhabited, ship->owner);
            setbit(Stars[ship->storbits]->explored, ship->owner);
            if(ship->whatorbits == LEVEL_PLAN) {
                planets[ship->storbits][ship->pnumorbits]->info[ship->owner-1].explored = 1;
            }
        }

        /* add ships, popn to total count to add AP's */
        if(update) {
            Power[ship->owner-1].ships_owned++;
            Power[ship->owner-1].resource += ship->resource;
            Power[ship->owner-1].fuel += ship->fuel;
            Power[ship->owner-1].destruct += ship->destruct;
            Power[ship->owner-1].popn += ship->popn;
            Power[ship->owner-1].troops += ship->troops;
        }

        if (ship->whatorbits==LEVEL_UNIV) {
            Sdatanumships[ship->owner-1]++;
            Sdatapopns[ship->owner] += ship->popn;
        } else {
            starnumships[ship->storbits][ship->owner-1]++;
            /* add popn of ships to popn */
            starpopns[ship->storbits][ship->owner-1] += ship->popn;
            /* set inhabited for ship */
            /* only if manned or probe.  Maarten */
            if (ship->popn || ship->type==OTYPE_PROBE) {
                StarsInhab[ship->storbits] = 1;
                setbit(Stars[ship->storbits]->inhabited, ship->owner);
                setbit(Stars[ship->storbits]->explored, ship->owner);
            }
        }

        if (ship->active) {
            /* bombard the planet */
            if (can_bombard(ship) && ship->bombard
                    && ship->whatorbits==LEVEL_PLAN
                    && ship->whatdest==LEVEL_PLAN
                    && ship->deststar== ship->storbits
                    && ship->destpnum== ship->pnumorbits) {
                /* ship bombards planet */
                Stinfo[ship->storbits][ship->pnumorbits].inhab = 1;
            }

            /* repair ship by the amount of crew it has */
            /* industrial complexes can repair (robot ships
               and offline factories can't repair) */
            if(ship->damage && Repair(ship))
                do_repair(ship);

            if(update)
                switch (ship->type) {  /* do this stuff during updates only*/
                case OTYPE_CANIST:
                    do_canister(ship);
                    break;
                case OTYPE_GREEN:
                    do_greenhouse(ship);
                    break;
                case STYPE_MIRROR:
                    do_mirror(ship);
                    break;
                case STYPE_GOD:
                    do_god(ship);
                    break;
                case OTYPE_AP:
                    do_ap(ship);
                    break;
                case OTYPE_VN:	/* Von Neumann machine */
                case OTYPE_BERS:
                    if(!ship->special.mind.progenitor)
                        ship->special.mind.progenitor = 1;
                    do_VN(ship);
                    break;
                case STYPE_OAP:
                    do_oap(ship);
                    break;
                case STYPE_HABITAT:
                    do_habitat(ship);
                    break;
                default:
                    break;
                }
            if(ship->type==STYPE_POD)
                do_pod(ship);
        }
    }
}
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);
   }
}