29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
|
import CSSettingsV3 from "@/FormTable/CSSettingsV3";
|
||
|
import { Shop } from "@/define/formkey";
|
||
|
import { ResourceInfo } from "@/define/resource";
|
||
|
import Player from "@/modules/player";
|
||
|
import { State } from "@/modules/player/define/data";
|
||
|
import { NumberEx } from "@/utils/Number/NumberEx";
|
||
|
import CSResource from "../CSResource";
|
||
|
import IResourceItem from "../IResourceItem";
|
||
|
import { ResourceItemType } from "../ResourceItemType";
|
||
|
|
||
|
export default class LpPointItem implements IResourceItem {
|
||
|
public get Name(): string { return CSSettingsV3.prototype.ShopString(Shop.String.LpPoint); }
|
||
|
public get ResourceType(): ResourceItemType { return ResourceItemType.LpPoint; }
|
||
|
public ID: number;
|
||
|
public Count: number;
|
||
|
|
||
|
public AddToResource(): void {
|
||
|
const playerData: State = Player.data.getState();
|
||
|
playerData.account.lpPoint = NumberEx.plus(playerData.account.lpPoint, this.Count);
|
||
|
Player.data.setState(playerData);
|
||
|
CSResource.Event.DispatchCallback(ResourceItemType.LpPoint, [playerData.account.lpPoint, this.Count]);
|
||
|
}
|
||
|
|
||
|
/** 從db來的格式建立可數資源物件 */
|
||
|
public constructor(db: ResourceInfo | JSON) {
|
||
|
this.Count = <number>db[1];
|
||
|
}
|
||
|
}
|