Created
December 5, 2012 19:23
-
-
Save f4hy/4218691 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def issuesafe(self, command, bot, target=None, facingDirection=None, lookAt=None, description=None, group=None): | |
if target: | |
safetarget = self.level.findNearestFreePosition(target) | |
self.needsorders.discard(bot) | |
if bot.name in self.moved_this_turn: | |
self.log.warn("do not issue order to {}, already issued this turn, passing".format(bot.name)) | |
return | |
self.moved_this_turn.add(bot.name) | |
if bot.state is bot.STATE_SHOOTING: | |
self.log.warn("do not issue order to firing bot {}, passing".format(bot.name)) | |
return | |
if bot.state is bot.STATE_TAKINGORDERS: | |
self.log.warn("WARNING: reissuing order to {}, {}, {}".format(bot.name, command, description)) | |
return | |
self.log.info("Issuing {} command {}".format(bot.name, description)) | |
self.currentcommand[bot] = {"command": command, "target": target, "facingDirection": facingDirection, | |
"lookAt": lookAt, "description": description} | |
if group is not None: | |
self.addtogroup(bot, group) | |
if command == commands.Move: | |
self.issue(commands.Move, bot, safetarget, description) | |
elif command == commands.Charge: | |
self.issue(commands.Charge, bot, safetarget, description) | |
elif command == commands.Attack: | |
self.issue(commands.Attack, bot, safetarget, lookAt, description) | |
elif command == commands.Defend: | |
self.issue(commands.Defend, bot, facingDirection, description) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment