當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inventory::updateOrDeleteEquipment方法代碼示例

本文整理匯總了PHP中Inventory::updateOrDeleteEquipment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inventory::updateOrDeleteEquipment方法的具體用法?PHP Inventory::updateOrDeleteEquipment怎麽用?PHP Inventory::updateOrDeleteEquipment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Inventory的用法示例。


在下文中一共展示了Inventory::updateOrDeleteEquipment方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionSetCombatPoints


//.........這裏部分代碼省略.........
                                                     $from_knight_round_data->status = RoundsData::STATUS_INJURIED;
                                                     $from_knight->pain = Rounds::getPainByInjuryType($from_knight_round_data->injury_type);
                                                 }
                                                 if ($to_knight->endurance < 0) {
                                                     Yii::trace('[CHARACTER][actionSetCombatPoints] to knight is injuried');
                                                     //Fall is obligatory
                                                     $to_knight_round_data->is_falled = 1;
                                                     //Load pain from new injury
                                                     $to_knight_round_data->injury_type = Rounds::getInjuryType($to_knight->life, $to_knight_total_damage - $to_knight_round_data->knights_endurance);
                                                     $to_knight_round_data->status = RoundsData::STATUS_INJURIED;
                                                     $to_knight->pain = Rounds::getPainByInjuryType($to_knight_round_data->injury_type);
                                                 }
                                                 //Check final status of this round
                                                 $round = Rounds::model()->find('combats_id = :combats_id AND number = :number', array(':combats_id' => $combat->id, ':number' => count($combat->rounds)));
                                                 if ($from_knight_round_data->is_falled == $to_knight_round_data->is_falled) {
                                                     //Both are falled or not
                                                     $round->status = Rounds::STATUS_DRAW;
                                                     Yii::trace('[CHARACTER][actionSetCombatPoints] FINAL STATUS ROUND: DRAW');
                                                 } else {
                                                     //One is falled and other is standing
                                                     if ($from_knight_round_data->is_falled) {
                                                         $round->status = Rounds::STATUS_TO_KNIGHT_WIN;
                                                         Yii::trace('[CHARACTER][actionSetCombatPoints] FINAL STATUS ROUND: TO KNIGHT WIN');
                                                     } else {
                                                         $round->status = Rounds::STATUS_FROM_KNIGHT_WIN;
                                                         Yii::trace('[CHARACTER][actionSetCombatPoints] FINAL STATUS ROUND: FROM KNGHT WIN');
                                                     }
                                                 }
                                                 /*
                                                  * UPDATE ROUND
                                                  */
                                                 //Update equipment
                                                 Yii::trace('[CHARACTER][actionSetCombatPoints] UPDATE EQUIPMENT');
                                                 Inventory::updateOrDeleteEquipment($from_knight_equipment['armour_object']);
                                                 Inventory::updateOrDeleteEquipment($from_knight_equipment['shield_object']);
                                                 Inventory::updateOrDeleteEquipment($from_knight_equipment['spear_object']);
                                                 Inventory::updateOrDeleteEquipment($to_knight_equipment['armour_object']);
                                                 Inventory::updateOrDeleteEquipment($to_knight_equipment['shield_object']);
                                                 Inventory::updateOrDeleteEquipment($to_knight_equipment['spear_object']);
                                                 //Update round_data
                                                 if (!$from_knight_round_data->save()) {
                                                     Yii::trace('[CHARACTER][actionSetCombatPoints] ERROR TO SAVE FROM KNIGHT ROUND DATA', 'error');
                                                 }
                                                 if (!$to_knight_round_data->save()) {
                                                     Yii::trace('[CHARACTER][actionSetCombatPoints] ERROR TO SAVE TO KNIGHT ROUND DATA', 'error');
                                                 }
                                                 //Round
                                                 Yii::trace('[CHARACTER][actionSetCombatPoints] UPDATE ROUND');
                                                 if (!$round->save()) {
                                                     Yii::trace('[CHARACTER][actionSetCombatPoints] ERROR TO UPDATE ROUND', 'warning');
                                                 }
                                                 /*
                                                  * STATS
                                                  */
                                                 $from_knight_stats = KnightsStats::model()->findByPk($from_knight->id);
                                                 $to_knight_stats = KnightsStats::model()->findByPk($to_knight->id);
                                                 $from_knight_stats_vs = KnightsStatsVs::model()->find('knights_id = :knights_id AND opponent = :opponent', array(':knights_id' => $from_knight->id, ':opponent' => $to_knight->id));
                                                 $to_knight_stats_vs = KnightsStatsVs::model()->find('knights_id = :knights_id AND opponent = :opponent', array(':knights_id' => $to_knight->id, ':opponent' => $from_knight->id));
                                                 $from_knight_stats_by_date = KnightsStatsByDate::model()->find('knights_id = :knights_id AND date = :date', array(':knights_id' => $from_knight->id, ':date' => substr($combat->date, 0, 10)));
                                                 $to_knight_stats_by_date = KnightsStatsByDate::model()->find('knights_id = :knights_id AND date = :date', array(':knights_id' => $to_knight->id, ':date' => substr($combat->date, 0, 10)));
                                                 if (!$from_knight_stats_by_date) {
                                                     $from_knight_stats_by_date = new KnightsStatsByDate();
                                                     $from_knight_stats_by_date = array('knights_id' => $combat->fromKnight->id, 'date' => date('Y-m-d'));
                                                 }
                                                 if (!$to_knight_stats_by_date) {
                                                     $to_knight_stats_by_date = new KnightsStatsByDate();
開發者ID:RubenDjOn,項目名稱:medieval-jousting-tournaments,代碼行數:67,代碼來源:CharacterController.php


注:本文中的Inventory::updateOrDeleteEquipment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。