| 684 | } |
| 685 | |
| 686 | void ItemDatabase::addBlueprints() { |
| 687 | auto assets = Root::singleton().assets(); |
| 688 | |
| 689 | for (auto const& recipe : m_recipes) { |
| 690 | auto baseDesc = recipe.output; |
| 691 | auto baseItem = itemShared(baseDesc); |
| 692 | |
| 693 | String blueprintName = strf("{}-recipe", baseItem->name()); |
| 694 | if (m_items.contains(blueprintName)) |
| 695 | continue; |
| 696 | |
| 697 | try { |
| 698 | ItemData blueprintData; |
| 699 | |
| 700 | blueprintData.type = ItemType::Blueprint; |
| 701 | JsonObject configInfo; |
| 702 | configInfo["recipe"] = baseDesc.singular().toJson(); |
| 703 | |
| 704 | String description = assets->json("/blueprint.config:description").toString(); |
| 705 | description = description.replace("<item>", baseItem->friendlyName()); |
| 706 | configInfo["description"] = Json(description); |
| 707 | |
| 708 | String shortDesc = assets->json("/blueprint.config:shortdescription").toString(); |
| 709 | shortDesc = shortDesc.replace("<item>", baseItem->friendlyName()); |
| 710 | configInfo["shortdescription"] = Json(shortDesc); |
| 711 | |
| 712 | configInfo["category"] = assets->json("/blueprint.config:category").toString(); |
| 713 | |
| 714 | blueprintData.name = blueprintName; |
| 715 | blueprintData.friendlyName = shortDesc; |
| 716 | configInfo["itemName"] = blueprintData.name; |
| 717 | |
| 718 | if (baseItem->instanceValue("inventoryIcon", false)) |
| 719 | configInfo["inventoryIcon"] = baseItem->instanceValue("inventoryIcon"); |
| 720 | |
| 721 | configInfo["rarity"] = RarityNames.getRight(baseItem->rarity()); |
| 722 | |
| 723 | configInfo["price"] = baseItem->price(); |
| 724 | |
| 725 | blueprintData.customConfig = std::move(configInfo); |
| 726 | blueprintData.directory = itemData(baseDesc.name()).directory; |
| 727 | |
| 728 | m_items[blueprintData.name] = blueprintData; |
| 729 | } catch (std::exception const& e) { |
| 730 | Logger::error("Could not create blueprint item from recipe: {}", outputException(e, false)); |
| 731 | } |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | void ItemDatabase::addCodexes() { |
| 736 | auto assets = Root::singleton().assets(); |
nothing calls this directly
no test coverage detected