]>
jfr.im git - irc/gameservirc.git/blob - gameserv/boolean.cpp
6 bool is_playing(char *u
); // True if the given nickname in the clients list is playing.
7 bool is_playing(aClient
*user
);
9 bool is_fighting(char *u
); // True if the given nick in the clients list is fighting anything.
10 bool is_fighting(aClient
*user
);
12 bool player_fight(char *u
); // True if the player is fighting another player.
13 bool player_fight(aClient
*user
);
15 bool master_fight(char *u
); // True if the player is fighting their master.
16 bool master_fight(aClient
*user
);
18 bool dragon_fight(char *u
); // True if the player is fighting the dragon.
19 bool dragon_fight(aClient
*user
);
21 bool alphaNumeric(const char *str
); // Returns true if all of the characters in str are alphanumeric non-special chars
22 /********** GameServ Booleans **********/
25 bool is_playing(char *u
)
28 if (!(user
= find(u
)))
31 return is_playing(user
);
34 bool is_playing(aClient
*user
)
40 else if (!user
->stats
)
44 else if (!FL_is_playing(user
))
48 else if (user
->stats
->getClient() != user
)
56 bool is_fighting(char *u
)
60 if (!(user
= find(u
)))
63 return is_fighting(user
);
66 bool is_fighting(aClient
*user
)
68 if (!is_playing(user
))
71 return player_fight(user
) || master_fight(user
) ||
72 user
->stats
->getMonster() != NULL
;
75 bool player_fight(char *u
)
79 if (!(user
= find(u
)))
82 return player_fight(user
);
85 bool player_fight(aClient
*user
)
87 if (!is_playing(user
))
89 else if (is_playing(user
->stats
->getBattle()))
97 bool master_fight(char *u
)
101 if (!(user
= find(u
)))
104 return master_fight(user
);
107 bool master_fight(aClient
*user
)
109 if (!is_playing(user
))
112 return user
->stats
->getMaster() != NULL
;
115 bool dragon_fight(char *u
)
118 if (!(user
= find(u
)))
121 return dragon_fight(user
);
124 bool dragon_fight(aClient
*user
)
126 if (!is_playing(user
))
129 return (isDragonFight(user
->stats
));
132 bool alphaNumeric(const char *str
)
134 int len
= strlen(str
);
135 for (int x
= 0; x
< len
; x
++)
137 if (!((int(str
[x
]) >= 65 && int(str
[x
]) <= 90) || (int(str
[x
]) >= 97 && int(str
[x
]) <= 122) || (int(str
[x
]) >= 48 && int(str
[x
]) <= 57) || int(str
[x
]) == 95))
143 bool passcmp(const char *encrypted
, char *plaintext
)
146 char *plaintext2
, *plainToencrypt
;
149 plaintext2
= new char[strlen(encrypted
) + strlen(plaintext
)]; // Extra
150 strcpy(plaintext2
, plaintext
);
152 salt
[0] = encrypted
[0];
153 salt
[1] = encrypted
[1];
156 plainToencrypt
= crypt(plaintext2
, salt
);
158 same
= (strcmp((const char *)encrypted
, plainToencrypt
) == 0 ? true : false);
165 bool check_password(char *name
, char *plaintext
)
169 if (!(p
= findplayer(name
)))
173 return passcmp(p
->getPassword().c_str(), plaintext
);
177 bool timedOut(Player
*p
)
181 else if (p
->lastcommand
== 0)
185 if ((time(NULL
) - p
->lastcommand
) >= maxidletime
)