Commit 12316b36 authored by AnimeGitB's avatar AnimeGitB
Browse files

Reimplement namecard claiming (fixes #1882)

parent 0fb7d50a
...@@ -181,6 +181,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> { ...@@ -181,6 +181,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
if (data.isUseOnGain()) { if (data.isUseOnGain()) {
var params = new UseItemParams(this.player, data.getUseTarget()); var params = new UseItemParams(this.player, data.getUseTarget());
params.usedItemId = data.getId();
this.player.getServer().getInventorySystem().useItemDirect(data, params); this.player.getServer().getInventorySystem().useItemDirect(data, params);
return null; return null;
} }
......
...@@ -24,7 +24,7 @@ public class ItemUseAction { ...@@ -24,7 +24,7 @@ public class ItemUseAction {
case ITEM_USE_GAIN_AVATAR -> new ItemUseGainAvatar(useParam); case ITEM_USE_GAIN_AVATAR -> new ItemUseGainAvatar(useParam);
case ITEM_USE_GAIN_COSTUME -> new ItemUseGainCostume(useParam); // TODO - real success/fail 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_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_CHEST_SELECT_ITEM -> new ItemUseChestSelectItem(useParam);
case ITEM_USE_ADD_SELECT_ITEM -> new ItemUseAddSelectItem(useParam); case ITEM_USE_ADD_SELECT_ITEM -> new ItemUseAddSelectItem(useParam);
case ITEM_USE_GRANT_SELECT_REWARD -> new ItemUseGrantSelectReward(useParam); case ITEM_USE_GRANT_SELECT_REWARD -> new ItemUseGrantSelectReward(useParam);
......
...@@ -13,6 +13,7 @@ public class ItemUseGainNameCard extends ItemUseAction { ...@@ -13,6 +13,7 @@ public class ItemUseGainNameCard extends ItemUseAction {
@Override @Override
public boolean useItem(UseItemParams params) { 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 { ...@@ -12,6 +12,7 @@ public class UseItemParams {
public int count = 1; public int count = 1;
public int optionId = 0; public int optionId = 0;
public boolean isEnterMpDungeonTeam = false; public boolean isEnterMpDungeonTeam = false;
public int usedItemId = 0;
public UseItemParams(Player player, ItemUseTarget itemUseTarget, Avatar targetAvatar, int count, int optionId, boolean isEnterMpDungeonTeam) { public UseItemParams(Player player, ItemUseTarget itemUseTarget, Avatar targetAvatar, int count, int optionId, boolean isEnterMpDungeonTeam) {
this.player = player; this.player = player;
......
...@@ -743,6 +743,7 @@ public class InventorySystem extends BaseGameSystem { ...@@ -743,6 +743,7 @@ public class InventorySystem extends BaseGameSystem {
if (itemData == null) return null; if (itemData == null) return null;
var params = new UseItemParams(player, itemData.getUseTarget(), target, count, optionId, isEnterMpDungeonTeam); var params = new UseItemParams(player, itemData.getUseTarget(), target, count, optionId, isEnterMpDungeonTeam);
params.usedItemId = item.getItemId();
if (useItemDirect(itemData, params)) { if (useItemDirect(itemData, params)) {
player.getInventory().removeItem(item, count); player.getInventory().removeItem(item, count);
var actions = itemData.getItemUseActions(); var actions = itemData.getItemUseActions();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment