mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 17:53:21 +08:00
Merge remote-tracking branch 'origin/unstable' into unstable
This commit is contained in:
commit
92afa64629
@ -36,8 +36,7 @@ export async function grantAvatar(
|
|||||||
talents = 6
|
talents = 6
|
||||||
): Promise<CommandResponse> {
|
): Promise<CommandResponse> {
|
||||||
// Validate the numbers.
|
// Validate the numbers.
|
||||||
if (invalid(avatar) || invalid(level)
|
if (invalid(avatar) || invalid(level) || invalid(constellations) || invalid(talents))
|
||||||
|| invalid(constellations) || invalid(talents))
|
|
||||||
return { status: -1, message: "Invalid arguments." };
|
return { status: -1, message: "Invalid arguments." };
|
||||||
|
|
||||||
return await fetch(`https://localhost:443/handbook/avatar`, {
|
return await fetch(`https://localhost:443/handbook/avatar`, {
|
||||||
@ -60,18 +59,16 @@ export async function grantAvatar(
|
|||||||
* @param item The item's ID.
|
* @param item The item's ID.
|
||||||
* @param amount The amount of the item to give.
|
* @param amount The amount of the item to give.
|
||||||
*/
|
*/
|
||||||
export async function giveItem(
|
export async function giveItem(item: number, amount = 1): Promise<CommandResponse> {
|
||||||
item: number, amount = 1
|
|
||||||
): Promise<CommandResponse> {
|
|
||||||
// Validate the number.
|
// Validate the number.
|
||||||
if (isNaN(amount) || amount < 1)
|
if (isNaN(amount) || amount < 1) return { status: -1, message: "Invalid amount." };
|
||||||
return { status: -1, message: "Invalid amount." };
|
|
||||||
|
|
||||||
return await fetch(`https://localhost:443/handbook/item`, {
|
return await fetch(`https://localhost:443/handbook/item`, {
|
||||||
method: "POST", body: JSON.stringify({
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
player: targetPlayer.toString(),
|
player: targetPlayer.toString(),
|
||||||
item: item.toString(),
|
item: item.toString(),
|
||||||
amount
|
amount
|
||||||
})
|
})
|
||||||
}).then(res => res.json());
|
}).then((res) => res.json());
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,10 @@ class ItemCard extends React.Component<IProps, IState> {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private async addToInventory(): Promise<void> {
|
private async addToInventory(): Promise<void> {
|
||||||
await giveItem(this.props.item?.id ?? 102,
|
await giveItem(
|
||||||
typeof(this.state.count) == "string" ?
|
this.props.item?.id ?? 102,
|
||||||
parseInt(this.state.count) : this.state.count);
|
typeof this.state.count == "string" ? parseInt(this.state.count) : this.state.count
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>, snapshot?: any) {
|
componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>, snapshot?: any) {
|
||||||
|
Loading…
Reference in New Issue
Block a user