def unitsInSpacesAoe(space): # NOTE(kgeffen) Check each space that could be targetted, # if one matchs _space_, return all units that are effected by # targetting it for targetCenter in logic.globalDict['spaceTarget']: if check.eq2D(space, targetCenter['space']): return targetCenter['units']
def moveAllowed(position): # If any of the validMoves match position, return True for move in logic.globalDict['validMove']: validSpace = move['space'] if check.eq2D(validSpace, position): return True
def storeSpecialSpaces(space): # NOTE(kgeffen) Nearly identical copy of below method # NOTE(kgeffen) Check each space that could be targetted, # if one matchs _space_, assign all it special spaces to globalDict for targetCenter in logic.globalDict['spaceTarget']: if check.eq2D(space, targetCenter['space']): logic.globalDict['commandSpecialSpaces'] = targetCenter['specialSpaces']
def do(): cursor = objectControl.getFromScene('cursor', 'battlefield') cursorPosition = cursor.worldPosition # The type of selection being made status = logic.globalDict['cursor'] if status == 'selecting': cursorSelect.unit.attempt(cursorPosition) elif status == 'move': # NOTE(kgeffen) When user is selecting a space to move unit, # is user selects unit, commandSelect opens unitPosition = logic.globalDict['actor']['position'] # If cursor is not over unit, move unit to space cursor is on if not check.eq2D(cursorPosition, unitPosition): cursorSelect.move.attempt(cursorPosition) # Else, open commandSelect screen else: cursorSelect.actor.attempt() else: # Selecting the target for a command cursorSelect.target.attempt(cursorPosition)
def getMovementConsumed(position): # Search through all valid moves until you find the one performed for move in logic.globalDict['validMove']: # If this was the move made, return the amount of mv it costs if check.eq2D(move['space'], position): return move['dMv']
def getTargetAtCursor(): cursor = objectControl.getFromScene('cursor', 'battlefield') cursorPosition = cursor.worldPosition for target in logic.globalDict['spaceTarget']: # If target happens on same space as given position, return it if check.eq2D(cursorPosition, target['space']): return target
def get(unit): scene = sceneControl.get('battlefield') # Get the object that is a 'unit' and has matching position for obj in scene.objects: if obj.name == 'unit': objPosition = obj.worldPosition if check.eq2D(objPosition, unit['position']): return obj
def moveToPosition(position): cursor = objectControl.getFromScene('cursor', 'battlefield') cursorAlreadyInPosition = check.eq2D(position, cursor.worldPosition) if cursorAlreadyInPosition: return False # Movement did not happen else: cursor.worldPosition = position return True # Movement happened
def inSpace(space): for unit in logic.globalDict['units']: if check.eq2D(unit['position'], space): return unit