feat: 전투 시뮬레이터에 시드 값 입력 가능
- 시드 값 입력시 반복 횟수는 1회로 고정 - 스킬 성공 여부는 동일하나, 실제 수치가 조금 다른 경우가 관측 이유는 추후 확인 - 히든 버프는 아직 미 반영
This commit is contained in:
@@ -65,8 +65,8 @@ if ($nationID) {
|
||||
전역 설정
|
||||
</div>
|
||||
<div class="card-body dragpad_battle">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="row gx-0">
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" aria-describedby="text_year" value="<?= $startYear ?>" disabled>
|
||||
<div class="input-group-text"> 년 시작 </div>
|
||||
@@ -76,9 +76,13 @@ if ($nationID) {
|
||||
<div class="input-group-text"> 월 </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-5 px-2">
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="input-group me-2" role="group">
|
||||
<div class="input-group-text">
|
||||
시드
|
||||
</div>
|
||||
<input type="text" class="form-control" id="seed" aria-describedby="text_seed">
|
||||
<div class="input-group-text">
|
||||
반복 횟수
|
||||
</div>
|
||||
@@ -87,6 +91,10 @@ if ($nationID) {
|
||||
<option value="1000">1000회 (요약 표기)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="btn-group me-2" role="group">
|
||||
<button type="button" class="btn btn-danger btn-begin_battle">전투</button>
|
||||
</div>
|
||||
|
||||
@@ -84,6 +84,7 @@ $rawDefenderList = $query['defenderGenerals'];
|
||||
$rawDefenderCity = $query['defenderCity'];
|
||||
$rawDefenderNation = $query['defenderNation'];
|
||||
|
||||
$warSeed = $query['seed'] ?? '';
|
||||
|
||||
$generalCheck = [
|
||||
'required'=>[
|
||||
@@ -297,10 +298,13 @@ function extractRankVar(array $rawVal):Map{
|
||||
function simulateBattle(
|
||||
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
||||
$rawDefenderList, $rawDefenderCity, $rawDefenderNation,
|
||||
$startYear, $year, $month
|
||||
$startYear, $year, $month, $warSeed
|
||||
){
|
||||
|
||||
$warSeed = bin2hex(random_bytes(16));
|
||||
if(!$warSeed){
|
||||
$warSeed = bin2hex(random_bytes(16));
|
||||
}
|
||||
|
||||
$warRng = new RandUtil(new LiteHashDRBG($warSeed));
|
||||
|
||||
$attacker = new WarUnitGeneral(
|
||||
@@ -400,12 +404,16 @@ $avgWar = 0;
|
||||
$attackerActivatedSkills = [];
|
||||
$defendersActivatedSkills = [];
|
||||
|
||||
if($warSeed){
|
||||
$repeatCnt = 1;
|
||||
}
|
||||
|
||||
foreach(Util::range($repeatCnt) as $repeatIdx){
|
||||
/** @var WarUnit $attacker */
|
||||
[$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice] = simulateBattle(
|
||||
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
||||
$rawDefenderList, $rawDefenderCity, $rawDefenderNation,
|
||||
$startYear, $year, $month
|
||||
$startYear, $year, $month, $warSeed
|
||||
);
|
||||
$lastWarLog = Util::mapWithKey(function($key, $values){
|
||||
return ConvertLog(join('<br>', $values));
|
||||
|
||||
@@ -84,6 +84,7 @@ type BattleInfo = {
|
||||
year: number,
|
||||
month: number,
|
||||
repeatCnt: number,
|
||||
seed?: string,
|
||||
};
|
||||
|
||||
type ExportedGeneralInfo = {
|
||||
@@ -638,6 +639,12 @@ $(function ($) {
|
||||
const defenderCity = battleData.defenderCity;
|
||||
const defenderNation = battleData.defenderNation;
|
||||
|
||||
const seed = battleData.seed;
|
||||
|
||||
if(seed){
|
||||
$('#seed').val(seed);
|
||||
}
|
||||
|
||||
$('#year').val(battleData.year);
|
||||
$('#month').val(battleData.month);
|
||||
$('#repeat_cnt').val(battleData.repeatCnt);
|
||||
@@ -712,6 +719,8 @@ $(function ($) {
|
||||
const month = parseInt(unwrap_any<string>($('#month').val()));
|
||||
const repeatCnt = parseInt(unwrap_any<string>($('#repeat_cnt').val()));
|
||||
|
||||
const seed = unwrap_any<string>($('#seed').val());
|
||||
|
||||
return {
|
||||
attackerGeneral: attackerGeneral,
|
||||
attackerCity: attackerCity,
|
||||
@@ -724,6 +733,8 @@ $(function ($) {
|
||||
year: year,
|
||||
month: month,
|
||||
repeatCnt: repeatCnt,
|
||||
|
||||
seed,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user