Began work on weapon armor and player handlers.
This commit is contained in:
commit
43174bc73f
22 changed files with 823 additions and 0 deletions
9
src/main/java/net/halfheart/Main.java
Normal file
9
src/main/java/net/halfheart/Main.java
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package net.halfheart;
|
||||
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
public class Main {
|
||||
static void main() {
|
||||
|
||||
}
|
||||
}
|
||||
32
src/main/java/net/halfheart/ventricleengine/Armor.java
Normal file
32
src/main/java/net/halfheart/ventricleengine/Armor.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Armor {
|
||||
String name;
|
||||
String description;
|
||||
String resType;
|
||||
List<byte[]> resistances;
|
||||
String resUnit;
|
||||
short cost;
|
||||
byte weight;
|
||||
|
||||
public Armor(
|
||||
String name,
|
||||
String description,
|
||||
String resType,
|
||||
List<byte[]> resistances,
|
||||
String resUnit,
|
||||
short cost,
|
||||
byte weight
|
||||
)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.resType = resType;
|
||||
this.resistances = resistances;
|
||||
this.resUnit = resUnit;
|
||||
this.cost = cost;
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
import org.json.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ArmorsHandler {
|
||||
private static Armor constructArmor(String weaponName) {
|
||||
String filename = "/armors.json";
|
||||
try (InputStream inputStream = WeaponsHandler.class.getResourceAsStream(filename)) {
|
||||
String jsonText = new BufferedReader(
|
||||
new InputStreamReader(Objects.requireNonNull(inputStream), StandardCharsets.UTF_8))
|
||||
.lines()
|
||||
.collect(Collectors.joining("\n"));
|
||||
|
||||
JSONArray jsonArray = new JSONArray(jsonText);
|
||||
|
||||
JSONObject wantedItem = null;
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject item = jsonArray.getJSONObject(i);
|
||||
if (item.opt("name").toString().equals(weaponName)) {
|
||||
wantedItem = item;
|
||||
}
|
||||
}
|
||||
assert wantedItem != null;
|
||||
String name = wantedItem.opt("name").toString();
|
||||
if (name.equals("Fists")) {
|
||||
switch ()
|
||||
}
|
||||
String description = wantedItem.opt("desc").toString();
|
||||
String dmgType = wantedItem.opt("type").toString();
|
||||
String ammoType = wantedItem.opt("ammo").toString();
|
||||
short damage = (short) wantedItem.opt("dmg");
|
||||
short cost = (short) wantedItem.opt("cost");
|
||||
byte weight = (byte) wantedItem.opt("weight");
|
||||
return new Weapon(name, description, dmgType, ammoType, damage, cost, weight);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
21
src/main/java/net/halfheart/ventricleengine/Item.java
Normal file
21
src/main/java/net/halfheart/ventricleengine/Item.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
|
||||
public class Item {
|
||||
byte weight;
|
||||
short cost;
|
||||
boolean consumable;
|
||||
String aidModifier;
|
||||
|
||||
public Item(
|
||||
byte weight,
|
||||
short cost,
|
||||
boolean consumable,
|
||||
String aidModifier
|
||||
){
|
||||
this.weight = weight;
|
||||
this.cost = cost;
|
||||
this.consumable = consumable;
|
||||
this.aidModifier = aidModifier;
|
||||
}
|
||||
}
|
||||
|
||||
74
src/main/java/net/halfheart/ventricleengine/Player.java
Normal file
74
src/main/java/net/halfheart/ventricleengine/Player.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Player {
|
||||
String name;
|
||||
byte strength;
|
||||
byte perception;
|
||||
byte endurance;
|
||||
byte charisma;
|
||||
byte intelligence;
|
||||
byte agility;
|
||||
byte luck;
|
||||
|
||||
short caps;
|
||||
short pwMoney;
|
||||
|
||||
short hpCap;
|
||||
short hp;
|
||||
|
||||
short food;
|
||||
|
||||
boolean isRadiated;
|
||||
byte radSeverity;
|
||||
byte radPoints;
|
||||
|
||||
int xp;
|
||||
short level;
|
||||
|
||||
List<Weapon> weapons = new ArrayList<>();
|
||||
List<Armor> armors = new ArrayList<>();
|
||||
List<Item> items = new ArrayList<>();
|
||||
|
||||
public Player(
|
||||
String name,
|
||||
byte strength,
|
||||
byte perception,
|
||||
byte endurance,
|
||||
byte charisma,
|
||||
byte intelligence,
|
||||
byte agility,
|
||||
byte luck,
|
||||
short caps,
|
||||
short pwMoney,
|
||||
short hpCap,
|
||||
short hp,
|
||||
short food,
|
||||
boolean isRadiated,
|
||||
byte radSeverity,
|
||||
byte radPoints,
|
||||
int xp,
|
||||
short level
|
||||
)
|
||||
{
|
||||
this.name = name;
|
||||
this.strength = strength;
|
||||
this.perception = perception;
|
||||
this.endurance = endurance;
|
||||
this.charisma = charisma;
|
||||
this.intelligence = intelligence;
|
||||
this.agility = agility;
|
||||
this.luck = luck;
|
||||
this.caps = caps;
|
||||
this.pwMoney = pwMoney;
|
||||
this.hpCap = hpCap;
|
||||
this.hp = hp;
|
||||
this.food = food;
|
||||
this.isRadiated = isRadiated;
|
||||
this.radSeverity = radSeverity;
|
||||
this.radPoints = radPoints;
|
||||
this.xp = xp;
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.json.*;
|
||||
|
||||
public class PlayerHandler {
|
||||
private static Player constructPlayer(String savePath) {
|
||||
try {
|
||||
String content = new String(Files.readAllBytes(Paths.get(savePath)));
|
||||
JSONObject jsonObject = new JSONObject(content);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
src/main/java/net/halfheart/ventricleengine/Weapon.java
Normal file
30
src/main/java/net/halfheart/ventricleengine/Weapon.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
|
||||
public class Weapon {
|
||||
String name;
|
||||
String description;
|
||||
String dmgType;
|
||||
String ammoType;
|
||||
short damage;
|
||||
short cost;
|
||||
byte weight;
|
||||
|
||||
public Weapon(
|
||||
String name,
|
||||
String description,
|
||||
String dmgType,
|
||||
String ammoType,
|
||||
short damage,
|
||||
short cost,
|
||||
byte weight
|
||||
)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.dmgType = dmgType;
|
||||
this.ammoType = ammoType;
|
||||
this.damage = damage;
|
||||
this.cost = cost;
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
import org.json.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WeaponsHandler {
|
||||
private static Weapon constructWeapon(String weaponName) {
|
||||
String filename = "/weapons.json";
|
||||
try (InputStream inputStream = WeaponsHandler.class.getResourceAsStream(filename)) {
|
||||
String jsonText = new BufferedReader(
|
||||
new InputStreamReader(Objects.requireNonNull(inputStream), StandardCharsets.UTF_8))
|
||||
.lines()
|
||||
.collect(Collectors.joining("\n"));
|
||||
|
||||
JSONArray jsonArray = new JSONArray(jsonText);
|
||||
|
||||
JSONObject wantedItem = null;
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject item = jsonArray.getJSONObject(i);
|
||||
if (item.opt("name").toString().equals(weaponName)) {
|
||||
wantedItem = item;
|
||||
}
|
||||
}
|
||||
assert wantedItem != null;
|
||||
String name = wantedItem.opt("name").toString();
|
||||
if (name.equals("Fists")) {
|
||||
switch ()
|
||||
}
|
||||
String description = wantedItem.opt("desc").toString();
|
||||
String dmgType = wantedItem.opt("type").toString();
|
||||
String ammoType = wantedItem.opt("ammo").toString();
|
||||
short damage = (short) wantedItem.opt("dmg");
|
||||
short cost = (short) wantedItem.opt("cost");
|
||||
byte weight = (byte) wantedItem.opt("weight");
|
||||
return new Weapon(name, description, dmgType, ammoType, damage, cost, weight);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static Weapon FISTS = constructWeapon("Fists");
|
||||
public static Weapon COMBATKNIFE = constructWeapon("Combat Knife");
|
||||
public static Weapon RIPPER = constructWeapon("Ripper");
|
||||
public static Weapon CHAINSAW = constructWeapon("Chainsaw");
|
||||
public static Weapon BASEBALLBAT = constructWeapon("Baseball Bat");
|
||||
public static Weapon POWERFIST = constructWeapon("Power Fist");
|
||||
public static Weapon SUPERSLEDGE = constructWeapon("Super Sledge");
|
||||
public static Weapon PISTOL10MM = constructWeapon("10mm Pistol");
|
||||
public static Weapon HUNTINGRIFLE = constructWeapon("Hunting Rifle");
|
||||
}
|
||||
17
src/main/resources/armors.json
Normal file
17
src/main/resources/armors.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"name": "Nothing",
|
||||
"desc": "Luckily you have skin, that's enough right?",
|
||||
"type": "skin",
|
||||
"resistances": {
|
||||
"bash": 0,
|
||||
"slash": 0,
|
||||
"balistic": 0,
|
||||
"laser": 0,
|
||||
"plasma": 0
|
||||
},
|
||||
"unit": "dr",
|
||||
"weight": 0,
|
||||
"cost": -1
|
||||
}
|
||||
]
|
||||
0
src/main/resources/playerdata.json
Normal file
0
src/main/resources/playerdata.json
Normal file
83
src/main/resources/weapons.json
Normal file
83
src/main/resources/weapons.json
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
[
|
||||
{
|
||||
"name": "Fists",
|
||||
"desc": "Your fists, ",
|
||||
"type": "bash",
|
||||
"ammo": "none",
|
||||
"dmg": 2,
|
||||
"cost": -1,
|
||||
"weight": 0
|
||||
},
|
||||
{
|
||||
"name": "Combat Knife",
|
||||
"desc": "A combat knife, does 5 slash damage",
|
||||
"type": "slash",
|
||||
"ammo": "none",
|
||||
"dmg": 5,
|
||||
"cost": 5,
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"name": "Ripper",
|
||||
"desc": "A ripper, does 10 slash damage",
|
||||
"type": "slash",
|
||||
"ammo": "none",
|
||||
"dmg": 5,
|
||||
"cost": 5,
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"name": "Chainsaw",
|
||||
"desc": "A combat knife, does 5 slash damage",
|
||||
"type": "slash",
|
||||
"ammo": "none",
|
||||
"dmg": 5,
|
||||
"cost": 5,
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"name": "Baseball Bat",
|
||||
"desc": "A baseball bat, does 5 bash damage",
|
||||
"type": "bash",
|
||||
"ammo": "none",
|
||||
"dmg": 5,
|
||||
"cost": 5,
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"name": "Power Fist",
|
||||
"desc": "A power fist, does 15 bash damage",
|
||||
"type": "bash",
|
||||
"ammo": "none",
|
||||
"dmg": 15,
|
||||
"cost": 10,
|
||||
"weight": 2
|
||||
},
|
||||
{
|
||||
"name": "Super Sledge",
|
||||
"desc": "A super sledge, does 30 bash damage",
|
||||
"type": "bash",
|
||||
"ammo": "none",
|
||||
"dmg": 30,
|
||||
"cost": 10,
|
||||
"weight": 15
|
||||
},
|
||||
{
|
||||
"name": "10mm Pistol",
|
||||
"desc": "A 10mm pistol, does 10 ballistic damage",
|
||||
"type": "ballistic",
|
||||
"ammo": "10",
|
||||
"dmg": 10,
|
||||
"cost": 10,
|
||||
"weight": 2
|
||||
},
|
||||
{
|
||||
"name": "Hunting Rifle",
|
||||
"desc": "A hunting rifle, does 15 balistic damage",
|
||||
"type": "ballistic",
|
||||
"ammo": "308",
|
||||
"dmg": 10,
|
||||
"cost": 10,
|
||||
"weight": 2
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue