]>
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
, " ");
23 notice(s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
24 notice(s_GameServ
, u
, " \ 2STORE SELL NUMBER\ 2");
25 notice(s_GameServ
, u
, " \ 2STORE BUY \1fNUMBER\1f\ 2");
28 else if (!(user
= find(u
)))
30 log("Fatal Error: could not find %s in client list", u
);
33 else if (isIgnore(user
))
36 log("Ignoring %s.", user
->getNick());
40 else if (!is_playing(user
))
42 notice(s_GameServ
, u
, "You must be playing to use the store!");
45 else if (is_fighting(user
))
47 notice(s_GameServ
, u
, "You can't go to the store while fighting!");
50 else if (!isAlive(user
->stats
))
52 notice(s_GameServ
, u
, "You are dead. Wait until tomorrow to purchase weapons and armor!");
55 updateTS(user
->stats
);
57 if (stricmp(cmd
, "LIST") == 0)
59 if (stricmp(num
, "WEAPONS") == 0)
61 notice(s_GameServ
, u
, "Welcome to Kain's Armory");
62 notice(s_GameServ
, u
, "Here are the weapons we have available for the killing, sire:");
63 for (item_iterator
= store
.begin(); item_iterator
!= store
.end(); ++item_iterator
)
65 if ((*item_iterator
)->getType() == WEAPON
)
67 space
= spaces(strlen((*item_iterator
)->getName().c_str()), ".");
68 notice(s_GameServ
, u
, "%s%ld. %20s..........%ld",
69 ((*item_iterator
)->getID() < 10 ? " " : ""),
70 (*item_iterator
)->getID(), (*item_iterator
)->getName().c_str(), (*item_iterator
)->price());
73 notice(s_GameServ
, u
, "To purchase a weapon, type /msg <S STORE BUY \ 2#\ 2.");
74 notice(s_GameServ
, u
, "Where # is the weapon number from the menu above.");
77 else if (stricmp(num
, "ARMOR") == 0)
79 notice(s_GameServ
, u
, "Welcome to Kain's Armory");
80 notice(s_GameServ
, u
, "I hope you enjoy the fine armor we have available for your protection:");
81 for (item_iterator
= store
.begin(); item_iterator
!= store
.end(); ++item_iterator
)
83 if ((*item_iterator
)->getType() == ARMOR
)
85 notice(s_GameServ
, u
, "%s%ld. %20s..........%d",
86 ((*item_iterator
)->getID() < 10 ? " " : ""),
87 (*item_iterator
)->getID(), (*item_iterator
)->getName().c_str(),
88 (*item_iterator
)->price());
92 notice(s_GameServ
, u
, "To purchase armor, type /msg <S store buy #");
93 notice(s_GameServ
, u
, "Where # is the armor number from the menu above.");
97 else if (stricmp(cmd
, "BUY") == 0)
102 notice(s_GameServ
, u
, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
107 id
= stringtoint(num
);
110 if (!isstringnum(num
))
112 notice(s_GameServ
, u
, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
115 else if (!(tempItem
= findStoreItemByID(id
)))
117 notice(s_GameServ
, u
, "Sorry, we don't carry that item!");
120 else if (p
->getGold() < tempItem
->price())
122 notice(s_GameServ
, u
, "You can't afford to buy %s", tempItem
->getName().c_str());
125 else if (p
->inventory
->addItem(tempItem
))
127 notice(s_GameServ
, u
, "You have purchased %s! Thanks for the gold!", tempItem
->getName().c_str());
128 p
->subtractGold(tempItem
->price());
129 notice(s_GameServ
, u
, "Don't forget to type /msg <S equip %ld", tempItem
->getID());
133 notice(s_GameServ
, u
, "You can't carry any more!");
136 else if (stricmp(cmd
, "SELL" ) == 0)
138 itemContainer
*tempContainer
;
140 id
= stringtoint(num
);
141 if (!isstringnum(num
))
143 notice(s_GameServ
, u
, "SYNTAX: /msg <S store sell #");
146 else if (!(tempContainer
= p
->inventory
->Find(id
)))
148 notice(s_GameServ
, u
, "You're not carrying that!");
151 else if (p
->getGold() >= 2000000000)
153 notice(s_GameServ
, u
, "You have enough gold. Just hang on to it for now.");
157 tempItem
= tempContainer
->getItem();
159 notice(s_GameServ
, u
, "Thank you for your business! We gave you %ld gold for %s!", (tempItem
->price() / 2), tempItem
->getName().c_str());
160 p
->addGold((tempItem
->price() / 2));
161 p
->inventory
->deleteItem(tempItem
);
162 if (tempItem
== p
->getWeapon())
164 notice(s_GameServ
, u
, "Since you equipped %s, you're going to have to reequip something", tempItem
->getName().c_str());
168 else if (tempItem
== p
->getArmor())
171 notice(s_GameServ
, u
, "Since you equipped %s, you're going to have to reequip something", tempItem
->getName().c_str());
178 notice(s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
179 notice(s_GameServ
, u
, " \ 2STORE SELL #\ 2");
180 notice(s_GameServ
, u
, " \ 2STORE BUY \1f#\1f\ 2");