Merge pull request 'Pulled v0.2 and CLI menu rework' (#1) from dev into master
Reviewed-on: #1
This commit is contained in:
commit
1f54d120a7
|
@ -10,10 +10,13 @@ As of now, you can:
|
|||
- Size
|
||||
- Pilot Skill
|
||||
- Total Movement Modifier
|
||||
- Add multiple mechs
|
||||
- Query a list of mechs based on player name
|
||||
|
||||
## Upcoming Features
|
||||
|
||||
Next on the release docket:
|
||||
- Modify mech stats on demand
|
||||
- Set mech armor and structure values
|
||||
- Set damage for each range bracket
|
||||
- Set heat scale
|
||||
|
@ -22,8 +25,9 @@ Next on the release docket:
|
|||
## Core Features
|
||||
|
||||
Once those key things are taken care of, you’ll be able to:
|
||||
- Load multiple mechs into memory
|
||||
- Run attack rolls to and against them
|
||||
- Load multiple mechs from a local file
|
||||
- Load multiple mechs from an online source
|
||||
- Run attack rolls to and against mechs
|
||||
- Automatic critical calculations upon structure damage
|
||||
- Turn-based damage, so all pending effects are held in a buffer
|
||||
before they apply after all actions in a turn
|
|
@ -0,0 +1,4 @@
|
|||
def clean(dirty_dict):
|
||||
# gets rid of None items in dictionaries
|
||||
clean_dict = {k:v for k,v in dirty_dict.items() if v is not None}
|
||||
return clean_dict
|
|
@ -0,0 +1,135 @@
|
|||
import mech
|
||||
import os
|
||||
|
||||
|
||||
class cli_menu():
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.main_menu = """Main Menu:
|
||||
(n)ew mech,
|
||||
(l)ist a player's mechs,
|
||||
(m)odify a mech,
|
||||
or (q)uit the session.
|
||||
"""
|
||||
self.mech_list = []
|
||||
|
||||
self.menu_choices = {
|
||||
"n": self.make_mech(self.mech_list),
|
||||
"l": self.get_player_mechs(self.mech_list),
|
||||
"m": self.modify_mech(self.mech_list)
|
||||
}
|
||||
|
||||
self.mech_modify_options = {
|
||||
"n": "name",
|
||||
"v": "dez",
|
||||
"s": "size",
|
||||
"p": "skill",
|
||||
"t": "tmm"
|
||||
}
|
||||
|
||||
#self.menu_choices = ["n", "l", "q", "m"]
|
||||
|
||||
#self.mech_modify_options = ["n","v","s","p","t","b"]
|
||||
|
||||
# add more choices as needed
|
||||
|
||||
|
||||
def make_mech(self,mech_list):
|
||||
# create a new mech
|
||||
new = mech.Mech(quiet=False, debug=False)
|
||||
# instantiate a Mech with CLI options for the mech's info
|
||||
mech_list.append(new)
|
||||
# add that to the mech_list
|
||||
return mech_list
|
||||
|
||||
|
||||
def get_player_mechs(self,mech_list, player=''):
|
||||
# lists all mechs of a player
|
||||
player = input("Search for player name: ")
|
||||
print("Mech list for: ", player,"\n")
|
||||
for unit in mech_list:
|
||||
u = unit # just for easy typing
|
||||
if u.get_player() == player:
|
||||
print("Mech name: ", u.get_name())
|
||||
print("Mech variant: ", u.get_dez())
|
||||
print("Mech size: ", u.get_size())
|
||||
print("\n")
|
||||
|
||||
|
||||
def search_player(self,mech_list):
|
||||
# creates list of mechs of a certain player
|
||||
# not front-facing function
|
||||
# used for modify_mech()
|
||||
player = input("Search for player: ")
|
||||
temp_list = []
|
||||
i = 0
|
||||
for unit in mech_list:
|
||||
if unit.get_player() == player:
|
||||
print('Unit: ', i, '\n')
|
||||
print(unit.card)
|
||||
temp_list.append(unit)
|
||||
i = i + 1
|
||||
return temp_list
|
||||
|
||||
|
||||
def modify_mech_attribute(self,mech_to_modify,user_choice):
|
||||
if user_choice != 'b':
|
||||
while user_choice not in self.mech_modify_options:
|
||||
user_choice = input("Invalid option. Try again: ")
|
||||
mech_to_modify[user_choice] = input("Change the data: ")
|
||||
else:
|
||||
print("Going back to the menu")
|
||||
|
||||
#return mech_to_modify
|
||||
|
||||
|
||||
def modify_mech(self,mech_list):
|
||||
# lets user modify a mech's attribute
|
||||
mechs_to_modify_list = self.search_player(mech_list)
|
||||
print("Which mech do you want to change?: ")
|
||||
selection = mechs_to_modify_list[int(input())]
|
||||
|
||||
print("""
|
||||
What attribute do you want to modify?
|
||||
(n)ame,
|
||||
(v)ariant,
|
||||
(s)ize,
|
||||
(p)ilot skill,
|
||||
(t)mm,
|
||||
|
||||
or, (b)ack to the menu:
|
||||
""")
|
||||
self.modify_mech_attribute(selection,input())
|
||||
|
||||
|
||||
def menu(self):
|
||||
print(self.main_menu)
|
||||
|
||||
choice = input("Make your choice: ")
|
||||
|
||||
if choice == 'q':
|
||||
print("Bye!")
|
||||
return False
|
||||
|
||||
while choice not in self.menu_choices:
|
||||
choice = input("Incorrect input. Try again: ")
|
||||
|
||||
self.menu_choices[choice]
|
||||
|
||||
|
||||
#elif choice == 'n':
|
||||
# self.menu_choices[n]
|
||||
# return True
|
||||
#elif choice == 'l':
|
||||
# self.get_player_mechs(self.mech_list)
|
||||
# return True
|
||||
#elif choice == 'q':
|
||||
# print("Bye!")
|
||||
# return False
|
||||
#elif choice == 'm':
|
||||
# self.modify_mech(self.mech_list)
|
||||
#else:
|
||||
# print("This should literally be impossible to get to.")
|
||||
# print("THOU FOOL! THOU HAST DESECRATED MINE ROBITZ")
|
||||
|
19
main.py
19
main.py
|
@ -1,7 +1,18 @@
|
|||
import mech
|
||||
import cli_menu as clm
|
||||
import os
|
||||
|
||||
test1 = mech.Mech('Wolverine WVR-7K',2,3,2)
|
||||
debug = True
|
||||
|
||||
test1.get_card()
|
||||
def main(debug):
|
||||
play = True
|
||||
menu = clm.cli_menu()
|
||||
# menu.menu(input("Make your choice: "))
|
||||
while play:
|
||||
# Clear the screen
|
||||
play = menu.menu()
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
# will automatically break the loop if you select 'q'
|
||||
|
||||
|
||||
main(debug)
|
||||
|
||||
test1.set_skill(4)
|
||||
|
|
70
mech.py
70
mech.py
|
@ -1,22 +1,52 @@
|
|||
import clean_dict as c
|
||||
|
||||
class Mech:
|
||||
def __init__(self, name='NewMech', size=1, skill=1, tmm=1):
|
||||
def __init__(self,
|
||||
name='NewMech',
|
||||
dez='NEW-1',
|
||||
size=1,
|
||||
skill=1,
|
||||
tmm=1,
|
||||
debug=True,
|
||||
quiet=True):
|
||||
# the 'quiet' flag tells the constructor whether
|
||||
# to set everything as defaults,
|
||||
# or to let the user set the data for the instance.
|
||||
if not quiet:
|
||||
self.name = input("Mech name: ")
|
||||
self.size = input("Mech size: ")
|
||||
self.skill = input("Pilot skill: ")
|
||||
self.tmm = input("Total Movement Modifier: ")
|
||||
self.dez = input("Variant name: ")
|
||||
self.debug = debug
|
||||
self.player = input("Assign mech to player? Leave blank for none: ")
|
||||
else:
|
||||
self.name = name
|
||||
self.dez = dez
|
||||
self.size = size
|
||||
self.skill = skill
|
||||
self.tmm = tmm
|
||||
self.debug = debug
|
||||
self.player = ''
|
||||
|
||||
self.card = {
|
||||
"name": self.name,
|
||||
"size": self.size,
|
||||
"skill": self.skill,
|
||||
"tmm": self.tmm
|
||||
}
|
||||
self.card = {
|
||||
"player": self.get_player(),
|
||||
"name": self.get_name(),
|
||||
"dez": self.get_dez(),
|
||||
"size": self.get_size(),
|
||||
"skill": self.get_skill(),
|
||||
"tmm": self.get_tmm()
|
||||
}
|
||||
|
||||
print(self.card)
|
||||
if debug: print(self.card)
|
||||
|
||||
def set_name(self, name):
|
||||
self.name = name
|
||||
self.card["name"] = name
|
||||
|
||||
def set_dez(self, dez):
|
||||
self.dez = dez
|
||||
self.card["dez"] = dez
|
||||
|
||||
def set_size(self, size):
|
||||
self.size = size
|
||||
|
@ -29,19 +59,27 @@ class Mech:
|
|||
def set_tmm(self, tmm):
|
||||
self.tmm = tmm
|
||||
self.card["tmm"] = tmm
|
||||
|
||||
def set_player(self, player):
|
||||
self.player = player
|
||||
self.card["player"] = player
|
||||
|
||||
def get_name(self):
|
||||
return self.__name
|
||||
return self.name
|
||||
|
||||
def get_dez(self):
|
||||
return self.dez
|
||||
|
||||
def get_size(self):
|
||||
return self.__size
|
||||
return self.size
|
||||
|
||||
def get_skill(self):
|
||||
return self.__skill
|
||||
return self.skill
|
||||
|
||||
def get_tmm(self):
|
||||
return self.__tmm
|
||||
|
||||
def get_card(self):
|
||||
return self.card
|
||||
|
||||
return self.tmm
|
||||
|
||||
def get_player(self):
|
||||
return self.player
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue