diff options
author | alexichi <alexbankai96@gmail.com> | 2016-05-11 11:56:19 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-05-11 11:56:19 +0200 |
commit | 35efaf74e828b738a20324a664cf9c2e08ef47d4 (patch) | |
tree | 183b4704c87c61b690010efbd6f3b30218328bcc /inc/messages.inc | |
parent | 2350d43a09495db18b22b86ffc815a84eeb35579 (diff) | |
parent | 1158d2063f00f38de19a4600566b244a942d86ba (diff) | |
download | candybox-35efaf74e828b738a20324a664cf9c2e08ef47d4.tar.gz candybox-35efaf74e828b738a20324a664cf9c2e08ef47d4.tar.bz2 candybox-35efaf74e828b738a20324a664cf9c2e08ef47d4.tar.xz candybox-35efaf74e828b738a20324a664cf9c2e08ef47d4.zip |
Merge branch 'master' of piernov.org:candybox into alexichialexichi
Conflicts:
inc/perso.inc
Diffstat (limited to 'inc/messages.inc')
-rw-r--r-- | inc/messages.inc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/inc/messages.inc b/inc/messages.inc index 3a7d9b1..7b0d624 100644 --- a/inc/messages.inc +++ b/inc/messages.inc @@ -1,11 +1,22 @@ <?php +/** + * Server to client error/info messages list and helpers. + * + * @package inc\messages.inc + * @author Alexandre Renoux + * @author Pierre-Emmanuel Novac + */ +/** + * Messages list. + */ $messages = array( "shop_already_built" => "You have already built a shop.", "gold_insufficient" => "You don't have enough gold.", "shop_missing_item" => "This item does not exist.", "guild_not_yet_created" => "You need to create a guild first.", "guild_already_built" => "You have aready built a guild.", + "cant_withdraw_in_dungeon" => "You cannot withdraw gold from the mine while you are in the dungeon.", "dungeon_already_available" => "You can already access the dungeon", "gamesave_ok" => "Game saved.", @@ -18,6 +29,14 @@ $messages = array( "upload_success" => "Save file uploaded successfully: %s", ); +/** + * Sends a message to the client. + * + * @param string $type message type, for example "info" or "error" + * @param string $msg message content + * @param string $fmt optional parameters to apply when formating message string + * @return void + */ function sendMessage($type, $msg, $fmt = null) { global $messages; $text = $messages[$msg]; @@ -25,10 +44,26 @@ function sendMessage($type, $msg, $fmt = null) { echo json_encode(array($type => $text)); } +/** + * Sends an error message to the client. + * Simple wrapper calling sendMessage with "error" as $type. + * + * @param string $msg message content + * @param string $fmt optional parameters to apply when formating message string + * @return void + */ function sendError($msg, $fmt = null) { sendMessage("error", $msg, $fmt); } +/** + * Sends an info message to the client. + * Simple wrapper calling sendMessage with "info" as $type. + * + * @param string $msg message content + * @param string $fmt optional parameters to apply when formating message string + * @return void + */ function sendInfo($msg, $fmt = null) { sendMessage("info", $msg, $fmt); } |