Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
12316b36
Commit
12316b36
authored
Nov 04, 2022
by
AnimeGitB
Browse files
Reimplement namecard claiming (fixes #1882)
parent
0fb7d50a
Changes
5
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
12316b36
...
...
@@ -181,6 +181,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
if
(
data
.
isUseOnGain
())
{
var
params
=
new
UseItemParams
(
this
.
player
,
data
.
getUseTarget
());
params
.
usedItemId
=
data
.
getId
();
this
.
player
.
getServer
().
getInventorySystem
().
useItemDirect
(
data
,
params
);
return
null
;
}
...
...
src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseAction.java
View file @
12316b36
...
...
@@ -24,7 +24,7 @@ public class ItemUseAction {
case
ITEM_USE_GAIN_AVATAR
->
new
ItemUseGainAvatar
(
useParam
);
case
ITEM_USE_GAIN_COSTUME
->
new
ItemUseGainCostume
(
useParam
);
// TODO - real success/fail
case
ITEM_USE_GAIN_FLYCLOAK
->
new
ItemUseGainFlycloak
(
useParam
);
// TODO - real success/fail
case
ITEM_USE_GAIN_NAME_CARD
->
new
ItemUseGainNameCard
(
useParam
);
// TODO
case
ITEM_USE_GAIN_NAME_CARD
->
new
ItemUseGainNameCard
(
useParam
);
case
ITEM_USE_CHEST_SELECT_ITEM
->
new
ItemUseChestSelectItem
(
useParam
);
case
ITEM_USE_ADD_SELECT_ITEM
->
new
ItemUseAddSelectItem
(
useParam
);
case
ITEM_USE_GRANT_SELECT_REWARD
->
new
ItemUseGrantSelectReward
(
useParam
);
...
...
src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseGainNameCard.java
View file @
12316b36
...
...
@@ -13,6 +13,7 @@ public class ItemUseGainNameCard extends ItemUseAction {
@Override
public
boolean
useItem
(
UseItemParams
params
)
{
return
false
;
// TODO: work out if this is actually used and how to get the namecard id
params
.
player
.
addNameCard
(
params
.
usedItemId
);
return
true
;
}
}
src/main/java/emu/grasscutter/game/props/ItemUseAction/UseItemParams.java
View file @
12316b36
...
...
@@ -12,6 +12,7 @@ public class UseItemParams {
public
int
count
=
1
;
public
int
optionId
=
0
;
public
boolean
isEnterMpDungeonTeam
=
false
;
public
int
usedItemId
=
0
;
public
UseItemParams
(
Player
player
,
ItemUseTarget
itemUseTarget
,
Avatar
targetAvatar
,
int
count
,
int
optionId
,
boolean
isEnterMpDungeonTeam
)
{
this
.
player
=
player
;
...
...
src/main/java/emu/grasscutter/game/systems/InventorySystem.java
View file @
12316b36
...
...
@@ -743,6 +743,7 @@ public class InventorySystem extends BaseGameSystem {
if
(
itemData
==
null
)
return
null
;
var
params
=
new
UseItemParams
(
player
,
itemData
.
getUseTarget
(),
target
,
count
,
optionId
,
isEnterMpDungeonTeam
);
params
.
usedItemId
=
item
.
getItemId
();
if
(
useItemDirect
(
itemData
,
params
))
{
player
.
getInventory
().
removeItem
(
item
,
count
);
var
actions
=
itemData
.
getItemUseActions
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment