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


PHP Inventory::updateAll方法代码示例

本文整理汇总了PHP中Inventory::updateAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Inventory::updateAll方法的具体用法?PHP Inventory::updateAll怎么用?PHP Inventory::updateAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


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

示例1: Inventory

 /**
  * Moving an Item from one spot to the other in a Bag
  */
 function game_change($from_bag_id = null, $from_bag_index = null, $to_bag_id = null, $to_bag_index = null)
 {
     $this->render(false);
     App::import('Model', 'Inventory');
     $Inventory = new Inventory();
     $Inventory->unbindModelAll();
     $fromInventory = $Inventory->find('first', array('conditions' => array('Inventory.character_id' => $this->characterInfo['id'], 'Inventory.bag_id' => $from_bag_id, 'Inventory.index' => $from_bag_index)));
     if (!empty($fromInventory)) {
         // KLijken of het vakje leeg is waar we heen gaan
         $toInventory = $Inventory->find('first', array('conditions' => array('Inventory.character_id' => $this->characterInfo['id'], 'Inventory.bag_id' => $to_bag_id, 'Inventory.index' => $to_bag_index)));
         if (!empty($toInventory)) {
             // Niks aan de hand, wisselen
             // to => from
             $oldIds = $Inventory->find('list', array('conditions' => array('Inventory.character_id' => $this->characterInfo['id'], 'Inventory.bag_id' => $from_bag_id, 'Inventory.index' => $from_bag_index)));
             $Inventory->updateAll(array('Inventory.bag_id' => $fromInventory['Inventory']['bag_id'], 'Inventory.index' => $fromInventory['Inventory']['index']), array('Inventory.bag_id' => $toInventory['Inventory']['bag_id'], 'Inventory.index' => $toInventory['Inventory']['index']));
             // from => to
             $Inventory->updateAll(array('Inventory.bag_id' => $toInventory['Inventory']['bag_id'], 'Inventory.index' => $toInventory['Inventory']['index']), array('Inventory.id' => $oldIds));
         } else {
             // kijken of er in de nieuwe bag slot wel ruimte is
             $this->Bag->recursive = 2;
             $toBag = $this->Bag->find('first', array('conditions' => array('Bag.id' => $to_bag_id, 'Bag.character_id' => $this->characterInfo['id'])));
             if (!empty($toBag)) {
                 // Kijken of de index lager is dan het aantal vrije slots
                 if ($toBag['Item']['StatNamed']['slots'] >= $to_bag_index) {
                     // Mag naar de lege plek
                     $Inventory->updateAll(array('Inventory.bag_id' => $to_bag_id, 'Inventory.index' => $to_bag_index), array('Inventory.bag_id' => $fromInventory['Inventory']['bag_id'], 'Inventory.index' => $fromInventory['Inventory']['index']));
                 }
             }
         }
     }
     $this->redirect('/game/bags/view/' . $to_bag_id);
     exit;
 }
开发者ID:MortalROs,项目名称:Naxasius-Game-Engine,代码行数:36,代码来源:bags_controller.php


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