]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_tavern.cpp
9 void do_tavern(char *u
)
11 char *cmd
= strtok(NULL
, " ");
16 if (!(user
= find(u
)))
18 notice(s_GameServ
, u
, "Fatal Error. See a <S admin for help");
21 else if (isIgnore(user
))
24 log("Ignoring %s.", user
->getNick());
28 else if (!is_playing(user
))
30 notice(s_GameServ
, u
, "You must be playing to go to the Tavern");
33 else if (is_fighting(user
))
35 notice(s_GameServ
, u
, "You cannot go to the Tavern during a fight!");
39 updateTS(user
->stats
);
44 notice(s_GameServ
, u
, "Welcome to Boot Liquors Mystic Apothecary and General Store");
45 notice(s_GameServ
, u
, "Your commands:");
46 notice(s_GameServ
, u
, "/msg <S TAVERN {LIST | BUY} [NUMBER]");
47 notice(s_GameServ
, u
, "What'll it be?");
49 else if (stricmp(cmd
, "LIST") == 0)
51 notice(s_GameServ
, u
, "Here is a list of what we have to offer:");
53 notice(s_GameServ
, u
, "To buy an item, type /msg <S TAVERN BUY #");
55 else if (stricmp(cmd
, "BUY") == 0)
58 char *chid
= strtok(NULL
, " ");
59 char *amount
= strtok(NULL
, " ");
62 amt
= stringtoint(amount
);
66 notice(s_GameServ
, u
, "SYNTAX: TAVERN BUY # [#]");
67 notice(s_GameServ
, u
, "Example: /msg <S TAVERN BUY 6001");
68 notice(s_GameServ
, u
, "Example: /msg <S TAVERN BUY 6001 10");
71 long id
= stringtoint(chid
);
74 if (!(tempItem
= findTavernItemByID(id
)) || user
->stats
->getLevel() < tempItem
->getLevel())
76 notice(s_GameServ
, u
, "Invalid Choice!");
77 notice(s_GameServ
, u
, "Here is a list of what we have to offer:");
79 notice(s_GameServ
, u
, "To buy an item, type /msg <S TAVERN BUY #");
82 else if (!amount
&& user
->stats
->getGold() < tempItem
->getItem()->price())
84 notice(s_GameServ
, u
, "You don't have enough gold!");
85 notice(s_GameServ
, u
, "Here is a list of what we have to offer:");
87 notice(s_GameServ
, u
, "To buy an item, type /msg <S TAVERN BUY #");
89 else if (user
->stats
->getGold() < amt
* tempItem
->getItem()->price())
91 notice(s_GameServ
, u
, "You don't have enough gold!");
92 notice(s_GameServ
, u
, "Here is a list of what we have to offer:");
94 notice(s_GameServ
, u
, "To buy an item, type /msg <S TAVERN BUY # [#]");
100 int amt
= stringtoint(amount
);
101 if (amt
< 0 || amount
[0] == '-')
103 notice(s_GameServ
, u
, "You trying to steal from me?");
105 else if (user
->stats
->inventory
->addItem(tempItem
->getItem(), amt
) == NULL
)
107 notice(s_GameServ
, u
, "You can't carry that many!");
111 notice(s_GameServ
, u
, "%d %s's coming right up!", amt
, tempItem
->getItem()->getName().c_str());
112 user
->stats
->subtractGold(tempItem
->getItem()->price() * amt
);
117 if (user
->stats
->inventory
->addItem(tempItem
->getItem()) == NULL
)
119 notice(s_GameServ
, u
, "You can't carry any more!");
123 notice(s_GameServ
, u
, "One %s coming right up!", tempItem
->getItem()->getName().c_str());
124 user
->stats
->subtractGold(tempItem
->getItem()->price());
131 notice(s_GameServ
, u
, "Improper Syntax.");
132 notice(s_GameServ
, u
, "Type /msg <S HELP TAVERN for help");