def attempt(): actor = logic.globalDict['actor'] if actor['act'] > 0: do() else: soundControl.play('negative')
def moveVertical(own, up): soundControl.play('navigate') if up: # Move up unless at top, otherwise loop to bottom if own['fieldNum'] != 0: own.worldPosition.y += D_HEIGHT own['fieldNum'] -= 1 else: # How many fields own must move down to get to bottom movesDown = len(FIELDS) - 1 own.worldPosition.y -= D_HEIGHT * movesDown own['fieldNum'] = movesDown else: # Move down unless at bottom, otherwise loop to top if own['fieldNum'] != len(FIELDS) - 1: own.worldPosition.y -= D_HEIGHT own['fieldNum'] += 1 else: # How many fields own must move up to get to top movesUp = len(FIELDS) - 1 own.worldPosition.y += D_HEIGHT * movesUp own['fieldNum'] = 0
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 attempt(position): # Success true even if command misses, # False if not valid target success = perform.attempt(position) if success: soundControl.play('attack') else: soundControl.play('negative')
def do(): selectedCommand = getSelectedCommand() if selectedCommand != None: if commandIsAllowed(selectedCommand): selectCommand(selectedCommand) soundControl.play('confirmation') else: soundControl.play('negative')
def dsahjkdsa(): soundControl.play('navigate') if left: objectControl.getFromScene('leftArrow2', 'partyCreate').worldScale = [1.5, 1.5, 1.5] # Cycle list entry = own[field].pop() own[field].insert(0, entry) else: objectControl.getFromScene('rightArrow2', 'partyCreate').worldScale = [1.5, 1.5, 1.5] # Cycle list entry = own[field].pop(0) own[field].append(entry)
def do(): lastMove = logic.globalDict['moveLog'].pop() unit = lastMove['unit'] oldSpace = lastMove['start'] oldMv = lastMove['mv'] # Move unit move.toSpace(unit, oldSpace) # Return unit's mv to previous amount unit['mv'] = oldMv # Play sound soundControl.play('return')
def moveVertical(own, up): soundControl.play('navigate') if up: # Move up unless at top, otherwise loop to bottom if own['fieldNum'] != 0: own.worldPosition.y += D_HEIGHT own['fieldNum'] -= 1 else: # How many fields own must move down to get to bottom movesDown = len(FIELDS) - 1 own.worldPosition.y -= D_HEIGHT * movesDown own['fieldNum'] = movesDown else: # Move down unless at bottom, otherwise loop to top if own['fieldNum'] != len(FIELDS) - 1: own.worldPosition.y -= D_HEIGHT own['fieldNum'] += 1 else: # How many fields own must move up to get to top movesUp = len(FIELDS) - 1 own.worldPosition.y += D_HEIGHT * movesUp own['fieldNum'] = 0 # Reset all fields to black/Ensure arrows visible for field in FIELDS: objectControl.getFromScene('text_' + field, 'main').color = (0, 0, 0, 1) # Make selected field white field = FIELDS[ own['fieldNum'] ] objectControl.getFromScene('text_' + field, 'main').color = (1, 1, 1, 1) # If selection is start button, make arrows invisible if field == 'start': objectControl.getFromScene('leftArrow', 'main').setVisible(False) objectControl.getFromScene('rightArrow', 'main').setVisible(False) else: objectControl.getFromScene('leftArrow', 'main').setVisible(True) objectControl.getFromScene('rightArrow', 'main').setVisible(True)
def moveHorizontal(own, left): field = FIELDS[ own['fieldNum'] ] # Start is a button, has no field if field == 'start': return soundControl.play('navigate') if left: objectControl.getFromScene('leftArrow', 'main').worldScale = [1.5, 1.5, 1.5] # Cycle list entry = own[field].pop() own[field].insert(0, entry) else: objectControl.getFromScene('rightArrow', 'main').worldScale = [1.5, 1.5, 1.5] # Cycle list entry = own[field].pop(0) own[field].append(entry)
def moveHorizontal(own, left): field = FIELDS[ own['fieldNum'] ] callDict = { 'party' : cycleParty, 'name' : cycleName, 'class' : cycleClass, 'addSkill' : cycleAddSkill, 'removeSkill' : cycleRemoveSkill, 'button' : cycleButton } method = callDict[field] method(own, left) # Scale up arrow chosen if left: objectControl.getFromScene('leftArrow2', 'partyCreate').worldScale = [1.5, 1.5, 1.5] else: objectControl.getFromScene('rightArrow2', 'partyCreate').worldScale = [1.5, 1.5, 1.5] # Play sound soundControl.play('navigate')
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(position): if moveAllowed(position): do(position) else: soundControl.play('negative')