Refactored WMUD_CLIENT_STATE_NEWCHAR state
WMUD_CLIENT_STATE_NEWCHAR is now removed in favour of WMUD_CLIENT_STATE_YESNO Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
parent
4e479e0045
commit
e821a44c71
@ -211,7 +211,8 @@ wmud_client_callback(GSocket *client_socket, GIOCondition condition, wmudClient
|
||||
{
|
||||
client->player = g_new0(wmudPlayer, 1);
|
||||
client->player->player_name = g_strdup(client->buffer->str);
|
||||
client->state = WMUD_CLIENT_STATE_NEWCHAR;
|
||||
client->state = WMUD_CLIENT_STATE_YESNO;
|
||||
client->yesNoCallback = wmud_client_newchar_answer;
|
||||
wmud_client_send(client, "Is %s new to this game? [Y/N] ", client->buffer->str);
|
||||
}
|
||||
}
|
||||
@ -295,23 +296,6 @@ wmud_client_callback(GSocket *client_socket, GIOCondition condition, wmudClient
|
||||
wmud_client_send(client, "Please enter a 'Y' or 'N' character: ");
|
||||
}
|
||||
break;
|
||||
case WMUD_CLIENT_STATE_NEWCHAR:
|
||||
if (g_ascii_strcasecmp(client->buffer->str, "n") == 0)
|
||||
{
|
||||
wmud_client_send(client, "What is your player-name, then? ");
|
||||
client->state = WMUD_CLIENT_STATE_FRESH;
|
||||
}
|
||||
else if (g_ascii_strcasecmp(client->buffer->str, "y") == 0)
|
||||
{
|
||||
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Creating new player\n");
|
||||
wmud_client_send(client, "Welcome to this MUD!\r\nPlease enter your e-mail address: ");
|
||||
client->state = WMUD_CLIENT_STATE_REGISTERING;
|
||||
}
|
||||
else
|
||||
{
|
||||
wmud_client_send(client, "Sorry, but for this question I only understand 'Y' or 'N'.\r\nIs %s a new player here? [Y/N] ", client->player->player_name);
|
||||
}
|
||||
break;
|
||||
case WMUD_CLIENT_STATE_REGISTERING:
|
||||
if (!*(client->buffer->str))
|
||||
{
|
||||
@ -608,3 +592,20 @@ wmud_client_quitanswer(wmudClient *client, gboolean answer)
|
||||
client->state = WMUD_CLIENT_STATE_MENU;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wmud_client_newchar_answer(wmudClient *client, gboolean answer)
|
||||
{
|
||||
if (answer)
|
||||
{
|
||||
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Creating new player\n");
|
||||
wmud_client_send(client, "Welcome to this MUD!\r\nPlease enter your e-mail address: ");
|
||||
client->state = WMUD_CLIENT_STATE_REGISTERING;
|
||||
}
|
||||
else
|
||||
{
|
||||
wmud_client_send(client, "What is your player-name, then? ");
|
||||
client->state = WMUD_CLIENT_STATE_FRESH;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,5 +65,6 @@ extern GSList *clients;
|
||||
gboolean wmud_networking_init(guint port_number, GMainContext *game_context, GSList *menu_items, GError **err);
|
||||
void wmud_client_send(wmudClient *client, const gchar *fmt, ...);
|
||||
void wmud_client_quitanswer(wmudClient *client, gboolean answer);
|
||||
void wmud_client_newchar_answer(wmudClient *client, gboolean answer);
|
||||
|
||||
#endif
|
||||
|
@ -45,8 +45,6 @@
|
||||
* that are called before and after the client enters a new state, this
|
||||
* could be a three-state stuff, in which the player can enter e.g ? as
|
||||
* the answer, so they would be presented with the question again.
|
||||
* @WMUD_CLIENT_STATE_NEWCHAR: Player name entered on the login screen was
|
||||
* invalid. Waiting for answer if this is a new player
|
||||
* @WMUD_CLIENT_STATE_REGISTERING: Registering a new player. Waiting for the
|
||||
* e-mail address to be given
|
||||
* @WMUD_CLIENT_STATE_REGEMAIL_CONFIRM: E-mail address entered séms valid,
|
||||
@ -60,7 +58,6 @@ typedef enum {
|
||||
WMUD_CLIENT_STATE_MENU,
|
||||
WMUD_CLIENT_STATE_INGAME,
|
||||
WMUD_CLIENT_STATE_YESNO,
|
||||
WMUD_CLIENT_STATE_NEWCHAR,
|
||||
WMUD_CLIENT_STATE_REGISTERING,
|
||||
WMUD_CLIENT_STATE_REGEMAIL_CONFIRM
|
||||
} wmudClientState;
|
||||
|
Loading…
Reference in New Issue
Block a user