mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 15:16:33 -08:00
BUG: Fix best in Python boxing
This commit is contained in:
@@ -23,9 +23,9 @@ class HitStats(NamedTuple):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Player:
|
class Player:
|
||||||
name: str
|
name: str
|
||||||
best: int # TODO: This is never used!
|
best: int # this hit guarantees 2 damage on opponent
|
||||||
|
weakness: int # you're always hit when your opponent uses this punch
|
||||||
is_computer: bool
|
is_computer: bool
|
||||||
weakness: int
|
|
||||||
|
|
||||||
# for each of the 4 punch types, we have a probability of hitting
|
# for each of the 4 punch types, we have a probability of hitting
|
||||||
hit_stats: Dict[Literal[1, 2, 3, 4], HitStats]
|
hit_stats: Dict[Literal[1, 2, 3, 4], HitStats]
|
||||||
@@ -216,7 +216,7 @@ def play_round(round_number: int, player: Player, opponent: Player) -> None:
|
|||||||
# Load the hit characteristics of the current player's punch
|
# Load the hit characteristics of the current player's punch
|
||||||
hit_stats = active.hit_stats[punch]
|
hit_stats = active.hit_stats[punch]
|
||||||
|
|
||||||
if punch == passive.weakness:
|
if punch == active.best:
|
||||||
passive.damage += 2
|
passive.damage += 2
|
||||||
|
|
||||||
print(hit_stats.pre_msg.format(active=active, passive=passive), end=" ")
|
print(hit_stats.pre_msg.format(active=active, passive=passive), end=" ")
|
||||||
|
|||||||
Reference in New Issue
Block a user