]> jfr.im git - irc/gameservirc.git/commitdiff
Finished splitting files, and updated dependencies.
authorkainazzzo <redacted>
Tue, 23 Jan 2007 21:45:03 +0000 (21:45 +0000)
committerkainazzzo <redacted>
Tue, 23 Jan 2007 21:45:03 +0000 (21:45 +0000)
Also added options.h to most new files

git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@477 bc333340-6410-0410-a689-9d09f3c113fa

27 files changed:
gameserv/.depend
gameserv/Makefile.in
gameserv/do_admin.cpp
gameserv/do_attack.cpp
gameserv/do_bank.cpp
gameserv/do_dragon.cpp [new file with mode: 0644]
gameserv/do_equip.cpp
gameserv/do_fight.cpp
gameserv/do_heal.cpp
gameserv/do_identify.cpp
gameserv/do_inventory.cpp
gameserv/do_list.cpp
gameserv/do_logout.cpp [new file with mode: 0644]
gameserv/do_master.cpp [new file with mode: 0644]
gameserv/do_refresh.cpp
gameserv/do_register.cpp
gameserv/do_reset.cpp [new file with mode: 0644]
gameserv/do_run.cpp [new file with mode: 0644]
gameserv/do_set.cpp [new file with mode: 0644]
gameserv/do_stats.cpp [new file with mode: 0644]
gameserv/do_store.cpp [new file with mode: 0644]
gameserv/do_tavern.cpp [new file with mode: 0644]
gameserv/do_use.cpp [new file with mode: 0644]
gameserv/gameserv.cpp
gameserv/loadsave.cpp
gameserv/messages.cpp
gameserv/misc.cpp

index 2baf48efab3302b983fee57d82c37418352ae409..766f3cf951f27c8df696f1e614dfd1a9d6fb7e9c 100644 (file)
@@ -12,6 +12,8 @@ do_attack.o: do_attack.cpp aClient.h options.h player.h script.h extern.h \
 do_bank.o: do_bank.cpp extern.h config.h options.h aClient.h player.h \
   script.h flags.h
 do_check.o: do_check.cpp extern.h config.h options.h flags.h
+do_dragon.o: do_dragon.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h item.h level.h
 do_equip.o: do_equip.cpp extern.h config.h options.h aClient.h player.h \
   script.h pouch.h item.h level.h flags.h
 do_fight.o: do_fight.cpp extern.h config.h options.h aClient.h player.h \
@@ -25,10 +27,28 @@ do_inventory.o: do_inventory.cpp extern.h config.h options.h aClient.h \
   player.h script.h flags.h
 do_list.o: do_list.cpp extern.h config.h options.h player.h script.h \
   aClient.h flags.h toplist.h
+do_logout.o: do_logout.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h
+do_master.o: do_master.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h level.h
 do_refresh.o: do_refresh.cpp extern.h config.h options.h aClient.h \
   player.h script.h flags.h
 do_register.o: do_register.cpp extern.h config.h options.h aClient.h \
   player.h script.h flags.h pouch.h item.h level.h toplist.h
+do_reset.o: do_reset.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h
+do_run.o: do_run.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h
+do_set.o: do_set.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h
+do_stats.o: do_stats.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h
+do_store.o: do_store.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h item.h level.h pouch.h
+do_tavern.o: do_tavern.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h item.h level.h pouch.h
+do_use.o: do_use.cpp extern.h config.h options.h aClient.h player.h \
+  script.h flags.h item.h level.h pouch.h
 find.o: find.cpp extern.h config.h options.h item.h level.h player.h \
   script.h
 gameserv.o: gameserv.cpp aClient.h options.h player.h script.h config.h \
@@ -41,7 +61,7 @@ level.o: level.cpp item.h level.h player.h script.h extern.h config.h \
 loadsave.o: loadsave.cpp extern.h config.h options.h level.h player.h \
   script.h aClient.h item.h pouch.h toplist.h flags.h
 log.o: log.cpp extern.h config.h options.h
-messages.o: messages.cpp aClient.h options.h player.h script.h item.h \
+messages.o: messages.cpp options.h aClient.h player.h script.h item.h \
   level.h pouch.h extern.h config.h sockhelp.h flags.h
 misc.o: misc.cpp extern.h config.h options.h flags.h aClient.h player.h \
   script.h pouch.h item.h level.h
index adf6fe85ec81154aedf8b46339f49d979ad304e2..605b14185ec1aab604493b4152c33cc817a8e689 100644 (file)
@@ -29,6 +29,7 @@ TSRCS =       aClient.cpp \
        do_attack.cpp \
        do_bank.cpp \
        do_check.cpp \
+       do_dragon.cpp \
        do_equip.cpp \
        do_fight.cpp \
        do_heal.cpp \
@@ -36,8 +37,17 @@ TSRCS =      aClient.cpp \
        do_identify.cpp \
        do_inventory.cpp \
        do_list.cpp \
+       do_logout.cpp \
+       do_master.cpp \
        do_refresh.cpp \
        do_register.cpp \
+       do_reset.cpp \
+       do_run.cpp \
+       do_set.cpp \
+       do_stats.cpp \
+       do_store.cpp \
+       do_tavern.cpp \
+       do_use.cpp \
        find.cpp \
        gameserv.cpp \
        hash.cpp \
index 48dc5634eadd66fbc553df2ab3c4280d15eec61b..5e1a9459fdbd0bfdbe251687c07ec14e5059ce6d 100755 (executable)
@@ -1,6 +1,7 @@
 #include "extern.h"
 #include "aClient.h"
 #include "flags.h"
+#include "options.h"
 
 void do_admin(char *u)
 {
index 023bd3800c986fba081a86483fc9362e8585689b..e123d276bbcffa7f8c3b87ef54b186c27d9087fa 100644 (file)
@@ -1,5 +1,6 @@
 #include "aClient.h"
 #include "extern.h"
+#include "options.h"
 #include "flags.h"
 #include "level.h"
 #include "player.h"
index d48def6ad851cc1df559314e13ed3f1c4c8b5d43..5ffae700c06b809d103051fda39c1759b31ee8f7 100644 (file)
@@ -2,6 +2,7 @@
 #include "aClient.h"
 #include "player.h"
 #include "flags.h"
+#include "options.h"
 
 
 void do_bank(char *u)
diff --git a/gameserv/do_dragon.cpp b/gameserv/do_dragon.cpp
new file mode 100644 (file)
index 0000000..f325cb5
--- /dev/null
@@ -0,0 +1,73 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "item.h"
+
+Monster dragon;                                // The current dragon
+
+void do_dragon(char *u)
+{
+  aClient *user;
+  
+  if (!(user = find(u)))
+    {
+         notice(s_GameServ, u, "Fatal error. Contact a(n) <S admin. buf: %s", strtok(NULL, ""));
+         return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+         log("Ignoring %s.", user->getNick());
+#endif
+         return;
+    }
+  else if (!is_playing(user))
+    {
+         notice(s_GameServ, u, "You must be playing to fight the dragon!");
+         return;
+    }
+  else if (is_fighting(user))
+    {
+         notice(s_GameServ, u, "You are already in a fight. How will you fight the almighty dragon!?");
+         return;
+    }
+  else if (!isAlive(user->stats))
+    {
+         notice(s_GameServ, u, "You're dead. Wait until tomorrow to see your master!");
+         return;
+    }
+  else if (user->stats->getLevel() < LEVELS)
+    {
+         notice(s_GameServ, u, "You fool! Only those strong enough "\
+                        "to vanquish any foe should DARE fight the dragon!");
+         notice(s_GameServ, u, "To put it in terms you can understand: "\
+                        "You are too weak. You must be Level %d!", REALLEVELS);
+         return;
+    }
+  
+  updateTS(user->stats);
+  
+  Player *p = user->stats;
+  setMaster(p);
+  notice(s_GameServ, u, "You approach the dragon's lair cautiously.");
+  notice(s_GameServ, u, "The stench of sulfer fills the air as a "\
+                "deep, red fog rolls in. The air is filled with the "\
+                "heated mist of deadly fire from beyond the cave "\
+                "entrance.");
+  notice(s_GameServ, u, "You adjust your %s, tighten your grip on "\
+                "your %s, and venture into the hot, dark cave. "\
+                "You are surprised at the angle of descent as you climb "\
+                "lower and lower, deeper into the dragon's den.", 
+                (p->getArmor() ? p->getArmor()->getName().c_str() : "Fists"), (p->getWeapon() ? p->getWeapon()->getName().c_str() : "Birthday Suit"));
+  notice(s_GameServ, u, "You come to the end of the cave to find "\
+                "a tooth. It is a large tooth... bigger than your torso."\
+                " Suddenly the darkness lifts from the gleam of an eye "\
+                " staring into your soul! The eye is large... HUGE!");
+  notice(s_GameServ, u, "Just then you notice the eye begin to "\
+                "glare orange! The tooth is moving... but it is still too "\
+                "dark for you to make out.... THE DRAGON! You see it!");
+  p->setMonster(&dragon);
+  setDragonFight(p);
+  display_monster(u);
+}
index 9e0aaeddbddfdd70fd00fa4417706a2e547aef1f..df20d27dc952b18e9d2012a3a00f4345f0353e2e 100644 (file)
@@ -1,5 +1,5 @@
 #include "extern.h"
-#include "config.h"
+#include "options.h"
 #include "aClient.h"
 #include "pouch.h"
 #include "item.h"
index 34bf7cdb51375054dc202c709155d88441b4256c..d8cce35e9ba72e52be78e413457cec431c5acaa2 100644 (file)
@@ -1,7 +1,7 @@
 #include "extern.h"
 #include "aClient.h"
 #include "player.h"
-#include "config.h"
+#include "options.h"
 #include "flags.h"
 
 void do_fight(char *u)
index dac5cb25b470f43ea46048b708aaed605388a27c..f01a312db6b4fb2aaaa5780afd1de8631d5372c3 100644 (file)
@@ -1,6 +1,6 @@
 #include "extern.h"
 #include "aClient.h"
-#include "config.h"
+#include "options.h"
 #include "flags.h"
 
 void do_heal(char *u)
index 246662341350441c115836685cd631c05c26d559..796dbf3fbabc318cce5b5bee95fd700520d9cbb9 100644 (file)
@@ -1,5 +1,5 @@
 #include "extern.h"
-#include "config.h"
+#include "options.h"
 #include "aClient.h"
 #include "player.h"
 #include "flags.h"
index b88406900c20123f67ebac0b73b2e4892e3716a3..3feecdf10cd019c23ed1e3326f73021122df0456 100644 (file)
@@ -1,5 +1,5 @@
 #include "extern.h"
-#include "config.h"
+#include "options.h"
 #include "aClient.h"
 #include "flags.h"
 
index 935ce833be4dfe8f3471ba1199b643b280aa0d80..5168c07b4b155476b780811015601ba4705a7938 100644 (file)
@@ -1,5 +1,5 @@
 #include "extern.h"
-#include "config.h"
+#include "options.h"
 #include "player.h"
 #include "aClient.h"
 #include "flags.h"
diff --git a/gameserv/do_logout.cpp b/gameserv/do_logout.cpp
new file mode 100644 (file)
index 0000000..47d10d7
--- /dev/null
@@ -0,0 +1,63 @@
+#include "extern.h"
+#include "config.h"
+#include "aClient.h"
+#include "flags.h"
+#include "player.h"
+#include "options.h"
+
+
+void do_logout(char *u)
+{
+  aClient *user;
+  Player *p;
+  char *name = strtok(NULL, " ");
+  
+  if (!(user = find(u)))
+    {
+         notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
+                        "Buf: %s LOGOUT", u);
+         log("Could not find aClient Buf: %s LOGOUT", 
+                 u);
+         return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+         log("Ignoring %s.", user->getNick());
+#endif
+         return;
+    }
+  
+  if (name)
+    {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "You must be a <S admin to use this command!");
+               }
+         else if (!(p = findplayer(name)))
+               {
+                 notice(s_GameServ, u, "Couldn't find a player named %s", name);
+               }
+         else
+               {
+                 notice(s_GameServ, u, "Logging out %s", p->getName().c_str());
+                 logout(p->getClient());
+               }
+    }
+  else if (!name)
+    {
+         if (!is_playing(user))
+               {
+                 notice(s_GameServ, u, "You're not logged in!");
+               }
+         else if (is_fighting(user))
+               {
+                 notice(s_GameServ, u, "You can't logout while fighting!");
+               }
+         else
+               {
+                 notice(s_GameServ, u, "You have left the fields. You have lived to kill another day!");
+                 logout(user);
+               }
+    }
+}
diff --git a/gameserv/do_master.cpp b/gameserv/do_master.cpp
new file mode 100644 (file)
index 0000000..de04d1e
--- /dev/null
@@ -0,0 +1,133 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "level.h"
+
+void do_master(char *u)
+{
+  aClient *user;
+  
+  
+  if (!(user = find(u)))
+    {
+         notice(s_GameServ, u, "Fatal error. Contact a(n) <S admin. buf: %s", strtok(NULL, ""));
+         return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+         log("Ignoring %s.", user->getNick());
+#endif
+         return;
+    }
+  else if (!is_playing(user))
+    {
+         notice(s_GameServ, u, "You must be playing to see your master!");
+         return;
+    }
+  else if (is_fighting(user))
+    {
+         notice(s_GameServ, u, "You're in the middle of a fight! Pay attention!");
+         return;
+    }
+  else if (!isAlive(user->stats))
+    {
+         notice(s_GameServ, u, "You're dead. Wait until tomorrow to see your master!");
+         return;
+    }
+  
+  updateTS(user->stats);
+  
+  char *cmd = strtok(NULL, " ");
+  Player *p = user->stats;
+  long int need = 0;
+  
+  if (seenMaster(p))
+    {
+         notice(s_GameServ, u, "You have already seen your master today. Wait until tomorrow to try again");
+         return;
+    }
+  
+  if (cmd != NULL)
+    {
+         switch(p->getLevel())
+               {
+           case 1:
+                 need = 200;
+                 break;
+           case 2:
+                 need = 800;
+                 break;
+           case 3:
+                 need = 2000;
+                 break;
+           case 4:
+                 need = 8000;
+                 break;
+           case 5:
+                 need = 20000;
+                 break;
+           case 6:
+                 need = 80000;
+                 break;
+           case 7:
+                 need = 200000;
+                 break;
+           case 8:
+                 need = 800000;
+                 break;
+           case 9:
+                 need = 2000000;
+                 break;
+           case 10:
+                 need = 8000000;
+                 break;
+           case 11:
+                 need = 20000000;
+                 break;
+                 
+           case REALLEVELS:
+                 need = p->getExp() + 1;
+                 notice(s_GameServ, u, "You are at level %d. You are the master. What's left? The DRAGON!", REALLEVELS);
+                 return;
+                 break;
+           default:
+                 need = p->getExp() + 1; // Unknown level... don't let them fight a fake master!
+                 break;
+               }   
+    }
+  else
+    {
+         notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
+         return;
+    }
+  
+  if (stricmp(cmd, "FIGHT") == 0)
+    {
+         if (p->getExp() >= need)
+               {
+                 setMaster(p);
+                 see_master(u);
+               }
+         else
+           notice(s_GameServ, u, "You are not worthy of fighting %s! You need %ld more experience.", 
+                          levels[p->getLevel() - 1].master.name.c_str(), (need - p->getExp()));
+         return;
+    }
+  else if (stricmp(cmd, "QUESTION") == 0)
+    {
+         if (p->getExp() >= need)
+           notice(s_GameServ, u, "%s looks you up and down and decides you are more ready than you will ever be.", 
+                          levels[p->getLevel() - 1].master.name.c_str());
+         else
+           notice(s_GameServ, u, "You pathetic fool! You are no match for %s, %s!", 
+                          levels[p->getLevel() - 1].master.name.c_str(), p->getName().c_str());
+         
+         return;
+    }
+  else
+    {
+         notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
+    }
+}
index dc54b41164d7c190b121bb2bbadc5ccdcfb91f98..479705e6f09ef1fce608113399ff1f072db3e792 100644 (file)
@@ -1,5 +1,5 @@
 #include "extern.h"
-#include "config.h"
+#include "options.h"
 #include "aClient.h"
 #include "player.h"
 #include "flags.h"
index f79db5f597fdc8838b20a9384646a8c3b160d877..c205e83bb5ff5fa69680ca41772383587f4f2e25 100644 (file)
@@ -1,5 +1,5 @@
 #include "extern.h"
-#include "config.h"
+#include "options.h"
 #include "aClient.h"
 #include "player.h"
 #include "flags.h"
diff --git a/gameserv/do_reset.cpp b/gameserv/do_reset.cpp
new file mode 100644 (file)
index 0000000..f122af6
--- /dev/null
@@ -0,0 +1,43 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "player.h"
+
+void do_reset(char *u)
+{
+  char *nick = strtok(NULL, " ");
+  aClient *user;
+  Player *p;
+  
+  if (!(user = find(u)))
+    {
+         notice(s_GameServ, u, "Error: aClient not found. Contact a <S admin");
+         log("Error: aClient not found: %s", u);
+         return;
+    }
+  else if (!isAdmin(user))
+    {
+         notice(s_GameServ, u, "You must be a <S admin to use this command!");
+         return;
+    }
+  
+  if (!nick)
+    {
+         notice(s_GameServ, u, "SYNTAX: RESET {ALL | NICK}");
+    }
+  else if (stricmp(nick, "ALL") == 0)
+    {
+         notice(s_GameServ, u, "Resetting everyone's stats!");
+         resetall();
+    }
+  else if (!(p = findplayer(nick)))
+       {
+         notice(s_GameServ, u, "Nick %s not found.", nick);
+       }
+  else
+    {
+         notice(s_GameServ, u, "Resetting %s.", p->getName().c_str());
+         reset(p);
+       }
+}
diff --git a/gameserv/do_run.cpp b/gameserv/do_run.cpp
new file mode 100644 (file)
index 0000000..e162bdc
--- /dev/null
@@ -0,0 +1,63 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "player.h"
+
+void do_run(char *u)
+{
+  aClient *user;
+  Player *p, *p2 = NULL;
+  
+  if (!(user = find(u)))
+    {
+         notice(s_GameServ, u, "Couldn't find you. Error. Contact a <S admin");
+         return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+         log("Ignoring %s.", user->getNick());
+#endif
+         return;
+    }
+  else if (!is_playing(user))
+    {
+         notice(s_GameServ, u, "You must be playing to run!");
+         return;
+    }
+  
+  updateTS(user->stats);
+  p = user->stats;
+  
+  if (p->getBattle())
+       p2 = p->getBattle()->stats;
+  
+  if (!is_fighting(user))
+       notice(s_GameServ, u, "You run in place... try fighting next time.");
+  else if (!player_fight(user) && !master_fight(user) && !dragon_fight(user))
+    {
+         notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p->getMonster()->name.c_str());
+         p->delMonster();
+    }
+  else if (player_fight(user) && isYourTurn(p))
+    {
+         notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p2->getName().c_str());
+         notice(s_GameServ, p->getBattle()->getNick(), "\ 2%s\ 2 ran away from you like a little baby!", p->getName().c_str());
+         addNews(todaysnews, "%s ran away from %s like a little baby!!", p->getName().c_str(), p2->getName().c_str()); /* DrLnet - edited by Kain */
+         p2->delBattle();
+         p->delBattle();
+       }
+  else if (player_fight(user) && !isYourTurn(p))
+    {
+         notice(s_GameServ, u, "It is not your turn. Please wait until \ 2%s\ 2 decides what to do.", p2->getName().c_str());
+    }
+  else if (master_fight(user))
+    {
+         notice(s_GameServ, u, "You cannot run from \ 2%s\ 2! FIGHT!", p->getMaster()->name.c_str());
+    }
+  else if (dragon_fight(user))
+       {
+         notice(s_GameServ, u, "You cannot run from %s! FIGHT!", dragon.name.c_str());
+       }
+}
diff --git a/gameserv/do_set.cpp b/gameserv/do_set.cpp
new file mode 100644 (file)
index 0000000..00dbb6a
--- /dev/null
@@ -0,0 +1,357 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "player.h"
+
+void do_set(char *u)
+{
+  aClient *user;
+  Player *p;
+  char *name = strtok(NULL, " ");
+  char *cmd = strtok(NULL, " ");
+  char *cmd2;
+  
+  if (!(user = find(u)))
+    {
+      notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
+                        "Buf: %s LOGOUT", u);
+      return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+      log("Ignoring %s.", user->getNick());
+#endif
+      return;
+    }
+  else if (!name || !cmd)
+    {
+      notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+      return;
+    }
+  else if (!(p = findplayer(name)))
+    {
+      // Back the pointers up... they didn't send a name probably
+      cmd2 = cmd;
+      cmd = name;
+      p = user->stats;
+         
+      if (!is_playing(user))
+               {
+                 notice(s_GameServ, u, "You must be playing to set things for yourself!");
+                 return;
+               }
+    }
+  else
+    {
+      cmd2 = strtok(NULL, " ");
+    }
+  if (!cmd2)
+       {
+         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+         return;
+       }
+  
+  // Regardless of the previous if/else, if it got here, we know we have the cmd pointer at the right spot.
+  if (stricmp(cmd, "PASSWORD") == 0)
+    {
+      // Person is looking to change their password
+      // If they're an admin, or it's theirself, allow it
+      // cmd2 is pointing to the password now
+      if (isAdmin(user) || user == p->getClient())
+               {
+                 p->setPassword(cmd2);
+                 notice(s_GameServ, u, "Password successfully changed");
+               }
+      else if (user != p->getClient() && !isAdmin(user))
+               {
+                 notice(s_GameServ, u, "You must be a <S admin to set other peoples' passwords.");
+                 return;
+               }
+    }
+  else if (stricmp(cmd, "BANK") == 0 || stricmp(cmd, "BALANCE") == 0)
+    {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;
+               }
+         else if (stricmp(cmd, "BANK") == 0)
+               {
+                 cmd2 = strtok(NULL, " "); // Need an extra parameter for set bank balance
+               }
+         if (!cmd2)
+               {
+                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] [BANK] BALANCE <NUMBER>");
+                 return;
+               }
+         
+         p->setBank(stringtoint(cmd2));
+         
+         notice(s_GameServ, u, "Bank balance changed to %ld!", p->getBank());
+    }
+  else if (stricmp(cmd, "PLAYER") == 0)
+    {
+      if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;
+               }
+      else if (stricmp(cmd2, "FIGHTS") != 0)
+               {
+                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] PLAYER FIGHTS <NUMBER>");
+                 return;
+               }
+      else
+               {
+                 cmd2 = strtok(NULL, " ");
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] PLAYER FIGHTS <NUMBER>");
+                         return;
+                       }
+                 p->setPlayerFights(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "Player fights changed to %d!", p->getPlayerFights());
+               }         
+    }
+  else if (stricmp(cmd, "FOREST") == 0)
+    {
+      if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;
+               }
+      else if (stricmp(cmd2, "FIGHTS") != 0)
+               {
+                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] FOREST FIGHTS <number>");
+                 return;
+               }
+      else
+               {
+                 cmd2 = strtok(NULL, " ");
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] FOREST FIGHTS <NUMBER>");
+                         return;
+                       }
+                 
+                 p->setForestFights(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "Forest fights changed to %d!", p->getForestFights());
+               }         
+    }
+  else if (stricmp(cmd, "GOLD") == 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] GOLD <NUMBER>");
+                         return;
+                       }
+                 p->setGold(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "Gold set to %ld", p->getGold());
+                 return;
+               }
+       }
+  else if (stricmp(cmd, "STRENGTH") == 0 && stricmp(cmd2, "POTIONS") != 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;         
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] STRENGTH <NUMBER>");
+                         return;
+                       }
+                 
+                 p->setStrength(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "Strength set to %d", p->getStrength());
+                 return;
+               }
+       }
+  else if (stricmp(cmd, "DEFENSE") == 0 && stricmp(cmd2, "POTIONS") != 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;         
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] DEFENSE <NUMBER>");
+                         return;
+                       }
+                 
+                 p->setDefense(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "Defense set to %d", p->getDefense());
+                 return;
+               }
+       }
+  else if (stricmp(cmd, "HP") == 0 && stricmp(cmd2, "POTIONS") != 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;         
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] HP <NUMBER>");
+                         return;
+                       }
+
+                 // Make sure it's easy for an admin to set the hp
+                 if (p->getMaxHP() < stringtoint(cmd2))
+                       p->setMaxHP(stringtoint(cmd2));
+                 
+                 p->setHP(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "HP set to %d", p->getHP());
+                 return;
+               }
+       }
+  else if (stricmp(cmd, "MAXHP") == 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;         
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] MAXHP <NUMBER>");
+                         return;
+                       }
+                 p->setMaxHP(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "MaxHP set to %d", p->getMaxHP());
+                 return;
+               }
+       }
+  else if (stricmp(cmd, "EXPERIENCE") == 0 || stricmp(cmd, "EXP") == 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;         
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {EXPERIENCE|EXP} <NUMBER>");
+                         return;
+                       }
+                 
+                 p->setExp(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "Exp set to %ld", p->getExp());
+                 return;
+               }
+       }
+  else if (stricmp(cmd, "LEVEL") == 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;         
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] LEVEL <NUMBER>");
+                         return;
+                       }
+                 p->setLevel(stringtoint(cmd2));
+                 
+                 notice(s_GameServ, u, "Level set to %d", p->getLevel());
+                 return;
+               }
+       }
+  else if (stricmp(cmd, "ALIVE") == 0)
+       {
+         if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;
+               }
+         else
+               {
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] ALIVE TRUE|FALSE");
+                         return;
+                       }
+                 else if (stricmp(cmd2, "TRUE") == 0)
+                       {
+                         notice(s_GameServ, u, "%s has been Resurrected!", p->getName().c_str());
+                         setAlive(p);
+                       }
+                 else
+                       {
+                         notice(s_GameServ, u, "%s is now dead!", p->getName().c_str());
+                         clearAlive(p);
+                       }
+               }
+       }
+  else if (stricmp(cmd, "SEEN") == 0)
+    {
+      if (!isAdmin(user))
+               {
+                 notice(s_GameServ, u, "Admins Only!");
+                 return;
+               }
+      else if (stricmp(cmd2, "MASTER") != 0)
+               {
+                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] SEEN MASTER {TRUE|FALSE}");
+                 return;
+               }
+      else
+               {
+                 cmd2 = strtok(NULL, " ");
+                 if (!cmd2)
+                       {
+                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NICK] SEEN MASTER {TRUE|FALSE}");
+                         return;
+                       }
+                 else if (stricmp(cmd2, "TRUE") == 0)
+                       {
+                         notice(s_GameServ, u, "%s has seen their master now.", p->getName().c_str());
+                         p->addFlag(FLAG_MASTER);
+                       }
+                 else
+                       {
+                         notice(s_GameServ, u, "%s has not seen their master now.", p->getName().c_str());
+                         p->remFlag(FLAG_MASTER);
+                       }
+               }         
+    }
+  else
+       {
+         notice(s_GameServ, u, "Unknown command: SET %s", cmd);
+         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+         return;
+       }
+}
diff --git a/gameserv/do_stats.cpp b/gameserv/do_stats.cpp
new file mode 100644 (file)
index 0000000..628537d
--- /dev/null
@@ -0,0 +1,41 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+
+void do_stats(char *u)
+{
+  char *nick;
+  aClient *user;
+  
+  nick = strtok(NULL, " ");
+  
+  if (!(user = find(u)))
+    {
+         log("Fatal Error: %s not found in client list", u);
+         return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+         log("Ignoring %s.", user->getNick());
+#endif
+         return;
+    }
+  else if (!nick)
+    {
+         if (!is_playing(user))
+               {
+                 notice(s_GameServ, u, "You're not playing, so you have no stats!");
+                 return;
+               }
+         else
+               {
+                 if (!is_fighting(user))
+                       updateTS(user->stats);
+                 showstats(u, user->stats->getName().c_str());
+               }
+    }
+  else
+       showstats(u, nick);
+}
diff --git a/gameserv/do_store.cpp b/gameserv/do_store.cpp
new file mode 100644 (file)
index 0000000..8a7eeda
--- /dev/null
@@ -0,0 +1,183 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "player.h"
+#include "item.h"
+#include "pouch.h"
+
+void do_store(char *u)
+{
+  list<item*>::iterator item_iterator;
+  item *tempItem;
+  char *cmd = strtok(NULL, " ");
+  char *num = strtok(NULL, " ");
+  char *space;
+  int id;
+  aClient *user;
+  Player *p;
+  
+  
+  if (!cmd || !num)
+    {
+      notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
+      notice(s_GameServ, u, "        \ 2STORE SELL NUMBER\ 2");
+      notice(s_GameServ, u, "        \ 2STORE BUY \1fNUMBER\1f\ 2");
+      return;
+    }
+  else if (!(user = find(u)))
+    {
+      log("Fatal Error: could not find %s in client list", u);
+      return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+      log("Ignoring %s.", user->getNick());
+#endif
+      return;
+    }
+  else if (!is_playing(user))
+    {
+      notice(s_GameServ, u, "You must be playing to use the store!");
+      return;
+    }
+  else if (is_fighting(user))
+    {
+      notice(s_GameServ, u, "You can't go to the store while fighting!");
+      return;
+    }
+  else if (!isAlive(user->stats))
+    {
+      notice(s_GameServ, u, "You are dead. Wait until tomorrow to purchase weapons and armor!");
+      return;
+    }
+  updateTS(user->stats);
+  
+  if (stricmp(cmd, "LIST") == 0)
+    {
+      if (stricmp(num, "WEAPONS") == 0)
+               {
+                 notice(s_GameServ, u, "Welcome to Kain's Armory");
+                 notice(s_GameServ, u, "Here are the weapons we have available for the killing, sire:");
+                 for (item_iterator = store.begin(); item_iterator != store.end(); ++item_iterator)
+            {
+                         if ((*item_iterator)->getType() == WEAPON)
+                               {
+                                 space = spaces(strlen((*item_iterator)->getName().c_str()), ".");
+                                 notice(s_GameServ, u, "%s%ld. %20s..........%ld", 
+              ((*item_iterator)->getID() < 10 ? " " : ""), 
+              (*item_iterator)->getID(), (*item_iterator)->getName().c_str(), (*item_iterator)->price());
+                               }
+                       }
+                 notice(s_GameServ, u, "To purchase a weapon, type /msg <S STORE BUY \ 2#\ 2.");
+                 notice(s_GameServ, u, "Where # is the weapon number from the menu above.");
+                 
+               }
+      else if (stricmp(num, "ARMOR") == 0)
+               {
+                 notice(s_GameServ, u, "Welcome to Kain's Armory");
+                 notice(s_GameServ, u, "I hope you enjoy the fine armor we have available for your protection:");
+                 for (item_iterator = store.begin(); item_iterator != store.end(); ++item_iterator)
+            {
+                         if ((*item_iterator)->getType() == ARMOR)
+                               {
+                                 notice(s_GameServ, u, "%s%ld. %20s..........%d",
+              ((*item_iterator)->getID() < 10 ? " " : ""), 
+               (*item_iterator)->getID(), (*item_iterator)->getName().c_str(), 
+               (*item_iterator)->price());
+                               }
+            }
+                 
+                 notice(s_GameServ, u, "To purchase armor, type /msg <S store buy #");
+                 notice(s_GameServ, u, "Where # is the armor number from the menu above.");
+               }
+      
+    } 
+  else if (stricmp(cmd, "BUY") == 0) 
+    {
+      p = user->stats;
+      if (!num)
+               {
+                 notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
+                 return;
+               }
+      else
+               {
+                 id = stringtoint(num);
+               }
+         
+      if (!isstringnum(num))
+               {
+                 notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
+                 return;
+               }
+      else if (!(tempItem = findStoreItemByID(id)))
+               {
+                 notice(s_GameServ, u, "Sorry, we don't carry that item!");
+                 return;
+               }
+      else if (p->getGold() < tempItem->price())
+               {
+                 notice(s_GameServ, u, "You can't afford to buy %s", tempItem->getName().c_str());
+                 return;
+               }
+      else if (p->inventory->addItem(tempItem))
+               {
+                 notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", tempItem->getName().c_str());
+                 p->subtractGold(tempItem->price());
+                 notice(s_GameServ, u, "Don't forget to type /msg <S equip %ld", tempItem->getID());
+               }
+         else
+               {
+                 notice(s_GameServ, u, "You can't carry any more!");
+               }
+    }
+  else if (stricmp(cmd, "SELL" ) == 0)
+    {
+      itemContainer *tempContainer;
+      p = user->stats;
+      id = stringtoint(num);
+      if (!isstringnum(num))
+               {
+                 notice(s_GameServ, u, "SYNTAX: /msg <S store sell #");
+                 return;
+               }
+      else if (!(tempContainer = p->inventory->Find(id)))
+               {
+                 notice(s_GameServ, u, "You're not carrying that!");
+                 return;
+               }
+      else if (p->getGold() >= 2000000000)
+               {
+                 notice(s_GameServ, u, "You have enough gold. Just hang on to it for now.");
+               }
+      else 
+               {
+                 tempItem = tempContainer->getItem();
+                 
+                 notice(s_GameServ, u, "Thank you for your business! We gave you %ld gold for %s!", (tempItem->price() / 2), tempItem->getName().c_str());
+                 p->addGold((tempItem->price() / 2));
+                 p->inventory->deleteItem(tempItem);
+                 if (tempItem == p->getWeapon())
+                       {
+                         notice(s_GameServ, u, "Since you equipped %s, you're going to have to reequip something", tempItem->getName().c_str());
+                         tempItem->undo(p);
+                         p->clearWeapon();
+                       }
+                 else if (tempItem == p->getArmor())
+                       {
+                         tempItem->undo(p);
+                         notice(s_GameServ, u, "Since you equipped %s, you're going to have to reequip something", tempItem->getName().c_str());
+                         p->clearArmor();
+                       }
+               }
+    }
+  else
+    {
+      notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
+      notice(s_GameServ, u, "        \ 2STORE SELL #\ 2");
+      notice(s_GameServ, u, "        \ 2STORE BUY \1f#\1f\ 2");
+      return;
+    }
+}
diff --git a/gameserv/do_tavern.cpp b/gameserv/do_tavern.cpp
new file mode 100644 (file)
index 0000000..9bc7a77
--- /dev/null
@@ -0,0 +1,136 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "player.h"
+#include "item.h"
+#include "pouch.h"
+
+void do_tavern(char *u)
+{
+  char *cmd = strtok(NULL, " ");
+
+  aClient *user;
+  Player *p;
+  
+  if (!(user = find(u)))
+    {
+      notice(s_GameServ, u, "Fatal Error. See a <S admin for help");
+      return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+      log("Ignoring %s.", user->getNick());
+#endif
+      return;
+    }
+  else if (!is_playing(user))
+    {
+      notice(s_GameServ, u, "You must be playing to go to the Tavern");
+      return;
+    }
+  else if (is_fighting(user))
+    {
+      notice(s_GameServ, u, "You cannot go to the Tavern during a fight!");
+      return;
+    }
+  
+  updateTS(user->stats);
+  p = user->stats;
+  
+  if (!cmd)
+    {
+      notice(s_GameServ, u, "Welcome to Boot Liquors Mystic Apothecary and General Store");
+      notice(s_GameServ, u, "Your commands:");
+      notice(s_GameServ, u, "/msg <S TAVERN {LIST | BUY} [NUMBER]");
+      notice(s_GameServ, u, "What'll it be?");
+    }
+  else if (stricmp(cmd, "LIST") == 0)
+    {
+      notice(s_GameServ, u, "Here is a list of what we have to offer:");
+      showTavern(user);
+      notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY #");
+    }
+  else if (stricmp(cmd, "BUY") == 0)
+    {
+         int amt = 1;
+      char *chid = strtok(NULL, " ");
+         char *amount = strtok(NULL, " ");
+
+         if (amount)
+               amt = stringtoint(amount);
+      
+      if (!chid)
+               {
+                 notice(s_GameServ, u, "SYNTAX: TAVERN BUY # [#]");
+                 notice(s_GameServ, u, "Example: /msg <S TAVERN BUY 6001");
+                 notice(s_GameServ, u, "Example: /msg <S TAVERN BUY 6001 10");
+                 return;
+               }
+      long id = stringtoint(chid);
+      tavernItem *tempItem;
+      
+      if (!(tempItem = findTavernItemByID(id)) || user->stats->getLevel() < tempItem->getLevel())
+               {
+                 notice(s_GameServ, u, "Invalid Choice!");
+                 notice(s_GameServ, u, "Here is a list of what we have to offer:");
+                 showTavern(user);
+                 notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY #");
+                 return;
+               }
+      else if (!amount && user->stats->getGold() < tempItem->getItem()->price())
+               {
+                 notice(s_GameServ, u, "You don't have enough gold!");
+                 notice(s_GameServ, u, "Here is a list of what we have to offer:");
+                 showTavern(user);
+                 notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY #");
+               }
+         else if (user->stats->getGold() < amt * tempItem->getItem()->price())
+               {
+                 notice(s_GameServ, u, "You don't have enough gold!");
+                 notice(s_GameServ, u, "Here is a list of what we have to offer:");
+                 showTavern(user);
+                 notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY # [#]");
+               }
+         else
+               {
+                 if (amount)
+                       {
+                         int amt = stringtoint(amount);
+                         if (amt < 0 || amount[0] == '-')
+                               {
+                                 notice(s_GameServ, u, "You trying to steal from me?");
+                               }
+                         else if (user->stats->inventory->addItem(tempItem->getItem(), amt) == NULL)
+                               {
+                                 notice(s_GameServ, u, "You can't carry that many!");
+                               }
+                         else
+                               {
+                                 notice(s_GameServ, u, "%d %s's coming right up!", amt, tempItem->getItem()->getName().c_str());
+                                 user->stats->subtractGold(tempItem->getItem()->price() * amt);
+                               }
+                       }
+                 else
+                       {
+                         if (user->stats->inventory->addItem(tempItem->getItem()) == NULL)
+                               {
+                                 notice(s_GameServ, u, "You can't carry any more!");
+                               }
+                         else
+                               {
+                                 notice(s_GameServ, u, "One %s coming right up!", tempItem->getItem()->getName().c_str());
+                                 user->stats->subtractGold(tempItem->getItem()->price());
+                               }
+                       }
+               }
+    }
+  else
+    {
+      notice(s_GameServ, u, "Improper Syntax.");
+      notice(s_GameServ, u, "Type /msg <S HELP TAVERN for help");
+    }
+  return;
+}
+
diff --git a/gameserv/do_use.cpp b/gameserv/do_use.cpp
new file mode 100644 (file)
index 0000000..962b4e9
--- /dev/null
@@ -0,0 +1,104 @@
+#include "extern.h"
+#include "aClient.h"
+#include "flags.h"
+#include "options.h"
+#include "item.h"
+#include "pouch.h"
+
+void do_use(char *u)
+{
+  aClient *user;
+  pouch *p;
+  
+  char *item = strtok(NULL, " ");
+  char *numuse = strtok(NULL, " ");
+  int id, num;
+  itemContainer *used;
+  
+  if (!item || int(item[0]) < 48 || int(item[0]) > 57 || (numuse && (int(numuse[0]) < 48 || int(numuse[0]) > 57)))
+    {
+         notice(s_GameServ, u, "SYNTAX: USE ####");
+         notice(s_GameServ, u, "Type /msg <S HELP USE for more information.");
+         return;
+    }
+  else if (!(user = find(u)))
+    {
+         notice(s_GameServ, u, "Fatal Error in do_use. Contact a(n) <S Admin");
+         return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+         log("Ignoring %s.", user->getNick());
+#endif
+         return;
+    }
+  else if (!is_playing(user))
+    {
+         notice(s_GameServ, u, "You must be playing to use items!");
+         return;
+    }
+  id = stringtoint(item);
+  
+  if (!numuse)
+       {
+         num = 1;
+       }
+  else
+       {
+         num = stringtoint(numuse);
+       }
+  
+  updateTS(user->stats);
+  p = user->stats->inventory;
+  
+
+  if (!(used = p->Find(id)))
+       {
+         if (!p->isEmpty())
+               {
+                 notice(s_GameServ, u, "You aren't carrying that item!");
+               }
+         showinventory(user->stats, user);
+       }
+  else if (used->getItem()->getType() != POTION)
+       {
+         notice(s_GameServ, u, "You can't use %s like that. Try /msg <S equip", used->getItem()->getName().c_str());
+       }
+  else
+       {
+         // Use the item(s)
+         if (num <= 1 || is_fighting(user))
+               {
+                 notice(s_GameServ, u, "You used %s.", used->getItem()->getName().c_str());
+                 used->use(user->stats);
+                 if (used->getUses() <= 0)
+                       {
+                         p->deleteItem(used->getItem());
+                       }
+                 end_turn(user);
+               }
+         else if (num > 1)
+               {
+                 int count;
+                 const char *name = used->getItem()->getName().c_str();
+                 for (count = 0; count < num; count++)
+                       {
+                         if (!(used = p->Find(id)))
+                               {
+                                 break;
+                               }
+                         else
+                               {
+                                 used->use(user->stats);
+                                 if (used->getUses() == 0)
+                                       {
+                                         p->deleteItem(used->getItem());
+                                       }
+                               }
+                       }
+                 notice(s_GameServ, u, "You used %d %s's", count, name);
+               }
+       }
+}
+
index d4f555597a6444b8145844a70dff3fff98c18355..d71c7b3d5d6613706dd426b79f3532080563fa61 100644 (file)
@@ -29,7 +29,7 @@ using namespace std;
 
 #endif
 
-Monster dragon;                                // The current dragon
+
 Level levels[LEVELS];                  // The newest way to store monsters
 list<item*> Items;                      // The master list of items
 list<tavernItem> tavern;                // The list of items available at the tavern
@@ -41,19 +41,6 @@ toplist myToplist;          // List of the top 10 players
 
 bool shuttingdown;
 
-void do_logout(char *u);
-void do_master(char *u);
-void do_dragon(char *u);
-void do_play(char *u);
-void do_quitg(char *u);
-void do_reset(char *u);
-void do_run(char *u);
-void do_set(char *u);
-void do_stats(char *u);
-void do_store(char *u);
-void do_tavern(char *u);
-void do_use(char *u);
-
 #define WNA 16
 
 int hpbonus[11] = {10, 15, 20, 30, 50, 75, 125, 185, 250, 350, 550};
@@ -329,1150 +316,3 @@ void gameserv(char *source, char *buf)
        cmd--;     // Same thing :)
 }
 
-
-
-
-void do_set(char *u)
-{
-  aClient *user;
-  Player *p;
-  char *name = strtok(NULL, " ");
-  char *cmd = strtok(NULL, " ");
-  char *cmd2;
-  
-  if (!(user = find(u)))
-    {
-      notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
-                        "Buf: %s LOGOUT", u);
-      return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-      log("Ignoring %s.", user->getNick());
-#endif
-      return;
-    }
-  else if (!name || !cmd)
-    {
-      notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
-      return;
-    }
-  else if (!(p = findplayer(name)))
-    {
-      // Back the pointers up... they didn't send a name probably
-      cmd2 = cmd;
-      cmd = name;
-      p = user->stats;
-         
-      if (!is_playing(user))
-               {
-                 notice(s_GameServ, u, "You must be playing to set things for yourself!");
-                 return;
-               }
-    }
-  else
-    {
-      cmd2 = strtok(NULL, " ");
-    }
-  if (!cmd2)
-       {
-         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
-         return;
-       }
-  
-  // Regardless of the previous if/else, if it got here, we know we have the cmd pointer at the right spot.
-  if (stricmp(cmd, "PASSWORD") == 0)
-    {
-      // Person is looking to change their password
-      // If they're an admin, or it's theirself, allow it
-      // cmd2 is pointing to the password now
-      if (isAdmin(user) || user == p->getClient())
-               {
-                 p->setPassword(cmd2);
-                 notice(s_GameServ, u, "Password successfully changed");
-               }
-      else if (user != p->getClient() && !isAdmin(user))
-               {
-                 notice(s_GameServ, u, "You must be a <S admin to set other peoples' passwords.");
-                 return;
-               }
-    }
-  else if (stricmp(cmd, "BANK") == 0 || stricmp(cmd, "BALANCE") == 0)
-    {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;
-               }
-         else if (stricmp(cmd, "BANK") == 0)
-               {
-                 cmd2 = strtok(NULL, " "); // Need an extra parameter for set bank balance
-               }
-         if (!cmd2)
-               {
-                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] [BANK] BALANCE <NUMBER>");
-                 return;
-               }
-         
-         p->setBank(stringtoint(cmd2));
-         
-         notice(s_GameServ, u, "Bank balance changed to %ld!", p->getBank());
-    }
-  else if (stricmp(cmd, "PLAYER") == 0)
-    {
-      if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;
-               }
-      else if (stricmp(cmd2, "FIGHTS") != 0)
-               {
-                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] PLAYER FIGHTS <NUMBER>");
-                 return;
-               }
-      else
-               {
-                 cmd2 = strtok(NULL, " ");
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] PLAYER FIGHTS <NUMBER>");
-                         return;
-                       }
-                 p->setPlayerFights(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "Player fights changed to %d!", p->getPlayerFights());
-               }         
-    }
-  else if (stricmp(cmd, "FOREST") == 0)
-    {
-      if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;
-               }
-      else if (stricmp(cmd2, "FIGHTS") != 0)
-               {
-                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] FOREST FIGHTS <number>");
-                 return;
-               }
-      else
-               {
-                 cmd2 = strtok(NULL, " ");
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] FOREST FIGHTS <NUMBER>");
-                         return;
-                       }
-                 
-                 p->setForestFights(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "Forest fights changed to %d!", p->getForestFights());
-               }         
-    }
-  else if (stricmp(cmd, "GOLD") == 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] GOLD <NUMBER>");
-                         return;
-                       }
-                 p->setGold(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "Gold set to %ld", p->getGold());
-                 return;
-               }
-       }
-  else if (stricmp(cmd, "STRENGTH") == 0 && stricmp(cmd2, "POTIONS") != 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;         
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] STRENGTH <NUMBER>");
-                         return;
-                       }
-                 
-                 p->setStrength(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "Strength set to %d", p->getStrength());
-                 return;
-               }
-       }
-  else if (stricmp(cmd, "DEFENSE") == 0 && stricmp(cmd2, "POTIONS") != 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;         
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] DEFENSE <NUMBER>");
-                         return;
-                       }
-                 
-                 p->setDefense(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "Defense set to %d", p->getDefense());
-                 return;
-               }
-       }
-  else if (stricmp(cmd, "HP") == 0 && stricmp(cmd2, "POTIONS") != 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;         
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] HP <NUMBER>");
-                         return;
-                       }
-
-                 // Make sure it's easy for an admin to set the hp
-                 if (p->getMaxHP() < stringtoint(cmd2))
-                       p->setMaxHP(stringtoint(cmd2));
-                 
-                 p->setHP(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "HP set to %d", p->getHP());
-                 return;
-               }
-       }
-  else if (stricmp(cmd, "MAXHP") == 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;         
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] MAXHP <NUMBER>");
-                         return;
-                       }
-                 p->setMaxHP(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "MaxHP set to %d", p->getMaxHP());
-                 return;
-               }
-       }
-  else if (stricmp(cmd, "EXPERIENCE") == 0 || stricmp(cmd, "EXP") == 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;         
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {EXPERIENCE|EXP} <NUMBER>");
-                         return;
-                       }
-                 
-                 p->setExp(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "Exp set to %ld", p->getExp());
-                 return;
-               }
-       }
-  else if (stricmp(cmd, "LEVEL") == 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;         
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] LEVEL <NUMBER>");
-                         return;
-                       }
-                 p->setLevel(stringtoint(cmd2));
-                 
-                 notice(s_GameServ, u, "Level set to %d", p->getLevel());
-                 return;
-               }
-       }
-  else if (stricmp(cmd, "ALIVE") == 0)
-       {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;
-               }
-         else
-               {
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] ALIVE TRUE|FALSE");
-                         return;
-                       }
-                 else if (stricmp(cmd2, "TRUE") == 0)
-                       {
-                         notice(s_GameServ, u, "%s has been Resurrected!", p->getName().c_str());
-                         setAlive(p);
-                       }
-                 else
-                       {
-                         notice(s_GameServ, u, "%s is now dead!", p->getName().c_str());
-                         clearAlive(p);
-                       }
-               }
-       }
-  else if (stricmp(cmd, "SEEN") == 0)
-    {
-      if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "Admins Only!");
-                 return;
-               }
-      else if (stricmp(cmd2, "MASTER") != 0)
-               {
-                 notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] SEEN MASTER {TRUE|FALSE}");
-                 return;
-               }
-      else
-               {
-                 cmd2 = strtok(NULL, " ");
-                 if (!cmd2)
-                       {
-                         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NICK] SEEN MASTER {TRUE|FALSE}");
-                         return;
-                       }
-                 else if (stricmp(cmd2, "TRUE") == 0)
-                       {
-                         notice(s_GameServ, u, "%s has seen their master now.", p->getName().c_str());
-                         p->addFlag(FLAG_MASTER);
-                       }
-                 else
-                       {
-                         notice(s_GameServ, u, "%s has not seen their master now.", p->getName().c_str());
-                         p->remFlag(FLAG_MASTER);
-                       }
-               }         
-    }
-  else
-       {
-         notice(s_GameServ, u, "Unknown command: SET %s", cmd);
-         notice(s_GameServ, u, "SYNTAX: /msg <S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
-         return;
-       }
-}
-
-void do_logout(char *u)
-{
-  aClient *user;
-  Player *p;
-  char *name = strtok(NULL, " ");
-  
-  if (!(user = find(u)))
-    {
-         notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
-                        "Buf: %s LOGOUT", u);
-         log("Could not find aClient Buf: %s LOGOUT", 
-                 u);
-         return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-         log("Ignoring %s.", user->getNick());
-#endif
-         return;
-    }
-  
-  if (name)
-    {
-         if (!isAdmin(user))
-               {
-                 notice(s_GameServ, u, "You must be a <S admin to use this command!");
-               }
-         else if (!(p = findplayer(name)))
-               {
-                 notice(s_GameServ, u, "Couldn't find a player named %s", name);
-               }
-         else
-               {
-                 notice(s_GameServ, u, "Logging out %s", p->getName().c_str());
-                 logout(p->getClient());
-               }
-    }
-  else if (!name)
-    {
-         if (!is_playing(user))
-               {
-                 notice(s_GameServ, u, "You're not logged in!");
-               }
-         else if (is_fighting(user))
-               {
-                 notice(s_GameServ, u, "You can't logout while fighting!");
-               }
-         else
-               {
-                 notice(s_GameServ, u, "You have left the fields. You have lived to kill another day!");
-                 logout(user);
-               }
-    }
-}
-
-void do_stats(char *u)
-{
-  char *nick;
-  aClient *user;
-  
-  nick = strtok(NULL, " ");
-  
-  if (!(user = find(u)))
-    {
-         log("Fatal Error: %s not found in client list", u);
-         return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-         log("Ignoring %s.", user->getNick());
-#endif
-         return;
-    }
-  else if (!nick)
-    {
-         if (!is_playing(user))
-               {
-                 notice(s_GameServ, u, "You're not playing, so you have no stats!");
-                 return;
-               }
-         else
-               {
-                 if (!is_fighting(user))
-                       updateTS(user->stats);
-                 showstats(u, user->stats->getName().c_str());
-               }
-    }
-  else
-       showstats(u, nick);
-}
-
-void do_use(char *u)
-{
-  aClient *user;
-  pouch *p;
-  
-  char *item = strtok(NULL, " ");
-  char *numuse = strtok(NULL, " ");
-  int id, num;
-  itemContainer *used;
-  
-  if (!item || int(item[0]) < 48 || int(item[0]) > 57 || (numuse && (int(numuse[0]) < 48 || int(numuse[0]) > 57)))
-    {
-         notice(s_GameServ, u, "SYNTAX: USE ####");
-         notice(s_GameServ, u, "Type /msg <S HELP USE for more information.");
-         return;
-    }
-  else if (!(user = find(u)))
-    {
-         notice(s_GameServ, u, "Fatal Error in do_use. Contact a(n) <S Admin");
-         return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-         log("Ignoring %s.", user->getNick());
-#endif
-         return;
-    }
-  else if (!is_playing(user))
-    {
-         notice(s_GameServ, u, "You must be playing to use items!");
-         return;
-    }
-  id = stringtoint(item);
-  
-  if (!numuse)
-       {
-         num = 1;
-       }
-  else
-       {
-         num = stringtoint(numuse);
-       }
-  
-  updateTS(user->stats);
-  p = user->stats->inventory;
-  
-
-  if (!(used = p->Find(id)))
-       {
-         if (!p->isEmpty())
-               {
-                 notice(s_GameServ, u, "You aren't carrying that item!");
-               }
-         showinventory(user->stats, user);
-       }
-  else if (used->getItem()->getType() != POTION)
-       {
-         notice(s_GameServ, u, "You can't use %s like that. Try /msg <S equip", used->getItem()->getName().c_str());
-       }
-  else
-       {
-         // Use the item(s)
-         if (num <= 1 || is_fighting(user))
-               {
-                 notice(s_GameServ, u, "You used %s.", used->getItem()->getName().c_str());
-                 used->use(user->stats);
-                 if (used->getUses() <= 0)
-                       {
-                         p->deleteItem(used->getItem());
-                       }
-                 end_turn(user);
-               }
-         else if (num > 1)
-               {
-                 int count;
-                 const char *name = used->getItem()->getName().c_str();
-                 for (count = 0; count < num; count++)
-                       {
-                         if (!(used = p->Find(id)))
-                               {
-                                 break;
-                               }
-                         else
-                               {
-                                 used->use(user->stats);
-                                 if (used->getUses() == 0)
-                                       {
-                                         p->deleteItem(used->getItem());
-                                       }
-                               }
-                       }
-                 notice(s_GameServ, u, "You used %d %s's", count, name);
-               }
-       }
-}
-void do_run(char *u)
-{
-  aClient *user;
-  Player *p, *p2 = NULL;
-  
-  if (!(user = find(u)))
-    {
-         notice(s_GameServ, u, "Couldn't find you. Error. Contact a <S admin");
-         return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-         log("Ignoring %s.", user->getNick());
-#endif
-         return;
-    }
-  else if (!is_playing(user))
-    {
-         notice(s_GameServ, u, "You must be playing to run!");
-         return;
-    }
-  
-  updateTS(user->stats);
-  p = user->stats;
-  
-  if (p->getBattle())
-       p2 = p->getBattle()->stats;
-  
-  if (!is_fighting(user))
-       notice(s_GameServ, u, "You run in place... try fighting next time.");
-  else if (!player_fight(user) && !master_fight(user) && !dragon_fight(user))
-    {
-         notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p->getMonster()->name.c_str());
-         p->delMonster();
-    }
-  else if (player_fight(user) && isYourTurn(p))
-    {
-         notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p2->getName().c_str());
-         notice(s_GameServ, p->getBattle()->getNick(), "\ 2%s\ 2 ran away from you like a little baby!", p->getName().c_str());
-         addNews(todaysnews, "%s ran away from %s like a little baby!!", p->getName().c_str(), p2->getName().c_str()); /* DrLnet - edited by Kain */
-         p2->delBattle();
-         p->delBattle();
-       }
-  else if (player_fight(user) && !isYourTurn(p))
-    {
-         notice(s_GameServ, u, "It is not your turn. Please wait until \ 2%s\ 2 decides what to do.", p2->getName().c_str());
-    }
-  else if (master_fight(user))
-    {
-         notice(s_GameServ, u, "You cannot run from \ 2%s\ 2! FIGHT!", p->getMaster()->name.c_str());
-    }
-  else if (dragon_fight(user))
-       {
-         notice(s_GameServ, u, "You cannot run from %s! FIGHT!", dragon.name.c_str());
-       }
-}
-
-void do_store(char *u)
-{
-  list<item*>::iterator item_iterator;
-  item *tempItem;
-  char *cmd = strtok(NULL, " ");
-  char *num = strtok(NULL, " ");
-  char *space;
-  int id;
-  aClient *user;
-  Player *p;
-  
-  
-  if (!cmd || !num)
-    {
-      notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
-      notice(s_GameServ, u, "        \ 2STORE SELL NUMBER\ 2");
-      notice(s_GameServ, u, "        \ 2STORE BUY \1fNUMBER\1f\ 2");
-      return;
-    }
-  else if (!(user = find(u)))
-    {
-      log("Fatal Error: could not find %s in client list", u);
-      return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-      log("Ignoring %s.", user->getNick());
-#endif
-      return;
-    }
-  else if (!is_playing(user))
-    {
-      notice(s_GameServ, u, "You must be playing to use the store!");
-      return;
-    }
-  else if (is_fighting(user))
-    {
-      notice(s_GameServ, u, "You can't go to the store while fighting!");
-      return;
-    }
-  else if (!isAlive(user->stats))
-    {
-      notice(s_GameServ, u, "You are dead. Wait until tomorrow to purchase weapons and armor!");
-      return;
-    }
-  updateTS(user->stats);
-  
-  if (stricmp(cmd, "LIST") == 0)
-    {
-      if (stricmp(num, "WEAPONS") == 0)
-               {
-                 notice(s_GameServ, u, "Welcome to Kain's Armory");
-                 notice(s_GameServ, u, "Here are the weapons we have available for the killing, sire:");
-                 for (item_iterator = store.begin(); item_iterator != store.end(); ++item_iterator)
-            {
-                         if ((*item_iterator)->getType() == WEAPON)
-                               {
-                                 space = spaces(strlen((*item_iterator)->getName().c_str()), ".");
-                                 notice(s_GameServ, u, "%s%ld. %20s..........%ld", 
-              ((*item_iterator)->getID() < 10 ? " " : ""), 
-              (*item_iterator)->getID(), (*item_iterator)->getName().c_str(), (*item_iterator)->price());
-                               }
-                       }
-                 notice(s_GameServ, u, "To purchase a weapon, type /msg <S STORE BUY \ 2#\ 2.");
-                 notice(s_GameServ, u, "Where # is the weapon number from the menu above.");
-                 
-               }
-      else if (stricmp(num, "ARMOR") == 0)
-               {
-                 notice(s_GameServ, u, "Welcome to Kain's Armory");
-                 notice(s_GameServ, u, "I hope you enjoy the fine armor we have available for your protection:");
-                 for (item_iterator = store.begin(); item_iterator != store.end(); ++item_iterator)
-            {
-                         if ((*item_iterator)->getType() == ARMOR)
-                               {
-                                 notice(s_GameServ, u, "%s%ld. %20s..........%d",
-              ((*item_iterator)->getID() < 10 ? " " : ""), 
-               (*item_iterator)->getID(), (*item_iterator)->getName().c_str(), 
-               (*item_iterator)->price());
-                               }
-            }
-                 
-                 notice(s_GameServ, u, "To purchase armor, type /msg <S store buy #");
-                 notice(s_GameServ, u, "Where # is the armor number from the menu above.");
-               }
-      
-    } 
-  else if (stricmp(cmd, "BUY") == 0) 
-    {
-      p = user->stats;
-      if (!num)
-               {
-                 notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
-                 return;
-               }
-      else
-               {
-                 id = stringtoint(num);
-               }
-         
-      if (!isstringnum(num))
-               {
-                 notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY \1f#\1f\ 2");
-                 return;
-               }
-      else if (!(tempItem = findStoreItemByID(id)))
-               {
-                 notice(s_GameServ, u, "Sorry, we don't carry that item!");
-                 return;
-               }
-      else if (p->getGold() < tempItem->price())
-               {
-                 notice(s_GameServ, u, "You can't afford to buy %s", tempItem->getName().c_str());
-                 return;
-               }
-      else if (p->inventory->addItem(tempItem))
-               {
-                 notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", tempItem->getName().c_str());
-                 p->subtractGold(tempItem->price());
-                 notice(s_GameServ, u, "Don't forget to type /msg <S equip %ld", tempItem->getID());
-               }
-         else
-               {
-                 notice(s_GameServ, u, "You can't carry any more!");
-               }
-    }
-  else if (stricmp(cmd, "SELL" ) == 0)
-    {
-      itemContainer *tempContainer;
-      p = user->stats;
-      id = stringtoint(num);
-      if (!isstringnum(num))
-               {
-                 notice(s_GameServ, u, "SYNTAX: /msg <S store sell #");
-                 return;
-               }
-      else if (!(tempContainer = p->inventory->Find(id)))
-               {
-                 notice(s_GameServ, u, "You're not carrying that!");
-                 return;
-               }
-      else if (p->getGold() >= 2000000000)
-               {
-                 notice(s_GameServ, u, "You have enough gold. Just hang on to it for now.");
-               }
-      else 
-               {
-                 tempItem = tempContainer->getItem();
-                 
-                 notice(s_GameServ, u, "Thank you for your business! We gave you %ld gold for %s!", (tempItem->price() / 2), tempItem->getName().c_str());
-                 p->addGold((tempItem->price() / 2));
-                 p->inventory->deleteItem(tempItem);
-                 if (tempItem == p->getWeapon())
-                       {
-                         notice(s_GameServ, u, "Since you equipped %s, you're going to have to reequip something", tempItem->getName().c_str());
-                         tempItem->undo(p);
-                         p->clearWeapon();
-                       }
-                 else if (tempItem == p->getArmor())
-                       {
-                         tempItem->undo(p);
-                         notice(s_GameServ, u, "Since you equipped %s, you're going to have to reequip something", tempItem->getName().c_str());
-                         p->clearArmor();
-                       }
-               }
-    }
-  else
-    {
-      notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
-      notice(s_GameServ, u, "        \ 2STORE SELL #\ 2");
-      notice(s_GameServ, u, "        \ 2STORE BUY \1f#\1f\ 2");
-      return;
-    }
-}
-
-
-void do_tavern(char *u)
-{
-  char *cmd = strtok(NULL, " ");
-
-  aClient *user;
-  Player *p;
-  
-  if (!(user = find(u)))
-    {
-      notice(s_GameServ, u, "Fatal Error. See a <S admin for help");
-      return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-      log("Ignoring %s.", user->getNick());
-#endif
-      return;
-    }
-  else if (!is_playing(user))
-    {
-      notice(s_GameServ, u, "You must be playing to go to the Tavern");
-      return;
-    }
-  else if (is_fighting(user))
-    {
-      notice(s_GameServ, u, "You cannot go to the Tavern during a fight!");
-      return;
-    }
-  
-  updateTS(user->stats);
-  p = user->stats;
-  
-  if (!cmd)
-    {
-      notice(s_GameServ, u, "Welcome to Boot Liquors Mystic Apothecary and General Store");
-      notice(s_GameServ, u, "Your commands:");
-      notice(s_GameServ, u, "/msg <S TAVERN {LIST | BUY} [NUMBER]");
-      notice(s_GameServ, u, "What'll it be?");
-    }
-  else if (stricmp(cmd, "LIST") == 0)
-    {
-      notice(s_GameServ, u, "Here is a list of what we have to offer:");
-      showTavern(user);
-      notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY #");
-    }
-  else if (stricmp(cmd, "BUY") == 0)
-    {
-         int amt = 1;
-      char *chid = strtok(NULL, " ");
-         char *amount = strtok(NULL, " ");
-
-         if (amount)
-               amt = stringtoint(amount);
-      
-      if (!chid)
-               {
-                 notice(s_GameServ, u, "SYNTAX: TAVERN BUY # [#]");
-                 notice(s_GameServ, u, "Example: /msg <S TAVERN BUY 6001");
-                 notice(s_GameServ, u, "Example: /msg <S TAVERN BUY 6001 10");
-                 return;
-               }
-      long id = stringtoint(chid);
-      tavernItem *tempItem;
-      
-      if (!(tempItem = findTavernItemByID(id)) || user->stats->getLevel() < tempItem->getLevel())
-               {
-                 notice(s_GameServ, u, "Invalid Choice!");
-                 notice(s_GameServ, u, "Here is a list of what we have to offer:");
-                 showTavern(user);
-                 notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY #");
-                 return;
-               }
-      else if (!amount && user->stats->getGold() < tempItem->getItem()->price())
-               {
-                 notice(s_GameServ, u, "You don't have enough gold!");
-                 notice(s_GameServ, u, "Here is a list of what we have to offer:");
-                 showTavern(user);
-                 notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY #");
-               }
-         else if (user->stats->getGold() < amt * tempItem->getItem()->price())
-               {
-                 notice(s_GameServ, u, "You don't have enough gold!");
-                 notice(s_GameServ, u, "Here is a list of what we have to offer:");
-                 showTavern(user);
-                 notice(s_GameServ, u, "To buy an item, type /msg <S TAVERN BUY # [#]");
-               }
-         else
-               {
-                 if (amount)
-                       {
-                         int amt = stringtoint(amount);
-                         if (amt < 0 || amount[0] == '-')
-                               {
-                                 notice(s_GameServ, u, "You trying to steal from me?");
-                               }
-                         else if (user->stats->inventory->addItem(tempItem->getItem(), amt) == NULL)
-                               {
-                                 notice(s_GameServ, u, "You can't carry that many!");
-                               }
-                         else
-                               {
-                                 notice(s_GameServ, u, "%d %s's coming right up!", amt, tempItem->getItem()->getName().c_str());
-                                 user->stats->subtractGold(tempItem->getItem()->price() * amt);
-                               }
-                       }
-                 else
-                       {
-                         if (user->stats->inventory->addItem(tempItem->getItem()) == NULL)
-                               {
-                                 notice(s_GameServ, u, "You can't carry any more!");
-                               }
-                         else
-                               {
-                                 notice(s_GameServ, u, "One %s coming right up!", tempItem->getItem()->getName().c_str());
-                                 user->stats->subtractGold(tempItem->getItem()->price());
-                               }
-                       }
-               }
-    }
-  else
-    {
-      notice(s_GameServ, u, "Improper Syntax.");
-      notice(s_GameServ, u, "Type /msg <S HELP TAVERN for help");
-    }
-  return;
-}
-
-
-
-void do_dragon(char *u)
-{
-  aClient *user;
-  
-  if (!(user = find(u)))
-    {
-         notice(s_GameServ, u, "Fatal error. Contact a(n) <S admin. buf: %s", strtok(NULL, ""));
-         return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-         log("Ignoring %s.", user->getNick());
-#endif
-         return;
-    }
-  else if (!is_playing(user))
-    {
-         notice(s_GameServ, u, "You must be playing to fight the dragon!");
-         return;
-    }
-  else if (is_fighting(user))
-    {
-         notice(s_GameServ, u, "You are already in a fight. How will you fight the almighty dragon!?");
-         return;
-    }
-  else if (!isAlive(user->stats))
-    {
-         notice(s_GameServ, u, "You're dead. Wait until tomorrow to see your master!");
-         return;
-    }
-  else if (user->stats->getLevel() < LEVELS)
-    {
-         notice(s_GameServ, u, "You fool! Only those strong enough "\
-                        "to vanquish any foe should DARE fight the dragon!");
-         notice(s_GameServ, u, "To put it in terms you can understand: "\
-                        "You are too weak. You must be Level %d!", REALLEVELS);
-         return;
-    }
-  
-  updateTS(user->stats);
-  
-  Player *p = user->stats;
-  setMaster(p);
-  notice(s_GameServ, u, "You approach the dragon's lair cautiously.");
-  notice(s_GameServ, u, "The stench of sulfer fills the air as a "\
-                "deep, red fog rolls in. The air is filled with the "\
-                "heated mist of deadly fire from beyond the cave "\
-                "entrance.");
-  notice(s_GameServ, u, "You adjust your %s, tighten your grip on "\
-                "your %s, and venture into the hot, dark cave. "\
-                "You are surprised at the angle of descent as you climb "\
-                "lower and lower, deeper into the dragon's den.", 
-                (p->getArmor() ? p->getArmor()->getName().c_str() : "Fists"), (p->getWeapon() ? p->getWeapon()->getName().c_str() : "Birthday Suit"));
-  notice(s_GameServ, u, "You come to the end of the cave to find "\
-                "a tooth. It is a large tooth... bigger than your torso."\
-                " Suddenly the darkness lifts from the gleam of an eye "\
-                " staring into your soul! The eye is large... HUGE!");
-  notice(s_GameServ, u, "Just then you notice the eye begin to "\
-                "glare orange! The tooth is moving... but it is still too "\
-                "dark for you to make out.... THE DRAGON! You see it!");
-  p->setMonster(&dragon);
-  setDragonFight(p);
-  display_monster(u);
-}
-
-void do_master(char *u)
-{
-  aClient *user;
-  
-  
-  if (!(user = find(u)))
-    {
-         notice(s_GameServ, u, "Fatal error. Contact a(n) <S admin. buf: %s", strtok(NULL, ""));
-         return;
-    }
-  else if (isIgnore(user))
-    {
-#ifdef DEBUGMODE
-         log("Ignoring %s.", user->getNick());
-#endif
-         return;
-    }
-  else if (!is_playing(user))
-    {
-         notice(s_GameServ, u, "You must be playing to see your master!");
-         return;
-    }
-  else if (is_fighting(user))
-    {
-         notice(s_GameServ, u, "You're in the middle of a fight! Pay attention!");
-         return;
-    }
-  else if (!isAlive(user->stats))
-    {
-         notice(s_GameServ, u, "You're dead. Wait until tomorrow to see your master!");
-         return;
-    }
-  
-  updateTS(user->stats);
-  
-  char *cmd = strtok(NULL, " ");
-  Player *p = user->stats;
-  long int need = 0;
-  
-  if (seenMaster(p))
-    {
-         notice(s_GameServ, u, "You have already seen your master today. Wait until tomorrow to try again");
-         return;
-    }
-  
-  if (cmd != NULL)
-    {
-         switch(p->getLevel())
-               {
-           case 1:
-                 need = 200;
-                 break;
-           case 2:
-                 need = 800;
-                 break;
-           case 3:
-                 need = 2000;
-                 break;
-           case 4:
-                 need = 8000;
-                 break;
-           case 5:
-                 need = 20000;
-                 break;
-           case 6:
-                 need = 80000;
-                 break;
-           case 7:
-                 need = 200000;
-                 break;
-           case 8:
-                 need = 800000;
-                 break;
-           case 9:
-                 need = 2000000;
-                 break;
-           case 10:
-                 need = 8000000;
-                 break;
-           case 11:
-                 need = 20000000;
-                 break;
-                 
-           case REALLEVELS:
-                 need = p->getExp() + 1;
-                 notice(s_GameServ, u, "You are at level %d. You are the master. What's left? The DRAGON!", REALLEVELS);
-                 return;
-                 break;
-           default:
-                 need = p->getExp() + 1; // Unknown level... don't let them fight a fake master!
-                 break;
-               }   
-    }
-  else
-    {
-         notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
-         return;
-    }
-  
-  if (stricmp(cmd, "FIGHT") == 0)
-    {
-         if (p->getExp() >= need)
-               {
-                 setMaster(p);
-                 see_master(u);
-               }
-         else
-           notice(s_GameServ, u, "You are not worthy of fighting %s! You need %ld more experience.", 
-                          levels[p->getLevel() - 1].master.name.c_str(), (need - p->getExp()));
-         return;
-    }
-  else if (stricmp(cmd, "QUESTION") == 0)
-    {
-         if (p->getExp() >= need)
-           notice(s_GameServ, u, "%s looks you up and down and decides you are more ready than you will ever be.", 
-                          levels[p->getLevel() - 1].master.name.c_str());
-         else
-           notice(s_GameServ, u, "You pathetic fool! You are no match for %s, %s!", 
-                          levels[p->getLevel() - 1].master.name.c_str(), p->getName().c_str());
-         
-         return;
-    }
-  else
-    {
-         notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
-    }
-}
-
-
-
-void do_reset(char *u)
-{
-  char *nick = strtok(NULL, " ");
-  aClient *user;
-  Player *p;
-  
-  if (!(user = find(u)))
-    {
-         notice(s_GameServ, u, "Error: aClient not found. Contact a <S admin");
-         log("Error: aClient not found: %s", u);
-         return;
-    }
-  else if (!isAdmin(user))
-    {
-         notice(s_GameServ, u, "You must be a <S admin to use this command!");
-         return;
-    }
-  
-  if (!nick)
-    {
-         notice(s_GameServ, u, "SYNTAX: RESET {ALL | NICK}");
-    }
-  else if (stricmp(nick, "ALL") == 0)
-    {
-         notice(s_GameServ, u, "Resetting everyone's stats!");
-         resetall();
-    }
-  else if (!(p = findplayer(nick)))
-       {
-         notice(s_GameServ, u, "Nick %s not found.", nick);
-       }
-  else
-    {
-         notice(s_GameServ, u, "Resetting %s.", p->getName().c_str());
-         reset(p);
-       }
-}
-
-
-
-
-
index b3a506049601e29bd8ff7eb34edfcda681b0c458..0004d0a80f1fcb45885df218ae1f26d35d8416cb 100755 (executable)
@@ -10,6 +10,7 @@
  #include "pouch.h"
  #include "toplist.h"
  #include "flags.h"
+ #include "options.h"
  
  #include <fstream>
  
index 002ecfdf4c412a661079e1e40315e11c2abbb60d..e996471929d48f923339460f7f72757549be0276 100644 (file)
@@ -1,5 +1,6 @@
 /* This file contains only functions related to sending messages over the
     ircd socket */
+#include "options.h"
 #include "aClient.h"
 #include "player.h"
 #include "item.h"
index 9197d512ba885204e41369abc6fb748c484550c2..f18a40e8cd7eb462858de6fec26d3e35c3bf9b7a 100644 (file)
@@ -4,6 +4,7 @@
 #include "aClient.h"
 #include "pouch.h"
 #include "item.h"
+#include "options.h"
 
 void see_master(char *u)
 {