|
@@ -16,11 +16,15 @@
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
-package com.iohao.mmo.common.provide.kit;
|
|
|
+package com.iohao.mmo.client.common.item;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.iohao.mmo.common.provide.kit.JsonKit;
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* 客户端 - 物品通用工具
|
|
|
*
|
|
@@ -29,21 +33,27 @@ import lombok.experimental.UtilityClass;
|
|
|
*/
|
|
|
@UtilityClass
|
|
|
public class ItemTypeNodeKit {
|
|
|
- public ItemNodeMap itemNodeMap = new ItemNodeMap();
|
|
|
+ final Map<String, InternalItemTypeConfig> map = new HashMap<>();
|
|
|
+
|
|
|
+ public void add(String itemTypeId, String name, String description) {
|
|
|
+ var nodeConfig = new InternalItemTypeConfig(itemTypeId, name, description);
|
|
|
+
|
|
|
+ map.put(itemTypeId, nodeConfig);
|
|
|
+ }
|
|
|
|
|
|
- public String toString(ItemNode itemNode) {
|
|
|
- var node = itemNodeMap.getItem(itemNode.itemId());
|
|
|
+ public String toString(ItemTypeNode itemTypeNode) {
|
|
|
+ var nodeConfig = map.get(itemTypeNode.itemTypeId());
|
|
|
String line = "\n物品信息:[%s x %s];物品描述:%s";
|
|
|
|
|
|
return String.format(line
|
|
|
- , node.name()
|
|
|
- , itemNode.quantity()
|
|
|
- , node.description()
|
|
|
+ , nodeConfig.name()
|
|
|
+ , itemTypeNode.quantity()
|
|
|
+ , nodeConfig.description()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public JSONObject toJSON(String itemId) {
|
|
|
- var item = itemNodeMap.getItem(itemId);
|
|
|
- return JsonKit.toJSON(item);
|
|
|
+ public JSONObject toJSON(String itemTypeId) {
|
|
|
+ var nodeConfig = map.get(itemTypeId);
|
|
|
+ return JsonKit.toJSON(nodeConfig);
|
|
|
}
|
|
|
}
|