protected function _exec() { $enemyId = $this->getParam('enemyId', 'string'); $battletype = $this->getParam('battletype', 'string'); $heroId = $this->getParam('heroid', 'int'); $battleStar = $this->getParam('battleStar', 'int'); $battleMgr = new BattleManager(); $cacheInfo = $battleMgr->getBattleCache($heroId); if (!empty($cacheInfo)) { $cacheInfoArr = explode(":", $cacheInfo); if ($cacheInfoArr[2] == 1) { $this->throwException("battle has get rewards"); } } $battleMgr->setBattleCache($heroId, $enemyId, $battletype, 1); //Elite Ordinary if ($battleStar > 0 && $battleStar <= 3) { $rateHeroMgr = new RatingHeroManager(); $enemyScore = $rateHeroMgr->getHeroRate($enemyId); $addScore = $battleStar * 10; $rateHeroMgr->addHeroRate($heroId, $addScore); return array("score" => $addScore); } return FALSE; }
protected function _exec() { $specId = $this->getParam('specId', 'string'); $battletype = $this->getParam('battletype', 'string'); $characterId = $this->getParam('heroid', 'int'); $isHelp = $this->getParam('isHelp', 'bool'); //power $hero_mgr = new CharacterAccountManager(); $hero_info = $hero_mgr->getCharacterAccount($characterId); $new_hero_info = StaticFunction::resetCurPower($hero_info); $cur_power = $new_hero_info['power']; if ($cur_power < StaticFunction::$power_battle_cost) { $this->throwException("power is not enough ,cur power = {$cur_power} "); } else { $heroChange = array('power' => $cur_power - StaticFunction::$power_battle_cost, 'powertime' => $new_hero_info['powertime']); $hero_mgr->updateUserStatus($characterId, $heroChange); $battleMgr = new BattleManager(); $battleMgr->setBattleCache($characterId, $specId, $battletype, 0); if ($isHelp === TRUE) { $item_mgr = new UserGameItemManager($characterId); $item_mgr->subItem("80002", 1); $item_mgr->checkReduceItemCount(); $item_mgr->commitToDB(); } return $heroChange; } }
protected function _exec() { $gameuid = $this->getParam('gameuid', 'int'); $specId = $this->getParam('specId', 'string'); $battletype = $this->getParam('battletype', 'string'); $heroId = $this->getParam('heroid', 'int'); $rewards = $this->getParam('battlerewards', 'array'); $battleStar = $this->getParam('battleStar', 'int'); $battleMgr = new BattleManager(); $cacheInfo = $battleMgr->getBattleCache($heroId); if (!empty($cacheInfo)) { $cacheInfoArr = explode(":", $cacheInfo); if ($cacheInfoArr[2] == 1) { $this->throwException("battle has get rewards"); } } $battleMgr->setBattleCache($heroId, $specId, $battletype, 1); $heroMgr = new CharacterAccountManager(); $itemMgr = new UserGameItemManager($heroId); foreach ($rewards as $oneReward) { if ($oneReward['item_id'] == 'coin') { $userMgr = new UserAccountManager(); $userMgr->updateUserCoin($gameuid, $oneReward['count']); } else { if ($oneReward['item_id'] == 'exp') { $heroMgr->updateUserExperience($heroId, $oneReward['count']); } else { $itemMgr->addItem($oneReward['item_id'], $oneReward['count']); $itemMgr->commitToDB(); } } } //Elite Ordinary if ($battleStar > 0 && $battleStar <= 3) { if ($battletype == "Ordinary") { $newItemId = $specId; } else { $newItemId = 100000 + intval($specId); } $itemInfo = $itemMgr->getItem($newItemId); if (empty($itemInfo)) { $itemMgr->addItem($newItemId, $battleStar); } else { $oldC = $itemInfo['count']; if ($oldC < $battleStar) { $itemMgr->addItem($newItemId, $battleStar - $oldC); } } $itemMgr->commitToDB(); } return TRUE; }
protected function _exec() { $characterId = $this->getParam('heroid', 'int'); $clanID = $this->getParam('clanId', 'int'); $userClanMgr = new UserClanManager(); $userclaninfo = $userClanMgr->getUserClanInfo($characterId); if (empty($userclaninfo) || $userclaninfo['bossTime'] > time()) { $this->throwException("hero has attack boss today "); } $bossMgr = new ClanBossManager(); $boosInfo = $bossMgr->getCurClanBoss(); $curTime = $boosInfo['Date']; //power $hero_mgr = new CharacterAccountManager(); $hero_info = $hero_mgr->getCharacterAccount($characterId); $new_hero_info = StaticFunction::resetCurPower($hero_info); $cur_power = $new_hero_info['power']; if ($cur_power < StaticFunction::$power_battle_cost) { $this->throwException("power is not enough ,cur power = {$cur_power} "); } else { $heroChange = array('power' => $cur_power - StaticFunction::$power_battle_cost, 'powertime' => $new_hero_info['powertime']); $rateMgr = new RatingClanManager(); $clanRateInfo = $rateMgr->getClanRate($clanID); if (empty($clanRateInfo)) { $newclanRate = array('id' => $clanID, 'date' => $curTime, 'level' => 1, 'kills' => 0); $rateMgr->addNewClanRate($clanID, $newclanRate); } else { if ($clanRateInfo['date'] == $curTime) { $newclanRate = $clanRateInfo; } else { $newclanRate = array('id' => $clanID, 'date' => $curTime, 'level' => 1, 'kills' => 0); $rateMgr->updateClanRate($clanID, $newclanRate); } } $battleMgr = new BattleManager(); $battleMgr->setBattleCache($characterId, $curTime, 1, 0); $hero_mgr->updateUserStatus($characterId, $heroChange); //bossTime $userclaninfo['bossTime'] = strtotime("next day"); $userClanMgr->updateUserClan($userclaninfo); $heroChange['clanRateInfo'] = $newclanRate; $heroChange['bossData'] = $boosInfo; return $heroChange; } }
protected function _exec() { $enemyId = $this->getParam('enemyId', 'string'); $characterId = $this->getParam('heroid', 'int'); $hero_mgr = new CharacterAccountManager(); $hero_info = $hero_mgr->getCharacterAccount($characterId); $vipLevel = StaticFunction::expToVip($hero_info['vip']); $vipDATA = StaticFunction::$VipList[$vipLevel]; $maxPkCOUNT = $vipDATA['pkAddCount']; $cacheInfo = $hero_mgr->getVipCache($characterId); $usedCount = 0; if (!empty($cacheInfo) && $cacheInfo['time'] > time()) { $usedCount = $cacheInfo['pkAddCount']; $newCacheInfo = $cacheInfo; } else { $newCacheInfo['time'] = strtotime(date("Y-m-d", strtotime("+1 day"))); } $newCacheInfo['pkAddCount'] = $usedCount + 1; if ($maxPkCOUNT <= $usedCount) { $this->throwException("pk too much used {$usedCount} , total = {$maxPkCOUNT}"); } else { $new_hero_info = StaticFunction::resetCurPower($hero_info); $cur_power = $new_hero_info['power']; if ($cur_power < StaticFunction::$power_battle_cost) { $this->throwException("power is not enough ,cur power = {$cur_power} "); } else { $heroChange = array('power' => $cur_power - StaticFunction::$power_battle_cost, 'powertime' => $new_hero_info['powertime']); $hero_mgr->updateUserStatus($characterId, $heroChange); $hero_mgr->setVipCache($characterId, $newCacheInfo); $battleMgr = new BattleManager(); $battleMgr->setBattleCache($characterId, $enemyId, 2, 0); $heroChange['vipCache'] = $newCacheInfo; return $heroChange; } } }
$ship2Quantity = isset($_POST['ship2_quantity']) ? $_POST['ship2_quantity'] : 1; if (!$ship1Name || !$ship2Name) { header('Location: /index.php?error=missing_data'); die; } if (!isset($ships[$ship1Name]) || !isset($ships[$ship2Name])) { header('Location: /index.php?error=bad_ships'); die; } if ($ship1Quantity <= 0 || $ship2Quantity <= 0) { header('Location: /index.php?error=bad_quantities'); die; } $ship1 = $ships[$ship1Name]; $ship2 = $ships[$ship2Name]; $battleManager = new BattleManager(); $battleResult = $battleManager->battle($ship1, $ship1Quantity, $ship2, $ship2Quantity); ?> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>OO Battleships</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> <link href='http://fonts.googleapis.com/css?family=Audiowide' rel='stylesheet' type='text/css'>