Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #13 #15

Merged
merged 22 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
48809fe
Updates homepage for the future splitting of config windows
zaxhutchinson May 22, 2024
a6460d2
Separates Advanced Config UIs by JSON files
zaxhutchinson May 23, 2024
abf9709
First pass at the team config revamp.
zaxhutchinson May 24, 2024
3e20c2e
ui_team_config no longer keeps team template state locally. All data …
zaxhutchinson May 26, 2024
814fe60
Almost done on component config screen. Need to reexamine delete_comp…
zaxhutchinson May 28, 2024
437ada8
Component delete button tested. A few other fixes with clearing field…
zaxhutchinson May 29, 2024
8353a9b
fixes #14
zaxhutchinson Jun 1, 2024
e9f6075
Object config revamp. Some error fixing in previously revamped configs.
zaxhutchinson Jun 6, 2024
139e215
More work on map config
zaxhutchinson Jun 11, 2024
b4671e5
Map Config revamp v1 done.
zaxhutchinson Jun 19, 2024
e7b5c59
Adds Item Config screen and reworks button layout on the home screen
zaxhutchinson Jun 19, 2024
8ce9506
Revamps item and gstate config
zaxhutchinson Jun 21, 2024
442858d
Format new work
zaxhutchinson Jun 21, 2024
e1848c6
Fixes f-string errors
zaxhutchinson Jun 21, 2024
97260b9
More format fixes
zaxhutchinson Jun 21, 2024
dae4281
Forgot to save file from last fix.
zaxhutchinson Jun 21, 2024
6acaf44
Adjusted imports and other minor fixes
zaxhutchinson Jun 21, 2024
bf88af1
Fixed two accidentally deleted imports
zaxhutchinson Jun 21, 2024
a562357
Renamed old dir to old_code
zaxhutchinson Jun 21, 2024
6236fdc
Format
zaxhutchinson Jun 21, 2024
77092b7
Format
zaxhutchinson Jun 21, 2024
5f077e8
Format
zaxhutchinson Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Lower.heic
Binary file not shown.
8 changes: 5 additions & 3 deletions ai_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
def pretty_print_view(view, out=sys.stdout, indent=""):
"""View coming from the simulation

This method will print an indented version of the view (dict of world state) using the
This method will print an indented version of the view (dict of world
state) using the
output file specified. By default it sends output to stdout.
Users can but in general should not need to pass in a value for indent.
"""
Expand Down Expand Up @@ -41,7 +42,7 @@ def get_sub_view(view, *args):
return get_sub_view(subview, *args[1:])
except IndexError:
return view
except:
except Exception:
return None


Expand Down Expand Up @@ -193,7 +194,8 @@ def search_radar_for_obj_name(view, name):
def get_comp_views_of_vtype(view, vtype):
"""Gets component views of a vtype

Returns a list of all the views within the comp view with a specific vtype."""
Returns a list of all the views within the comp view with a specific
vtype."""
views = []
comp_subview = get_sub_view(view, "comp")
if comp_subview is not None:
Expand Down
59 changes: 47 additions & 12 deletions comp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import math

import vec2
import copy
import action

CTYPES_LIST = ["FixedGun", "Engine", "Radar", "CnC", "Radio", "Arm"]

COMP_ATTRS_BY_CTYPE = {
"FixedGun": [
("reload_ticks", 1),
("ammunition", 0),
("min_damage", 0),
("max_damage", 0),
("range", 0),
],
"Engine": [("min_speed", 0.0), ("max_speed", 0.0), ("max_turnrate", 0.0)],
"Radar": [
("range", 0),
("level", 0),
("visarc", 0),
("offset_angle", 0),
("resolution", 0),
],
"CnC": [("max_cmds_per_tick", 0)],
"Radio": [
("max_range", 0),
],
"Arm": [("max_bulk", 0), ("max_weight", 0)],
}


class Comp:
def __init__(self, data):
Expand All @@ -12,7 +35,7 @@ def __init__(self, data):
Sets command, update, and view_keys functions based on component type
"""

self.data = data
self.data = copy.deepcopy(data)

self.command = self.no_command
self.update = self.no_update
Expand All @@ -24,14 +47,19 @@ def __init__(self, data):
self.command = self.fixed_gun_command
self.update = self.fixed_gun_update
self.set_view_keys_fixed_gun()
self.data["reload_ticks_remaining"] = 0
self.data["reloading"] = False
elif ctype == "Engine":
self.command = self.engine_command
self.update = self.engine_update
self.set_view_keys_engine()
self.data["cur_speed"] = 0.0
self.data["cur_turnrate"] = 0.0
elif ctype == "Radar":
self.command = self.radar_command
self.update = self.radar_update
self.set_view_keys_radar()
self.data["active"] = False
elif ctype == "CnC":
self.command = self.cnc_command
self.update = self.cnc_update
Expand All @@ -40,10 +68,12 @@ def __init__(self, data):
self.command = self.radar_command
self.update = self.radio_update
self.set_view_keys_radio()
self.data["message"] = None
elif ctype == "Arm":
self.command = self.arm_command
self.update = self.arm_update
self.set_view_keys_arm()
self.data["item"] = None

def get_data(self, key):
"""Gets data"""
Expand Down Expand Up @@ -154,7 +184,10 @@ def fixed_gun_command(self, cmd):
a.set_type("HIGHSPEED_PROJECTILE")
a.add_data("slot_id", self.get_data("slot_id"))
a.add_data("compname", self.get_data("name"))
a.add_data("direction", self.get_data("parent").get_data("facing"))
a.add_data(
"direction",
self.get_data("parent").get_data("facing")
)
a.add_data("min_damage", self.get_data("min_damage"))
a.add_data("max_damage", self.get_data("max_damage"))
a.add_data("range", self.get_data("range"))
Expand Down Expand Up @@ -214,7 +247,8 @@ def engine_command(self, cmd):
if abs(new_turnrate) <= self.get_data("max_turnrate"):
self.data["cur_turnrate"] = new_turnrate
else:
self.data["cur_turnrate"] = self.get_data("max_turnrate")
self.data["cur_turnrate"] = \
self.get_data("max_turnrate")

return actions

Expand Down Expand Up @@ -367,7 +401,7 @@ def arm_update(self):
return []

###########################################################################
## WEAPON RELATED FUNCTIONS
# WEAPON RELATED FUNCTIONS
def set_reload_ticks_to_full(self):
"""Set reload ticks to full"""
self.data["reload_ticks_remaining"] = self.data["reload_ticks"]
Expand All @@ -387,7 +421,7 @@ def update_reloading(self):
self.data["reloading"] = False

###########################################################################
## ENGINE RELATED FUNCTIONS
# ENGINE RELATED FUNCTIONS
def is_moving(self):
"""Determines if engine is moving"""
return self.data["cur_speed"] != 0.0
Expand All @@ -397,25 +431,26 @@ def is_turning(self):
return self.data["cur_turnrate"] != 0.0

###########################################################################
## RADAR RELATED FUCNTIONS
# RADAR RELATED FUCNTIONS
def is_transmitting(self):
"""Determines if radar is transmitting"""
return self.get_data("active")

###########################################################################
## ARM RELATED FUNCTIONS
# ARM RELATED FUNCTIONS
def is_holding_item(self):
"""Determines if arm is holding an item"""
return self.get_data("item") is not None

def can_take_item(self, weight, bulk):
"""Determines if arm can take item"""
return (
self.get_data("max_weight") >= weight and self.get_data("max_bulk") >= bulk
self.get_data("max_weight") >= weight
and self.get_data("max_bulk") >= bulk
)

###########################################################################
##
#
def is_active(self):
"""Determines if component is active"""
return self.get_data("active")
Expand Down
Loading
Loading