123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?php
- namespace loyalsoft;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- include_once __DIR__ . '/../../main.php';
- //taskDeal();
- textInterface();
- function taskDeal() {
- $db = daoInst();
- $zoneid = 1;
- $index = 0;
- $size = 20;
- $page = 0;
-
- $userUidArr = array();
- while (true) {
- $page = $index * $size;
- $sql = "select * from tab_rolename WHERE zoneid= $zoneid limit %d,%d";
- $queryStr = sprintf($sql, $page, $size);
- $result = $db->query($queryStr)->fetchAll();
-
- if(count($result) == 0){
- break;
- }
-
- foreach ($result as $arr) {
- foreach ($arr as $k=>$item) {
- if($k == "userID" && !in_array($item, $userUidArr)){
- $userUidArr[] = $item;
- }
-
- }
- }
-
- $index += 1;
- }
-
- startDeal($userUidArr);
-
- }
- /**
- * 测试接口 可以自己添加uid测试
- */
- function textInterface() {
- $userUidArr = array();
- //$userUidArr[] = "6347a46975d0a43de55f0cec";
- $userUidArr[] = "EA74E58DCEB076ACC2D824684499CDA2";
-
- startDeal($userUidArr);
- }
- /**
- * 开始处理玩家任务信息
- * @param type $userUidArr
- */
- function startDeal($userUidArr) {
- $mem = gMem();
- $weaponConf = GameConfig::weaponextra_level();
-
- foreach ($userUidArr as $userUid) {
- $userRedisKey = MemKey_User::Info_hash(1, $userUid);
- if(!$mem->exists($userRedisKey)){
- //$sFname = "savData/" ."noRedisExistUserUid.txt";
- $sFname = isOnline("otherData", "noRedisExistUserUid.txt");
- //$sFname = "../../../../../../ylsjTaskData/otherData/"."noRedisExistUserUid.txt";
- $fd = fopen($sFname, 'a');
- fwrite($fd, "\r\n" . $userRedisKey);
- fclose($fd);
- continue;
- }
-
- if(!$mem->hexists($userRedisKey,'privateState')){
- //$sFname = "savData/" ."noPrivateState.txt";
- //$sFname = "../../../../../../ylsjTaskData/otherData/"."noPrivateState.txt";
- $sFname = isOnline("otherData", "noPrivateState.txt");
- $fd = fopen($sFname, 'a');
- fwrite($fd, "\r\n" . $userRedisKey);
- fclose($fd);
- continue;
- }
-
- if(!$mem->hexists($userRedisKey,'store')){
- //$sFname = "savData/" ."noStore.txt";
- //$sFname = "../../../../../../ylsjTaskData/otherData/"."noStore.txt";
- $sFname = isOnline("otherData", "noStore.txt");
- $fd = fopen($sFname, 'a');
- fwrite($fd, "\r\n" . $userRedisKey);
- fclose($fd);
- continue;
- }
-
- $privateState = $mem->hget($userRedisKey, 'privateState');
- if(!StlUtil::dictHasProperty($privateState,'weapon_index')){
- $privateState->weapon_index = 0;
- }
- $startIndex = $privateState->weapon_index;
- if($startIndex > 0){
- continue;
- }
- $store = $mem->hget($userRedisKey, 'store');
- $equipment = $store->equipment;
-
- //处理前玩家数据保存
- taskSav_start($userRedisKey, $store, $privateState);
-
- $tempDic = new \stdClass();
- $index = 0;
- foreach ($equipment as $k => $item) {
- $typeId = $item->typeId;
-
- if(!StlUtil::dictHasProperty($weaponConf, $typeId)){
- $sFname = isOnline("otherData", "noConf.txt");
- $fd = fopen($sFname, 'a');
- fwrite($fd, "\r\n" . $typeId);
- fclose($fd);
- continue;
- }
-
- $lv = $item->level;
- $dic = $weaponConf->$typeId;
- $arr = (array)$dic;
- ksort($arr);
- foreach ($arr as $star => $val) {
- if($lv >= $val->starlimitLv){
- $item->starLevel = $val->starLv;
- }
- }
- $index += 1;
- $tempDic->$k = $item;
- $privateState->weapon_index = $index;
- }
-
- $store->equipment = $tempDic;
-
- taskSav_end($userRedisKey, $store, $privateState);
-
- //玩家数据回存
- gMem()->hset($userRedisKey, 'store', $store);
- gMem()->hset($userRedisKey, 'privateState', $privateState);
- }
-
- }
- /**
- * 保存数据地址 ----自己去方法里面设置 true或是false
- * @param type $g
- * @param type $name
- * @return string
- */
- function isOnline($g,$name) {
- $Online = false;
- $sFname = $name;
- if($Online){
- if($g == "start"){
- $sFname = "../../../../../../ylsjWeaponData/sav_start/".$name;
- } elseif ($g == "end") {
- $sFname = "../../../../../../ylsjWeaponData/sav_last/".$name;
- } else {
- $sFname = "../../../../../../ylsjWeaponData/otherData/".$name;
- }
- } else {
- $sFname = "savData/". $name;
- }
- return $sFname;
- }
- /**
- * 处理完后数据回存
- * @param type $userUid
- * @param type $store
- * @param type $privateState
- * @param type $hero
- */
- function taskSav_start($userUid,$store,$privateState) {
- $name = isOnline("start", $userUid."-pre.txt");
- $fd = fopen($name, 'a');
- fwrite($fd, json_encode($store)."\r\n");
- fwrite($fd, "\r\n" . json_encode($privateState)."\r\n");
- fclose($fd);
- }
- function taskSav_end($userUid,$store,$privateState) {
- //$name ="savData/". "$userUid"."-last.txt";
- //$name = "../../../../../../ylsjTaskData/sav_last/"."$userUid"."-last.txt";
- $name = isOnline("end", $userUid."-last.txt");
- $fd = fopen($name, 'a');
- fwrite($fd,"\r\n" . json_encode($store)."\r\n");
- fwrite($fd, "\r\n" . json_encode($privateState)."\r\n");
-
- fclose($fd);
- }
|