from ...player import Player
from ...enums import ActionType
from ...playeraction import PlayerAction

__all__ = ["LoosePassiveBot"]


class LoosePassiveBot(Player):
    """A bot that plays too many hands and calls too often (calling station).

    Uses hand strength evaluation but still calls with weak equity. Understands
    pot odds in theory but applies them poorly, calling with insufficient equity
    and playing passively even with strong hands.

    - **Key Traits:** Limping, calling with weak or marginal hands, uses hand strength poorly.
    - **Strengths:** Pays off strong hands, occasionally has hand equity on their side.
    - **Weaknesses:** Long-term losing style, calls with insufficient equity.
    - **Common At:** Casual home games and low-stakes casinos.
    """

    def decide_action(
        self, *, valid_actions: list[ActionType], min_bet_amount: int, **_
    ) -> PlayerAction:
        """Call frequently with many hands using hand strength poorly, rarely raise."""
        # NOTE: Loose passive doesn't rely on hand strength estimation. In fact it doesn't
        # even look at the cards at all. It just calls a lot.

        # Check when possible
        if ActionType.CHECK in valid_actions:
            return PlayerAction(player_id=self.id, action_type=ActionType.CHECK)

        # Call almost anything, even with weak equity
        if ActionType.CALL in valid_actions:
            return PlayerAction(player_id=self.id, action_type=ActionType.CALL)

        # Rarely bet, but will if no one else has
        if ActionType.BET in valid_actions:
            bet_amount = min(min_bet_amount, self.state.stack)
            return PlayerAction(
                player_id=self.id, action_type=ActionType.BET, amount=bet_amount
            )

        # Almost never raise (not aggressive)
        # Fold only when can't call
        return PlayerAction(player_id=self.id, action_type=ActionType.FOLD)
