Module blaseball_mike.models.fight

Expand source code
import json

from .base import Base
from .game import Game
from .player import Player
from .team import Team
from .. import tables, chronicler


class Fight(Game):
    """Represents a Blaseball boss fight."""
    @classmethod
    def _get_fields(cls):
        p = cls.load_by_id("6754f45d-52a6-4b2f-b63c-15dcd520f8cf")
        return [cls._from_api_conversion(x) for x in p.fields]

    class DamageResults(Base):
        """
        Information regarding a specific damage event
        """
        @Base.lazy_load("_dmg_type")
        def dmg_type(self):
            return tables.DamageType(self._dmg_type)

        @Base.lazy_load("_player_source_id", cache_name="_player_source")
        def player_source(self):
            return Player.load_one(self._player_source_id)

        @Base.lazy_load("_team_target_id", cache_name="_team_target")
        def team_target(self):
            return Team.load(self._team_target_id)

    @classmethod
    def load_by_id(cls, id_):
        fights = list(chronicler.get_entities("bossfight", id_=id_))
        if len(fights) != 1:
            return None
        return cls(fights[0]["data"])

    @classmethod
    def load_by_season(cls, season):
        return {
            x['id']: cls(x["data"]) for x in chronicler.get_fights(season=season)
        }

    @Base.lazy_load("_away_hp")
    def away_hp(self):
        return int(self._away_hp)

    @Base.lazy_load("_home_hp")
    def home_hp(self):
        return int(self._home_hp)

    @Base.lazy_load("_away_max_hp")
    def away_max_hp(self):
        return int(self._away_max_hp)

    @Base.lazy_load("_home_max_hp")
    def home_max_hp(self):
        return int(self._home_max_hp)

    @Base.lazy_load("_damage_results_str", cache_name="_damage_results", default_value=list())
    def damage_results(self):
        return [self.DamageResults(x) for x in json.loads(self._damage_results_str)]

Classes

class Fight (data, strict=False)

Represents a Blaseball boss fight.

Expand source code
class Fight(Game):
    """Represents a Blaseball boss fight."""
    @classmethod
    def _get_fields(cls):
        p = cls.load_by_id("6754f45d-52a6-4b2f-b63c-15dcd520f8cf")
        return [cls._from_api_conversion(x) for x in p.fields]

    class DamageResults(Base):
        """
        Information regarding a specific damage event
        """
        @Base.lazy_load("_dmg_type")
        def dmg_type(self):
            return tables.DamageType(self._dmg_type)

        @Base.lazy_load("_player_source_id", cache_name="_player_source")
        def player_source(self):
            return Player.load_one(self._player_source_id)

        @Base.lazy_load("_team_target_id", cache_name="_team_target")
        def team_target(self):
            return Team.load(self._team_target_id)

    @classmethod
    def load_by_id(cls, id_):
        fights = list(chronicler.get_entities("bossfight", id_=id_))
        if len(fights) != 1:
            return None
        return cls(fights[0]["data"])

    @classmethod
    def load_by_season(cls, season):
        return {
            x['id']: cls(x["data"]) for x in chronicler.get_fights(season=season)
        }

    @Base.lazy_load("_away_hp")
    def away_hp(self):
        return int(self._away_hp)

    @Base.lazy_load("_home_hp")
    def home_hp(self):
        return int(self._home_hp)

    @Base.lazy_load("_away_max_hp")
    def away_max_hp(self):
        return int(self._away_max_hp)

    @Base.lazy_load("_home_max_hp")
    def home_max_hp(self):
        return int(self._home_max_hp)

    @Base.lazy_load("_damage_results_str", cache_name="_damage_results", default_value=list())
    def damage_results(self):
        return [self.DamageResults(x) for x in json.loads(self._damage_results_str)]

Ancestors

Class variables

var DamageResults

Information regarding a specific damage event

Static methods

def load_by_id(id_)

Load by ID

Expand source code
@classmethod
def load_by_id(cls, id_):
    fights = list(chronicler.get_entities("bossfight", id_=id_))
    if len(fights) != 1:
        return None
    return cls(fights[0]["data"])
def load_by_season(season)

Return dictionary of games for a given season keyed by game ID. Can optionally be filtered by in-game day or team ID. Season and Day are 1-indexed

Expand source code
@classmethod
def load_by_season(cls, season):
    return {
        x['id']: cls(x["data"]) for x in chronicler.get_fights(season=season)
    }

Instance variables

var at_bat_balls
var at_bat_strikes
var away_balls
var away_bases
var away_batter
var away_batter_name
var away_hp
var away_max_hp
var away_odds
var away_outs
var away_pitcher
var away_pitcher_name
var away_score
var away_strikes
var away_team
var away_team_batter_count
var away_team_color
var away_team_emoji
var away_team_name
var away_team_nickname
var away_team_secondary_color
var base_runner_names
var base_runners
var baserunner_count
var bases_occupied
var damage_results
var day
var finalized
var game_complete
var game_start
var half_inning_outs
var half_inning_score
var home_balls
var home_bases
var home_batter
var home_batter_name
var home_hp
var home_max_hp
var home_odds
var home_outs
var home_pitcher
var home_pitcher_name
var home_score
var home_strikes
var home_team
var home_team_batter_count
var home_team_color
var home_team_emoji
var home_team_name
var home_team_nickname
var home_team_secondary_color
var id
var inning
var is_postseason
var last_update
var outcomes
var phase
var play_count
var repeat_count
var rules
var season
var series_index
var series_length
var shame
var statsheet
var terminology
var top_of_inning
var weather