mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 13:01:03 +00:00
Reimplement namecard claiming (fixes #1882)
This commit is contained in:
parent
0fb7d50acd
commit
12316b36b1
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user