CurrencyMods02_12_06/
CurrencyMods02_12_06/banks/
CurrencyMods02_12_06/money/
// ==> This file will deal with shopping


#include "../mud.h"
#include "../character.h"
#include "../account.h"
#include "../storage.h"
#include "../auxiliary.h"
#include "../handler.h"
#include "../socket.h"
#include "../utils.h"
#include "../save.h"
#include "../object.h"
#include "../set_val/set_val.h"
#include "../scripts/scripts.h"
#include "../scripts/pychar.h"
#include "../room.h"
#include "../items/items.h"
#include "../items/worn.h"
#include "money.h"
#include "shops.h"




COMMAND(cmd_list)
{
  ROOM_DATA *room = charGetRoom(ch);
  if(bitIsOneSet(roomGetBits(room), "tailorshop"))
  {
  send_to_char(ch, "{nA tailor informs you that he dyes to make the following colors:\r\n");
  send_to_char(ch, "{cred, blue, green, white{n\r\n");
  send_to_char(ch, "{nA tailor informs you that he has the following materials to use:\r\n");
  send_to_char(ch, "{ccotton, denim{n\r\n");
  send_to_char(ch, "{nA tailor informs you that he can make the following items:\r\n");
  send_to_char(ch, "{cshirt, pants{n\r\n\n\r");
  send_to_char(ch, "{nTo get a quote use the following syntax:\r\n");
  send_to_char(ch, "{cprice (color) (material) (type){n\r\n");
  send_to_char(ch, "{nTo order clothing use the following syntax:\r\n");
  send_to_char(ch, "{cbuy (color) (material) (type){n\r\n");
  }else{
    send_to_char(ch, "{nYou must stand within a shop to see what goods are listed for sale.");
    return;
  }
}

COMMAND(cmd_price)
{
  ROOM_DATA *room = charGetRoom(ch);
 if(bitIsOneSet(roomGetBits(room), "tailorshop")){
  char *color = NULL;
  char *material = NULL;
  char *purchase = NULL;
  int dyecost;
  int matcost;
  int clothcost;
  if(!parse_args(ch, TRUE, cmd, arg, "word word word", &color, &material, &purchase))
    return;
  if(!strcmp(color, "white")){
    dyecost = 0;
  }else   if(!strcmp(color, "red")){
    dyecost = 5;
  }else   if(!strcmp(color, "blue")){
    dyecost = 5;
  }else   if(!strcmp(color, "green")){
    dyecost = 5;
  }else{
    send_to_char(ch, "{nA tailor states that %s is not a color of dye he uses.\r\n", color);
    return;
  }
  if(!strcmp(material, "cotton")){
    matcost = 0;
  }else if(!strcmp(material, "denim")){
    matcost = 10;
  }else{
    send_to_char(ch, "{nA tailor states that %s is not a material he uses.\r\n", material);
    return;
  }
  if(!strcmp(purchase, "shirt")){
    clothcost = 150;
    int purchase_cost;
    purchase_cost = (dyecost + matcost + clothcost);
    send_to_char(ch, "{nA tailor elaborates, informing you that such a shirt would cost you"
			"{c%d{n gold%s.\r\n", purchase_cost, (purchase_cost == 1 ? "" : "s"));
  }else if(!strcmp(purchase, "pants")){
    clothcost = 100;
    int purchase_cost;
    purchase_cost = (dyecost + matcost + clothcost);
    send_to_char(ch, "{nA tailor elaborates, informing you that such trousers would cost you"
			" {c%d{n gold%s.\r\n", purchase_cost, (purchase_cost == 1 ? "" : "s"));
  }else{
    send_to_char(ch, "{nA tailor states that %s is not type of clothing he makes.\r\n", purchase);
    return;
  }

 }else{
   send_to_char(ch, "{gYou must stand within a shop to check prices.");
   return;
 }
}


COMMAND(cmd_buy)
{
  ROOM_DATA *room = charGetRoom(ch);
  if(bitIsOneSet(roomGetBits(room), "tailorshop"))
  {
    char *color = NULL;
    char *material = NULL;
    char *purchase = NULL;
    char *colordesc = NULL;
    char *materialdesc = NULL;
    char *purchasedesc = NULL;
    int dyecost;
    int matcost;
    int clothcost;
    if(!parse_args(ch, TRUE, cmd, arg, "word word word", &color, &material, &purchase))
      return;
    if(!strcmp(color, "white")){
      colordesc = "This garment has been crafted using a brightly bleached, white";
      dyecost = 0;
    }else   if(!strcmp(color, "red")){
      colordesc = "This garment has been crafted using a vibrantly dyed, red";
      dyecost = 5;
    }else   if(!strcmp(color, "blue")){
      colordesc = "This garment has been crafted using a deep blue";
      dyecost = 5;
    }else   if(!strcmp(color, "green")){
      colordesc = "This garment has been crafted using a boldly dyed, green";
      dyecost = 5;
    }else{
      send_to_char(ch, "{nA tailor states that %s is not a color of dye he uses.\r\n", color);
      return;
    }
    if(!strcmp(material, "cotton")){
      materialdesc = "cotton.  Its stitching and lines are simple and clean.  The tag inside the collar states that it was manufactured by a city tailor..";
      matcost = 0;
    }else   if(!strcmp(material, "denim")){
      materialdesc = "denim.  Its stitching and lines are simple and clean.  The tag inside the collar states that it was manufactured by a city tailor..";
      matcost = 0;
    }else{
      send_to_char(ch, "{nA tailor states that %s is not a material he uses.\r\n", material);
      return;
    }
    if(!strcmp(purchase, "shirt")){
      clothcost = 150;
      int purchase_cost;
      purchase_cost = (dyecost + matcost + clothcost);
      int char_cash;
      char_cash = (charGetMoney(ch));
      if(char_cash < purchase_cost)
      {
         send_to_char(ch, "{nYou don't have enough cash on hand to buy that.\r\n");
         return;
      }else{
        int newcash;
        newcash = (char_cash - purchase_cost);
        charSetMoney(ch, newcash);
        purchasedesc = "A simple tee-shirt has short sleeves, a v-neck and no collar."; 
        char posbuf[SMALL_BUFFER];
        sprintf(posbuf, "{n%s %s %s", purchasedesc, colordesc, materialdesc);
        OBJ_DATA *obj = newObj();
        objSetName (obj, "a tee shirt");
        objSetKeywords (obj, "shirt, tee");
        objSetType (obj, "worn");
        wornSetType (obj, "shirt");
        objSetRdesc (obj, "A tee shirt lies, crumpled here.");
        objSetMultiName (obj, "%d tee shirts");
        objSetMultiRdesc (obj, "%d tee shirts lay here, crumpled.");
        objSetDesc (obj, posbuf);
        send_to_char(ch, "A tailor gives you a tee shirt.\r\n");
        obj_to_game(obj);
        obj_to_char(obj, ch);
      }
    }else if(!strcmp(purchase, "pants")){
      clothcost = 100;
      int purchase_cost;
      purchase_cost = (dyecost + matcost + clothcost);
      int char_cash;
      char_cash = (charGetMoney(ch));
      if(char_cash < purchase_cost)
      {
         send_to_char(ch, "{nYou don't have enough cash on hand to buy that.\r\n");
         return;
      }else{
        int newcash;
        newcash = (char_cash - purchase_cost);
        charSetMoney(ch, newcash);
        purchasedesc = "A pair of pants has been made with a button fly, tapered legs and belt loops."; 
        char posbuf[SMALL_BUFFER];
        sprintf(posbuf, "{n%s %s %s", purchasedesc, colordesc, materialdesc);
        OBJ_DATA *obj = newObj();
        objSetName (obj, "a pair of pants");
        objSetKeywords (obj, "pants, trousers");
        objSetType (obj, "worn");
        wornSetType (obj, "pants");
        objSetRdesc (obj, "A pair of pants lies here, crumpled up.");
        objSetMultiName (obj, "%d pairs of pants");
        objSetMultiRdesc (obj, "%d pairs of pants lay here in a crumpled pile.");
        objSetDesc (obj, posbuf);
        send_to_char(ch, "A tailor gives you a pair of pants.\r\n");
        obj_to_game(obj);
       obj_to_char(obj, ch);
      }

    }else{
      send_to_char(ch, "{nA tailor states that %s is not type of clothing he makes.\r\n", purchase);
      return;
    }

  }else{
    send_to_char(ch, "{nYou must stand within a shop to buy anything.\r\n");
    return;
  }
}

/************************************************************************
	Below here are all of the init_ functions for this file.
*************************************************************************/
void init_shops(void)
{
	add_cmd("list", "list", cmd_list, POS_UNCONCIOUS, POS_FLYING, "player", TRUE, FALSE);
	add_cmd("buy", "buy", cmd_buy, POS_UNCONCIOUS, POS_FLYING, "player", TRUE, FALSE);
	add_cmd("price", "price", cmd_price, POS_UNCONCIOUS, POS_FLYING, "player", TRUE, FALSE);
      bitvectorAddBit("room_bits", "tailorshop");
}