def hit_target(self, target, weapon, base=None): # send triggered_event if self.team is not target.team: trigger_event(self.participation, self.events["hit"], target=target.id, weapon=weapon) print("%s hit %s with %s" % (self, target, weapon)) else: trigger_event(self.participation, self.events["teamhit"], target=target.id, weapon=weapon) print("%s teamhit %s with %s" % (self, target, weapon))
def was_hit(self, player, weapon, base=None): if base: trigger_event( self.participation, self.events["hit in action"], player=player.id, weapon=weapon, base=str(base) ) print("%s was hit by %s with %s while defending %s" % (self, player, weapon, base)) player_was_hit(self, player.id, weapon) print("%s was hit by %s with %s" % (self, player, weapon))
def failed_to_defend(self, base, player): trigger_event(self.participation, self.events["weak defender"], base=str(base), player=player.id) print("%s failed to defend %s against %s" % (self, base, player))
def assisted(self, player, base): trigger_event(self.participation, self.events["base assist"], base=str(base), player=player.id) print("%s assisted %s capturing %s" % (self, player, base))
def captured(self, base): trigger_event(self.participation, self.events["base captured"], base=str(base)) trigger_event(self.participation, self.events["base capturer"]) print("%s captured %s" % (self, base))
def misses(self): trigger_event(self.participation, self.events["neverhit"]) print("%s misses" % self)
def wandered_off(self, base): print("%s wandered alone in %s during base capture" % (self, str(base))) trigger_event(self.participation, self.events["lonely wolf"], base=str(base))
def give_answers(self, answers): self.answers = answers # evaluate answer answered_correctly = True for a in answers: if a.right: # send right answer print("%s answered %s correctly with %s" % (self, self.question, a)) else: self.active = False answered_correctly = False # send wrong answer print("%s answered %s wrong with %s" % (self, self.question, a)) answers_str = [str(a) for a in answers] answer_options = [str(a) for a in self.question.answers] correct_answers = [str(a) for a in self.question.answers if a.right] if answered_correctly: trigger_event( self.participation, self.events["correct answer"], given_answers=answers_str, question=str(self.question), answer_options=answer_options, difficulty=self.question.difficulty, correct_answers=correct_answers, ) self.cnt_wrong_answers = 0 self.cnt_wright_answers += 1 if self.cnt_wright_answers == 3: trigger_event(self.participation, self.events["streak"]) elif self.cnt_wright_answers == 10: trigger_event(self.participation, self.events["genius"]) else: trigger_event( self.participation, self.events["wrong answer"], given_answers=answers_str, question=str(self.question), answer_options=answer_options, difficulty=self.question.difficulty, correct_answers=correct_answers, ) self.cnt_wrong_answers += 1 self.cnt_wright_answers = 0 if self.cnt_wrong_answers == 3: trigger_event(self.participation, self.events["slack"]) elif self.cnt_wrong_answers == 10: trigger_event(self.participation, self.events["whoami"]) return answered_correctly
def was_defender(self, base): trigger_event(self.participation, self.events["base defender"], base=str(base)) print("%s is defender of %s" % (self, base))
def defended(self, base): trigger_event(self.participation, self.events["base defended"], base=str(base)) print("%s defended %s" % (self, base)) self.was_defender(base)