54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
require_once('models/Hero.php');
|
|
require_once('models/HeroSkin.php');
|
|
|
|
use models\Hero;
|
|
use models\HeroSkin;
|
|
class HeroSkinController extends BaseAuthedController {
|
|
|
|
public function skinList()
|
|
{
|
|
$skinList = array();
|
|
HeroSkin::getSkinList(function ($row) use(&$skinList) {
|
|
array_push($heroList,$row);
|
|
});
|
|
$this->_rspData(array(
|
|
'skin_list' => $skinList
|
|
));
|
|
}
|
|
|
|
public function takeonSkin()
|
|
{
|
|
$heroUniId = getReqVal('hero_uniid', 0);
|
|
$skinUniId = getReqVal('skin_uniid', 0);
|
|
$heroDb = Hero::find($heroUniId);
|
|
$heroSkinDb = HeroSkin::find($skinUniId);
|
|
if (!$heroDb) {
|
|
$this->_rspErr(1, "You don't have the hero yet");
|
|
return;
|
|
}
|
|
|
|
if (!$heroSkinDb) {
|
|
$this->_rspErr(1, "You don't have the skin yet");
|
|
return;
|
|
}
|
|
Hero::update( $heroUniId,array(
|
|
'skin_id' => $skinUniId
|
|
));
|
|
$this->_rspOk();
|
|
}
|
|
|
|
public function unequip(){
|
|
$heroUniId = getReqVal('hero_uniid', 0);
|
|
$heroDb = Hero::find($heroUniId);
|
|
if (!$heroDb) {
|
|
$this->_rspErr(1, "You don't have the hero yet");
|
|
return;
|
|
}
|
|
Hero::update( $heroUniId,array(
|
|
'skin_id' => 0
|
|
));
|
|
$this->_rspOk();
|
|
}
|
|
|
|
} |