|
@ -1,5 +1,6 @@ |
|
|
package org.bitbiome.shop; |
|
|
package org.bitbiome.shop; |
|
|
|
|
|
|
|
|
|
|
|
import org.bitbiome.classes.JsonParser; |
|
|
import org.json.JSONArray; |
|
|
import org.json.JSONArray; |
|
|
import org.json.JSONObject; |
|
|
import org.json.JSONObject; |
|
|
|
|
|
|
|
@ -14,6 +15,7 @@ import java.util.Random; |
|
|
public class Shop { |
|
|
public class Shop { |
|
|
public ArrayList<Item> allItems; |
|
|
public ArrayList<Item> allItems; |
|
|
public ArrayList<Item> currentShopItems; |
|
|
public ArrayList<Item> currentShopItems; |
|
|
|
|
|
public JsonParser jsonParser = new JsonParser(); |
|
|
|
|
|
|
|
|
public Shop() { |
|
|
public Shop() { |
|
|
try { |
|
|
try { |
|
@ -79,9 +81,7 @@ public class Shop { |
|
|
tempJSON.put("amount", intNewAmount); |
|
|
tempJSON.put("amount", intNewAmount); |
|
|
jsonArray2.put(tempJSON); |
|
|
jsonArray2.put(tempJSON); |
|
|
gameConfig.put("shopitems", jsonArray2); |
|
|
gameConfig.put("shopitems", jsonArray2); |
|
|
FileWriter fileWriter = new FileWriter("src/main/resources/gameconfig.json"); |
|
|
|
|
|
fileWriter.write(gameConfig.toString()); |
|
|
|
|
|
fileWriter.close(); |
|
|
|
|
|
|
|
|
jsonParser.writeObject("gameconfig.json", gameConfig); |
|
|
currentShopItems = loadCurrentShopItems(); |
|
|
currentShopItems = loadCurrentShopItems(); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -98,9 +98,7 @@ public class Shop { |
|
|
tempJSON.put("amount", newAmount); |
|
|
tempJSON.put("amount", newAmount); |
|
|
jsonArray.put(tempJSON); |
|
|
jsonArray.put(tempJSON); |
|
|
playerConfig.put("inventory", jsonArray); |
|
|
playerConfig.put("inventory", jsonArray); |
|
|
FileWriter fileWriter = new FileWriter("src/main/resources/playerconfig.json"); |
|
|
|
|
|
fileWriter.write(playerConfig.toString()); |
|
|
|
|
|
fileWriter.close(); |
|
|
|
|
|
|
|
|
jsonParser.writeObject("playerconfig.json", playerConfig); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -121,9 +119,7 @@ public class Shop { |
|
|
|
|
|
|
|
|
jsonArray.put(inventory); |
|
|
jsonArray.put(inventory); |
|
|
playerConfig.put("inventory", jsonArray); |
|
|
playerConfig.put("inventory", jsonArray); |
|
|
FileWriter fileWriter = new FileWriter("src/main/resources/playerconfig.json"); |
|
|
|
|
|
fileWriter.write(playerConfig.toString()); |
|
|
|
|
|
fileWriter.close(); |
|
|
|
|
|
|
|
|
jsonParser.writeObject("playerconfig.json", playerConfig); |
|
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
}catch (Exception e){ |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
@ -195,9 +191,8 @@ public class Shop { |
|
|
//write in gameconfig.json |
|
|
//write in gameconfig.json |
|
|
gameConfig.remove("shopitems"); |
|
|
gameConfig.remove("shopitems"); |
|
|
gameConfig.put("shopitems", shopitems); |
|
|
gameConfig.put("shopitems", shopitems); |
|
|
FileWriter fileWriter = new FileWriter("src/main/resources/gameconfig.json"); |
|
|
|
|
|
fileWriter.write(gameConfig.toString()); |
|
|
|
|
|
fileWriter.close(); |
|
|
|
|
|
|
|
|
jsonParser.writeObject("gameconfig.json", gameConfig); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
}catch (Exception e){ |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|