From 09b4dcbea950e317d19a293211afbdbdcdbc8b17 Mon Sep 17 00:00:00 2001 From: Raymonf <8991740+Raymonf@users.noreply.github.com> Date: Mon, 8 Apr 2024 23:42:34 -0400 Subject: [PATCH] v2 --- src/lib/columns/column_impl.ts | 6 +++--- src/lib/lifeto/lifeto.ts | 4 +++- src/lib/lifeto/order.ts | 20 ++++++++++---------- src/lib/lifeto/order_manager.ts | 11 ++++++----- src/lib/old.ts | 6 +++--- src/lib/session.ts | 2 +- src/lib/trickster.ts | 12 +++--------- 7 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/lib/columns/column_impl.ts b/src/lib/columns/column_impl.ts index 8fad85f..90b328f 100644 --- a/src/lib/columns/column_impl.ts +++ b/src/lib/columns/column_impl.ts @@ -17,7 +17,7 @@ class Image implements ColumnInfo { displayName = " " renderer = coverRenderer getter(item:TricksterItem):(string|number) { - return item.image ? item.image : "" + return item.item_image ? item.item_image : "" } } @@ -207,7 +207,7 @@ class Compound implements ColumnInfo { } const compFilter= (item:TricksterItem): boolean => { - return (item.item_desc.toLowerCase().includes("compound item")) + return (item.item_comment.toLowerCase().includes("compound item")) } @@ -379,7 +379,7 @@ class Desc implements ColumnInfo { displayName = "desc" renderer = descRenderer getter(item:TricksterItem):(string|number){ - return item.item_desc + return item.item_comment } } function descRenderer(instance:any, td:any, row:any, col:any, prop:any, value:any, cellProperties:any) { diff --git a/src/lib/lifeto/lifeto.ts b/src/lib/lifeto/lifeto.ts index 87f7bb2..df61e73 100644 --- a/src/lib/lifeto/lifeto.ts +++ b/src/lib/lifeto/lifeto.ts @@ -46,7 +46,8 @@ export class LTOApiv0 implements LTOApi { if(char_path.startsWith(":")) { char_path = char_path.replace(":","") } - return this.s.request("GET", `item-manager/items/account/${char_path}`,undefined).then((ans:AxiosResponse)=>{ + let type = char_path.includes("/") ? "char" : "account" + return this.s.request("GET", `v2/item-manager/items/${type}/${char_path}`,undefined).then((ans:AxiosResponse)=>{ const o = ans.data log.debug("GetInventory", o) let name = "bank" @@ -70,6 +71,7 @@ export class LTOApiv0 implements LTOApi { galders, items: Object.fromEntries((Object.entries(o.items) as any).map(([k, v]: [string, TricksterItem]):[string, TricksterItem]=>{ v.unique_id = Number(k) + console.log(k, v) return [k, v] })), } as TricksterInventory diff --git a/src/lib/lifeto/order.ts b/src/lib/lifeto/order.ts index 76be3b3..d02139d 100644 --- a/src/lib/lifeto/order.ts +++ b/src/lib/lifeto/order.ts @@ -117,9 +117,9 @@ export class InvalidOrder extends Order{ } export interface BasicResponse { - status: number + status: string data: any - msg?: string + message?: string } @@ -153,14 +153,14 @@ export class InternalXfer extends BasicOrder{ this.mark("WORKING") return api.BankAction("internal-xfer-item",this.originalRequest) .then((x:InternalXferResponse)=>{ - if(x.status == 200){ + if(x.status === 'success'){ this.originalResponse = x this.stage = 1 this.mark("SUCCESS") const origin_item = r.invs.value.get(this.details?.origin_path!)!.items[this.details?.item_uid!]! origin_item.item_count = origin_item.item_count - this.details?.count! }else{ - throw x.msg + throw x.message } }) .catch((e)=>{ @@ -207,14 +207,14 @@ export class BankItem extends BasicOrder{ return api.BankAction("bank-item",this.originalRequest) .then((x)=>{ debug("BankItem",x) - if(x.status == 200){ + if(x.status === 'success'){ this.stage = 1 this.originalResponse = x this.mark("SUCCESS") const origin_item = r.invs.value.get(this.details?.origin_path!)!.items[this.details?.item_uid!]! origin_item.item_count = origin_item.item_count - this.details?.count! }else { - throw x.msg ? x.msg : "unknown error" + throw x.message ? x.message : "unknown error" } }) .catch((e)=>{ @@ -272,7 +272,7 @@ export class PrivateMarket extends BasicOrder{ return api.BankAction("sell-item",this.originalRequest) .then((x)=>{ debug("PrivateMarket",x) - if(x.status == 200){ + if(x.status === 'success'){ this.stage = 1 this.originalResponse = x this.mark("SUCCESS") @@ -284,7 +284,7 @@ export class PrivateMarket extends BasicOrder{ }catch(e){ } }else { - throw x.msg ? x.msg : "unknown error" + throw x.message ? x.message : "unknown error" } }) .catch((e)=>{ @@ -364,7 +364,7 @@ export class MarketMove extends PrivateMarket { .then((x)=>{ debug("MarketMove",x) this.moveResponse = x - if(x.status == 200){ + if(x.status === 'success'){ this.moveStage = 1 this.moveState = "SUCCESS" this.newUid = x.item_uid @@ -440,7 +440,7 @@ export class MarketMoveToChar extends MarketMove { .then((x)=>{ debug("MarketMoveToChar",x) this.charResponse = x - if(x.status == 200){ + if(x.status === 'success'){ this.charStage = 1 this.charState = "SUCCESS" }else { diff --git a/src/lib/lifeto/order_manager.ts b/src/lib/lifeto/order_manager.ts index ada9212..a41cc1c 100644 --- a/src/lib/lifeto/order_manager.ts +++ b/src/lib/lifeto/order_manager.ts @@ -122,9 +122,9 @@ export class OrderSender { return notFound } const [account, name] = splitPath(target.path) - if(account != origin.path) { + /*if(account != origin.path) { return new MarketMoveToChar(this.transformInternalOrder(o)) - } + }*/ return new InternalXfer(this.transformInternalOrder(o)) } user_to_bank(o:OrderDetails): Order{ @@ -134,9 +134,9 @@ export class OrderSender { return notFound } const [account, name] = splitPath(origin.path) - if(account != target.path) { + /*if(account != target.path) { return new MarketMove(this.transformInternalOrder(o)) - } + }*/ return new BankItem(this.transformInternalOrder(o)) } user_to_user(o:OrderDetails): Order{ @@ -145,7 +145,8 @@ export class OrderSender { if(!(origin && target)) { return notFound } - return new MarketMoveToChar(this.transformInternalOrder(o)) + // return new MarketMoveToChar(this.transformInternalOrder(o)) + return new InternalXfer(this.transformInternalOrder(o)) } private transformInternalOrder(o:OrderDetails):TxnDetails { diff --git a/src/lib/old.ts b/src/lib/old.ts index 7343065..7236bc9 100644 --- a/src/lib/old.ts +++ b/src/lib/old.ts @@ -80,7 +80,7 @@ class Image implements ColumnInfo { displayName = " " renderer = coverRenderer getter(item:TricksterItem):(string|number) { - return item.image ? item.image : "" + return item.item_image ? item.item_image : "" } } @@ -255,7 +255,7 @@ class Compound implements ColumnInfo { } const compFilter= (item:TricksterItem): boolean => { - return (item.item_desc.toLowerCase().includes("compound item")) + return (item.item_comment.toLowerCase().includes("compound item")) } @@ -427,7 +427,7 @@ class Desc implements ColumnInfo { displayName = "desc" renderer = descRenderer getter(item:TricksterItem):(string|number){ - return item.item_desc + return item.item_comment } } function descRenderer(instance:any, td:any, row:any, col:any, prop:any, value:any, cellProperties:any) { diff --git a/src/lib/session.ts b/src/lib/session.ts index 93a3fff..d53cff5 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -6,7 +6,7 @@ import { getCookie, removeCookie } from "typescript-cookie"; export const SITE_ROOT = "/lifeto/" export const API_ROOT = "api/lifeto/" -export const BANK_ROOT = "item-manager-action/" +export const BANK_ROOT = "api/lifeto/v2/item-manager/" export const MARKET_ROOT = "marketplace-api/" const login_endpoint = (name:string)=>{ diff --git a/src/lib/trickster.ts b/src/lib/trickster.ts index 790fae9..a9a7695 100644 --- a/src/lib/trickster.ts +++ b/src/lib/trickster.ts @@ -1,24 +1,18 @@ -export interface ItemExpireTime { - text: string - us: string -} - export interface TricksterItem { unique_id: number; item_name: string; - item_id: number; item_count: number; - item_desc: string; + item_comment: string; item_use: string; item_slots?: number; item_min_level?: number; is_equip?: boolean; is_drill?: boolean; - item_expire_time?: ItemExpireTime; + item_expire_time?: string; refine_level?: number; refine_type?: number; refine_state?: number; - image?: string; + item_image?: string; stats?: {[key: string]:any} }