def commands(cont): # Get the first list of commands (The one onscreen) unit = logic.globalDict['actor'] commandsList = unit['commands'] commands = commandsList[0] # Don't cycle commands if there are only 1 or 0 commands if len(commands) <= 1: return upKey = cont.sensors['upKey'].positive downKey = cont.sensors['downKey'].positive # Do nothing if both or neither are pressed if (upKey and downKey) or (not upKey and not downKey): return if upKey: command = commands.pop() commands.insert(0, command) elif downKey: command = commands.pop(0) commands.append(command) # Reset extent logic.globalDict['extent'] = 0 # Reset choices logic.globalDict['commandChoices'] = [] # Play sound soundControl.play('navigate') setup.screen()
def commandLists(cont): # Get list of command unit = logic.globalDict['actor'] commandsList = unit['commands'] # Don't cycle lists if there is only 1 list if len(commandsList) == 1: return leftKey = cont.sensors['leftKey'].positive rightKey = cont.sensors['rightKey'].positive # Do nothing if both or neither are pressed if (leftKey and rightKey) or (not leftKey and not rightKey): return if leftKey: # 'commands' - A list of commands commands = commandsList.pop() commandsList.insert(0, commands) elif rightKey: # 'commands' - A list of commands commands = commandsList.pop(0) commandsList.append(commands) # Reset extent logic.globalDict['extent'] = 0 # Reset choices logic.globalDict['commandChoices'] = [] # Play sound soundControl.play('navigate') setup.screen()
def alter(cont): aKey = cont.sensors["aKey"].positive dKey = cont.sensors["dKey"].positive if aKey and logic.globalDict["extent"] != 0: logic.globalDict["extent"] -= 1 elif dKey: logic.globalDict["extent"] += 1 # Display the new cost of the command setup.screen()
def max(cont): command = getSelectedCommand() if cont.sensors["gKey"].positive: if commandControl.hasTag(command, "extends"): # Start extent at zero and increase until the first cost greater than actor's sp is found # If actor cannot afford to pay for command at extent = 0, set to 0 anyways (Not -1) ARBITRARILY_LARGE_NUMBER = 1000 logic.globalDict["extent"] = 0 # NOTE(kgeffen) Not 'while True' to prevent infinite loop if 'extends' tag wrongly added while logic.globalDict["extent"] < ARBITRARILY_LARGE_NUMBER: if commandControl.cost(command) > logic.globalDict["actor"]["sp"]: if logic.globalDict["extent"] != 0: logic.globalDict["extent"] -= 1 else: soundControl.play("negative") break else: logic.globalDict["extent"] += 1 # Display the new cost of the command setup.screen()
def cycle(cont): leftKey = cont.sensors['leftKey'].positive rightKey = cont.sensors['rightKey'].positive # Do nothing if both or neither are pressed if (leftKey and rightKey) or (not leftKey and not rightKey): return choices = logic.globalDict['commandChoices'] if choices != []: if leftKey: choice = choices.pop() choices.insert(0, choice) elif rightKey: choice = choices.pop(0) choices.append(choice) # Play sound soundControl.play('navigate') # Display the new cost of the command setup.screen()
def attempt(cont): if cont.sensors['startup'].positive: setup.screen()