Esempio n. 1
0
    def activate(self):
        pros, cons = self._build_pros_cons()

        if 'unfortunate' in self.actor.conditions:
            cons.append('unfortunate')
        if self.actor.vigor < 1:
            cons.append('exausted')

        for p in pros:
            self.pros.append(p)
        for c in cons:
            self.cons.append(c)

        if self.actor.player_controlled:
            renpy.call_in_new_context(self._label, self) 
        else:
            if not self.motivation:
                raise Exception("npc action activated without motivation")
            motivated_check(self.actor, self.motivation, pros, cons)
        result = get_action_power(self.actor, pros, cons, self._skill, self.morality)
        
        if not 'unfortunate' in self.actor.conditions:
            if 'unlucky' in self.cons:
                self.actor.conditions.append('unfortunate')
        else:
            if result > 0:
                self.actor.conditions.remove('unfortunate')

        return result
Esempio n. 2
0
 def add_token(self, token, free=False):
     if not self.has_token(token):
         self.tokens.append(token)
         if token not in ('accordance', 'antagonism'):
             if not free:
                 self.player_relations().stability += 1
             self.relations_tendency[token] += 1
         renpy.call_in_new_context('lbl_notify', self, token)
Esempio n. 3
0
 def start(self):
     self.current_ally = self._get_combatant('allies')
     self.current_enemy = self._get_combatant('enemies')
     self.current_ally.send_event('fight_started')
     self.current_enemy.send_event('fight_started')
     self.points = {'allies': init_points(self.current_ally, self.current_enemy, self.situation),
                     'enemies': init_points(self.current_enemy, self.current_ally, self.situation)}
     self.start_new_round()
     renpy.call_in_new_context('duel_battle_init', self)
Esempio n. 4
0
 def skip_turn(self):
     # self.player.sparks += self.calc_income(self.player)
     # self.player.sparks -= 5
     self.player_approachability = 5
     self.before_skip_turn()
     if self.player.sparks < 0:
         renpy.call_in_new_context('lbl_gameover')
     self.decade += 1
     self.player.exhausted = False
     self.stress_test()
     for i in self.player.slaves:
         Slave(i).refresh()
         i.exhausted = False
Esempio n. 5
0
 def skillcheck(self, actor, skill, difficulty=0, tense_needs=[], satisfy_needs=[], beneficiar=None,
                morality=0, special_motivators=[], threshold=None):
     skill = actor.skill(skill)
     motivation = actor.motivation(
         skill.name, tense_needs, satisfy_needs, beneficiar)
     # factors['attraction'] and equipment bonuses not implemented yet
     factors = {'level': 1 + skill.level,
                skill.attribute: skill.attribute_value(),
                'focus': skill.focus,
                'mood': actor.mood,
                'motivation': motivation,
                'vitality': actor.vitality,
                'bonus': actor.count_modifiers(skill.name)}
     result = 1 + skill.level
     used = []
     found = False
     while result != 0:
         difficulty_check = 1
         used = []
         for k, v in factors.items():
             if difficulty < difficulty_check:
                 found = True
             elif k != 'level' and v >= result:
                 difficulty_check += 1
                 used.append(k)
         if difficulty < difficulty_check:
             found = True
         if not found:
             result -= 1
         else:
             break
     if motivation < 1:
         result = -1
     renpy.call_in_new_context(
         'lbl_skillcheck_info', result, factors, skill, used, threshold, difficulty)
     if result >= 0:
         for need in tense_needs:
             getattr(actor, need).set_tension()
         for need in satisfy_needs:
             getattr(actor, need).satisfaction = result
         actor.use_skill(skill)
         if actor == self.player and beneficiar == actor.master:
             if result > actor.merit:
                 actor.merit = result
         actor.moral_action(morality)
     return result
Esempio n. 6
0
 def drop_card(self, who):
     if len(self.hand[who]) > 0:
         if who == self.player:
             cards = [i for i in self.hand[who]]
             random.shuffle(cards)
             card = renpy.call_in_new_context('lbl_duel_drop_card', cards[0:2])
         else:
             card = random.choice(self.hand[who])
         self.hand[who].remove(card)
Esempio n. 7
0
 def trigger(self, target=None, skipcheck=False):
     """
     On event activation
     """
     if self.seen > 0 and self.unique:
         return False
     self.skipcheck = skipcheck
     self.target = target
     if self.restrictions == 'player':
         try:
             if not target.player_controlled:
                 return False
         except AttributeError:
             return False
     elif self.restrictions != None and self.restrictions != target.event_type:
         return False
     result = renpy.call_in_new_context(self.goto, self)
     if result:
         self.seen += 1
     self.skipcheck = False
     self.target = None
     return result
Esempio n. 8
0
 def _on_use(self, person):
     if self.attribute is not None:
         if person.player_controlled:
             renpy.call_in_new_context(
                 'lbl_jobcheck', self, person)
Esempio n. 9
0
 def appearance_chance(self, person):
     # gets chance for wish to appear at this person
     chance = renpy.call_in_new_context(self._chance_label(), person=person)
     return max(0, chance)
Esempio n. 10
0
 def call(self):
     renpy.call_in_new_context(self.lbl, self)
Esempio n. 11
0
 def go_to_route(self, player, person):
     return renpy.call_in_new_context(self.label,
                                      player=player,
                                      person=person,
                                      crisis=self.crisis)
Esempio n. 12
0
 def start(self):
     renpy.call_in_new_context('lbl_zombieworld_combat',
                               combat=self,
                               world=self.world)
Esempio n. 13
0
 def _end_fight(self, loosed_side):
     self.loser = loosed_side
     self.ended = True
     renpy.call_in_new_context('lbl_duel_battle_end', self)
Esempio n. 14
0
 def is_available(self):
     try:
         return renpy.call_in_new_context(self._check_label(), self)
     except:
         return True
Esempio n. 15
0
 def run(self, person):
     if renpy.has_label(self._run_label()):
         renpy.call_in_new_context(self._run_label(),
                                   motivation=self,
                                   person=person)
Esempio n. 16
0
 def run(self):
     return renpy.call_in_new_context(self.action.lbl(), action=self)
Esempio n. 17
0
 def add(self, person, prev_ability):
     lbl = self._data.get('on_add')
     if lbl is not None:
         return renpy.call_in_new_context(lbl, person, self, prev_ability)
Esempio n. 18
0
 def interact(self, source, actor):
     lbl = 'lbl_interaction_%s' % self._id
     if renpy.has_label(lbl):
         return renpy.call_in_new_context(lbl, source=source, actor=actor)
Esempio n. 19
0
 def call_on_remove(self):
     removal_label = self.lbl + '_' + 'remove'
     if renpy.has_label(removal_label):
         renpy.call_in_new_context(removal_label, self)
Esempio n. 20
0
def _call(label, *args, **kwargs):
    if renpy.has_label(label):
        return renpy.call_in_new_context(label, *args, **kwargs)
    else:
        return renpy.call_in_new_context("lb_missed", label=label)
Esempio n. 21
0
 def act(self, person):
     lbl = 'lbl_npc_action_%s_act' % self._id
     if renpy.has_label(lbl):
         return renpy.call_in_new_context(lbl, person=person, action=self)
Esempio n. 22
0
 def _on_init(self):
     lbl = 'lbl_intrigue_%s_on_init' % self.id
     try:
         return renpy.call_in_new_context(lbl, self)
     except:
         return
Esempio n. 23
0
 def trigger_crisis(self, crisis):
     renpy.call_in_new_context('lbl_crisis_menu_glue', crisis, self)
Esempio n. 24
0
 def intervene(self):
     try:
         renpy.call_in_new_context(self._intervene_label(), self)
     except:
         raise Exception("intrigue '%s' has no intervene label" % self.id)
Esempio n. 25
0
 def run(self):
     return renpy.call_in_new_context(self._label, self)
Esempio n. 26
0
 def call(self, person, world):
     renpy.call_in_new_context(self.label(),
                               event=self,
                               person=person,
                               world=world)
Esempio n. 27
0
 def show(self, call=True, x_size=200, y_size=300, spacing=5):
     call = True
     renpy.call_in_new_context('_lbl_card_menu', self, call, x_size, y_size,
                               spacing, self.cancel)
Esempio n. 28
0
 def visit(self, visitor):
     self.visitor = visitor
     self.on_visit(visitor)
     renpy.call_in_new_context(self.entry_label(), self)
Esempio n. 29
0
 def activate(self, person):
     # called when whish is fulfilled
     renpy.call_in_new_context(self._end_label(), person=person)
Esempio n. 30
0
 def run(self):
     return renpy.call_in_new_context(self._action.lbl,
                                      person=self.person,
                                      action=self)
Esempio n. 31
0
    def recalculate_mood(self):
        mood = 0
        happines = []
        dissapointment = []
        dissapointments_inf = []
        satisfactions_inf = collections.defaultdict(list)
        determination = []
        anxiety = []
        for need in self.get_needs().values():
            if need.tension and need.level > 0:
                dissapointment.append(need.level)
                dissapointments_inf.append(need)
            if need.satisfaction > 0:
                happines.append(need.satisfaction)
                satisfactions_inf[need.satisfaction].append(need)
                if need.level == 3:
                    happines.append(need.satisfaction)
                    satisfactions_inf[need.satisfaction].append(need)
        for i in range(self.determination):
            happines.append(1)
            determination.append('determination')
        for i in range(self.anxiety):
            dissapointment.append(1)
            anxiety.append('anxiety')
        hlen = len(happines)
        dlen = len(dissapointment)
        happines.sort()
        dissapointment.sort()
        renpy.call_in_new_context('mood_recalc_result', dissapointments_inf, satisfactions_inf, determination, anxiety, True, self)
        if hlen > dlen:
            dissapointment = []
            for i in range(dlen):
                happines.pop(0)
            threshold = happines.count(5)
            sens = 5-self.sensitivity
            if threshold > sens:
                mood = 5
            elif threshold+happines.count(4) > sens:
                mood = 4
            elif threshold+happines.count(4)+happines.count(3) > sens:
                mood = 3
            elif threshold+happines.count(4)+happines.count(3)+happines.count(2) > sens:
                mood = 2
            elif threshold+happines.count(4)+happines.count(3)+happines.count(2)+happines.count(1) > sens:
                mood = 1

        elif hlen < dlen:
            axniety_holder = self.anxiety
            happines = []
            for i in range(hlen):
                dissapointment.pop(0)
            dissapointment = [i for i in dissapointment if i > 1]
            despair = 6-self.sensitivity-dissapointment.count(2)
            despair2 = dissapointment.count(3)
            if despair < 0:
                if abs(despair) > self.anxiety:
                    self.anxiety += 1
                    mood = -1
            else:
                despair2 -= despair
            if despair2 > 0:
                self.anxiety += despair2
                mood = -1

        
        else:
            mood = 0
        for key in satisfactions_inf:
            for need in satisfactions_inf[key]:
                need.satisfaction = 0
                need.tension = False
        for need in dissapointments_inf:
            need.satisfaction = 0
            need.tension = False
        self.mood = mood