This commit is contained in:
aozhiwei 2021-11-26 13:44:00 +08:00
parent cb6b43f294
commit 33607dc617
11 changed files with 0 additions and 830 deletions

View File

@ -1,106 +0,0 @@
<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getActExplode($string)
{
$delim = "|";
$drop_multiply = explode($delim, $string);
$delim1 = ":";
$arr = array();
for ($i = 0; $i < count($drop_multiply); $i++) {
$mul = explode($delim1, $drop_multiply[$i]);
array_push($arr, $mul);
}
return $arr;
}
function getActivityConf()
{
return _internalGetActivityConf();
}
function getActivityById($act_id)
{
$conf = getActivityConf();
$act_id = (int)$act_id;
return array_key_exists($act_id, $conf) ? $conf[$act_id] : null;
}
function _internalGetActivityConf()
{
global $g_act_table;
if (!$g_act_table) {
$g_act_table = require(getConfigBaseDir() . 'activity@activity.php');
}
return $g_act_table;
}
function getNowActivity()
{
$conf = getActivityConf();
for ($i = 1; $i <= count($conf); $i++) {
$act = getActivityById($i);
if (phpcommon\getNowTime() >= strtotime($act['time1']) && phpcommon\getNowTime() <= strtotime($act['time2'])) {
return $act;
}
}
return null;
}
function getActInfo($act_conf)
{
$info_list = array();
$conditions = getActExplode($act_conf['condition']);
for ($i = 0; $i < count($conditions); $i++) {
array_push($info_list,array(
'id' => $i,
'status' => 0,
'times' => 0,
'type' => $conditions[$i][0],
'condition' => $conditions[$i][1],
));
}
return $info_list;
}
function getRewardInfo($act_id, $id, $type)
{
$act_conf = getActivityById($act_id);
if (!$act_conf) {
return null;
}
$items = explode('|', $act_conf['reward']);
if ($type == 1) {
if (empty($act_conf['extra_reward'])) {
return null;
}
$items = explode('|', $act_conf['extra_reward']);
}
$arr = array();
for ($i = 0; $i < count($items); $i++) {
$mul = explode(';', $items[$i]);
array_push($arr, $mul);
}
$arr2 = array();
$str = $arr[$id];
for ($i = 0; $i < count($str); $i++) {
$mul = explode(':', $str[$i]);
array_push($arr2, $mul);
}
return $arr2;
}

View File

@ -1,93 +0,0 @@
<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getActPlusConf()
{
return _internalGetActPlusConf();
}
function getActPlusById($act_id)
{
$conf = getActPlusConf();
$act_id = (int)$act_id;
return array_key_exists($act_id, $conf) ? $conf[$act_id] : null;
}
function _internalGetActPlusConf()
{
global $g_act_table;
if (!$g_act_table) {
$g_act_table = require(getConfigBaseDir() . 'activityplus@activityplus.php');
}
return $g_act_table;
}
function getActPlusInfo($type)
{
$conf = getActPlusConf();
$info_list = array();
for ($i = 1; $i <= count($conf); $i++) {
$act = getActPlusById($i);
if ($act['type'] != $type) {
continue;
}
array_push($info_list, array(
'id' => $act['id'],
));
}
return $info_list;
}
class ActivityPlus
{
public static function get($id)
{
return self::getMeta()[$id];
}
public static function getCondIdx($actMeta, $cond)
{
$condConf = explode('|', $actMeta['condition']);
$idx = 0;
foreach ($condConf as $c) {
if ($c == $cond) {
return $idx;
}
++$idx;;
}
return -1;
}
public static function getReward($actMeta, $condIdx)
{
$rewardConf = explode('|', $actMeta['reward']);
return $rewardConf[$condIdx];
}
protected static function getMeta()
{
if (!self::$meta) {
self::$meta = getMetaTable('activityplus@activityplus.php');
}
return self::$meta;
}
private static $meta = null;
}

View File

@ -1,26 +0,0 @@
<?php
namespace metatable;
use phpcommon;
function getDrawConf()
{
return _internalGetDrawConf();
}
function getDrawById($draw_id)
{
$conf = getDrawConf();
$draw_id = (int)$draw_id;
return array_key_exists($draw_id, $conf) ? $conf[$draw_id] : null;
}
function _internalGetDrawConf()
{
global $g_draw_table;
if (!$g_draw_table) {
$g_draw_table = require(getConfigBaseDir() . 'draw@draw.php');
}
return $g_draw_table;
}

View File

@ -1,138 +0,0 @@
<?php
namespace metatable;
use phpcommon;
function getDropConf()
{
return _internalGetDropConf();
}
function getDropById($drop_id)
{
$conf = getDropConf();
$drop_id = (int)$drop_id;
return array_key_exists($drop_id, $conf) ? $conf[$drop_id] : null;
}
function getExplode($string)
{
$delim = "|";
$drop_multiply = explode($delim, $string);
$delim1 = ":";
$arr = array();
for ($i = 0; $i < count($drop_multiply); $i++) {
$mul = explode($delim1, $drop_multiply[$i]);
array_push($arr, $mul);
}
return $arr;
}
function _internalGetDropConf()
{
global $g_drop_table;
if (!$g_drop_table) {
$g_drop_table = require(getConfigBaseDir() . 'drop@drop.php');
}
return $g_drop_table;
}
function getDropAllListById($drop_id, $item_list)
{
$d = getDropById($drop_id);
if (!$d) {
return null;
}
$item_list = getDropInfo($d, $item_list);
return $item_list;
}
function getDropInfo($d, $item_list) {
$item_id_array = getExplode($d['item_id']);
$item_num_array = getExplode($d['num']);
$weight_array = getExplode($d['weight']);
$time_array = getExplode($d['time']);
if ($d['type'] == 1) {
for ($i = 0; $i < count($weight_array); $i++) {
$random = Rand(0, 10000);
if ($weight_array[$i][0] > $random) {
$item_id = $item_id_array[$i][0];
$item_num = $item_num_array[$i][0];
$time = 0;
if (!empty($time_array[$i][0]) && $time_array[$i][0] != '') {
$time = $time_array[$i][0];
}
array_push($item_list, array(
'item_id' => $item_id,
'item_num' => $item_num,
'time' => $time,
));
}
}
} else if ($d['type'] == 2) {
$weight_sum = 0;
$keys = 0;
for ($i = 0; $i < count($weight_array); $i++) {
$weight_sum += $weight_array[$i][0];
}
$random = Rand(0, $weight_sum);
$weight = 0;
for ($i = 0; $i < count($weight_array); $i++) {
$weight += $weight_array[$i][0];
if ($weight > $random) {
$keys = $i;
break;
}
}
$item_id = $item_id_array[$keys][0];
$item_num = $item_num_array[$keys][0];
$item_time = $time_array[$keys][0];
array_push($item_list, array(
'item_id' => $item_id,
'item_num' => $item_num,
'time' => $item_time,
));
}
return $item_list;
}
function getDropListById($drop_id)
{
$d = getDropById($drop_id);
if (!$d) {
return null;
}
$item_list = array();
$item_list = getDropInfo($d, $item_list);
return $item_list;
}
function getDropInfoById($drop_id)
{
$d = getDropById($drop_id);
if (!$d) {
return null;
}
$item_list = array();
$item_id_array = getExplode($d['item_id']);
$item_num_array = getExplode($d['num']);
$weight_array = getExplode($d['weight']);
$time_array = getExplode($d['time']);
for ($i = 0; $i < count($weight_array); $i++) {
$item_id = $item_id_array[$i][0];
$item_num = $item_num_array[$i][0];
$weight = $weight_array[$i][0];
$time = 0;
if (!empty($time_array[$i][0]) && $time_array[$i][0] != '') {
$time = $time_array[$i][0];
}
array_push($item_list, array(
'item_id' => $item_id,
'item_num' => $item_num,
'time' => $time,
'weight' => $weight,
));
}
return $item_list;
}

View File

@ -1,38 +0,0 @@
<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getEquipConf()
{
return _internalGetEquipConf();
}
function getEquipById($equip_id)
{
$conf = getEquipConf();
$equip_id = (int)$equip_id;
return array_key_exists($equip_id, $conf) ? $conf[$equip_id] : null;
}
function _internalGetEquipConf()
{
global $g_equip_table;
if (!$g_equip_table) {
$g_equip_table = require(getConfigBaseDir() . 'equip@equip.php');
}
return $g_equip_table;
}

View File

@ -1,26 +0,0 @@
<?php
namespace metatable;
use phpcommon;
function getItemConf()
{
return _internalGetItemConf();
}
function getItemById($item_id)
{
$conf = getItemConf();
$item_id = (int)$item_id;
return array_key_exists($item_id, $conf) ? $conf[$item_id] : null;
}
function _internalGetItemConf()
{
global $g_item_table;
if (!$g_item_table) {
$g_item_table = require(getConfigBaseDir() . 'item@item.php');
}
return $g_item_table;
}

View File

@ -1,37 +0,0 @@
<?php
namespace metatable;
use phpcommon;
function getParameterConf()
{
return _internalGetParameterConf();
}
function getParameterById($parameter_id)
{
$conf = getParameterConf();
$parameter_id = (int)$parameter_id;
return array_key_exists($parameter_id, $conf) ? $conf[$parameter_id] : null;
}
function getParameterByName($param_name)
{
$conf = getParameterConf();
foreach ($conf as $key => $val) {
if ($val['param_name'] == $param_name) {
return $val['param_value'];
}
}
return null;
}
function _internalGetParameterConf()
{
global $g_parameter_table;
if (!$g_parameter_table) {
$g_parameter_table = require(getConfigBaseDir() . 'parameter@parameter.php');
}
return $g_parameter_table;
}

View File

@ -1,63 +0,0 @@
<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getSeasonConf()
{
return _internalGetSeasonConf();
}
function getSeasonById($sea_id)
{
$conf = getSeasonConf();
$sea_id = (int)$sea_id;
return array_key_exists($sea_id, $conf) ? $conf[$sea_id] : null;
}
function _internalGetSeasonConf()
{
global $g_sea_table;
if (!$g_sea_table) {
$g_sea_table = require(getConfigBaseDir() . 'season@season.php');
}
return $g_sea_table;
}
function getNowSeason()
{
$conf = getSeasonConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeasonById($i);
if (phpcommon\getNowTime() >= strtotime($sea['time1']) && phpcommon\getNowTime() <= strtotime($sea['time2'])) {
return $sea;
}
}
return null;
}
function getNowSeasonNum()
{
$conf = getSeasonConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeasonById($i);
if (phpcommon\getNowTime() >= strtotime($sea['time1']) && phpcommon\getNowTime() <= strtotime($sea['time2'])) {
return $i;
}
}
return null;
}

View File

@ -1,124 +0,0 @@
<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getSeacardConf()
{
return _internalGetSeacardConf();
}
function getSeacardById($sea_id)
{
$conf = getSeacardConf();
$sea_id = (int)$sea_id;
return array_key_exists($sea_id, $conf) ? $conf[$sea_id] : null;
}
function _internalGetSeacardConf()
{
global $g_seacard_table;
if (!$g_seacard_table) {
$g_seacard_table = require(getConfigBaseDir() . 'seasoncard@seasoncard.php');
}
return $g_seacard_table;
}
function getNowSeasoncard($score)
{
$level = 0;
$sum_score = 0;
$pass_score = 0;
$max_pass_score = 0;
$sum_point = 0;
$conf = getSeacardConf();
$pass_array = array();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeacardById($i);
if ($score >= $sea['min_point'] && $score <= $sea['max_exp']
|| $score >= $sea['min_point'] && $sea['max_exp'] == -1) {
$level = $sea['lv'];
$pass_score = $score - $sea['min_point'] + 1;
$max_pass_score = $sea['max_exp'] - $sea['min_point'] + 1;
$min_pass_score = $sea['min_point'];
if ($sea['max_exp'] == -1) {
$max_pass_score = $sea['min_point'];
$pass_score = $score;
}
array_push($pass_array, array(
'level' => $level,
'pass_score' => $pass_score,
'max_pass_score' => $max_pass_score,
'min_pass_score' => $min_pass_score,
'exp' => $sea['task_exp'],
));
return $pass_array;
}
}
return null;
}
function getNowSeasoncardInfo($score)
{
$conf = getSeacardConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeacardById($i);
if ($score >= $sea['min_point'] && $score <= $sea['max_exp']
|| $score >= $sea['min_point'] && $sea['max_exp'] == -1) {
return $sea['lv'];
}
}
return null;
}
function getNowSeasoncardExp($score)
{
$conf = getSeacardConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeacardById($i);
if ($score >= $sea['min_point'] && $score <= $sea['max_exp']
|| $score >= $sea['min_point'] && $sea['max_exp'] == -1) {
return $sea['task_exp'];
}
}
return null;
}
function getNowSeasoncardMaxExp($score)
{
$conf = getSeacardConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeacardById($i);
if ($score >= $sea['min_point'] && $score <= $sea['max_exp']
|| $score >= $sea['min_point'] && $sea['max_exp'] == -1) {
return $sea['max_exp'];
}
}
return null;
}
function getNowSeasoncardCost($score)
{
$conf = getSeacardConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeacardById($i);
if ($score >= $sea['min_point'] && $score <= $sea['max_exp']
|| $score >= $sea['min_point'] && $sea['max_exp'] == -1) {
return $sea['cost'];
}
}
return null;
}

View File

@ -1,141 +0,0 @@
<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getExplode1($string)
{
$delim = "|";
$drop_multiply = explode($delim, $string);
$delim1 = ":";
$arr = array();
for ($i = 0; $i < count($drop_multiply); $i++) {
$mul = explode($delim1, $drop_multiply[$i]);
array_push($arr, $mul);
}
return $arr;
}
function getShopConf()
{
return _internalGetShopConf();
}
function getShopById($shop_id)
{
$conf = getShopConf();
$shop_id = (int)$shop_id;
return array_key_exists($shop_id, $conf) ? $conf[$shop_id] : null;
}
function randGoods($shop_conf, $exclude_goods)
{
$num = $shop_conf['num'];
$goods_list = explode('|', $shop_conf['goods_list']);
$goods_weight = explode('|', $shop_conf['goods_weight']);
$goods_buy = getExplode1($shop_conf['price']);
$goods_discount = explode('|', $shop_conf['discount']);
$discount_num = $shop_conf['discount_num'];
$goods = array();
for ($i = 0; $i < $num; ++$i) {
$rand_space = 0;
foreach ($goods_weight as $value) {
$rand_space += $value;
}
if ($rand_space <= 0) {
break;
}
$rnd_val = rand(0, $rand_space);
$curr_val = 0;
$discount = false;
if ($discount_num != 0) {
$discount = true;
$discount_num--;
}
for ($ii = 0; $ii < count($goods_weight); ++$ii) {
$curr_val += $goods_weight[$ii];
$limit_val = 0;
if ($shop_conf['limit'] != '') {
$limit = explode('|', $shop_conf['limit']);
$limit_val = $limit[$ii];
}
if ($rnd_val <= $curr_val) {
array_push($goods, array(
'id' => $goods_list[$ii],
'buy' => $goods_buy[$ii][0],
'price' => $goods_buy[$ii][1],
'status' => 0,
'isdiscount' => $discount,
'dis_num' => $goods_discount[$ii],
'limit_val' => $limit_val,
'isdorefresh' => $shop_conf['isdorefresh'],
'hasrefreshnum' => 0,
'refreshnum' => $shop_conf['refreshnum'],
));
array_splice($goods_list, $ii, 1);
array_splice($goods_weight, $ii, 1);
array_splice($goods_buy, $ii, 1);
array_splice($goods_discount, $ii, 1);
break;
}
}
}
return $goods;
}
function shopGoodsList($shop_conf)
{
$goods_list = explode('|', $shop_conf['goods_list']);
$goods_weight = explode('|', $shop_conf['goods_weight']);
$goods_buy = getExplode1($shop_conf['price']);
$goods_discount = explode('|', $shop_conf['discount']);
$discount_num = $shop_conf['discount_num'];
$goods = array();
$discount = false;
if ($discount_num != 0) {
$discount = true;
$discount_num--;
}
for ($ii = 0; $ii < count($goods_weight); ++$ii) {
$limit_val = 0;
if ($shop_conf['limit'] != '') {
$limit = explode('|', $shop_conf['limit']);
$limit_val = $limit[$ii];
}
array_push($goods, array(
'id' => $goods_list[$ii],
'buy' => $goods_buy[$ii][0],
'price' => $goods_buy[$ii][1],
'status' => 0,
'isdiscount' => $discount,
'dis_num' => $goods_discount[$ii],
'weight' => $goods_weight[$ii],
'limit_val' => $limit_val,
));
}
return $goods;
}
function _internalGetShopConf()
{
global $g_shop_table;
if (!$g_shop_table) {
$g_shop_table = require(getConfigBaseDir() . 'shop@shop.php');
}
return $g_shop_table;
}

View File

@ -1,38 +0,0 @@
<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getShopGoodsConf()
{
return _internalGetShopGoodsConf();
}
function getShopGoodsById($shop_id)
{
$conf = getShopGoodsConf();
$shop_id = (int)$shop_id;
return array_key_exists($shop_id, $conf) ? $conf[$shop_id] : null;
}
function _internalGetShopGoodsConf()
{
global $g_shopGoods_table;
if (!$g_shopGoods_table) {
$g_shopG_table = require(getConfigBaseDir() . 'shopGoods@shopGoods.php');
}
return $g_shopG_table;
}