-
+
+
+
+
+ getItems() as $itemKey => $item) : ?>
+
+
+
+
개인용 CSS
diff --git a/hwe/sammo/API/General/DropItem.php b/hwe/sammo/API/General/DropItem.php
new file mode 100644
index 00000000..2c0c8017
--- /dev/null
+++ b/hwe/sammo/API/General/DropItem.php
@@ -0,0 +1,66 @@
+args);
+ $v->rule('required', [
+ 'itemType',
+ ])
+ ->rule('in', 'itemType', array_keys(GameConst::$allItems));
+
+ if (!$v->validate()) {
+ return "{$v->errorStr()}";
+ }
+ return null;
+ }
+
+ public function getRequiredSessionMode(): int
+ {
+ return static::REQ_GAME_LOGIN;
+ }
+
+ public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag)
+ {
+ $generalID = $session->generalID;
+ $me = General::createGeneralObjFromDB($generalID);
+
+ $itemType = $this->args['itemType'];
+ $item = $me->getItem($itemType);
+
+ if ($item->getRawClassName() === 'None') {
+ return '아이템을 가지고 있지 않습니다.';
+ }
+
+ $me->setItem($itemType, 'None');
+ $logger = $me->getLogger();
+
+ $generalName = $me->getName();
+ $josaYi = JosaUtil::pick($generalName, '이');
+
+ $itemName = $item->getName();
+ $josaUl = JosaUtil::pick($itemName, '을');
+ $logger->pushGeneralActionLog("
{$itemName}>{$josaUl} 버렸습니다.");
+
+ $nationName = $me->getStaticNation()['name'];
+ if (!$item->isBuyable()) {
+ $logger->pushGlobalActionLog("{$generalName}>{$josaYi} {$itemName}>{$josaUl} 잃었습니다!");
+ $logger->pushGlobalHistoryLog("【망실】>{$nationName}>의 {$generalName}>{$josaYi} {$itemName}>{$josaUl} 잃었습니다!");
+ }
+
+ $me->applyDB(DB::db());
+
+ return null;
+ }
+}
diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts
index 0ce97172..a8cd1f84 100644
--- a/hwe/ts/SammoAPI.ts
+++ b/hwe/ts/SammoAPI.ts
@@ -13,7 +13,7 @@ import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListRespo
import type { UploadImageResponse } from "./defs/API/Misc";
import type { GeneralLogType, GetGeneralLogResponse, JoinArgs } from "./defs/API/General";
import type { GetConstResponse, GetCurrentHistoryResponse, GetDiplomacyResponse, GetHistoryResponse } from "./defs/API/Global";
-import type { CachedMapResult, GeneralListResponse, MapResult } from "./defs";
+import type { CachedMapResult, GeneralListResponse, ItemTypeKey, MapResult } from "./defs";
const apiRealPath = {
Betting: {
@@ -53,7 +53,10 @@ const apiRealPath = {
GetGeneralLog: GET as APICallT<{
reqType: GeneralLogType,
reqTo?: number
- }, GetGeneralLogResponse>
+ }, GetGeneralLogResponse>,
+ DropItem: PUT as APICallT<{
+ itemType: ItemTypeKey
+ }>
},
Global: {
GeneralList: GET as APICallT,
diff --git a/hwe/ts/myPage.ts b/hwe/ts/myPage.ts
index 01a94c90..cd449c68 100644
--- a/hwe/ts/myPage.ts
+++ b/hwe/ts/myPage.ts
@@ -2,7 +2,7 @@ import "@scss/myPage.scss";
import axios from 'axios';
import $ from 'jquery';
-import { type InvalidResponse, keyScreenMode, type ScreenModeType } from '@/defs';
+import { type InvalidResponse, keyScreenMode, type ScreenModeType, type ItemTypeKey } from '@/defs';
import { convertFormData } from '@util/convertFormData';
import { setAxiosXMLHttpRequest } from '@util/setAxiosXMLHttpRequest';
import { unwrap } from '@util/unwrap';
@@ -10,13 +10,24 @@ import { unwrap_any } from '@util/unwrap_any';
import { auto500px } from './util/auto500px';
import { initTooltip } from "./legacy/initTooltip";
import { insertCustomCSS } from "./util/customCSS";
-
+import * as JosaUtil from '@util/JosaUtil';
+import { SammoAPI } from "./SammoAPI";
type LogResponse = {
result: true;
log: Record;
};
+declare const staticValues: {
+ items: Record
+}
+
$(function ($) {
setAxiosXMLHttpRequest();
@@ -111,8 +122,8 @@ $(function ($) {
const $screenModeRadios = $('input:radio[name=screenMode]');
- $screenModeRadios.prop('checked', false).filter(`[value="${localStorage.getItem(keyScreenMode)??'auto'}"]`).prop('checked', true);
- $screenModeRadios.on('click', function(e){
+ $screenModeRadios.prop('checked', false).filter(`[value="${localStorage.getItem(keyScreenMode) ?? 'auto'}"]`).prop('checked', true);
+ $screenModeRadios.on('click', function (e) {
const mode = (e.target as HTMLInputElement).value as ScreenModeType;
localStorage.setItem(keyScreenMode, mode);
document.dispatchEvent(new CustomEvent('tryChangeScreenMode'));
@@ -201,7 +212,7 @@ $(function ($) {
})
});
result = response.data;
- if(!result.result){
+ if (!result.result) {
throw result.reason;
}
}
@@ -216,6 +227,42 @@ $(function ($) {
});
+ $('.drop-item-btn').on('click', async function (e) {
+ e.preventDefault();
+ const $this = $(this);
+ const type = $this.data('item-type') as ItemTypeKey | undefined;
+ if (!type) {
+ return;
+ }
+
+ console.log(`${type} 판매 시도`);
+ const item = staticValues.items[type];
+ console.log(item);
+
+ const josaUl = JosaUtil.pick(item.rawName, '을');
+ if (!confirm(`${item.name}${josaUl} 버리시겠습니까? (판매시 가치: ${item.cost})`)) {
+ return;
+ }
+
+ if(!item.isBuyable && !confirm(`이 아이템은 유니크 아이템입니다. 진짜로 ${item.name}${josaUl} 버리시겠습니까?`)){
+ return;
+ }
+
+
+ try{
+ await SammoAPI.General.DropItem({
+ itemType: type,
+ });
+ alert(`${item.name}${josaUl} 버렸습니다.`);
+ location.reload();
+ }
+ catch(e){
+ console.error(e);
+ alert(e);
+ }
+
+ });
+
initTooltip();
insertCustomCSS();
});