Attempting to construct city results in NullPointerException
To Reproduce:
Steps to reproduce the behavior:
Start new game
Enter the following command: construct city
Expected behavior:
I expect the game to not crash. I don't know what a city is intended to do yet, so I can't speak to any further expected behavior
Desktop (please complete the following information):
OS: Linux Mint 19.1 Tessa
Version: 0.8.2
Java vendor: OpenJDK
Java version: 11.0.10
Stack trace:
Exception in thread "main" java.lang.NullPointerException
at com.samgauck.CityManagement.Economy.getPrice(Economy.java:95)
at com.samgauck.CityManagement.Economy.updatePrice(Economy.java:129)
at com.samgauck.CityManagement.Command.construct(Command.java:277)
at com.samgauck.CityManagement.Command.execute(Command.java:69)
at com.samgauck.CityManagement.Main.main(Main.java:143)
Additional context:
At a glance, it seems like it is trying to update the price of city after constructing it. But "city" is not in the list of items, so it fails. One possible solution is to simply not try to update the price if the constructable is not in items. In fact, I think that is what was intended by this:
if (!item.contains(item)) return;
I think that line was meant to be this
if (!items.contains(item)) return;
Describe the bug:
Attempting to construct city results in NullPointerException
To Reproduce:
Steps to reproduce the behavior:
construct city
Expected behavior:
I expect the game to not crash. I don't know what a city is intended to do yet, so I can't speak to any further expected behavior
Desktop (please complete the following information):
Stack trace:
Additional context:
At a glance, it seems like it is trying to update the price of city after constructing it. But "city" is not in the list of items, so it fails. One possible solution is to simply not try to update the price if the constructable is not in items. In fact, I think that is what was intended by this:
if (!item.contains(item)) return;
I think that line was meant to be thisif (!items.contains(item)) return;