コード例 #1
0
ファイル: objects.py プロジェクト: isaaclockett72/skiJumpSim
 def introduce_hill(self, skijumpers):
     """Announce and begin the selected hill."""
     sk.tap_to_continue()
     self.print_stats()
     self.attendance = self.calculate_attendance(skijumpers)
     kv_print("Attendance", f"{self.attendance:,}")
     if self.attendance == self.capacity:
         line_break()
         type_out("It's a sellout!")
     pass
コード例 #2
0
def tap_to_continue(options=None):
    """Pause until user enters a key."""
    if options:
        type_out(f"\n\n{yellow}**Custom options:")
        for option in options:
            kv_print((option, light_white), options[option])
    else:
        line_break()
    user_input = input(f"{light_purple}--- Tap Enter to continue ---\n\n{light_white}")
    return user_input
コード例 #3
0
ファイル: objects.py プロジェクト: isaaclockett72/skiJumpSim
 def print_stats(self):
     """Print out the stats for a ski jumper."""
     dashed_line()
     kv_print("Skijumper Name", (self.name, light_green))
     dashed_line()
     line_break()
     kv_print("Country", (self.country_of_origin, light_green))
     kv_print("Home Hill", (self.home_hill, light_green))
     line_break()
     # type_out(f"{yellow}{'-'*21} STATS {'-'*22}{light_white}")
     type_out(f"{yellow}{' STATS ':-^50}{light_white}")
     line_break()
     kv_print("Personality", (", ".join(self.personality), light_blue))
     kv_print("Height", round(self.height, 2), "cm")
     kv_print("Weight", round(self.weight, 2), "kg")
     kv_print("Popularity", self.popularity, colour_map=True, symbol="◼︎")
     kv_print("Speed", self.speed, colour_map=True, symbol="◼︎")
     kv_print("Balance", self.balance, colour_map=True, symbol="◼︎")
     kv_print("Style", self.style, colour_map=True, symbol="◼︎")
     kv_print("Consistency", self.consistency, colour_map=True, symbol="◼︎")
     kv_print("Risk taker", self.risk_taking, colour_map=True, symbol="◼︎")
     kv_print("Relationship with father",
              self.relationship_with_father,
              colour_map=True,
              symbol="◼︎")
     line_break()
     type_out(f"{yellow}{' OVERALL SCORE ':-^50}{light_white}")
     kv_print("Overall score", self.overall_score)
     pass
コード例 #4
0
ファイル: objects.py プロジェクト: isaaclockett72/skiJumpSim
 def initiate_jump(self):
     """Initiate the jump."""
     dashed_line()
     skijumper_name = f"{light_green}{self.skijumper.name}{light_white}"
     type_out(f"{skijumper_name} is beginnning their jump...")
     dashed_line()
     line_break()
     self.calculate_height_bonus()
     self.calculate_weight_bonus()
     self.calculate_popularity_bonus()
     self.calculate_consistency_bonus()
     self.calculate_jump_speed()
     self.calculate_risk_bonus()
     self.calculate_form_bonus()
     self.calculate_father_bonus()
     self.calculate_horizontal_wind()
     self.jump_distance = max(round(self.jump_distance, 2), 0)
     kv_print("Expected distance", self.estimate, "m")
     pass
コード例 #5
0
ファイル: objects.py プロジェクト: isaaclockett72/skiJumpSim
 def print_stats(self):
     """Print stats for the hill."""
     dashed_line()
     type_out(f"Welcome to {light_green}{self.name} Hill!")
     dashed_line()
     line_break()
     kv_print("Hill Name", (self.name, light_green))
     line_break()
     kv_print("Hill Horizontal Wind", self.base_wind_horizontal, "km/h")
     kv_print("Hill Wind Variability", self.wind_variability)
     line_break()
     kv_print("Height", self.height, "m")
     kv_print("Calculation Line", self.calculation_line, "m")
     kv_print("Hill Record", self.hill_record, "m")
     line_break()
     kv_print("Hill Capacity", f"{self.capacity:,}")
     pass
コード例 #6
0
ファイル: objects.py プロジェクト: isaaclockett72/skiJumpSim
 def introduce_country(self):
     """Announce a country upon arrival."""
     dashed_line()
     type_out(f"Welcome to {light_green}{self.name}")
     dashed_line()
     line_break()
     kv_print('Official country name', (self.full_name, light_green))
     kv_print('Population', f"{self.population:,}")
     kv_print('Hill count', self.hill_count)
     line_break()
     all_hills = ', '.join([hill.name for hill in self.hills])
     type_out("Hills:")
     type_out(f"""{light_green}{all_hills}{light_white}""")
     line_break()
     hill_name = self.hills[0].name
     type_out(
         f"Our first hill will be {light_green}{hill_name}{light_white}")
     pass
コード例 #7
0
ファイル: objects.py プロジェクト: isaaclockett72/skiJumpSim
 def calculate_father_bonus(self):
     """Calculate the penalty / bonus for father presence."""
     self.father_present = random.random()
     # type_out(f"{light_white}They're looking around...")
     line_break()
     if self.father_present > 0.5:
         # type_out(f"* Their father is in the crowd")
         line_break()
         self.father_bonus = round(
             (self.father_present - 0.5) *
             self.skijumper.relationship_with_father, 2) / 5
     else:
         # type_out(f"* Looks like Dad didn't show up")
         line_break()
         self.father_bonus = round(
             (self.father_present - 0.5) *
             (10 - self.skijumper.relationship_with_father), 2)
     self.jump_distance += self.father_bonus
     self.estimate = round(self.estimate, 2)
     pass
コード例 #8
0
ファイル: objects.py プロジェクト: isaaclockett72/skiJumpSim
    def start_jumping(self, skip_continue_taps=False, skip_ten=False):
        """Start jumping."""
        self.results = []
        i = 0
        while True:
            if i % 10 == 0:
                skip_ten = False
            try:
                current_skijumper = self.skijumpers[self.roster.__next__()]
                i += 1
            except StopIteration:
                break
            type_out(f"Jumper {i}")
            current_skijumper.print_stats()
            if not skip_continue_taps and not skip_ten:
                user_input = sk.tap_to_continue({
                    "ss":
                    "Skip future taps",
                    "s10":
                    "Skip to start of next 10"
                })
                skip_continue_taps = user_input == "ss"
                skip_ten = user_input == "s10"
            # BASIC RESULTS
            if self.results:
                # kv_print("Current Record", max(results.values()), "m")
                current_results = DataFrame(self.results)
                type_out(
                    current_results.sort_values("jump_distance",
                                                ascending=False)[[
                                                    "skijumper",
                                                    "jump_distance"
                                                ]].head(5))
                line_break()
            else:
                kv_print("Calculation line", self.hill.calculation_line, "m")
                line_break()
            # JUMP
            current_jump = Jump(current_skijumper, self.hill)
            current_jump.initiate_jump()

            jump_distance = max(round(current_jump.jump_distance, 2), 0)

            self.results.append(current_jump.get_series_data())
            if not skip_continue_taps and not skip_ten:
                sk.tap_to_continue()
                time.sleep(0.5)
            dashed_line(colour=light_green)
            kv_print("Result", jump_distance, "m")
            dashed_line(colour=light_green)
            line_break()
            dashed_line()
            if jump_distance > self.hill.hill_record:
                type_out("\nIt's a new hill record!\n")
                line_break()
                self.hill.hill_record = jump_distance
            results_df = DataFrame(self.results)
            type_out(
                results_df.sort_values("jump_distance", ascending=False)[[
                    "skijumper",
                    "home_country",
                    "jump_distance",
                ]].head(5))
            results_df.to_pickle(
                f"results/{self.hill.name}_round_{self.round_type}.pkl")
            if not skip_continue_taps and not skip_ten:
                user_input = sk.tap_to_continue({"b": "Breakdown Results"})
                if user_input == "b":
                    current_jump.print_jump_breakdown()
                    secondary_user_input = sk.tap_to_continue(
                        {"ds": "Display Stats"})
                    if secondary_user_input == "ds":
                        current_skijumper.print_stats()
                        sk.tap_to_continue()