Skip to content

Commit

Permalink
Merge pull request #2 from cli branch
Browse files Browse the repository at this point in the history
support .json and command line arguments added
  • Loading branch information
katzerax authored Dec 30, 2022
2 parents 3689bd3 + 4445b0f commit 8baf29c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
16 changes: 11 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import matplotlib.pyplot as plt
import argparse, json

agp = argparse.ArgumentParser()
agp.add_argument("-rf", "--read-file", default="weapons.json", type=str, help="file of weapon information to read. default: weapons.json")

args = agp.parse_args()

weaponData = json.load(open(args.read_file))

# Predefined variables used in the functions, modifiable
data_points = 45000 # please make data_points and x_scale in multiples of 10
Expand Down Expand Up @@ -59,13 +67,11 @@ def plot_dps_graph(fire_delay, reload_time, damage_per_shot, magazine_capacity,
# Add legend label to list
legend_labels.append(legend_label)

# example function calls (fire_delay, reload_time, damage_per_shot, magazine_capacity, ammo_reserve, legend_label, delay_first_shot)
plot_dps_graph(0.067, 0.73, 5200, 150, 547, "lmg", False)
plot_dps_graph(3, 1.25, 193000, 2, 8, "rocket launcher", False)
plot_dps_graph(0.5, 0.83, 98000, 8, 26, "charge up rifle", True)
for weapon in weaponData['weapons']:
plot_dps_graph(weapon['fire_delay'], weapon['reload_time'], weapon['damage_per_shot'], weapon['magazine_capacity'], weapon['ammo_reserve'], weapon['name'], weapon['delay_first_shot'])

# Add a legend with all labels
plt.legend(legend_labels)

# Show the plot
plt.show()
plt.show()
31 changes: 31 additions & 0 deletions weapons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"weapons":[
{
"name": "lmg",
"fire_delay": 0.067,
"reload_time": 0.73,
"damage_per_shot": 5200,
"magazine_capacity": 150,
"ammo_reserve": 547,
"delay_first_shot": false
},
{
"name": "rocket launcher",
"fire_delay": 3,
"reload_time": 1.25,
"damage_per_shot": 193000,
"magazine_capacity": 2,
"ammo_reserve": 8,
"delay_first_shot": false
},
{
"name": "linear fusion rifle",
"fire_delay": 0.5,
"reload_time": 0.83,
"damage_per_shot": 98000,
"magazine_capacity": 8,
"ammo_reserve": 26,
"delay_first_shot": true
}
]
}

0 comments on commit 8baf29c

Please sign in to comment.