本文整理汇总了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();