예제 #1
0
파일: Run_Game.py 프로젝트: kfirc/psycho
    def __init__(self, name, start_level=1):
        self.current_streak = 0
        self.max_streak = 0
        self.total_points = 0
        self.total_time = 0
        self.name = name
        self.level = Level(start_level)
        self.question = None

        io.send("welcome", name=self.name)
예제 #2
0
파일: Run_Game.py 프로젝트: kfirc/psycho
    def ask(self):
        io.send("question", question=self.question, time=self.level.time)

        answered = False
        while not answered:
            self.user_answer, self.time = Question.get_answer()
            if self.user_answer is None:
                Game.help()
            else:
                answered = True

        self._calculate_points()
예제 #3
0
파일: Run_Game.py 프로젝트: kfirc/psycho
 def help():
     io.send("help")
예제 #4
0
파일: Run_Game.py 프로젝트: kfirc/psycho
 def try_exit(self):
     if self.question.user_answer in EXIT_REQUEST:
         io.send("quit", streak=self.max_streak, points=self.total_points)
         self.log()
         sys.exit()
예제 #5
0
파일: Run_Game.py 프로젝트: kfirc/psycho
 def _calculate_level(self):
     if not (self.question.correct and self.question.in_time):
         self.level = Level(max(1, self.level.level - 1))
     elif self.current_streak % 5 == 0 and self.current_streak and self.level.level < NUMBER_OF_LEVELS:
         self.level = Level(self.level.level + 1)
         io.send("level up", level=self.level.level)
예제 #6
0
파일: Run_Game.py 프로젝트: kfirc/psycho
    def run(self):
        self.ask_question()

        self.try_exit()
        self.question.log()

        self.total_points += self.question.points
        self.total_time += self.question.time
        self._calculate_streak()

        if self.question.correct and self.question.in_time:
            io.send("success")
        elif not self.question.in_time:
            io.send("time failure", self.question.correct_answer)
        elif not self.question.correct:
            io.send("failure", self.question.correct_answer)

        if self.current_streak > 3:
            io.send("streak", streak=self.current_streak)

        io.send("points", points=self.total_points, end=' ')
        io.send("time", time=self.question.time)
        io.send("question end")

        self._calculate_level()
        self.run()