Functions

buildDungeon

Allows acces to the dungeon in the session and sends it to the client.

Debits the dungeon's ticket cost from the player's gold.

package

inc\dungeon.inc

« More »

buildShop

Creates the shop in the session and sends it to the client.

Debits the shop's cost from the player's gold.

package

inc\shop.inc

« More »

buyItem

Debits the item's cost specified as the item POST parameter, adds it to the Inventory and sends it to the client.

package

inc\shop.inc

« More »

createGuild

Create the miners guild in the session.

Debits GUILD_COST from the player's gold.

package

inc\guild.inc

« More »

creditAccount

Credits the account of a certain amount of gold.

package

inc\account.inc

Arguments

$amount

integer

amount to credit

« More »

debitAccount

Debits the account of a certain amount of gold.

package

inc\account.inc

Arguments

$amount

integer

amount to debit

Response

boolean

true if player had enough gold, false otherwise

« More »

deleteSave

Deletes a save file given as the filename POST parameter.

package

inc\savegame.inc

« More »

downSave

Sends the current game or a specific save file given by the filename GET parameter to the client.

package

inc\savegame.inc

« More »

exitDungeon

Marks the dungeon as not accessible in the session.

package

inc\dungeon.inc

« More »

generateMonster

Loads all the dungeon's monsters from the XML file data/monsters.xml.

package

inc\dungeon.inc

Response

array

contains all the Monster objects

« More »

genFilename

Generates the save file name using current date/time.

The date function will use the server's timezone which could be inconsistent with the client timezone.

package

inc\savegame.inc

Response

string

the generated file name

« More »

genSave

Generates the XML save tree from the session.

package

inc\savegame.inc

« More »

genXML

Recursively generates an XML tree from an array.

If objects are found, call addToXML() methods which should serialize the object as a child of the XML tree passed as parameter.

package

inc\savegame.inc

Arguments

$table

array

an array with mixed type elements to convert to XML

$xml

\SimpleXMLElement

root XML to add the elements to

« More »

getItem

Gets an Item object from the shop from its name.

package

inc\shop.inc

params

string $name the name of the object to search for

Arguments

$name

Response

\Item|false

the Item object or false if the item was not found

« More »

hireMiner

Hire one miner.

Debits MINER_COST from the player's gold.

package

inc\guild.inc

« More »

increasePerso

Increases a player's stat.

package

inc\perso.inc

Arguments

$prop

integer

stat to increase

$num

« More »

initDungeon

Marks the dungeon as accessible in the session.

package

inc\dungeon.inc

« More »

initMineIfNeeded

Initializes the gold amount and miners count in the session.

package

inc\mine.inc

« More »

initMinersIfNeeded

package

inc\guild.inc

« More »

initPerso

Initializes the player's stats.

package

inc\perso.inc

« More »

initShop

Marks the shop as created in the session.

package

inc\shop.inc

« More »

initUsedItem

package

inc\perso.inc

« More »

launchDungeon

Sends monsters for a specific floor as specified by the floor POST parameter to the client.

package

inc\dungeon.inc

« More »

limitUse

traite le fait que wooden sword n'est pas cumulable metal sword non plus life bottle cumulable 3 fois si on clique sur wooden sword alors que on avait une metal sword, le bonusPower passe de +3 à +1

package

inc\perso.inc

Arguments

$item

« More »

listSaves

Sends the list of available saves to the client.

Warning: this function changes directory.

package

inc\savegame.inc

« More »

loadSave

Loads a save file given as the filename POST parameter to the session.

Empties the session beforehand.

package

inc\savegame.inc

« More »

loadShop

Loads all the shop's items from the XML file data/items.xml.

package

inc\shop.inc

Response

array

contains all the Item objects

« More »

parseSave

Reads an XML tree and deserializes it to an array.

package

inc\savegame.inc

Arguments

$xml

\SimpleXMLElement

root XML to read the elements from

$table

array

an empty array to stores the elements to, passed by reference

« More »

reportBadRequest

Indique au client une message requete.

package

Default

« More »

reusable

package

inc\perso.inc

« More »

saveGame

Save the XML save tree as an XML file named after the results of genFilename in SAVEDIR.

Fails and send an error the the client if permissions are incorrectly set. Watch for errors in PHP log.

package

inc\savegame.inc

« More »

sendCraftMine

Sends all data from previous session on page load.

All data from the different modules are packed in an array.

package

inc\craftmine.inc

« More »

sendDungeon

Returns the dungeon array if it was created.

package

inc\dungeon.inc

Response

array

dungeon array as created by generateMonster

« More »

sendDungeonProgress

Updates floor and monster number from the POST parameters in the session.

package

inc\dungeon.inc

« More »

sendError

Sends an error message to the client.

Simple wrapper calling sendMessage with "error" as $type.

package

inc\messages.inc

Arguments

$msg

string

message content

$fmt

string

optional parameters to apply when formating message string

« More »

sendInfo

Sends an info message to the client.

Simple wrapper calling sendMessage with "info" as $type.

package

inc\messages.inc

Arguments

$msg

string

message content

$fmt

string

optional parameters to apply when formating message string

« More »

sendMessage

Sends a message to the client.

package

inc\messages.inc

Arguments

$type

string

message type, for example "info" or "error"

$msg

string

message content

$fmt

string

optional parameters to apply when formating message string

« More »

sendMine

Returns the amount of gold currently owned by the player.

package

inc\mine.inc

Response

integer

amount of gold available

« More »

sendMiners

Returns the number of miners currently in the guild.

package

inc\guild.inc

Response

integer

number of miners in the guild

« More »

sendPerso

Returns all player's stats after initializing them if needed.

package

inc\perso.inc

Response

array<mixed,integer>

arrays containing player's stats

« More »

sendShop

Returns the shop array if it was created.

package

inc\shop.inc

Response

array

shop array as created by loadShop

« More »

updatePerso

Copies stats given in POST request to session.

package

inc\perso.inc

« More »

uploadSave

Reads a save file sent by the client.

Parse the received file then generate it again to clean it for any unwanted and make sure that it is a valid XML save file. XML errors are simply ignored and an error is sent to the client if something wrong happens.

package

inc\savegame.inc

« More »

useItem

Invoke useItem on an item passed as the item POST parameter, sends to the client the updated player stats and the item.

package

inc\shop.inc

« More »

withdrawMine

Transfers all gold from the mine to the player's account.

package

inc\mine.inc

« More »

Constants

SAVEDIR

Directory to save to and load from.

The PHP/Apache user must have write permission on this directory. Use the following commands to give write permissions to the http group:

sudo chown :http data/save sudo chmod g+w data/save
« More »

GUILD_COST

Amount of gold required to build the miners guild.

« More »

MINER_COST

Amount of gold required to hire a miner.

« More »

Classes, interfaces and traits

Inventory

Represent the player's Inventory.

Implemented as a singleton in the session.

« More »

Item

Represent an Item in the shop or in the Inventory.

« More »

Monster

Represent an Item in the shop or in the Inventory.

« More »