Inventory

Represent the player's Inventory.

Implemented as a singleton in the session.

package

inc\Inventory.inc

author

Alexandre Renoux

author

Pierre-Emmanuel Novac

Methods

Adds an Item object to the Inventory, incrementing the Item's count if it was already present.

_addItem(\Item $item) : array

Arguments

$item

\Item

Item to add to the Inventory

Response

array

Item and Item's count

_removeItem

_removeItem( $item) 

Arguments

$item

_useItem

_useItem( $item) 

Arguments

$item

Adds an Item object to the singleton's Inventory from session.

addItem(\Item $item) : array
static

Arguments

$item

\Item

Item to add to the Inventory

Response

array

Item and Item's count

addToXML

addToXML( $root) 

Arguments

$root

Checks if the Inventory was already created in the session

created() : boolean
static

Response

boolean

true if Inventory was already created, false otherwise

Returns the Inventory from the session.

get() : \Inventory
static

Implements the singleton pattern.

Response

\Inventory

the Inventory object

removeItem

removeItem( $item) 
static

Arguments

$item

Returns the Inventory's content from the session.

sendContent() : array
static

Response

array

array of Items and number

useItem

useItem( $item) 
static

Arguments

$item

Properties

Arrays of array with Item and Item's count

items : 

Type(s)