]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_store.cpp
11 list
<item
*>::iterator item_iterator
;
13 char *cmd
= strtok(NULL
, " ");
14 char *num
= strtok(NULL
, " ");
22 notice(s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
23 notice(s_GameServ
, u
, " \ 2STORE SELL NUMBER\ 2");
24 notice(s_GameServ
, u
, " \ 2STORE BUY \1fNUMBER\1f\ 2");
27 else if (!(user
= find(u
)))
29 log("Fatal Error: could not find %s in client list", u
);
32 else if (isIgnore(user
))
35 log("Ignoring %s.", user
->getNick());
39 else if (!is_playing(user
))
41 notice(s_GameServ
, u
, "You must be playing to use the store!");
44 else if (is_fighting(user
))
46 notice(s_GameServ
, u
, "You can't go to the store while fighting!");
49 else if (!isAlive(user
->stats
))
51 notice(s_GameServ
, u
, "You are dead. Wait until tomorrow to purchase weapons and armor!");
54 updateTS(user
->stats
);
56 if (stricmp(cmd
, "LIST") == 0)
58 if (stricmp(num
, "WEAPONS") == 0)
60 notice(s_GameServ
, u
, "Welcome to Kain's Armory");
61 notice(s_GameServ
, u
, "Here are the weapons we have available for the killing, sire:");
62 for (item_iterator
= store
.begin(); item_iterator
!= store
.end(); ++item_iterator
)
64 if ((*item_iterator
)->getType() == WEAPON
)
66 notice(s_GameServ
, u
, "%s%ld. %20s..........%ld",
67 ((*item_iterator
)->getID() < 10 ? " " : ""),
68 (*item_iterator
)->getID(), (*item_iterator
)->getName().c_str(), (*item_iterator
)->price());
71 notice(s_GameServ
, u
, "To purchase a weapon, type /msg <S STORE BUY \ 2#\ 2.");
72 notice(s_GameServ
, u
, "Where # is the weapon number from the menu above.");
75 else if (stricmp(num
, "ARMOR") == 0)
77 notice(s_GameServ
, u
, "Welcome to Kain's Armory");
78 notice(s_GameServ
, u
, "I hope you enjoy the fine armor we have available for your protection:");
79 for (item_iterator
= store
.begin(); item_iterator
!= store
.end(); ++item_iterator
)
81 if ((*item_iterator
)->getType() == ARMOR
)
83 notice(s_GameServ
, u
, "%s%ld. %20s..........%d",
84 ((*item_iterator
)->getID() < 10 ? " " : ""),
85 (*item_iterator
)->getID(), (*item_iterator
)->getName().c_str(),
86 (*item_iterator
)->price());
90 notice(s_GameServ
, u
, "To purchase armor, type /msg <S store buy #");
91 notice(s_GameServ
, u
, "Where # is the armor number from the menu above.");
95 else if (stricmp(cmd
, "BUY") == 0)
100 notice(s_GameServ
, u
, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
105 id
= stringtoint(num
);
108 if (!isstringnum(num
))
110 notice(s_GameServ
, u
, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
113 else if (!(tempItem
= findStoreItemByID(id
)))
115 notice(s_GameServ
, u
, "Sorry, we don't carry that item!");
118 else if (p
->getGold() < tempItem
->price())
120 notice(s_GameServ
, u
, "You can't afford to buy %s", tempItem
->getName().c_str());
123 else if (p
->inventory
->addItem(tempItem
))
125 notice(s_GameServ
, u
, "You have purchased %s! Thanks for the gold!", tempItem
->getName().c_str());
126 p
->subtractGold(tempItem
->price());
127 notice(s_GameServ
, u
, "Don't forget to type /msg <S equip %ld", tempItem
->getID());
131 notice(s_GameServ
, u
, "You can't carry any more!");
134 else if (stricmp(cmd
, "SELL" ) == 0)
136 itemContainer
*tempContainer
;
138 id
= stringtoint(num
);
139 if (!isstringnum(num
))
141 notice(s_GameServ
, u
, "SYNTAX: /msg <S store sell #");
144 else if (!(tempContainer
= p
->inventory
->Find(id
)))
146 notice(s_GameServ
, u
, "You're not carrying that!");
149 else if (p
->getGold() >= 2000000000)
151 notice(s_GameServ
, u
, "You have enough gold. Just hang on to it for now.");
155 tempItem
= tempContainer
->getItem();
157 notice(s_GameServ
, u
, "Thank you for your business! We gave you %ld gold for %s!", (tempItem
->price() / 2), tempItem
->getName().c_str());
158 p
->addGold((tempItem
->price() / 2));
159 p
->inventory
->deleteItem(tempItem
);
160 if (tempItem
== p
->getWeapon())
162 notice(s_GameServ
, u
, "Since you equipped %s, you're going to have to reequip something", tempItem
->getName().c_str());
166 else if (tempItem
== p
->getArmor())
169 notice(s_GameServ
, u
, "Since you equipped %s, you're going to have to reequip something", tempItem
->getName().c_str());
176 notice(s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
177 notice(s_GameServ
, u
, " \ 2STORE SELL #\ 2");
178 notice(s_GameServ
, u
, " \ 2STORE BUY \1f#\1f\ 2");