Reimplement namecard claiming (fixes #1882)

This commit is contained in:
AnimeGitB 2022-11-04 15:05:51 +10:30
parent 0fb7d50acd
commit 12316b36b1
5 changed files with 6 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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();