getSelfMysql(), 't_hero', array( 'accountid' => myself()->getAccountId(), 'hero_id' => $heroId, ) ); return $row; } public static function toDto($row) { return array( 'hero_id' => $row['hero_id'], 'hero_lv' => $row['hero_lv'], 'skin_id' => $row['skin_id'], 'skill1_lv1' => $row['skill1_lv1'], 'skill1_lv2' => $row['skill1_lv2'], 'yoke_lv' => $row['yoke_lv'], 'yoke_exp' => $row['yoke_exp'], ); } public static function addHero($heroMeta) { $defSkin = mt\Hero::getDefaultSkin($heroMeta); SqlHelper::upsert( myself()->getSelfMysql(), 't_hero', array( 'accountid' => myself()->getAccountId(), 'hero_id' => $heroMeta['id'] ), array( ), array( 'accountid' => myself()->getAccountId(), 'hero_id' => $heroMeta['id'], 'hero_lv' => 1, 'skin_id' => $defSkin, 'skill1_lv1' => 1, 'skill1_lv2' => 1, 'yoke_lv' => 0, 'yoke_exp' => 0, 'createtime' => myself()->getNowTime(), 'modifytime' => myself()->getNowTime() ) ); if ($defSkin) { HeroSkin::addSkin($defSkin); } } public static function takeonSkin($heroId, $skinId) { SqlHelper::update( myself()->getSelfMysql(), 't_hero', array( 'accountid' => myself()->getAccountId(), 'hero_id' => $heroMeta['id'] ), array( 'skin_id' => $skinId, 'modifytime' => myself()->getNowTime() ) ); } public static function upgradeSkill($heroId, $skillIdx) { if (!in_array($skillIdx, array(0, 1))) { return; } $fieldName = 'skill1_lv' . ($skillIdx + 1); SqlHelper::update( myself()->getSelfMysql(), 't_hero', array( 'accountid' => myself()->getAccountId(), 'hero_id' => $heroId ), array( $fieldName => function () use($fieldName) { return "${fieldName} + 1"; }, 'modifytime' => myself()->getNowTime() ) ); } }