gametree: fix player
This commit is contained in:
13
test/pg.py
13
test/pg.py
@@ -15,6 +15,7 @@ from gametree.model import act_fold, act_call, act_check, act_bet, act_raise, ac
|
||||
GAME_FILE = "pg.json"
|
||||
|
||||
def create_file_idx():
|
||||
Path("data").mkdir(exist_ok=True)
|
||||
files = list(Path("data").glob("pg_*.json"))
|
||||
game_id = len(files) + 1
|
||||
return f"data/pg_{game_id:03d}.json"
|
||||
@@ -64,7 +65,7 @@ def display_game_status(game: Game, player_names: Dict[int,str], show_cards_for:
|
||||
marks.append("->")
|
||||
if pstate.folded:
|
||||
marks.append("F")
|
||||
if pstate.all_in:
|
||||
if pstate.allin:
|
||||
marks.append("A")
|
||||
info = f"{i}:{name} stack={pstate.stack} bet={pstate.committed} [{' '.join(marks)}]"
|
||||
if show_cards_for == "all" or show_cards_for == name:
|
||||
@@ -144,8 +145,8 @@ def display_player_turn():
|
||||
elif a == ActionType.RAISE:
|
||||
min_raise, max_raise = GAME.get_raise_bounds(pid)
|
||||
print(f" - raise (min: {min_raise}, max: {max_raise})")
|
||||
elif a == ActionType.ALL_IN:
|
||||
print(f" - all_in (amount: {GAME.get_allin_amt(pid)})")
|
||||
elif a == ActionType.ALLIN:
|
||||
print(f" - allin (amount: {GAME.get_allin_amt(pid)})")
|
||||
|
||||
|
||||
print("----------------------------------------------------")
|
||||
@@ -200,7 +201,7 @@ def main():
|
||||
return
|
||||
input = shlex.split(args)
|
||||
if len(input) < 2:
|
||||
print("act <player_name> <fold|call|check|bet|raise|all_in> [amount]")
|
||||
print("act <player_name> <fold|call|check|bet|raise|allin> [amount]")
|
||||
return
|
||||
pname = input[0]
|
||||
action = input[1]
|
||||
@@ -213,7 +214,7 @@ def main():
|
||||
|
||||
legal = GAME.legal_actions(pid)
|
||||
if action.lower() == 'allin':
|
||||
atype = ActionType.ALL_IN
|
||||
atype = ActionType.ALLIN
|
||||
elif action.lower() in ('fold', 'call', 'check', 'bet', 'raise'):
|
||||
atype = ActionType[action.upper()]
|
||||
else:
|
||||
@@ -273,7 +274,7 @@ def main():
|
||||
def cmd_help(args):
|
||||
print("可用命令:")
|
||||
print(" set <small>/<big> <p1> [p2 ...] [--stack N] ")
|
||||
print(" act <player> <fold|call|check|bet|raise|all_in> [amount]")
|
||||
print(" act <player> <fold|call|check|bet|raise|allin> [amount]")
|
||||
print(" status [player|all] ")
|
||||
print(" save ")
|
||||
print(" reset ")
|
||||
|
||||
Reference in New Issue
Block a user