Beispiel #1
0
 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
Beispiel #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
Beispiel #3
0
 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
Beispiel #4
0
 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
Beispiel #5
0
 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
Beispiel #6
0
    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()
Beispiel #7
0
 def print_jump_breakdown(self):
     """Print the jump breakdown results."""
     dashed_line(n=50)
     kv_print("Height Bonus", self.height_bonus, "m", signed=True)
     kv_print("Weight Bonus", self.weight_bonus, "m", signed=True)
     kv_print("Home Hill Bonus", self.hill_bonus, "m", signed=True)
     kv_print("Home Country Bonus", self.home_bonus, "m", signed=True)
     dashed_line(n=50)
     kv_print("Jump Speed", self.jump_speed, "km/h", signed=True)
     kv_print("Jump Speed Bonus", self.jump_bonus / 2, "m", signed=True)
     dashed_line(n=50)
     kv_print("Consistency Bonus", self.consistency_bonus, "m", signed=True)
     kv_print("Risk Impact", self.risk_bonus, "m", signed=True)
     kv_print("Form Impact", self.form_bonus, "m", signed=True)
     kv_print("Father Presence", self.father_bonus, "m", signed=True)
     dashed_line(n=50)
     kv_print("Wind Horizontal", self.wind_horizontal, "km/h", signed=True)
     pass
Beispiel #8
0
 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