]> jfr.im git - irc/gameservirc.git/blob - gameserv/do_master.cpp
Removed GameServ.suo
[irc/gameservirc.git] / gameserv / do_master.cpp
1 #include "extern.h"
2 #include "aClient.h"
3 #include "flags.h"
4 #include "options.h"
5 #include "level.h"
6
7 void do_master(char *u)
8 {
9 aClient *user;
10
11
12 if (!(user = find(u)))
13 {
14 notice(s_GameServ, u, "Fatal error. Contact a(n) <S admin. buf: %s", strtok(NULL, ""));
15 return;
16 }
17 else if (isIgnore(user))
18 {
19 #ifdef DEBUGMODE
20 log("Ignoring %s.", user->getNick());
21 #endif
22 return;
23 }
24 else if (!is_playing(user))
25 {
26 notice(s_GameServ, u, "You must be playing to see your master!");
27 return;
28 }
29 else if (is_fighting(user))
30 {
31 notice(s_GameServ, u, "You're in the middle of a fight! Pay attention!");
32 return;
33 }
34 else if (!isAlive(user->stats))
35 {
36 notice(s_GameServ, u, "You're dead. Wait until tomorrow to see your master!");
37 return;
38 }
39
40 updateTS(user->stats);
41
42 char *cmd = strtok(NULL, " ");
43 Player *p = user->stats;
44 long int need = 0;
45
46 if (seenMaster(p))
47 {
48 notice(s_GameServ, u, "You have already seen your master today. Wait until tomorrow to try again");
49 return;
50 }
51
52 if (cmd != NULL)
53 {
54 switch(p->getLevel())
55 {
56 case 1:
57 need = 200;
58 break;
59 case 2:
60 need = 800;
61 break;
62 case 3:
63 need = 2000;
64 break;
65 case 4:
66 need = 8000;
67 break;
68 case 5:
69 need = 20000;
70 break;
71 case 6:
72 need = 80000;
73 break;
74 case 7:
75 need = 200000;
76 break;
77 case 8:
78 need = 800000;
79 break;
80 case 9:
81 need = 2000000;
82 break;
83 case 10:
84 need = 8000000;
85 break;
86 case 11:
87 need = 20000000;
88 break;
89
90 case REALLEVELS:
91 need = p->getExp() + 1;
92 notice(s_GameServ, u, "You are at level %d. You are the master. What's left? The DRAGON!", REALLEVELS);
93 return;
94 break;
95 default:
96 need = p->getExp() + 1; // Unknown level... don't let them fight a fake master!
97 break;
98 }
99 }
100 else
101 {
102 notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
103 return;
104 }
105
106 if (stricmp(cmd, "FIGHT") == 0)
107 {
108 if (p->getExp() >= need)
109 {
110 setMaster(p);
111 see_master(u);
112 }
113 else
114 notice(s_GameServ, u, "You are not worthy of fighting %s! You need %ld more experience.",
115 levels[p->getLevel() - 1].master.name.c_str(), (need - p->getExp()));
116 return;
117 }
118 else if (stricmp(cmd, "QUESTION") == 0)
119 {
120 if (p->getExp() >= need)
121 notice(s_GameServ, u, "%s looks you up and down and decides you are more ready than you will ever be.",
122 levels[p->getLevel() - 1].master.name.c_str());
123 else
124 notice(s_GameServ, u, "You pathetic fool! You are no match for %s, %s!",
125 levels[p->getLevel() - 1].master.name.c_str(), p->getName().c_str());
126
127 return;
128 }
129 else
130 {
131 notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
132 }
133 }