diff options
author | alexichi <alexbankai96@gmail.com> | 2016-04-25 10:43:56 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-04-25 10:43:56 +0200 |
commit | 1ffba62faae83e18597270b68580a90ac3032a31 (patch) | |
tree | 603d33ed48a9dd3690aeef379eeb7fd8ce3a257f /inc/Inventory.inc | |
parent | 3ece645cc83e36aaa36c0258afa0f1b36eb13ca2 (diff) | |
parent | dc28807625b9f53e621ec0d7063d99c2527cfa02 (diff) | |
download | candybox-1ffba62faae83e18597270b68580a90ac3032a31.tar.gz candybox-1ffba62faae83e18597270b68580a90ac3032a31.tar.bz2 candybox-1ffba62faae83e18597270b68580a90ac3032a31.tar.xz candybox-1ffba62faae83e18597270b68580a90ac3032a31.zip |
Merge remote-tracking branch 'origin/piernov' into alexichi
Conflicts:
craftmine.php
index.xhtml
Diffstat (limited to 'inc/Inventory.inc')
-rw-r--r-- | inc/Inventory.inc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/inc/Inventory.inc b/inc/Inventory.inc new file mode 100644 index 0000000..efe54f2 --- /dev/null +++ b/inc/Inventory.inc @@ -0,0 +1,41 @@ +<?php + +class Inventory { + + public $items = array(); + + public static function created() { + return !empty($_SESSION["inventory"]); + } + + public static function sendContent() { + return self::get()->items; + } + + public static function get() { + if(!self::created()) { + $_SESSION["inventory"] = new Inventory(); + } + return $_SESSION["inventory"]; + } + + private function _addItem($item) { + $this->items[] = $item; + } + + public static function addItem($item) { + $inv = self::get(); + $inv->_addItem($item); + } + + private function _removeItem($item) { + unset($this->items[array_search($item, $this->items)]); + } + + public static function removeItem($item) { + $inv = self::get(); + $inv->_removeItem($item); + } +} + +?> |