Beispiel #1
0
    def __init__(self, mission):
        self._mission = mission
        self._squads = []
        self._goons = GoonGroup()
        self._traits = set()
        self._narrative = Narrative()
        self._reward = mission.get_reward()
        self._objective_results = {}
        self._failed_objectives = set()

        for objective in mission.objectives:
            self._squads.append(MissionObjectiveSquad(objective, self._narrative, self))
Beispiel #2
0
class MissionAttempt(object):
    def __init__(self, mission):
        self._mission = mission
        self._squads = []
        self._goons = GoonGroup()
        self._traits = set()
        self._narrative = Narrative()
        self._reward = mission.get_reward()
        self._objective_results = {}
        self._failed_objectives = set()

        for objective in mission.objectives:
            self._squads.append(MissionObjectiveSquad(objective, self._narrative, self))

    @property
    def goons(self):
        return self._goons

    @property
    def reward(self):
        return self._reward

    def get_squad_for_objective(self, objective_id, create=True):
        objective = self._mission.get_objective(objective_id)
        for squad in self._squads:
            if squad.objective == objective:
                return squad

        if create:
            return MissionObjectiveSquad(objective, self._narrative, self)

    def add_goon_to_objective(self, objective_id, goon):
        if goon not in self._goons:
            self._goons.add(goon)
        squad = self.get_squad_for_objective(objective_id)
        squad.add_goon(goon)

    def attempt(self):
        for objective_squad in self._squads:
            self._narrative.add('_____________________________________________________________________________________')
            skip = False
            for obj in objective_squad.objective.objectives_required:
                if obj in self._failed_objectives:
                    self._narrative.add('Cannot attempt objective: [%s], failed required objective(s)' % objective_squad.objective.name)
                    skip = True
                    break

            if skip:
                continue

            self._narrative.add('Attempting objective: [%s]' % objective_squad.objective.name)

            complications, complication_traits = objective_squad.objective.get_complications()
            for complication in complications:
                self._narrative.add("We've ran into a bit of a problem, %s" % complication.name)

            if objective_squad.attempt_objective(complication_traits):
                self._narrative.add('The team succeeded [%s]!' % objective_squad.objective.name)
                self._objective_results[objective_squad.objective.id] = True
                reward = objective_squad.objective.get_reward()
                if reward:
                    self._narrative.add('$%s was obtained!' % reward)
                    self._reward += reward
            else:
                self._narrative.add('The team failed [%s].' % objective_squad.objective.name)
                self._objective_results[objective_squad.objective.id] = False
                self._failed_objectives.add(objective_squad.objective.id)