feat: 장수 생성 시 유산 포인트에 따라 생성해주는 기능 추가
This commit is contained in:
+2
-2
@@ -2158,7 +2158,7 @@ function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null)
|
|||||||
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
|
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
|
||||||
$randFraction = Util::randRangeInt(0, 999999) / 1000000; //6자리 소수
|
$randFraction = Util::randRangeInt(0, 999999) / 1000000; //6자리 소수
|
||||||
|
|
||||||
return $baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s');
|
return $baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s.u');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandTurn2($term, ?\DateTimeInterface $baseDateTime = null)
|
function getRandTurn2($term, ?\DateTimeInterface $baseDateTime = null)
|
||||||
@@ -2173,5 +2173,5 @@ function getRandTurn2($term, ?\DateTimeInterface $baseDateTime = null)
|
|||||||
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
|
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
|
||||||
$randFraction = Util::randRangeInt(0, 999999) / 1000000; //6자리 소수
|
$randFraction = Util::randRangeInt(0, 999999) / 1000000; //6자리 소수
|
||||||
|
|
||||||
return $baseDateTime->sub(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s');
|
return $baseDateTime->sub(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s.u');
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -1150,14 +1150,23 @@ function checkEmperior()
|
|||||||
LogHistory();
|
LogHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetInheritanceUser(int $userID, bool $isRebirth=false){
|
function resetInheritanceUser(int $userID, bool $isRebirth=false):float{
|
||||||
$rebirthDegraded = [
|
$rebirthDegraded = [
|
||||||
'dex'=>0.5,
|
'dex'=>0.5,
|
||||||
];
|
];
|
||||||
|
|
||||||
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
|
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
|
||||||
$totalPoint = 0;
|
$totalPoint = 0;
|
||||||
foreach($inheritStor->getAll() as $key=>[$value,]){
|
$allPoints = $inheritStor->getAll();
|
||||||
|
if(count($allPoints) == 0){
|
||||||
|
//비었으므로 리셋 안함
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(count($allPoints) == 1 && key_exists('previous', $allPoints)){
|
||||||
|
//이미 리셋되었으므로 리셋 안함
|
||||||
|
return $allPoints['previous'];
|
||||||
|
}
|
||||||
|
foreach($allPoints as $key=>[$value,]){
|
||||||
if($isRebirth && key_exists($key, $rebirthDegraded)){
|
if($isRebirth && key_exists($key, $rebirthDegraded)){
|
||||||
$value *= $rebirthDegraded[$key];
|
$value *= $rebirthDegraded[$key];
|
||||||
}
|
}
|
||||||
@@ -1166,6 +1175,7 @@ function resetInheritanceUser(int $userID, bool $isRebirth=false){
|
|||||||
$totalPoint = Util::toInt($totalPoint);
|
$totalPoint = Util::toInt($totalPoint);
|
||||||
$inheritStor->resetValues();
|
$inheritStor->resetValues();
|
||||||
$inheritStor->setValue('previous', [$totalPoint, null]);
|
$inheritStor->setValue('previous', [$totalPoint, null]);
|
||||||
|
return $totalPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMaxDomesticCritical(General $general, $score){
|
function updateMaxDomesticCritical(General $general, $score){
|
||||||
|
|||||||
+114
-45
@@ -1,9 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
|
function dieMsg(string $msg)
|
||||||
|
{
|
||||||
|
$jmsg = Json::encode($msg);
|
||||||
|
echo "<html><head><style>html,body{background:black;}</style><script>alert({$jmsg});history.go(-1);</script></head><body></body></html>";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
$v = new Validator($_POST);
|
$v = new Validator($_POST);
|
||||||
$v
|
$v
|
||||||
->rule('required', [
|
->rule('required', [
|
||||||
@@ -28,12 +36,15 @@ $v
|
|||||||
'strength',
|
'strength',
|
||||||
'intel'
|
'intel'
|
||||||
], GameConst::$defaultStatMax)
|
], GameConst::$defaultStatMax)
|
||||||
->rule('in', 'character', array_merge(GameConst::$availablePersonality, ['Random']));
|
->rule('in', 'character', array_merge(GameConst::$availablePersonality, ['Random']))
|
||||||
|
->rule('in', 'inheritSpecial', GameConst::$availableSpecialWar)
|
||||||
|
->rule('integer', 'inheritTurntime')
|
||||||
|
->rule('min', 'inheritTurntime', 0)
|
||||||
|
->rule('in', 'inheritCity', array_keys(CityConst::all()))
|
||||||
|
->rule('integerArray', 'inheritBonusStat');
|
||||||
|
|
||||||
if (!$v->validate()) {
|
if (!$v->validate()) {
|
||||||
MessageBox($v->errorStr());
|
dieMsg($v->errorStr());
|
||||||
echo "<script>history.go(-1);</script>";
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$session = Session::requireLogin()->setReadOnly();
|
$session = Session::requireLogin()->setReadOnly();
|
||||||
@@ -52,6 +63,11 @@ $leadership = Util::getPost('leadership', 'int', 50);
|
|||||||
$strength = Util::getPost('strength', 'int', 50);
|
$strength = Util::getPost('strength', 'int', 50);
|
||||||
$intel = Util::getPost('intel', 'int', 50);
|
$intel = Util::getPost('intel', 'int', 50);
|
||||||
|
|
||||||
|
$inheritSpecial = Util::getPost('inheritSpecial');
|
||||||
|
$inheritTurntime = Util::getPost('inheritTurntime', 'int');
|
||||||
|
$inheritCity = Util::getPost('inheritCity', 'int');
|
||||||
|
$inheritBonusStat = Util::getPost('inheritBonusStat', 'array_int');
|
||||||
|
|
||||||
$join = Util::getPost('join'); //쓸모 없음
|
$join = Util::getPost('join'); //쓸모 없음
|
||||||
|
|
||||||
$rootDB = RootDB::db();
|
$rootDB = RootDB::db();
|
||||||
@@ -59,9 +75,7 @@ $rootDB = RootDB::db();
|
|||||||
$member = $rootDB->queryFirstRow('SELECT `no`, id, picture, grade, `name`, imgsvr FROM member WHERE no=%i', $userID);
|
$member = $rootDB->queryFirstRow('SELECT `no`, id, picture, grade, `name`, imgsvr FROM member WHERE no=%i', $userID);
|
||||||
|
|
||||||
if (!$member) {
|
if (!$member) {
|
||||||
MessageBox("잘못된 접근입니다!!!");
|
dieMsg("잘못된 접근입니다!!!");
|
||||||
echo "<script>history.go(-1);</script>";
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
@@ -74,62 +88,95 @@ $oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i',
|
|||||||
$oldName = $db->queryFirstField('SELECT `no` FROM general WHERE `name`=%s', $name);
|
$oldName = $db->queryFirstField('SELECT `no` FROM general WHERE `name`=%s', $name);
|
||||||
|
|
||||||
if ($oldGeneral) {
|
if ($oldGeneral) {
|
||||||
echo("<script>
|
dieMsg("이미 등록하셨습니다!");
|
||||||
window.alert('이미 등록하셨습니다!')
|
|
||||||
history.go(-1)
|
|
||||||
</script>");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
if ($oldName) {
|
if ($oldName) {
|
||||||
echo("<script>
|
dieMsg("이미 있는 장수입니다. 다른 이름으로 등록해 주세요!");
|
||||||
window.alert('이미 있는 장수입니다. 다른 이름으로 등록해 주세요!')
|
|
||||||
history.go(-1)
|
|
||||||
</script>");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
if ($gameStor->maxgeneral <= $gencount) {
|
if ($gameStor->maxgeneral <= $gencount) {
|
||||||
echo("<script>
|
dieMsg("더이상 등록할 수 없습니다!");
|
||||||
window.alert('더이상 등록할 수 없습니다!')
|
|
||||||
history.go(-1)
|
|
||||||
</script>");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
if ($name == '') {
|
if ($name == '') {
|
||||||
echo("<script>
|
dieMsg("이름이 짧습니다. 다시 가입해주세요!");
|
||||||
window.alert('이름이 짧습니다. 다시 가입해주세요!')
|
|
||||||
history.go(-1)
|
|
||||||
</script>");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
if (mb_strwidth($name) > 18) {
|
if (mb_strwidth($name) > 18) {
|
||||||
echo("<script>
|
dieMsg("이름이 유효하지 않습니다. 다시 가입해주세요!");
|
||||||
window.alert('이름이 유효하지 않습니다. 다시 가입해주세요!')
|
|
||||||
history.go(-1)
|
|
||||||
</script>");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
if ($leadership + $strength + $intel > GameConst::$defaultStatTotal) {
|
if ($leadership + $strength + $intel > GameConst::$defaultStatTotal) {
|
||||||
echo("<script>
|
dieMsg("능력치가 " . GameConst::$defaultStatTotal . "을 넘어섰습니다. 다시 가입해주세요!");
|
||||||
window.alert('능력치가 ".GameConst::$defaultStatTotal."을 넘어섰습니다. 다시 가입해주세요!')
|
|
||||||
history.go(-1)
|
|
||||||
</script>");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$genius = Util::randBool(0.01);
|
if ($inheritBonusStat) {
|
||||||
|
if (count($inheritBonusStat) != 3) {
|
||||||
|
dieMsg("보너스 능력치가 잘못 지정되었습니다. 다시 가입해주세요!");
|
||||||
|
}
|
||||||
|
$sum = array_sum($inheritBonusStat);
|
||||||
|
if ($sum < 3 || $sum > 5) {
|
||||||
|
dieMsg("보너스 능력치 합이 잘못 지정되었습니다. 다시 가입해주세요!");
|
||||||
|
}
|
||||||
|
foreach ($inheritBonusStat as $stat) {
|
||||||
|
if ($stat < 0) {
|
||||||
|
dieMsg("보너스 능력치가 음수입니다. 다시 가입해주세요!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$admin = $gameStor->getValues(['scenario', 'turnterm', 'turntime', 'show_img_level', 'startyear', 'year']);
|
||||||
|
|
||||||
|
$inheritTotalPoint = resetInheritanceUser($userID);
|
||||||
|
$inheritRequiredPoint = 0;
|
||||||
|
|
||||||
|
if ($inheritCity !== null) {
|
||||||
|
$inheritRequiredPoint += GameConst::$inheritBornCityPoint;
|
||||||
|
}
|
||||||
|
if ($inheritBonusStat !== null) {
|
||||||
|
$inheritRequiredPoint += GameConst::$inheritBornMaxBonusStat;
|
||||||
|
}
|
||||||
|
if ($inheritSpecial !== null) {
|
||||||
|
$inheritRequiredPoint += GameConst::$inheritBornSpecialPoint;
|
||||||
|
}
|
||||||
|
if ($inheritTurntime !== null) {
|
||||||
|
$inheritRequiredPoint += GameConst::$inheritBornTurntimePoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($inheritTotalPoint < $inheritRequiredPoint) {
|
||||||
|
dieMsg("유산 포인트가 부족합니다. 다시 가입해주세요!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($inheritSpecial !== null && $gameStor->genius == 0) {
|
||||||
|
dieMsg("이미 천재가 모두 나타났습니다. 다시 가입해주세요!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($inheritCity !== null && !key_exists($inheritCity, CityConst::all())) {
|
||||||
|
dieMsg("도시가 잘못 지정되었습니다. 다시 가입해주세요!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($inheritSpecial) {
|
||||||
|
$genius = true;
|
||||||
|
} else {
|
||||||
// 현재 1%
|
// 현재 1%
|
||||||
|
$genius = Util::randBool(0.01);
|
||||||
|
}
|
||||||
|
|
||||||
if ($genius && $gameStor->genius > 0) {
|
if ($genius && $gameStor->genius > 0) {
|
||||||
$gameStor->genius = $gameStor->genius - 1;
|
$gameStor->genius = $gameStor->genius - 1;
|
||||||
} else {
|
} else {
|
||||||
$genius = false;
|
$genius = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($inheritCity !== null) {
|
||||||
|
$city = $inheritCity;
|
||||||
|
} else {
|
||||||
// 공백지에서만 태어나게
|
// 공백지에서만 태어나게
|
||||||
$city = $db->queryFirstField("select city from city where level>=5 and level<=6 and nation=0 order by rand() limit 0,1");
|
$city = $db->queryFirstField("select city from city where level>=5 and level<=6 and nation=0 order by rand() limit 0,1");
|
||||||
if (!$city) {
|
if (!$city) {
|
||||||
$city = $db->queryFirstField("select city from city where level>=5 and level<=6 order by rand() limit 0,1");
|
$city = $db->queryFirstField("select city from city where level>=5 and level<=6 order by rand() limit 0,1");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($inheritBonusStat) {
|
||||||
|
[$pleadership, $pstrength, $pintel] = $inheritBonusStat;
|
||||||
|
} else {
|
||||||
$pleadership = 0;
|
$pleadership = 0;
|
||||||
$pstrength = 0;
|
$pstrength = 0;
|
||||||
$pintel = 0;
|
$pintel = 0;
|
||||||
@@ -146,18 +193,21 @@ foreach(Util::range(Util::randRangeInt(3, 5)) as $statIdx){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$leadership = $leadership + $pleadership;
|
$leadership = $leadership + $pleadership;
|
||||||
$strength = $strength + $pstrength;
|
$strength = $strength + $pstrength;
|
||||||
$intel = $intel + $pintel;
|
$intel = $intel + $pintel;
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['scenario', 'turnterm', 'turntime', 'show_img_level', 'startyear', 'year']);
|
|
||||||
$relYear = Util::valueFit($admin['year'] - $admin['startyear'], 0);
|
$relYear = Util::valueFit($admin['year'] - $admin['startyear'], 0);
|
||||||
|
|
||||||
$age = 20 + ($pleadership + $pstrength + $pintel) * 2 - (mt_rand(0, 1));
|
$age = 20 + ($pleadership + $pstrength + $pintel) * 2 - (mt_rand(0, 1));
|
||||||
// 아직 남았고 천재등록상태이면 특기 부여
|
// 아직 남았고 천재등록상태이면 특기 부여
|
||||||
if ($genius) {
|
if ($genius) {
|
||||||
$specage2 = $age;
|
$specage2 = $age;
|
||||||
|
if ($inheritSpecial) {
|
||||||
|
$special2 = $inheritSpecial;
|
||||||
|
} else {
|
||||||
$special2 = SpecialityHelper::pickSpecialWar([
|
$special2 = SpecialityHelper::pickSpecialWar([
|
||||||
'leadership' => $leadership,
|
'leadership' => $leadership,
|
||||||
'strength' => $strength,
|
'strength' => $strength,
|
||||||
@@ -168,6 +218,7 @@ if ($genius) {
|
|||||||
'dex4' => 0,
|
'dex4' => 0,
|
||||||
'dex5' => 0
|
'dex5' => 0
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$specage2 = Util::valueFit(Util::round((GameConst::$retirementYear - $age) / 6 - $relYear / 2), 3) + $age;
|
$specage2 = Util::valueFit(Util::round((GameConst::$retirementYear - $age) / 6 - $relYear / 2), 3) + $age;
|
||||||
$special2 = GameConst::$defaultSpecialWar;
|
$special2 = GameConst::$defaultSpecialWar;
|
||||||
@@ -183,8 +234,7 @@ if ($admin['scenario'] >= 1000) {
|
|||||||
|
|
||||||
if ($relYear < 3) {
|
if ($relYear < 3) {
|
||||||
$experience = 0;
|
$experience = 0;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$expGenCount = $db->queryFirstField('SELECT count(*) FROM general WHERE nation != 0 AND npc < 4');
|
$expGenCount = $db->queryFirstField('SELECT count(*) FROM general WHERE nation != 0 AND npc < 4');
|
||||||
$targetGenOrder = Util::round($expGenCount * 0.2);
|
$targetGenOrder = Util::round($expGenCount * 0.2);
|
||||||
$experience = $db->queryFirstField(
|
$experience = $db->queryFirstField(
|
||||||
@@ -194,9 +244,17 @@ else{
|
|||||||
$experience *= 0.8;
|
$experience *= 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($inheritTurntime === null) {
|
||||||
|
$inheritTurntime = $inheritTurntime % ($gameStor->turnterm * 60);
|
||||||
|
$inheritTurntime += Util::randRangeInt(0, 999999) / 1000000;
|
||||||
|
$turntime = cutTurn($admin['turntime'], $admin['turnterm']);
|
||||||
|
$turntime = TimeUtil::nowAddSeconds($inheritTurntime, true);
|
||||||
|
} else {
|
||||||
$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
|
$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
|
||||||
|
}
|
||||||
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
|
$now = TimeUtil::now(true);
|
||||||
if ($now >= $turntime) {
|
if ($now >= $turntime) {
|
||||||
$turntime = addTurn($turntime, $admin['turnterm']);
|
$turntime = addTurn($turntime, $admin['turnterm']);
|
||||||
}
|
}
|
||||||
@@ -266,8 +324,6 @@ foreach(Util::range(GameConst::$maxTurn) as $turnIdx){
|
|||||||
}
|
}
|
||||||
$db->insert('general_turn', $turnRows);
|
$db->insert('general_turn', $turnRows);
|
||||||
|
|
||||||
resetInheritanceUser($userID);
|
|
||||||
|
|
||||||
$rank_data = [];
|
$rank_data = [];
|
||||||
foreach (array_keys(General::RANK_COLUMN) as $rankColumn) {
|
foreach (array_keys(General::RANK_COLUMN) as $rankColumn) {
|
||||||
$rank_data[] = [
|
$rank_data[] = [
|
||||||
@@ -333,9 +389,22 @@ $rootDB->insert('member_log', [
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
window.alert('정상적으로 회원 가입되었습니다. 장수명 : <?= $name ?> \n위키와 팁/강좌 게시판을 꼭 읽어보세요!');
|
window.alert('정상적으로 회원 가입되었습니다. 장수명 : <?= $name ?> \n위키와 팁/강좌 게시판을 꼭 읽어보세요!');
|
||||||
|
location.replace('./');
|
||||||
</script>
|
</script>
|
||||||
<script>location.replace('./');</script>
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
class GameConstBase
|
class GameConstBase
|
||||||
@@ -189,6 +190,11 @@ class GameConstBase
|
|||||||
'che_은둔', 'None'
|
'che_은둔', 'None'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static $inheritBornSpecialPoint = 12000;
|
||||||
|
public static $inheritBornTurntimePoint = 3000;
|
||||||
|
public static $inheritBornCityPoint = 1000;
|
||||||
|
public static $inheritBornMaxBonusStat = 1000;
|
||||||
|
|
||||||
public static $allItems = [
|
public static $allItems = [
|
||||||
'horse' => [
|
'horse' => [
|
||||||
'che_명마_01_노기' => 0, 'che_명마_02_조랑' => 0, 'che_명마_03_노새' => 0,
|
'che_명마_01_노기' => 0, 'che_명마_02_조랑' => 0, 'che_명마_03_노새' => 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user