From 08ef3f7b32962648f2f9c9b4f3f77d78d2f66391 Mon Sep 17 00:00:00 2001 From: hudescottes Date: Sun, 2 Jun 2024 23:14:48 +0200 Subject: [PATCH] Add rarity to items --- .gitignore | 2 +- README.md | 1 + .../com/gdx/game/inventory/InventoryItem.java | 36 + .../inventory/slot/InventorySlotTooltip.java | 7 +- .../slot/InventorySlotTooltipListener.java | 2 +- .../resources/scripts/inventory_items.json | 680 +++++++++--------- 6 files changed, 405 insertions(+), 323 deletions(-) diff --git a/.gitignore b/.gitignore index f5c8a719..0782f0c3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ lib/ *.hprof .DS_Store *.sav -/**/settings/keys.json +**/settings ### STS ### .apt_generated diff --git a/README.md b/README.md index dafdd3c1..d9f0bef8 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ graph TD; - [x] battle feature - [ ] entities' animation while attacking + - [ ] ultimate attack cutscene - [ ] implement bonus gained by class - [ ] implement magic, resist, ... stats diff --git a/core/src/main/java/com/gdx/game/inventory/InventoryItem.java b/core/src/main/java/com/gdx/game/inventory/InventoryItem.java index 9c9fdde5..abb061cb 100644 --- a/core/src/main/java/com/gdx/game/inventory/InventoryItem.java +++ b/core/src/main/java/com/gdx/game/inventory/InventoryItem.java @@ -1,5 +1,6 @@ package com.gdx.game.inventory; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.scenes.scene2d.ui.Image; @@ -61,10 +62,36 @@ public enum ItemTypeID { NONE } + public enum ItemRarity { + COMMON("Common", Color.DARK_GRAY), + UNCOMMON("Uncommon", Color.GREEN), + RARE("Rare", Color.BLUE), + EPIC("Epic", Color.MAGENTA), + LEGENDARY("Legendary", Color.ORANGE), + UNIQUE("Unique", Color.RED); + + private final String value; + private final Color itemRarityColor; + + ItemRarity(String value, Color itemRarityColor) { + this.value = value; + this.itemRarityColor = itemRarityColor; + } + + public String getValue() { + return value; + } + + public Color getColor() { + return itemRarityColor; + } + } + private int itemAttributes; private int itemUseType; private int itemUseTypeValue; private ItemTypeID itemTypeID; + private ItemRarity itemRarity; private String itemShortDescription; private int itemValue; @@ -88,6 +115,7 @@ public InventoryItem(InventoryItem inventoryItem) { this.itemAttributes = inventoryItem.getItemAttributes(); this.itemUseType = inventoryItem.getItemUseType(); this.itemUseTypeValue = inventoryItem.getItemUseTypeValue(); + this.itemRarity = inventoryItem.getItemRarity(); this.itemShortDescription = inventoryItem.getItemShortDescription(); this.itemValue = inventoryItem.getItemValue(); } @@ -132,6 +160,14 @@ public void setItemUseType(int itemUseType) { this.itemUseType = itemUseType; } + public ItemRarity getItemRarity() { + return itemRarity; + } + + public void setItemRarity(ItemRarity itemRarity) { + this.itemRarity = itemRarity; + } + public String getItemShortDescription() { return itemShortDescription; } diff --git a/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltip.java b/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltip.java index 9fb8bd82..3b9b165b 100644 --- a/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltip.java +++ b/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltip.java @@ -34,10 +34,12 @@ public void setVisible(InventorySlot inventorySlot, boolean visible) { } } - public void updateDescription(InventorySlot inventorySlot){ + public void updateTooltip(InventorySlot inventorySlot) { if (inventorySlot.hasItem()) { StringBuilder string = new StringBuilder(); InventoryItem item = inventorySlot.getTopInventoryItem(); + string.append(String.format("Rarity: %s", item.getItemRarity().getValue())); + string.append(System.getProperty("line.separator")); string.append(item.getItemShortDescription()); if (item.isInventoryItemOffensive()) { string.append(System.getProperty("line.separator")); @@ -52,6 +54,9 @@ public void updateDescription(InventorySlot inventorySlot){ string.append(String.format("Trade Value: %s GP", item.getTradeValue())); description.setText(string); + + this.getTitleLabel().setText(item.getItemTypeID().toString()); + this.getTitleLabel().setColor(item.getItemRarity().getColor()); } else { description.setText(""); } diff --git a/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltipListener.java b/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltipListener.java index 7c9c59bc..d66581cf 100644 --- a/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltipListener.java +++ b/core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltipListener.java @@ -51,7 +51,7 @@ public void enter(InputEvent event, float x, float y, int pointer, Actor fromAct currentCoords.set(x, y); inventorySlot.localToStageCoordinates(currentCoords); - tooltip.updateDescription(inventorySlot); + tooltip.updateTooltip(inventorySlot); tooltip.setPosition(currentCoords.x + offset.x, currentCoords.y + offset.y); tooltip.toFront(); tooltip.setVisible(inventorySlot, true); diff --git a/core/src/main/resources/scripts/inventory_items.json b/core/src/main/resources/scripts/inventory_items.json index da7e6201..fd9b9cd8 100644 --- a/core/src/main/resources/scripts/inventory_items.json +++ b/core/src/main/resources/scripts/inventory_items.json @@ -1,323 +1,363 @@ [ -{ - itemAttributes: 2 - itemUseType: 128 - itemUseTypeValue: 20 - itemTypeID: SHIELD01 - itemShortDescription: Medium tier shield forged from copper - itemValue: 50 -}, -{ - itemAttributes: 2 - itemUseType: 128 - itemUseTypeValue: 10 - itemTypeID: SHIELD02 - itemShortDescription: A wooden shield fit for a peasant - itemValue: 25 -}, -{ - itemAttributes: 2 - itemUseType: 128 - itemUseTypeValue: 30 - itemTypeID: SHIELD03 - itemShortDescription: Medium tier shield carved from dragon bone - itemValue: 100 -}, -{ - itemAttributes: 2 - itemUseType: 128 - itemUseTypeValue: 60 - itemTypeID: SHIELD04 - itemShortDescription: Top tier shield forged from iron - itemValue: 200 -}, -{ - itemAttributes: 2 - itemUseType: 128 - itemUseTypeValue: 100 - itemTypeID: SHIELD05 - itemShortDescription: Top tier shield forged by a rare metal Adamantium - itemValue: 400 -}, -{ - itemAttributes: 2 - itemUseType: 512 - itemUseTypeValue: 60 - itemTypeID: ARMOR01 - itemShortDescription: Top tier armor built from the scales of a dragon - itemValue: 200 -}, -{ - itemAttributes: 2 - itemUseType: 512 - itemUseTypeValue: 30 - itemTypeID: ARMOR02 - itemShortDescription: Top tier armor blessed by fairies - itemValue: 100 -}, -{ - itemAttributes: 2 - itemUseType: 512 - itemUseTypeValue: 100 - itemTypeID: ARMOR03 - itemShortDescription: Top tier armor forged from the hide of a hellspawn demon - itemValue: 400 -}, -{ - itemAttributes: 2 - itemUseType: 512 - itemUseTypeValue: 10 - itemTypeID: ARMOR04 - itemShortDescription: Broken mail armor fit for a peasant - itemValue: 25 -}, -{ - itemAttributes: 2 - itemUseType: 512 - itemUseTypeValue: 20 - itemTypeID: ARMOR05 - itemShortDescription: Medium tier armor with iron plates - itemValue: 50 -}, -{ - itemAttributes: 2 - itemUseType: 1024 - itemUseTypeValue: 60 - itemTypeID: BOOTS01 - itemShortDescription: Top tier boots worthy of a knight - itemValue: 200 -}, -{ - itemAttributes: 2 - itemUseType: 1024 - itemUseTypeValue: 20 - itemTypeID: BOOTS02 - itemShortDescription: Medium tier boots with iron buckles - itemValue: 50 -}, -{ - itemAttributes: 2 - itemUseType: 1024 - itemUseTypeValue: 10 - itemTypeID: BOOTS03 - itemShortDescription: Leather boots fit for a peasant - itemValue: 25 -}, -{ - itemAttributes: 2 - itemUseType: 1024 - itemUseTypeValue: 30 - itemTypeID: BOOTS04 - itemShortDescription: Medium tier boots made of imp hide - itemValue: 100 -}, -{ - itemAttributes: 2 - itemUseType: 1024 - itemUseTypeValue: 100 - itemTypeID: BOOTS05 - itemShortDescription: Top tier boots made from dragon's tongue - itemValue: 400 -}, -{ - itemAttributes: 2 - itemUseType: 256 - itemUseTypeValue: 100 - itemTypeID: HELMET01 - itemShortDescription: Top tier helmet built for a king's guard - itemValue: 400 -}, -{ - itemAttributes: 2 - itemUseType: 256 - itemUseTypeValue: 20 - itemTypeID: HELMET02 - itemShortDescription: A medium tier helmet made of copper - itemValue: 50 -}, -{ - itemAttributes: 2 - itemUseType: 256 - itemUseTypeValue: 60 - itemTypeID: HELMET03 - itemShortDescription: A medium tier helmet built for prolonged battles - itemValue: 200 -}, -{ - itemAttributes: 2 - itemUseType: 256 - itemUseTypeValue: 30 - itemTypeID: HELMET04 - itemShortDescription: A medium tier helmet forged from iron - itemValue: 100 -}, -{ - itemAttributes: 2 - itemUseType: 256 - itemUseTypeValue: 10 - itemTypeID: HELMET05 - itemShortDescription: A leather helmet fit for a peasant - itemValue: 25 -}, -{ - itemAttributes: 2 - itemUseType: 32 - itemUseTypeValue: 100 - itemTypeID: WANDS01 - itemShortDescription: Top tier wand used by fairies - itemValue: 400 -}, -{ - itemAttributes: 2 - itemUseType: 32 - itemUseTypeValue: 10 - itemTypeID: WANDS02 - itemShortDescription: Small wand used by mage apprentices - itemValue: 25 -}, -{ - itemAttributes: 2 - itemUseType: 32 - itemUseTypeValue: 60 - itemTypeID: WANDS03 - itemShortDescription: Medium tier wand used to smite fire demons - itemValue: 200 -}, -{ - itemAttributes: 2 - itemUseType: 64 - itemUseTypeValue: 20 - itemTypeID: WANDS04 - itemShortDescription: Medium tier wand used for spell damage bonuses - itemValue: 50 -}, -{ - itemAttributes: 2 - itemUseType: 64 - itemUseTypeValue: 30 - itemTypeID: WANDS05 - itemShortDescription: Medium tier wand used to increase luck in loot drops - itemValue: 100 -}, -{ - itemAttributes: 2 - itemUseType: 8 - itemUseTypeValue: 10 - itemTypeID: WEAPON01 - itemShortDescription: A copper sword of a peasant - itemValue: 25 -}, -{ - itemAttributes: 2 - itemUseType: 8 - itemUseTypeValue: 100 - itemTypeID: WEAPON02 - itemShortDescription: Top tier sword forged from the hate of the demon king - itemValue: 400 -}, -{ - itemAttributes: 2 - itemUseType: 16 - itemUseTypeValue: 30 - itemTypeID: WEAPON03 - itemShortDescription: Medium tier axe forged from iron - itemValue: 100 -}, -{ - itemAttributes: 2 - itemUseType: 16 - itemUseTypeValue: 60 - itemTypeID: WEAPON04 - itemShortDescription: Top tier pike used by the king's guard - itemValue: 200 -}, -{ - itemAttributes: 2 - itemUseType: 16 - itemUseTypeValue: 20 - itemTypeID: WEAPON05 - itemShortDescription: Medium tier hammer forged from iron - itemValue: 50 -}, -{ - itemAttributes: 5 - itemUseType: 2 - itemUseTypeValue: 10 - itemTypeID: POTIONS01 - itemShortDescription: Potion that restores 10MP - itemValue: 10 -}, -{ - itemAttributes: 5 - itemUseType: 2 - itemUseTypeValue: 50 - itemTypeID: POTIONS02 - itemShortDescription: Potion that restores 50MP - itemValue: 50 -}, -{ - itemAttributes: 5 - itemUseType: 2 - itemUseTypeValue: 100 - itemTypeID: POTIONS03 - itemShortDescription: Potion that restores 100MP - itemValue: 100 -}, -{ - itemAttributes: 5 - itemUseType: 1 - itemUseTypeValue: 10 - itemTypeID: SCROLL01 - itemShortDescription: Scroll that restores 10HP - itemValue: 10 -}, -{ - itemAttributes: 5 - itemUseType: 1 - itemUseTypeValue: 50 - itemTypeID: SCROLL02 - itemShortDescription: Scroll that restores 50HP - itemValue: 50 -}, -{ - itemAttributes: 5 - itemUseType: 1 - itemUseTypeValue: 100 - itemTypeID: SCROLL03 - itemShortDescription: Scroll that restores 100HP - itemValue: 100 -}, -{ - itemAttributes: 4 - itemUseType: 2048 - itemUseTypeValue: 0 - itemTypeID: HERB001 - itemShortDescription: Quest Item Herb - itemValue: -1 -}, -{ - itemAttributes: 4 - itemUseType: 2048 - itemUseTypeValue: 0 - itemTypeID: BABY001 - itemShortDescription: Quest Item Baby - itemValue: -1 -}, -{ - itemAttributes: 4 - itemUseType: 2048 - itemUseTypeValue: 0 - itemTypeID: FUR001 - itemShortDescription: Quest Item Fur - itemValue: -1 -}, -{ - itemAttributes: 4 - itemUseType: 2048 - itemUseTypeValue: 0 - itemTypeID: HORNS001 - itemShortDescription: Quest Item Horns - itemValue: -1 -}, + { + itemAttributes: 2 + itemUseType: 128 + itemUseTypeValue: 20 + itemTypeID: SHIELD01 + itemRarity: COMMON + itemShortDescription: Medium tier shield forged from copper + itemValue: 50 + }, + { + itemAttributes: 2 + itemUseType: 128 + itemUseTypeValue: 10 + itemTypeID: SHIELD02 + itemRarity: COMMON + itemShortDescription: A wooden shield fit for a peasant + itemValue: 25 + }, + { + itemAttributes: 2 + itemUseType: 128 + itemUseTypeValue: 30 + itemTypeID: SHIELD03 + itemRarity: COMMON + itemShortDescription: Medium tier shield carved from dragon bone + itemValue: 100 + }, + { + itemAttributes: 2 + itemUseType: 128 + itemUseTypeValue: 60 + itemTypeID: SHIELD04 + itemRarity: COMMON + itemShortDescription: Top tier shield forged from iron + itemValue: 200 + }, + { + itemAttributes: 2 + itemUseType: 128 + itemUseTypeValue: 100 + itemTypeID: SHIELD05 + itemRarity: COMMON + itemShortDescription: Top tier shield forged by a rare metal Adamantium + itemValue: 400 + }, + { + itemAttributes: 2 + itemUseType: 512 + itemUseTypeValue: 60 + itemTypeID: ARMOR01 + itemRarity: COMMON + itemShortDescription: Top tier armor built from the scales of a dragon + itemValue: 200 + }, + { + itemAttributes: 2 + itemUseType: 512 + itemUseTypeValue: 30 + itemTypeID: ARMOR02 + itemRarity: COMMON + itemShortDescription: Top tier armor blessed by fairies + itemValue: 100 + }, + { + itemAttributes: 2 + itemUseType: 512 + itemUseTypeValue: 100 + itemTypeID: ARMOR03 + itemRarity: COMMON + itemShortDescription: Top tier armor forged from the hide of a hellspawn demon + itemValue: 400 + }, + { + itemAttributes: 2 + itemUseType: 512 + itemUseTypeValue: 10 + itemTypeID: ARMOR04 + itemRarity: COMMON + itemShortDescription: Broken mail armor fit for a peasant + itemValue: 25 + }, + { + itemAttributes: 2 + itemUseType: 512 + itemUseTypeValue: 20 + itemTypeID: ARMOR05 + itemRarity: COMMON + itemShortDescription: Medium tier armor with iron plates + itemValue: 50 + }, + { + itemAttributes: 2 + itemUseType: 1024 + itemUseTypeValue: 60 + itemTypeID: BOOTS01 + itemRarity: COMMON + itemShortDescription: Top tier boots worthy of a knight + itemValue: 200 + }, + { + itemAttributes: 2 + itemUseType: 1024 + itemUseTypeValue: 20 + itemTypeID: BOOTS02 + itemRarity: COMMON + itemShortDescription: Medium tier boots with iron buckles + itemValue: 50 + }, + { + itemAttributes: 2 + itemUseType: 1024 + itemUseTypeValue: 10 + itemTypeID: BOOTS03 + itemRarity: COMMON + itemShortDescription: Leather boots fit for a peasant + itemValue: 25 + }, + { + itemAttributes: 2 + itemUseType: 1024 + itemUseTypeValue: 30 + itemTypeID: BOOTS04 + itemRarity: COMMON + itemShortDescription: Medium tier boots made of imp hide + itemValue: 100 + }, + { + itemAttributes: 2 + itemUseType: 1024 + itemUseTypeValue: 100 + itemTypeID: BOOTS05 + itemRarity: COMMON + itemShortDescription: Top tier boots made from dragon's tongue + itemValue: 400 + }, + { + itemAttributes: 2 + itemUseType: 256 + itemUseTypeValue: 100 + itemTypeID: HELMET01 + itemRarity: COMMON + itemShortDescription: Top tier helmet built for a king's guard + itemValue: 400 + }, + { + itemAttributes: 2 + itemUseType: 256 + itemUseTypeValue: 20 + itemTypeID: HELMET02 + itemRarity: COMMON + itemShortDescription: A medium tier helmet made of copper + itemValue: 50 + }, + { + itemAttributes: 2 + itemUseType: 256 + itemUseTypeValue: 60 + itemTypeID: HELMET03 + itemRarity: COMMON + itemShortDescription: A medium tier helmet built for prolonged battles + itemValue: 200 + }, + { + itemAttributes: 2 + itemUseType: 256 + itemUseTypeValue: 30 + itemTypeID: HELMET04 + itemRarity: COMMON + itemShortDescription: A medium tier helmet forged from iron + itemValue: 100 + }, + { + itemAttributes: 2 + itemUseType: 256 + itemUseTypeValue: 10 + itemTypeID: HELMET05 + itemRarity: COMMON + itemShortDescription: A leather helmet fit for a peasant + itemValue: 25 + }, + { + itemAttributes: 2 + itemUseType: 32 + itemUseTypeValue: 100 + itemTypeID: WANDS01 + itemRarity: COMMON + itemShortDescription: Top tier wand used by fairies + itemValue: 400 + }, + { + itemAttributes: 2 + itemUseType: 32 + itemUseTypeValue: 10 + itemTypeID: WANDS02 + itemRarity: UNCOMMON + itemShortDescription: Small wand used by mage apprentices + itemValue: 25 + }, + { + itemAttributes: 2 + itemUseType: 32 + itemUseTypeValue: 60 + itemTypeID: WANDS03 + itemRarity: COMMON + itemShortDescription: Medium tier wand used to smite fire demons + itemValue: 200 + }, + { + itemAttributes: 2 + itemUseType: 64 + itemUseTypeValue: 20 + itemTypeID: WANDS04 + itemRarity: COMMON + itemShortDescription: Medium tier wand used for spell damage bonuses + itemValue: 50 + }, + { + itemAttributes: 2 + itemUseType: 64 + itemUseTypeValue: 30 + itemTypeID: WANDS05 + itemRarity: COMMON + itemShortDescription: Medium tier wand used to increase luck in loot drops + itemValue: 100 + }, + { + itemAttributes: 2 + itemUseType: 8 + itemUseTypeValue: 10 + itemTypeID: WEAPON01 + itemRarity: COMMON + itemShortDescription: A copper sword of a peasant + itemValue: 25 + }, + { + itemAttributes: 2 + itemUseType: 8 + itemUseTypeValue: 100 + itemTypeID: WEAPON02 + itemRarity: COMMON + itemShortDescription: Top tier sword forged from the hate of the demon king + itemValue: 400 + }, + { + itemAttributes: 2 + itemUseType: 16 + itemUseTypeValue: 30 + itemTypeID: WEAPON03 + itemRarity: COMMON + itemShortDescription: Medium tier axe forged from iron + itemValue: 100 + }, + { + itemAttributes: 2 + itemUseType: 16 + itemUseTypeValue: 60 + itemTypeID: WEAPON04 + itemRarity: COMMON + itemShortDescription: Top tier pike used by the king's guard + itemValue: 200 + }, + { + itemAttributes: 2 + itemUseType: 16 + itemUseTypeValue: 20 + itemTypeID: WEAPON05 + itemRarity: COMMON + itemShortDescription: Medium tier hammer forged from iron + itemValue: 50 + }, + { + itemAttributes: 5 + itemUseType: 2 + itemUseTypeValue: 10 + itemTypeID: POTIONS01 + itemRarity: COMMON + itemShortDescription: Potion that restores 10MP + itemValue: 10 + }, + { + itemAttributes: 5 + itemUseType: 2 + itemUseTypeValue: 50 + itemTypeID: POTIONS02 + itemRarity: COMMON + itemShortDescription: Potion that restores 50MP + itemValue: 50 + }, + { + itemAttributes: 5 + itemUseType: 2 + itemUseTypeValue: 100 + itemTypeID: POTIONS03 + itemRarity: COMMON + itemShortDescription: Potion that restores 100MP + itemValue: 100 + }, + { + itemAttributes: 5 + itemUseType: 1 + itemUseTypeValue: 10 + itemTypeID: SCROLL01 + itemRarity: COMMON + itemShortDescription: Scroll that restores 10HP + itemValue: 10 + }, + { + itemAttributes: 5 + itemUseType: 1 + itemUseTypeValue: 50 + itemTypeID: SCROLL02 + itemRarity: COMMON + itemShortDescription: Scroll that restores 50HP + itemValue: 50 + }, + { + itemAttributes: 5 + itemUseType: 1 + itemUseTypeValue: 100 + itemTypeID: SCROLL03 + itemRarity: COMMON + itemShortDescription: Scroll that restores 100HP + itemValue: 100 + }, + { + itemAttributes: 4 + itemUseType: 2048 + itemUseTypeValue: 0 + itemTypeID: HERB001 + itemRarity: COMMON + itemShortDescription: Quest Item Herb + itemValue: -1 + }, + { + itemAttributes: 4 + itemUseType: 2048 + itemUseTypeValue: 0 + itemTypeID: BABY001 + itemRarity: COMMON + itemShortDescription: Quest Item Baby + itemValue: -1 + }, + { + itemAttributes: 4 + itemUseType: 2048 + itemUseTypeValue: 0 + itemTypeID: FUR001 + itemRarity: COMMON + itemShortDescription: Quest Item Fur + itemValue: -1 + }, + { + itemAttributes: 4 + itemUseType: 2048 + itemUseTypeValue: 0 + itemTypeID: HORNS001 + itemRarity: COMMON + itemShortDescription: Quest Item Horns + itemValue: -1 + }, ] \ No newline at end of file