def __init__(self, action_dict):
		assert_type(action_dict, dict, "action specification")

		try:
			self.action_type = action_dict['type']
		except KeyError:
			raise InvalidScenarioFileFormat('Encountered action without type\n'+str(action_dict))
		try:
			self.callback = ACTIONS.get(self.action_type)
		except KeyError:
			raise InvalidScenarioFileFormat('Found invalid action type: %s' % self.action_type)

		self.arguments = action_dict.get('arguments', [])
示例#2
0
	def __init__(self, action_dict):
		assert_type(action_dict, dict, "action specification")

		try:
			self.action_type = action_dict['type']
		except KeyError:
			raise InvalidScenarioFileFormat('Encountered action without type\n'+str(action_dict))
		try:
			self.callback = ACTIONS.get(self.action_type)
		except KeyError:
			raise InvalidScenarioFileFormat('Found invalid action type: %s' % self.action_type)

		self.arguments = action_dict.get('arguments', [])
示例#3
0
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.scenario import ACTIONS


# Patch scenario actions for easier detection


def do_win(session):
    session._scenariotest_won = True


def do_lose(session):
    session._scenariotest_lose = True


def goal_reached(session, goal):
    if hasattr(session, "_scenariotest_goals"):
        session._scenariotest_goals.append(goal)
    else:
        session._scenariotest_goals = [goal]


# We replace the code object on the original functions because replacing all
# references on these functions in the scenario manager is too cumbersome
ACTIONS.get("win").func_code = do_win.func_code
ACTIONS.get("lose").func_code = do_lose.func_code
ACTIONS.get("goal_reached").func_code = goal_reached.func_code
示例#4
0
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.scenario import ACTIONS


# Patch scenario actions for easier detection

def do_win(session):
	session._scenariotest_won = True


def do_lose(session):
	session._scenariotest_lose = True


def goal_reached(session, goal):
	if hasattr(session, '_scenariotest_goals'):
		session._scenariotest_goals.append(goal)
	else:
		session._scenariotest_goals = [goal]


# We replace the code object on the original functions because replacing all
# references on these functions in the scenario manager is too cumbersome
ACTIONS.get('win').func_code = do_win.func_code
ACTIONS.get('lose').func_code = do_lose.func_code
ACTIONS.get('goal_reached').func_code = goal_reached.func_code
示例#5
0
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.scenario import ACTIONS

# Patch scenario actions for easier detection


def do_win(session):
    session._scenariotest_won = True


def do_lose(session):
    session._scenariotest_lose = True


def goal_reached(session, goal):
    if hasattr(session, '_scenariotest_goals'):
        session._scenariotest_goals.append(goal)
    else:
        session._scenariotest_goals = [goal]


# We replace the code object on the original functions because replacing all
# references on these functions in the scenario manager is too cumbersome
ACTIONS.get('win').__code__ = do_win.__code__
ACTIONS.get('lose').__code__ = do_lose.__code__
ACTIONS.get('goal_reached').__code__ = goal_reached.__code__
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.scenario import ACTIONS

# Patch scenario actions for easier detection


def do_win(session):
	session._scenariotest_won = True


def do_lose(session):
	session._scenariotest_lose = True


def goal_reached(session, goal):
	if hasattr(session, '_scenariotest_goals'):
		session._scenariotest_goals.append(goal)
	else:
		session._scenariotest_goals = [goal]


# We replace the code object on the original functions because replacing all
# references on these functions in the scenario manager is too cumbersome
ACTIONS.get('win').__code__ = do_win.__code__
ACTIONS.get('lose').__code__ = do_lose.__code__
ACTIONS.get('goal_reached').__code__ = goal_reached.__code__