当前位置: 首页>>代码示例>>PHP>>正文


PHP add_item函数代码示例

本文整理汇总了PHP中add_item函数的典型用法代码示例。如果您正苦于以下问题:PHP add_item函数的具体用法?PHP add_item怎么用?PHP add_item使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了add_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bet

 /**
  * User command for betting on the coin toss game in the casino
  *
  * @param bet int The amount of money to bet on the coin toss game
  * @return Array
  *
  * @note
  * If the player bets within ~1% of the maximum bet, they will receive a reward item
  */
 public function bet()
 {
     $player = new Player(self_char_id());
     $bet = intval(in('bet'));
     $negative = $bet < 0;
     set_setting('bet', max(0, $bet));
     $pageParts = ['reminder-max-bet'];
     if ($negative) {
         $pageParts = ['result-cheat'];
         $player->vo->health = subtractHealth($player->id(), 99);
     } else {
         if ($bet > $player->vo->gold) {
             $pageParts = ['result-no-gold'];
         } else {
             if ($bet > 0 && $bet <= self::MAX_BET) {
                 if (rand(0, 1) === 1) {
                     $pageParts = ['result-win'];
                     $player->vo->gold = add_gold($player->id(), $bet);
                     if ($bet >= round(self::MAX_BET * 0.99)) {
                         // within about 1% of the max bet & you win, you get a reward item.
                         add_item($player->id(), self::REWARD, 1);
                     }
                 } else {
                     $player->vo->gold = subtract_gold($player->id(), $bet);
                     $pageParts = ['result-lose'];
                 }
             }
         }
     }
     // End of not cheating check.
     return $this->render(['pageParts' => $pageParts, 'player' => $player, 'bet' => get_setting('bet')]);
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:41,代码来源:CasinoController.php

示例2: buyDimMak

 /**
  * Action to request the Dim Mak form AND execute the purchase
  *
  * @todo split form request (GET) and purchase (POST) into separate funcs
  * @return ViewSpec
  */
 public function buyDimMak()
 {
     if (is_logged_in()) {
         $player = new Player(self_char_id());
         $showMonks = false;
         $parts = [];
         RequestWrapper::init();
         if (RequestWrapper::$request && RequestWrapper::$request->isMethod('POST')) {
             $error = $this->dimMakReqs($player, self::DIM_MAK_COST);
             if (!$error) {
                 $player->changeTurns(-1 * self::DIM_MAK_COST);
                 add_item($player->id(), 'dimmak', 1);
                 $parts['pageParts'] = ['success-dim-mak'];
                 $showMonks = true;
             } else {
                 $parts['error'] = $error;
             }
         } else {
             $parts['pageParts'] = ['form-dim-mak'];
             $parts['dim_mak_cost'] = self::DIM_MAK_COST;
         }
         return $this->render($parts, $player, $showMonks);
     } else {
         return $this->accessDenied();
     }
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:32,代码来源:DojoController.php

示例3: bet

 /**
  * User command for betting on the coin toss game in the casino
  *
  * @param bet int The amount of money to bet on the coin toss game
  * @return Array
  *
  * @note
  * If the player bets within ~1% of the maximum bet, they will receive a
  * reward item
  */
 public function bet()
 {
     $player = Player::find(self_char_id());
     $bet = intval(in('bet'));
     $pageParts = ['reminder-max-bet'];
     if ($bet < 0) {
         $pageParts = ['result-cheat'];
         $player->harm(self::CHEAT_DMG);
     } else {
         if ($bet > $player->gold) {
             $pageParts = ['result-no-gold'];
         } else {
             if ($bet > 0 && $bet <= self::MAX_BET) {
                 if (rand(0, 1) === 1) {
                     $pageParts = ['result-win'];
                     $player->set_gold($player->gold + $bet);
                     if ($bet >= round(self::MAX_BET * 0.99)) {
                         // within about 1% of the max bet & you win, you get a reward item.
                         add_item($player->id(), self::REWARD, 1);
                     }
                 } else {
                     $player->set_gold($player->gold - $bet);
                     $pageParts = ['result-lose'];
                 }
             }
         }
     }
     $player->save();
     return $this->render(['pageParts' => $pageParts, 'player' => $player]);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:40,代码来源:CasinoController.php

示例4: add_to_basket

function add_to_basket($tab)
{
    if (isset($_SESSION) && isset($_SESSION['logged_on_user'])) {
        $_SESSION['basket'][] = add_item($tab);
        // utiliser count pour le nombre d'article.
    } else {
        echo "<p>Vous devez etre loggé.</p>";
    }
}
开发者ID:tcharrey,项目名称:rem_aide,代码行数:9,代码来源:rush_functions_basket.php

示例5: setUp

 function setUp()
 {
     $this->controller = new InventoryController();
     $this->char = TestAccountCreateAndDestroy::char();
     $request = new Request([], []);
     RequestWrapper::inject($request);
     SessionFactory::init(new MockArraySessionStorage());
     $sess = SessionFactory::getSession();
     $sess->set('player_id', $this->char->id());
     add_item($this->char->id(), self::ITEM);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:11,代码来源:InventoryControllerTest.php

示例6: add_item_wrap

/**
 * Wrapper and actualiser to add an item. Does not return.
 *
 * @param  MEMBER		The member performing the action
 * @param  string		The name of the item
 * @param  integer	The cost the item
 * @param  BINARY		Whether the item is finite
 * @param  BINARY		Whether the item may be used for bribes
 * @param  BINARY		Whether the item may be used to provide a health boost
 * @param  URLPATH	The picture of the item
 * @param  integer	The maximum number of these items a player may have
 * @param  BINARY		Whether the item may be replicated via a new item copy source
 * @param  string		Description for the item
 */
function add_item_wrap($member_id, $name, $cost, $not_infinite, $bribable, $healthy, $picture_url, $max_per_player, $replicateable, $description)
{
    if ($healthy != 1) {
        $healthy = 0;
    }
    if ($bribable != 1) {
        $bribable = 0;
    }
    if ($not_infinite != 1) {
        $not_infinite = 0;
    }
    if (!($cost > 0)) {
        $cost = 0;
    }
    if (!($max_per_player > 0)) {
        $max_per_player = 0;
    }
    if ($replicateable != 1) {
        $replicateable = 0;
    }
    if ($name == '') {
        ocw_refresh_with_message(do_lang_tempcode('W_MISSING_NAME'), 'warn');
    }
    // Get $realm,$x,$y from $member_id
    list($realm, $x, $y) = get_loc_details($member_id);
    if (!has_specific_permission($member_id, 'administer_ocworld') && $GLOBALS['SITE_DB']->query_value('w_realms', 'owner', array('id' => $realm)) != $member_id && $GLOBALS['SITE_DB']->query_value('w_realms', 'r_private', array('id' => $realm)) == 1) {
        ocw_refresh_with_message(do_lang_tempcode('W_NO_EDIT_ACCESS_PRIVATE_REALM'), 'warn');
    }
    // Make sure the item does not already exist! (people aren't allowed to arbitarily duplicate items for security reasons)
    $r = $GLOBALS['SITE_DB']->query_value_null_ok('w_itemdef', 'bribable', array('name' => $name));
    if (!is_null($r)) {
        ocw_refresh_with_message(do_lang_tempcode('W_DUPE_ITEM'), 'warn');
    }
    // Make sure that they aren't in the brig and adding a bribable!
    if ($x == 0 && $y == 2 && $bribable == 1) {
        ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn');
    }
    // Charge them
    if (!has_specific_permission($member_id, 'administer_ocworld')) {
        $price = get_price('mud_item');
        if (available_points($member_id) < $price) {
            ocw_refresh_with_message(do_lang_tempcode('W_EXPENSIVE', escape_html($price)), 'warn');
        }
        require_code('points2');
        charge_member($member_id, $price, do_lang('W_MADE_OCWORLD', $name));
    }
    add_item($name, $bribable, $healthy, $picture_url, $member_id, $max_per_player, $replicateable, $description);
    add_item_to_room($realm, $x, $y, $name, $not_infinite, $cost, $member_id);
    ocw_refresh_with_message(do_lang_tempcode('W_MADE_ITEM_AT', escape_html($name)));
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:64,代码来源:ocworld_action.php

示例7: buy

 /**
  * Command for current user to purchase a quantity of a specific item
  *
  * @param quantity int The quantity of the item to purchase
  * @param item string The identity of the item to purchase
  * @return Array
  */
 public function buy()
 {
     $in_quantity = in('quantity');
     $in_item = in('item');
     $gold = get_gold($this->sessionData['char_id']);
     $current_item_cost = 0;
     $no_funny_business = false;
     // Pull the item info from the database
     $item_costs = $this->itemForSaleCosts();
     $item = getItemByID(item_id_from_display_name($in_item));
     $quantity = whichever(positive_int($in_quantity), 1);
     $item_text = null;
     if ($item instanceof Item) {
         $item_text = $quantity > 1 ? $item->getPluralName() : $item->getName();
         $purchaseOrder = new PurchaseOrder();
         // Determine the quantity from input or as a fallback, default of 1.
         $purchaseOrder->quantity = $quantity;
         $purchaseOrder->item = $item;
         $potential_cost = isset($item_costs[$purchaseOrder->item->identity()]['item_cost']) ? $item_costs[$purchaseOrder->item->identity()]['item_cost'] : null;
         $current_item_cost = first_value($potential_cost, 0);
         $current_item_cost = $current_item_cost * $purchaseOrder->quantity;
         if (!$this->sessionData['char_id'] || !$purchaseOrder->item || $purchaseOrder->quantity < 1) {
             $no_funny_business = true;
         } else {
             if ($gold >= $current_item_cost) {
                 // Has enough gold.
                 try {
                     add_item($this->sessionData['char_id'], $purchaseOrder->item->identity(), $purchaseOrder->quantity);
                     subtract_gold($this->sessionData['char_id'], $current_item_cost);
                 } catch (\Exception $e) {
                     $invalid_item = $e->getMessage();
                     error_log('Invalid Item attempted :' . $invalid_item);
                     $no_funny_business = true;
                 }
             }
         }
     } else {
         $no_funny_business = true;
     }
     $parts = array('current_item_cost' => $current_item_cost, 'quantity' => $quantity, 'item_text' => $item_text, 'no_funny_business' => $no_funny_business, 'view_part' => 'buy');
     return $this->render($parts);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:49,代码来源:ShopController.php

示例8: add

 /**
  * Add item
  *
  * {@source}
  * @access public
  * @static
  * @since 1.8
  * @version 1
  *
  * Input array $items has following structure and default values :
  * <code>
  * array( array(
  * *'description'			=> *,
  * *'key_'				=> *,
  * *'hostid'				=> *,
  * 'delay'				=> 60,
  * 'history'				=> 7,
  * 'status'				=> ITEM_STATUS_ACTIVE,
  * 'type'				=> ITEM_TYPE_ZABBIX,
  * 'snmp_community'			=> '',
  * 'snmp_oid'				=> '',
  * 'value_type'				=> ITEM_VALUE_TYPE_STR,
  * 'data_type'				=> ITEM_DATA_TYPE_DECIMAL,
  * 'trapper_hosts'			=> 'localhost',
  * 'snmp_port'				=> 161,
  * 'units'				=> '',
  * 'multiplier'				=> 0,
  * 'delta'				=> 0,
  * 'snmpv3_securityname'		=> '',
  * 'snmpv3_securitylevel'		=> 0,
  * 'snmpv3_authpassphrase'		=> '',
  * 'snmpv3_privpassphrase'		=> '',
  * 'formula'				=> 0,
  * 'trends'				=> 365,
  * 'logtimefmt'				=> '',
  * 'valuemapid'				=> 0,
  * 'delay_flex'				=> '',
  * 'params'				=> '',
  * 'ipmi_sensor'			=> '',
  * 'applications'			=> array(),
  * 'templateid'				=> 0
  * ), ...);
  * </code>
  *
  * @static
  * @param array $items multidimensional array with items data
  * @return array|boolean
  */
 public static function add($items)
 {
     $itemids = array();
     DBstart(false);
     $result = false;
     foreach ($items as $item) {
         $result = add_item($item);
         if (!$result) {
             break;
         }
         $itemids['result'] = $result;
     }
     $result = DBend($result);
     if ($result) {
         return $itemids;
     } else {
         self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error');
         return false;
     }
 }
开发者ID:phedders,项目名称:zabbix,代码行数:68,代码来源:class.citem.php

示例9: foreach

    if ($s = $i->prepare("UPDATE ITEMS SET ARCHIVED = 1 WHERE ID = ? AND OWNER = ?")) {
        foreach ($ids as $i) {
            $s->bind_param('is', $i, $_SESSION['user-id']);
            if (!$s->execute()) {
                $errors[] = $i->error;
            }
        }
        $s->close();
        if (count($errors)) {
            error_log("Encountered errors while archiving items: " . print_r($errors, true));
        }
    } else {
        error_log("There was an error while preparing the item archive statement: {$i->error}");
    }
    json_error("There was actually no error...");
}
$action = array_get($_POST, "a", "dump");
switch ($action) {
    case 'dump':
        echo get_items($i);
        break;
    case 'add':
        echo add_item($i, $_POST['title'], $_POST['parent']);
        break;
    case 'save':
        echo save_items($i, $_POST['items']);
        break;
    case 'archive':
        echo archive_items($i, $_POST['ids']);
        break;
}
开发者ID:AlexArendsen,项目名称:newlist,代码行数:31,代码来源:items.php

示例10: filter_input

// Include cart functions
require_once 'cart.php';
// Get the action to perform
$action = filter_input(INPUT_POST, 'action');
if ($action === NULL) {
    $action = filter_input(INPUT_GET, 'action');
    if ($action === NULL) {
        $action = 'show_add_item';
    }
}
// Add or update cart as needed
switch ($action) {
    case 'add':
        $product_key = filter_input(INPUT_POST, 'productkey');
        $item_qty = filter_input(INPUT_POST, 'itemqty');
        add_item($product_key, $item_qty);
        include 'cart_view.php';
        break;
    case 'update':
        $new_qty_list = filter_input(INPUT_POST, 'newqty', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
        foreach ($new_qty_list as $key => $qty) {
            if ($_SESSION['cart12'][$key]['qty'] != $qty) {
                update_item($key, $qty);
            }
        }
        include 'cart_view.php';
        break;
    case 'show_cart':
        include 'cart_view.php';
        break;
    case 'show_add_item':
开发者ID:j-jm,项目名称:web182,代码行数:31,代码来源:index.php

示例11: header

    }
}
//	modify item
if (isset($_POST["mod"])) {
    if (mod_item($this_table, $_POST["id"], $_POST["mod"])) {
        header("Location:index.php?page=" . ADMIN_PAGE . "&id_modified=" . $_POST["id"] . "&msg=mod_OK");
    } else {
        $warning = $lang["msg_mod_KO"];
    }
}
//	add new item
if (isset($_POST["add"])) {
    //	define next list order
    $_POST["add"]["list_order"] = get_next_order($this_table);
    $_POST["add"]["id_user"] = $_SESSION["admin_id"];
    if (add_item($this_table, $_POST["add"], false)) {
        header("Location:index.php?page=" . ADMIN_PAGE . "&id_added=" . mysql_insert_id() . "&msg=add_OK");
    } else {
        $warning = $lang["msg_add_KO"];
    }
}
if (isset($_REQUEST["action"])) {
    $xtra_moo .= '
	new FormCheck("item_form");
	';
    switch ($_REQUEST["action"]) {
        case "new":
            $page_title_add = ' - ' . $lang["title_add"];
            $contents .= '
			<form method="post" id="item_form">
			<table>
开发者ID:praveenpgoswami,项目名称:codeigniter_project,代码行数:31,代码来源:items.admin.php

示例12: update_item

// | This program is distributed in the hope that it will be useful,          |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                             |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with this program; if not, write to the Free Software Foundation,  |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.          |
// |                                                                          |
// +--------------------------------------------------------------------------+
require_once $_CONF['path_html'] . "/fckeditor/fckeditor.php";
if (isset($_POST['update_item'])) {
    $error = update_item(basename($_FILES['picture_small']['name']), basename($_FILES['picture_large']['name']));
} else {
    if (isset($_POST['add_item'])) {
        $error = add_item(basename($_FILES['picture_small']['name']), basename($_FILES['picture_large']['name']));
    } else {
        if (isset($_POST['add_catagory'])) {
            $error = add_catagory();
        } else {
            if (isset($_GET['delete_cat'])) {
                $error = delete_catagory();
            } else {
                $error = "";
            }
        }
    }
}
$T = new Template($_CONF['path'] . 'plugins/ecommerce/templates/admin');
$T->set_file('text', 'item.thtml');
//Catagories
开发者ID:glFusion,项目名称:ecommerce,代码行数:31,代码来源:item.php

示例13: switch

// Include cart functions
require_once 'cart.php';
// Get the action to perform
if (isset($_POST['action'])) {
    $action = $_POST['action'];
} else {
    if (isset($_GET['action'])) {
        $action = $_GET['action'];
    } else {
        $action = 'show_add_item';
    }
}
// Add or update cart as needed
switch ($action) {
    case 'add':
        add_item($_POST['productkey'], $_POST['itemqty']);
        include 'cart_view.php';
        break;
    case 'update':
        $new_qty_list = $_POST['newqty'];
        foreach ($new_qty_list as $key => $qty) {
            if ($_SESSION['cart13'][$key]['qty'] != $qty) {
                update_item($key, $qty);
            }
        }
        include 'cart_view.php';
        break;
    case 'show_cart':
        include 'cart_view.php';
        break;
    case 'show_add_item':
开发者ID:Romrell-Launa,项目名称:CIT336,代码行数:31,代码来源:index.php

示例14: add_item

 * Created on Nov 8, 2005
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
function add_item($catalog, $itemId, $desc, $price, $quantity, $warehouseId)
{
    $item = $catalog->createDataObject('item');
    $item->itemId = $itemId;
    $item->description = $desc;
    $item->price = $price;
    $item->quantity = $quantity;
    $item->warehouseId = $warehouseId;
}
$xmldas = SDO_DAS_XML::create('Catalog.xsd');
$catalog = $xmldas->createDataObject('catalogNS', 'CatalogType');
add_item($catalog, 1, 'A Partridge in a Pear Tree', 1.99, 0, 1);
add_item($catalog, 2, 'Turtle Doves', 2.99, 0, 1);
add_item($catalog, 3, 'French Hens', 3.99, 0, 1);
add_item($catalog, 4, 'Calling Birds', 4.99, 0, 1);
add_item($catalog, 5, 'Golden Rings', 5.99, 0, 1);
add_item($catalog, 6, 'Geese a-laying', 6.99, 0, 1);
add_item($catalog, 7, 'Swans a-swimming', 7.99, 0, 1);
add_item($catalog, 8, 'Maids a-milking', 8.99, 0, 1);
add_item($catalog, 9, 'Ladies dancing', 9.99, 0, 1);
add_item($catalog, 10, 'Lords a-leaping', 10.99, 0, 1);
add_item($catalog, 11, 'Pipers piping', 11.99, 0, 1);
add_item($catalog, 12, 'Drummers drumming', 12.99, 0, 1);
$doc = $xmldas->createDocument('catalogNS', 'catalog', $catalog);
// echo htmlspecialchars($xmldas->saveString($doc));
$xmldas->saveFile($doc, 'Catalog.xml', 4);
开发者ID:psagi,项目名称:sdo,代码行数:31,代码来源:create_catalog.php

示例15: addItem

 /**
  * Add an item using the old display name
  */
 private function addItem($who, $item, $quantity = 1)
 {
     $item_identity = $this->itemIdentityFromDisplayName($item);
     if ((int) $quantity > 0 && !empty($item) && $item_identity) {
         add_item(get_char_id($who), $item_identity, $quantity);
     } else {
         throw new \Exception('Improper deprecated item addition request made.');
     }
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:12,代码来源:InventoryController.php


注:本文中的add_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。