Пример #1
0
$_data = $_country_handle->use_collection(NameMapper::get_country_uid_list_collection_name())->find();
//如果报名的人数不够则 不再进行国战
if ($_data->count() <= Player_Const::COUNTRY_BATTLE_GROUP_MAX_NUM / 2 || $_data->count() <= Player_Const::COUNTRY_BATTLE_GROUP_MAX_NUM / 2 && $battle_num == Player_Const::COUNTRY_BATTLE_GROUP_MAX_NUM / 2) {
    echo "plase user num  lt COUNTRY_BATTLE_GROUP_MAX_NUM/2";
    exit;
}
foreach ($_data as $r) {
    print_r($r);
}
if ($battle_num == Player_Const::COUNTRY_BATTLE_GROUP_MAX_NUM / 2) {
    $_country_handle->use_collection(NameMapper::get_country_uid_list_collection_name())->createIndex(array('uid' => 1), array('unique' => true));
    $_country_handle->use_collection(NameMapper::get_country_samurai_collection_name())->createIndex(array('uid' => 1), array('unique' => true));
    $_country_handle->use_collection(NameMapper::get_country_family_collection_name())->createIndex(array('uid' => 1), array('unique' => true));
    $_country_handle->use_collection(NameMapper::get_country_vassal_collection_name())->createIndex(array('uid' => 1), array('unique' => true));
    $_country_handle->use_collection(NameMapper::get_country_backpack_collection_name())->createIndex(array('uid' => 1), array('unique' => true));
    $_country_handle->use_collection(NameMapper::get_country_hp_collection_name())->createIndex(array('uid' => 1), array('unique' => true));
}
$_data = $_country_handle->use_collection(NameMapper::get_country_uid_list_collection_name())->find(array('rank' => (int) $battle_num * 2, 'battle_num' => (int) $battle_num * 2));
$count = $_data->count();
$count = ceil($count / 2);
if (empty($count)) {
    echo 'Error count:', $count, PHP_EOL;
    exit;
}
$uid = 'de721bcef5cba1fc182d186d98afe072';
list($player, $ret) = Player::instance($uid);
$player_country_handle = $player->get_player_class_handle('country');
for ($i = $count; $i > 0; $i--) {
    $player_country_handle->attack($battle_num);
}
echo date("Y-m-d H:i:s") . "|cron_start_country end \n";
Пример #2
0
                $temp_player_tmp_backpack_handle = $player->get_player_class_handle('tmpbackpack');
                if ($player) {
                    $bonus_list = array();
                    if (isset($bonus[$data['rank']])) {
                        foreach ($bonus[$data['rank']]['bonus'] as $bval) {
                            $temp_player_tmp_backpack_handle->add_item($bval['id'], $bval['number'], 'country_bonus');
                        }
                    }
                }
                //如果此人第一,将起加入到当天国战中
                if ($data['rank'] == 1) {
                    $player_country_handle = $player->get_player_class_handle('country');
                    $times = date('Ymd', strtotime($player_country_handle->_counrty_week_str[Player_Const::COUNTRY_BATTLE_WEEK], NOWTIME));
                    $userinfo = $player_country_handle->get_country_user_list(array('uid' => $data['uid']));
                    $userinfo = $userinfo[0];
                    $userinfo['player_detail'] = $player_country_handle->player_detail($data['uid']);
                    $country_data = $_country_handle->use_collection(NameMapper::get_country_info_collection_name())->update(array('times' => (string) $times), array('$set' => array('top' => serialize($userinfo), 'status' => 1)));
                    Logger::error('$times:' . $times . 'top:' . serialize($userinfo));
                    echo date('Y-m-d H:i:s'), '$times:' . $times;
                    $lasttimes = date('Ymd', strtotime("last " . $player_country_handle->_counrty_week_str[Player_Const::COUNTRY_BATTLE_WEEK], NOWTIME));
                    $_country_handle->use_collection(NameMapper::get_country_info_collection_name())->update(array('times' => (string) $lasttimes), array('$set' => array('top' => array())));
                    Logger::error('$lasttimes:' . $lasttimes);
                    echo '$lasttimes:' . $lasttimes;
                }
            }
        }
    } else {
        echo 'error 1', PHP_EOL;
    }
}
echo date("Y-m-d H:i:s") . "|cron_country_bonus end \n";
Пример #3
0
    //Backup
    error_log("\r\n rank_content:" . json_encode($last_rank_list), 3, $logfile);
    $redis_handle->hMset(NameMapper::get_arena_challenge_week_bonus_history_redis_key(), $last_rank_list);
    $backup_challenge_rank_list_expire_result = $redis_handle->expire(NameMapper::get_arena_challenge_week_bonus_history_redis_key(), Player_Const::ARENA_CHALLENGE_WEEK_RANK_BONUS_HISTORY_EXPIRE);
    //发放竞技场Challenge前500名奖励物品
    $current_challenge_week_bonus_config = $system_rank_handle->get_current_challenge_week_bonus_config();
    foreach ($last_rank_list as $temp_rank => $temp_uid) {
        $temp_rank = $temp_rank + 1;
        //Rank 1 => Celebrity
        if ($temp_rank == 1) {
            $celebrity_player = $redis_handle->set(NameMapper::get_arena_challenge_week_celebrity_redis_key(), $temp_uid);
        }
        $temp_bonus = $system_rank_handle->get_current_challenge_week_bonus_data($temp_rank, $current_challenge_week_bonus_config);
        list($temp_player_handle, $instance_failure_message) = Player::make($temp_uid);
        if ($temp_player_handle) {
            $temp_player_tmp_backpack_handle = $temp_player_handle->get_player_class_handle('tmpbackpack');
            $bonus = array();
            foreach ($temp_bonus as $bonus_data) {
                $bonus[] = array('item' => $bonus_data['id'], 'number' => $bonus_data['number']);
                list($add_item_result, $err_msg) = $temp_player_tmp_backpack_handle->add_item($bonus_data['id'], $bonus_data['number'], 'challengeweek:' + $temp_rank);
            }
            PlayerMessage::add_message($temp_uid, 14, array('battlerank' => $temp_rank));
            error_log("\r\n user:{$tmp_uid}, rank:{$temp_rank}, bonus:" . json_encode($bonus), 3, $logfile);
        }
    }
}
//修改本周竞技场Challenge前N名奖励物品配置 redis => arena_challenge_week_bonus_index
$system_rank_handle->set_current_challenge_week_bonus_config();
//update last challenge week rank bonus time
$redis_handle->set(NameMapper::get_arena_challenge_week_bonus_time_redis_key(), date('Y-m-d', time()));
error_log("\r\n end send bonus time:" . date("Y-m-d H:i:s"), 3, $logfile);