Esempio n. 1
0
def commandIsAllowed(command):
	unit = logic.globalDict['actor']
	
	# Not allowed if unit can't afford it (In sp)
	cost = commandControl.cost(command)
	if cost > unit['sp']:
		return False
	
	return True
Esempio n. 2
0
def costText():
    # Get the first list of commands
    commands = getCommandsList()[0]

    # Form displayed text
    text = ""
    if len(commands) != 0:
        # Get the cost of the first command in the list
        cost = commandControl.cost(commands[0])

        # Get actor's current sp
        unit = logic.globalDict["actor"]
        currentSp = unit["sp"]

        text = "Cost: " + str(cost) + "/" + str(currentSp)

        # Set the text of the object
    object = objectControl.getFromScene(COST_OBJECT_NAME, SCENE_NAME)
    object["Text"] = text
Esempio n. 3
0
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()
Esempio n. 4
0
def consumeSp(unit):
	command = logic.globalDict['cursor']
	cost = commandControl.cost(command)
	
	unit['sp'] -= cost