/**
  * 装备页面
  */
 public function equip()
 {
     // 取得对象玩家卡片的ID
     $intOwnedCardId = Input::get("owned_card_id");
     $intEquipmentPositionId = Input::get("equipment_position_id");
     if ($intOwnedCardId <= 0) {
     }
     // 取得对象玩家卡片的实例
     $objOwnedCard = OwnedCard::find($intOwnedCardId);
     if (!$objOwnedCard || $objOwnedCard->player_id != $this->_intPlayerId) {
     }
     // 卡片数据实例
     $objCard = Card::find($objOwnedCard->card_id);
     $intFromOwnedEquipmentId = 0;
     switch ($intEquipmentPositionId) {
         case 1:
             echo "[Lv{$objOwnedCard->level}]{$objCard->name_cn}武器装备<br />";
             $intFromOwnedEquipmentId = $objOwnedCard->owned_equipment_id_1;
             break;
         case 2:
             echo "[Lv{$objOwnedCard->level}]{$objCard->name_cn}头部装备<br />";
             $intFromOwnedEquipmentId = $objOwnedCard->owned_equipment_id_2;
             break;
         case 3:
             echo "[Lv{$objOwnedCard->level}]{$objCard->name_cn}胸部装备<br />";
             $intFromOwnedEquipmentId = $objOwnedCard->owned_equipment_id_3;
             break;
         case 4:
             echo "[Lv{$objOwnedCard->level}]{$objCard->name_cn}脚部装备<br />";
             $intFromOwnedEquipmentId = $objOwnedCard->owned_equipment_id_4;
             break;
         case 5:
             echo "[Lv{$objOwnedCard->level}]{$objCard->name_cn}耳环装备<br />";
             $intFromOwnedEquipmentId = $objOwnedCard->owned_equipment_id_5;
             break;
         case 6:
             echo "[Lv{$objOwnedCard->level}]{$objCard->name_cn}项链装备<br />";
             $intFromOwnedEquipmentId = $objOwnedCard->owned_equipment_id_6;
             break;
     }
     // 检查是否有当前装备
     if ($intFromOwnedEquipmentId > 0) {
         $objFromOwnedEquipment = OwnedEquipment::find($intFromOwnedEquipmentId);
         $objFromEquipment = Equipment::find($objFromOwnedEquipment->equipment_id);
         echo "当前装备[{$objFromOwnedEquipment->level}]{$objFromEquipment->name_cn}<br />";
         echo "<a href='equip-exec?player_id={$this->_intPlayerId}&owned_equipment_id=0&owned_card_id={$intOwnedCardId}&equipment_position_id={$intEquipmentPositionId}'>卸下装备</a><br />";
     }
     // 该当装备类型的未装备装备列表取得
     $lstOwnedEquipments = OwnedEquipment::where("equipment_type_id", $intEquipmentPositionId)->where("owned_card_id", 0)->get();
     foreach ($lstOwnedEquipments as $objOwnedEquipment) {
         $objEquipment = Equipment::find($objOwnedEquipment->equipment_id);
         echo "<a href='equip-exec?player_id={$this->_intPlayerId}&owned_equipment_id={$objOwnedEquipment->id}&owned_card_id={$intOwnedCardId}&equipment_position_id={$intEquipmentPositionId}'>[Lv.{$objOwnedEquipment->level}]{$objEquipment->name_cn}</a><br />";
     }
 }
Beispiel #2
0
 /**
  * 装备
  * *必须在未装备的前提下,才可以装备
  * @param $intTargetEquipmentId
  * @param int $intOwnedEquipmentId
  */
 public function equip($intTargetEquipmentId, $intOwnedEquipmentId = 0)
 {
     // 不正目标装备位置ID
     if ($intTargetEquipmentId <= 0 || $intTargetEquipmentId > self::intMaxEquipmentCount) {
         return;
     }
     // Transaction
     DB::beginTransaction();
     // 装备实装
     try {
         if ($intOwnedEquipmentId != 0) {
             // 装备目标装备
             $objOwnedEquipment = OwnedEquipment::find($intOwnedEquipmentId);
             // 目标玩家装备是否存在
             if (empty($objOwnedEquipment) || !$objOwnedEquipment) {
                 throw new Exception('Wrong Equipment');
             }
             // 目标装备是否装备中
             if ($objOwnedEquipment->owned_card_id > 0) {
                 throw new Exception('Already Equipmented');
             }
             // 取得目标装备详细
             $objOwnedEquipment->getEquipmentDetail();
             $objEquipment = $objOwnedEquipment->_objEquipment;
             // 目标装备位置是否可以装备此装备
             if ($intTargetEquipmentId != $objEquipment->type) {
                 throw new Exception('Wrong Equipment Type');
             }
             // 进行装备
             switch ($intTargetEquipmentId) {
                 case 1:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_1 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_1);
                         // 重置原玩家装备玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 重置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 配置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     }
                     break;
                 case 2:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_1 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_1);
                         // 重置原玩家装备玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 重置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 配置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     }
                     break;
                 case 3:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_1 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_1);
                         // 重置原玩家装备玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 重置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 配置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     }
                     break;
                 case 4:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_1 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_1);
                         // 重置原玩家装备玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 重置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 配置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     }
                     break;
                 case 5:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_1 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_1);
                         // 重置原玩家装备玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 重置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         // 新装备set
                         $objOwnedEquipment->owned_card_id = $this->id;
                         // 配置装备
                         $this->owned_equipment_id_1 = $objOwnedEquipment->id;
                         // 保存修改
                         if (!$this->save() || !$objOwnedEquipment->save()) {
                             throw new Exception('Save Failed');
                         }
                     }
                     break;
             }
         } else {
             // 卸下装备
             switch ($intTargetEquipmentId) {
                 case 1:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_1 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_1);
                         // 重置玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 重置装备
                         $this->owned_equipment_id_1 = 0;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         throw new Exception('Cant Null To Null');
                     }
                     break;
                 case 2:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_2 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_2);
                         // 重置玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 重置装备
                         $this->owned_equipment_id_2 = 0;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         throw new Exception('Cant Null To Null');
                     }
                     break;
                 case 3:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_3 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_3);
                         // 重置玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 重置装备
                         $this->owned_equipment_id_3 = 0;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         throw new Exception('Cant Null To Null');
                     }
                     break;
                 case 4:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_4 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_4);
                         // 重置玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 重置装备
                         $this->owned_equipment_id_4 = 0;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         throw new Exception('Cant Null To Null');
                     }
                     break;
                 case 5:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_5 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_5);
                         // 重置玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 重置装备
                         $this->owned_equipment_id_5 = 0;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         throw new Exception('Cant Null To Null');
                     }
                     break;
                 case 6:
                     // 目标装备位是否有装备
                     if ($this->owned_equipment_id_6 > 0) {
                         // 原玩家装备对象取得
                         $objFromOwnedEquipment = OwnedEquipment::find($this->owned_equipment_id_6);
                         // 重置玩家卡片ID
                         $objFromOwnedEquipment->owned_card_id = 0;
                         // 重置装备
                         $this->owned_equipment_id_6 = 0;
                         // 保存修改
                         if (!$objFromOwnedEquipment->save() || !$this->save()) {
                             throw new Exception('Save Failed');
                         }
                     } else {
                         throw new Exception('Cant Null To Null');
                     }
                     break;
             }
         }
         // 重新计算卡片数据
         $this->setUpStatus();
         DB::commit();
     } catch (Exception $e) {
         // TODO Dev Log
         DB::rollback();
     }
 }
Beispiel #3
0
 public function equipment()
 {
     // 把装备装备到卡片
     $playerId = Input::get('player_id', 0);
     $ownedCardId = Input::get('owned_card_id', 0);
     $ownedEquipmentId = Input::get('owned_equipment_id', 0);
     $ownedCard = OwnedCard::find($ownedCardId);
     $ownedEquipment = OwnedEquipment::find($ownedEquipmentId);
     // Ownerc Check
     if ($ownedCard->player_id != $playerId || $ownedEquipment->player_id != $playerId) {
     }
     // 装备限制Check
     $equipment = Equipment::find($ownedEquipment->equipment_id);
     if ($equipment->attr != 0) {
         if ($ownedCard->attr != $equipment->attr) {
             // Error
         }
     }
     if ($equipment->job != 0) {
         if ($ownedCard->job != $equipment->job) {
             // Error
         }
     }
     if ($equipment->race != 0) {
         if ($ownedCard->race != $equipment->race) {
             // Error
         }
     }
     if ($equipment->rare != 0) {
     }
     // 装备中的卡片
     $equipmentCardId = $ownedEquipment->owned_card_id;
     // 对象卡片原有装备
     $cardEquipmentId = $ownedCard->owned_equipment_id;
     switch ($equipment->type) {
         case 1:
             // 武器
             // 卸下
             if ($equipmentCardId != 0) {
                 $equipmentCard = OwnedCard::find($ownedEquipment->owned_card_id);
                 $equipmentCard->owned_equipment_id_1 = 0;
                 $ownedEquipment->owned_card_id = 0;
                 // 卡片数据更新
                 $equipmentCard->setUpStatus();
             }
             if ($cardEquipmentId != 0) {
                 $cardEquipment = OwnedEquipment::find($cardEquipmentId);
                 $cardEquipment->owned_card_id = 0;
                 $cardEquipment->save();
             }
             // 装备
             $ownedCard->owned_equipment_id_1 = $ownedEquipment->id;
             $ownedEquipment->owned_card_id = $ownedCard->id;
             $ownedCard->setUpStatus();
             break;
         case 2:
             // 头部
             // 卸下
             if ($equipmentCardId != 0) {
                 $equipmentCard = OwnedCard::find($ownedEquipment->owned_card_id);
                 $equipmentCard->owned_equipment_id_2 = 0;
                 $ownedEquipment->owned_card_id = 0;
                 // 卡片数据更新
                 $equipmentCard->setUpStatus();
             }
             if ($cardEquipmentId != 0) {
                 $cardEquipment = OwnedEquipment::find($cardEquipmentId);
                 $cardEquipment->owned_card_id = 0;
                 $cardEquipment->save();
             }
             // 装备
             $ownedCard->owned_equipment_id_2 = $ownedEquipment->id;
             $ownedEquipment->owned_card_id = $ownedCard->id;
             $ownedCard->setUpStatus();
             break;
         case 3:
             // 胸部
             // 卸下
             if ($equipmentCardId != 0) {
                 $equipmentCard = OwnedCard::find($ownedEquipment->owned_card_id);
                 $equipmentCard->owned_equipment_id_3 = 0;
                 $ownedEquipment->owned_card_id = 0;
                 // 卡片数据更新
                 $equipmentCard->setUpStatus();
             }
             if ($cardEquipmentId != 0) {
                 $cardEquipment = OwnedEquipment::find($cardEquipmentId);
                 $cardEquipment->owned_card_id = 0;
                 $cardEquipment->save();
             }
             // 装备
             $ownedCard->owned_equipment_id_3 = $ownedEquipment->id;
             $ownedEquipment->owned_card_id = $ownedCard->id;
             $ownedCard->setUpStatus();
             break;
         case 4:
             // 脚部
             // 卸下
             if ($equipmentCardId != 0) {
                 $equipmentCard = OwnedCard::find($ownedEquipment->owned_card_id);
                 $equipmentCard->owned_equipment_id_4 = 0;
                 $ownedEquipment->owned_card_id = 0;
                 // 卡片数据更新
                 $equipmentCard->setUpStatus();
             }
             if ($cardEquipmentId != 0) {
                 $cardEquipment = OwnedEquipment::find($cardEquipmentId);
                 $cardEquipment->owned_card_id = 0;
                 $cardEquipment->save();
             }
             // 装备
             $ownedCard->owned_equipment_id_4 = $ownedEquipment->id;
             $ownedEquipment->owned_card_id = $ownedCard->id;
             $ownedCard->setUpStatus();
             break;
         case 5:
             // 耳环
             // 卸下
             if ($equipmentCardId != 0) {
                 $equipmentCard = OwnedCard::find($ownedEquipment->owned_card_id);
                 $equipmentCard->owned_equipment_id_5 = 0;
                 $ownedEquipment->owned_card_id = 0;
                 // 卡片数据更新
                 $equipmentCard->setUpStatus();
             }
             if ($cardEquipmentId != 0) {
                 $cardEquipment = OwnedEquipment::find($cardEquipmentId);
                 $cardEquipment->owned_card_id = 0;
                 $cardEquipment->save();
             }
             // 装备
             $ownedCard->owned_equipment_id_5 = $ownedEquipment->id;
             $ownedEquipment->owned_card_id = $ownedCard->id;
             $ownedCard->setUpStatus();
             break;
         case 6:
             // 项链
             // 卸下
             if ($equipmentCardId != 0) {
                 $equipmentCard = OwnedCard::find($ownedEquipment->owned_card_id);
                 $equipmentCard->owned_equipment_id_6 = 0;
                 $ownedEquipment->owned_card_id = 0;
                 // 卡片数据更新
                 $equipmentCard->setUpStatus();
             }
             if ($cardEquipmentId != 0) {
                 $cardEquipment = OwnedEquipment::find($cardEquipmentId);
                 $cardEquipment->owned_card_id = 0;
                 $cardEquipment->save();
             }
             // 装备
             $ownedCard->owned_equipment_id_6 = $ownedEquipment->id;
             $ownedEquipment->owned_card_id = $ownedCard->id;
             $ownedCard->setUpStatus();
             break;
         default:
             # code...
             break;
     }
     $ownedEquipment->save();
     return Response::json($ownedCard);
     // 数据更新
     // if ($ownedEquipment->atk > 0) {
     // 	$ownedCard->updateAtk();
     // }
 }