diff --git a/webapp/classes/Quest.php b/webapp/classes/Quest.php index 33622fa..0a21458 100644 --- a/webapp/classes/Quest.php +++ b/webapp/classes/Quest.php @@ -21,7 +21,7 @@ class Quest{ protected function getQuest($quest_id) { - $g_conf_quest_cluster = require('../config/game2001api.quest.cluster.php'); + $g_conf_quest_cluster = require('../config/game2001api.task.cluster.php'); $quest_conf = getQuestConfig($g_conf_quest_cluster, $quest_id); $q = array( 'id' => $quest_conf['id'], diff --git a/webapp/controller/EquipController.class.php b/webapp/controller/EquipController.class.php index 43eb403..40625b5 100644 --- a/webapp/controller/EquipController.class.php +++ b/webapp/controller/EquipController.class.php @@ -114,10 +114,21 @@ class EquipController{ phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备'); return; } - if ($e['equip_cost'] > $coin_num) { - phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); - return; + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if ($row['coin_num'] < $e['equip_cost']) { + phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); + return; } + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':coin_num' => $row['coin_num'] - $e['equip_cost'] + )); + $row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND equip_id=:equip_id;', array( ':account_id' => $account_id, diff --git a/webapp/controller/HangController.class.php b/webapp/controller/HangController.class.php index d497a6a..22ef12f 100644 --- a/webapp/controller/HangController.class.php +++ b/webapp/controller/HangController.class.php @@ -49,11 +49,15 @@ class HangController{ if ($weight != 0) { $num = $num * 3; } + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, - ':coin_num' => $num + ':coin_num' => $num + $row['coin_num'] )); } echo json_encode(array( diff --git a/webapp/controller/QuestController.class.php b/webapp/controller/QuestController.class.php index 36fc8bf..d0fc6d4 100644 --- a/webapp/controller/QuestController.class.php +++ b/webapp/controller/QuestController.class.php @@ -19,7 +19,7 @@ class QuestController{ protected function getQuest($quest_id) { - $g_conf_quest_cluster = require('../config/game2001api.quest.cluster.php'); + $g_conf_quest_cluster = require('../config/game2001api.task.cluster.php'); $quest_conf = getQuestConfig($g_conf_quest_cluster, $quest_id); $q = array( 'id' => $quest_conf['id'], @@ -347,11 +347,15 @@ class QuestController{ 'item_num' => $item_num, )); if ($item_id == 10001) { + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, - ':coin_num' => $item_num + ':coin_num' => $item_num + $row['coin_num'] )); } } else { @@ -365,7 +369,7 @@ class QuestController{ ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, - ':coin_num' => $reward + ':coin_num' => $reward + $row['coin_num'] )); } if ($row['quest_type'] == 1) { diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index e63a032..e9b99e7 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -31,7 +31,7 @@ class RoleController{ )); if (!$row) { $ret = $conn->execScript('INSERT INTO user(accountid, rank, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his) ' . - ' VALUES(:accountid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);', + ' VALUES(:accountid, 0, 0, 0, 0, 0, 0, 0, 100000, 0, 0, 0, 0, 0);', array( ':accountid' => $account_id )); @@ -50,7 +50,7 @@ class RoleController{ 'harm' => 0, 'add_HP' => 0, 'alive_time' => 0, - 'coin_num' => 0, + 'coin_num' => 100000, )); } else { echo json_encode(array( diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index 74b933a..ce5a186 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -19,7 +19,7 @@ class SignController{ protected function getSign($sign_id) { - $g_conf_sign_cluster = require('../config/game2001api.sign.cluster.php'); + $g_conf_sign_cluster = require('../config/game2001api.signDaily.cluster.php'); $sign_conf = getSignConfig($g_conf_sign_cluster, $sign_id); $s = array( 'sign_id' => $sign_conf['sign_id'], @@ -92,11 +92,15 @@ class SignController{ $s = $this->getSign($sign_days % 7 + 90000); $item_id = $s['item_id']; $num = $s['num']; + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, - ':coin_num' => $num + ':coin_num' => $num + $row['coin_num'] )); //刷新每日任务 diff --git a/webapp/controller/SkinController.class.php b/webapp/controller/SkinController.class.php index f03bd70..0e4efda 100644 --- a/webapp/controller/SkinController.class.php +++ b/webapp/controller/SkinController.class.php @@ -17,16 +17,16 @@ class SkinController{ protected function getSkin($skin_id) { - $g_conf_skin_cluster = require('../config/game2001api.skin.cluster.php'); + $g_conf_skin_cluster = require('../config/game2001api.dress.cluster.php'); $skin_conf = getSkinConfig($g_conf_skin_cluster, $skin_id); $s = array( - 'skin_id' => $skin_conf['skin_id'], - 'skin_name' => $skin_conf['skin_name'], - 'skin_skillid' => $skin_conf['skin_skillid'], - 'skin_compose' => $skin_conf['skin_compose'], - 'skin_experience' => $skin_conf['skin_experience'], - 'skin_price' => $skin_conf['skin_price'] + 'skin_id' => $skin_conf['id'], + 'skin_name' => $skin_conf['name'], + 'skin_skillid' => $skin_conf['skill_id'], + 'skin_compose' => $skin_conf['compose'], + 'skin_experience' => $skin_conf['is_experience'], + 'skin_price' => $skin_conf['price'] ); return $s; } @@ -153,10 +153,21 @@ class SkinController{ $fragment_num = $row['frgment_num'] - $s['skin_compose']; }else{ $coin = $s['skin_price'] * 1.0 / $s['skin_compose'] * ($s['skin_compose'] - $row['frgment_num']); - if($coin_num < $coin){ - phpcommon\sendError(ERR_USER_BASE + 2, '金币不足'); + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if ($row['coin_num'] < $coin) { + phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); return; } + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':coin_num' => $row['coin_num'] - $coin + )); + $fragment_num = 0; } $ret = $conn->execScript('UPDATE skin SET frgment_num=:frgment_num ,skin_status=1 ' . diff --git a/webapp/controller/SupplyBoxController.class.php b/webapp/controller/SupplyBoxController.class.php index ce5a27d..b3399f1 100644 --- a/webapp/controller/SupplyBoxController.class.php +++ b/webapp/controller/SupplyBoxController.class.php @@ -19,7 +19,7 @@ class SupplyBoxController{ protected function getSupplyBox($box_id) { - $g_conf_supply_cluster = require('../config/game2001api.supplybox.cluster.php'); + $g_conf_supply_cluster = require('../config/game2001api.supply.cluster.php'); $supply_conf = getSupplyConfig($g_conf_supply_cluster, $box_id); $s = array( 'id' => $supply_conf['id'], @@ -201,12 +201,16 @@ class SupplyBoxController{ 'item_num' => $item_num, )); if ($item_id == 10001) { + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':coin_num' => $item_num - )); + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':coin_num' => $item_num + $row['coin_num'] + )); } $quest = new classes\Quest(); $quest->triggerQuest(71004, 1, 1, $account_id); @@ -239,10 +243,20 @@ class SupplyBoxController{ ':box_id' => $box_id )); if (!$row) { - if ($coin_num < $s['price']) { + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if ($row['coin_num'] < $s['price']) { phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); return; } + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':coin_num' => $row['coin_num'] - $s['price'] + )); $ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times, last_buy_time) ' . ' VALUES(:accountid, :box_id, :box_num, :buy_times, :last_buy_time);', array( @@ -257,10 +271,20 @@ class SupplyBoxController{ return; } } else { - if ($coin_num < $s['price'] * pow($s['parameter'], ($row['box_num'] - 1))) { + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if ($row['coin_num'] < $s['price'] * pow($s['parameter'], ($row['box_num'] - 1))) { phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); return; } + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':coin_num' => $row['coin_num'] - ($s['price'] * pow($s['parameter'], ($row['box_num'] - 1))) + )); $buy_times = $row['buy_times'] + 1; $box_num = $row['box_num'] + 1; $ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num, buy_times=:buy_times, last_buy_time=:time ' .