유산 보기 페이지
This commit is contained in:
+19
-10
@@ -16,6 +16,8 @@ $me = General::createGeneralObjFromDB($generalID);
|
||||
|
||||
|
||||
$pointHelpText = [
|
||||
'sum' => '다음 플레이에서 사용할 수 있는 총 포인트입니다.',
|
||||
'new' => '이번 플레이에서 얻은 총 포인트입니다.',
|
||||
'previous' => '이전에 물려받은 포인트입니다.',
|
||||
'lived_month' => '살아남은 기간입니다. (1개월 단위)',
|
||||
'max_belong' => '가장 오래 임관했던 국가의 연도입니다.',
|
||||
@@ -28,7 +30,10 @@ $pointHelpText = [
|
||||
'tournament' => '토너먼트 입상 포인트입니다.',
|
||||
'betting' => '성공적인 베팅을 했습니다. <br>수익율과 베팅 성공 횟수를 따릅니다.',
|
||||
];
|
||||
|
||||
$items = [];
|
||||
foreach(array_keys(General::INHERITANCE_KEY) as $key){
|
||||
$items[$key] = $me->getInheritancePoint($key)??0;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -48,6 +53,10 @@ $pointHelpText = [
|
||||
<?= WebUtil::printJS('../e_lib/bootstrap.bundle.min.js') ?>
|
||||
<?= WebUtil::printJS('js/common.js') ?>
|
||||
<?= WebUtil::printJS('js/inheritPoint.js') ?>
|
||||
<script>
|
||||
var items = <?=Json::encode($items)?>;
|
||||
var helpText = <?=Json::encode($pointHelpText)?>;
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body onload="formStart()">
|
||||
@@ -59,16 +68,16 @@ $pointHelpText = [
|
||||
</table>
|
||||
<div id="container" class="tb_layout bg0" style="width:1000px;margin:auto;border:solid 1px #888888;">
|
||||
<div id='inheritance_list'>
|
||||
<div id="inherit_total" class='inherit_item'>
|
||||
<div id="inherit_sum" class='inherit_item'>
|
||||
<div class="row">
|
||||
<label id="inherit_sum_head" class='inherit_head col-sm-6 col-form-label'>총 포인트</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control inherit_value" readonly id="inherit_<?= $key ?>_value" value="">
|
||||
<input type="text" class="form-control inherit_value" readonly id="inherit_sum_value" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="text-align:right">
|
||||
<small class="form-text text-muted"><?= $pointHelpText[$key] ?? "" ?></small>
|
||||
<small class="form-text text-muted"></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -76,16 +85,16 @@ $pointHelpText = [
|
||||
<div class="row">
|
||||
<label id="inherit_sum_head" class='inherit_head col-sm-6 col-form-label'>기존 포인트</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control inherit_value" readonly id="inherit_previous_value" value="<?= number_format(Util::toInt($me->getInheritancePoint('previous') ?? 0)) ?>">
|
||||
<input type="text" class="form-control inherit_value" readonly id="inherit_previous_value" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="text-align:right">
|
||||
<small class="form-text text-muted"><?= $pointHelpText[$key] ?? "" ?></small>
|
||||
<small class="form-text text-muted"></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="inherit_<?= $key ?>" class='inherit_item'>
|
||||
<div id="inherit_new" class='inherit_item'>
|
||||
<div class="row">
|
||||
<label id="inherit_sum_head" class='inherit_head col-sm-6 col-form-label'>신규 포인트</label>
|
||||
<div class="col-sm-6">
|
||||
@@ -94,7 +103,7 @@ $pointHelpText = [
|
||||
</div>
|
||||
|
||||
<div style="text-align:right">
|
||||
<small class="form-text text-muted"><?= $pointHelpText[$key] ?? "" ?></small>
|
||||
<small class="form-text text-muted"></small>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width:100%; padding:0 10px"><hr style="border-top:1px solid #888888;"></div>
|
||||
@@ -106,12 +115,12 @@ $pointHelpText = [
|
||||
<div class="row">
|
||||
<label id="inherit_<?= $key ?>_head" class='inherit_head col-sm-6 col-form-label'><?= $name ?></label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control inherit_value" readonly id="inherit_<?= $key ?>_value" value="<?= number_format(Util::toInt($me->getInheritancePoint($key) ?? 0)) ?>">
|
||||
<input type="text" class="form-control inherit_value" readonly id="inherit_<?= $key ?>_value" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="text-align:right">
|
||||
<small class="form-text text-muted"><?= $pointHelpText[$key] ?? "" ?></small>
|
||||
<small class="form-text text-muted"></small>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+27
-10
@@ -1,21 +1,38 @@
|
||||
import {random, range} from "lodash"
|
||||
|
||||
import { sum } from "lodash";
|
||||
import { unwrap } from "./util";
|
||||
declare global {
|
||||
interface Window { formStart: any; }
|
||||
interface Window {
|
||||
formStart: ()=>void;
|
||||
items: {[name: string]:number};
|
||||
helpText: {[name: string]:string};
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
||||
|
||||
function formStart() {
|
||||
console.log(window.pathConfig.root);
|
||||
|
||||
const a = 10;
|
||||
const b:number[] = [];
|
||||
for(const v of range(10)){
|
||||
b.push(random()*v);
|
||||
const dSum = unwrap(document.querySelector('#inherit_sum_value')) as HTMLInputElement ;
|
||||
const dOld = unwrap(document.querySelector('#inherit_previous_value')) as HTMLInputElement;
|
||||
const dNew = unwrap(document.querySelector('#inherit_new_value')) as HTMLInputElement;
|
||||
|
||||
const sumPoint = Math.floor(sum(Object.values(window.items)));
|
||||
const oldPoint = Math.floor(window.items['previous']);
|
||||
const sumNewPoint = sumPoint - oldPoint;
|
||||
|
||||
dSum.value = sumPoint.toLocaleString();
|
||||
dOld.value = oldPoint.toLocaleString();
|
||||
dNew.value = sumNewPoint.toLocaleString();
|
||||
|
||||
for(const [key, val] of Object.entries(window.items)){
|
||||
const dItem = unwrap(document.querySelector(`#inherit_${key}_value`)) as HTMLInputElement ;
|
||||
dItem.value = Math.floor(val).toLocaleString();
|
||||
}
|
||||
|
||||
for(const [key, text] of Object.entries(window.helpText)){
|
||||
const dText = unwrap(document.querySelector(`#inherit_${key} small.form-text`)) as HTMLElement;
|
||||
dText.innerHTML = text;
|
||||
}
|
||||
console.log(a + 10);
|
||||
console.log(b);
|
||||
}
|
||||
|
||||
window.formStart = formStart;
|
||||
@@ -0,0 +1,35 @@
|
||||
type ErrType<T> = { new(msg?: string): T }
|
||||
type Nullable<T> = T | null | undefined
|
||||
|
||||
export class RuntimeError extends Error {
|
||||
public name = 'RuntimeError';
|
||||
constructor(public message: string = '') {
|
||||
super(message);
|
||||
}
|
||||
toString(): string {
|
||||
if (this.message) {
|
||||
return this.name + ': ' + this.message;
|
||||
}
|
||||
else {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class NotNullExpected extends RuntimeError {
|
||||
public name = 'NotNullExpected';
|
||||
}
|
||||
|
||||
export function unwrap<T>(result: Nullable<T>): T {
|
||||
if (result === null || result === undefined) {
|
||||
throw new NotNullExpected();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function unwrap_err<T, ErrT extends Error>(result: Nullable<T>, errType: ErrType<ErrT>, errMsg?: string): T {
|
||||
if (result === null || result === undefined) {
|
||||
throw new errType(errMsg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user