Get MakerItemCreateEntry from new info provider

This commit is contained in:
P0nk
2023-03-08 21:09:47 +01:00
parent 1fd0963401
commit 0be48568d7
5 changed files with 69 additions and 65 deletions

View File

@@ -4,6 +4,7 @@ import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import constants.id.ItemId;
import net.jcip.annotations.ThreadSafe;
import server.MakerItemFactory.MakerItemCreateEntry;
import java.util.List;
import java.util.Optional;
@@ -60,4 +61,21 @@ public class MakerInfoProvider {
fee *= 1000;
return fee;
}
public Optional<MakerItemCreateEntry> getMakerItemEntry(int itemId) {
Optional<MakerRecipe> optionalRecipe = getMakerRecipe(itemId);
if (optionalRecipe.isEmpty()) {
return Optional.empty();
}
final MakerRecipe recipe = optionalRecipe.get();
final MakerItemCreateEntry makerEntry = new MakerItemCreateEntry(recipe.mesoCost(), recipe.requiredLevel(),
recipe.requiredMakerLevel());
makerEntry.addGainItem(itemId, recipe.quantity());
final List<MakerIngredient> ingredients = getIngredients(itemId);
ingredients.forEach(i -> makerEntry.addReqItem(i.itemId(), i.count()));
return Optional.of(makerEntry);
}
}