game2006api/webapp/models/HeroPreset.php
hujiabin a18bc42a28 1
2024-04-29 11:27:59 +08:00

88 lines
2.6 KiB
PHP

<?php
namespace models;
require_once('mt/Skill.php');
use mt;
use phpcommon;
use phpcommon\SqlHelper;
class HeroPreset extends BaseModel {
public static function getHeroPreset($heroUid){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_hero_preset',
array(
'account_id' => myself()->_getAccountId(),
'hero_uid' => $heroUid,
)
);
if ($row){
$data = array(
'skill_id' => $row['skill_id'],
'weapon_uid1' => $row['weapon_uid1'],
'weapon_uid2' => $row['weapon_uid2'],
'chip_page' => $row['chip_page'],
'gun_id1'=>0,
'gun_id2'=>0,
);
$gunDb1 = Gun::find($row['weapon_uid1']);
$gunDb2 = Gun::find($row['weapon_uid2']);
if ($gunDb1){
$data['gun_id1'] = $gunDb1['gun_id'];
$data['gun_lv1'] = $gunDb1['gun_lv'];
}
if ($gunDb2){
$data['gun_id2'] = $gunDb2['gun_id'];
$data['gun_lv2'] = $gunDb2['gun_lv'];
}
}else{
$data = array(
'skill_id' => mt\Skill::getDefSkill(),
'weapon_uid1' => 0,
'weapon_uid2' => 0,
'gun_id1'=>0,
'gun_id2'=>0,
'chip_page' => 1,
);
}
return $data;
}
public static function upsertPreset($heroId,$skillId,$chipPageId,$weaponUid1,$weaponUid2){
SqlHelper::upsert
(myself()->_getSelfMysql(),
't_hero_preset',
array(
'account_id' => myself()->_getAccountId(),
'hero_uid' => $heroId,
),
array(
'skill_id' => $skillId,
'weapon_uid1' => $weaponUid1,
'weapon_uid2' => $weaponUid2,
'chip_page' => $chipPageId,
'modifytime' => myself()->_getNowTime(),
),
array(
'account_id' => myself()->_getAccountId(),
'hero_uid' => $heroId,
'skill_id' => $skillId,
'weapon_uid1' => $weaponUid1,
'weapon_uid2' => $weaponUid2,
'chip_page' => $chipPageId,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
public static function upsertPresetNew($heroId,$skillId){
self::upsertPreset($heroId, $skillId, 0, 0, 0);
}
}