Example #1
0
<?php

//国战的奖励 顺便如果国战未开。也将其报名的小判归还
define('ROOT', dirname(__DIR__));
include ROOT . '/include/common.php';
Logger::set_name("cron_country_bonus");
echo date("Y-m-d H:i:s") . "|cron_country_bonus start \n";
//验证 是否存在国战中
$server_id = ConfigData::get('app|server_id', 1, TRUE);
$static_country_list = StaticData::read('country_list');
if (!isset($static_country_list[$server_id])) {
    echo "This server_id is no longer war in the country  \n";
    exit;
}
$_country_handle = new MongoFactory('country');
$_data = $_country_handle->use_collection(NameMapper::get_country_uid_list_collection_name())->find();
//如果报名的人数不够则 不再进行国战
if ($_data->count() <= Player_Const::COUNTRY_BATTLE_GROUP_MAX_NUM / 2) {
    $bonus = array('gold_buy' => Player_Const::COUNTRY_BATTLE_COST_NUM);
    //这里将 报名的小判归还玩家
    $_data = $_country_handle->use_collection(NameMapper::get_country_uid_list_collection_name())->find(array('server_id' => $server_id), array('uid' => true, 'server_id' => true, 'rank' => true));
    if ($_data->count()) {
        foreach ($_data as $data) {
            if ($data['server_id'] != $server_id) {
                continue;
            }
            if ($data['uid']) {
                $suid = explode("_", $data['uid']);
                $suid = end($suid);
                list($player, $ret) = Player::instance($suid);
                if ($player) {
Example #2
0
reset($scountry);
/*if(current($scountry) != $server_id){
    echo "This crontab  Return to normal\n";
    exit;
}*/
$argv = array_slice($_SERVER['argv'], 1);
if (empty($argv) || !isset($argv[0])) {
    echo "plase use php cron_start_country.php battle_num \n";
    exit;
}
$battle_num = (int) $argv[0];
if ($battle_num < 1 && $battle_num >= Player_Const::COUNTRY_BATTLE_GROUP_MAX_NUM / 2) {
    echo "plase battle_num gt COUNTRY_BATTLE_GROUP_MAX_NUM \n";
    exit;
}
$_country_handle = new MongoFactory('country');
$_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));