コード例 #1
0
ファイル: setup.py プロジェクト: Kiva-Entertainment/yohk
def extentText():
    # Get the command currently being considered
    command = getCommandsList()[0][0]

    text = ""
    if commandControl.hasTag(command, "extends"):
        extent = logic.globalDict["extent"]
        text = "Extent: " + str(extent)

        # Set the text of the object
    object = objectControl.getFromScene(EXTENT_OBJECT_NAME, SCENE_NAME)
    object["Text"] = text
コード例 #2
0
def cycleUntilValidTarget(targets):
	commandName = logic.globalDict['cursor']
	# If command can only be performed if it targets units
	# Conversely, if requiresUnits is False, command MUST not target any units
	requiresUnits = commandControl.hasTag(commandName, 'targets')

	# NOTE(kgeffen) For loop runs up to length times, but since targets list is cycling,
	# first entry of targets is always the one being considered
	for i in range(len(targets)):

		# If no units are hit for first entry in targets
		if targets[0]['units'] == []:
			if requiresUnits:
				cycleList(targets)
			else:
				return True
		else:
			if requiresUnits:
				return True
			else:
				cycleList(targets)
コード例 #3
0
ファイル: perform.py プロジェクト: Kiva-Entertainment/yohk
def attempt(cursorPosition):
	# List of units effected by command happening at given position
	effectedUnits = unitsInSpacesAoe(cursorPosition)

	# If list is None (None, not empty list) command cannot target given position, thus can't be performed
	# TODO(kgeffen) This is an implementation detail, make the check for valid space more obvious
	if effectedUnits is None:
		return False

	commandName = logic.globalDict['cursor']
	requiresTarget = commandControl.hasTag(commandName, 'targets')

	if requiresTarget and effectedUnits == []:
		return False
	else:
		# Store effected special spaces in 'commandSpecialSpaces'
		storeSpecialSpaces(cursorPosition)
		
		do(effectedUnits)

		# Indicate that command was performed
		return True
コード例 #4
0
ファイル: extent.py プロジェクト: Kiva-Entertainment/yohk
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()