47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
|
|
import argparse
|
||
|
|
|
||
|
|
import pirate_names_generator
|
||
|
|
from bot_ai import BotAi
|
||
|
|
from engine import LiarsDiceEngine
|
||
|
|
from ui import MyEngineHandler
|
||
|
|
|
||
|
|
|
||
|
|
def play_game(args: argparse.Namespace):
|
||
|
|
names = ["You"] + pirate_names_generator.get_names(args.num_players - 1, False)
|
||
|
|
|
||
|
|
listener = MyEngineHandler(state=None, player_names=names, bot_ai=BotAi())
|
||
|
|
engine = LiarsDiceEngine.new_game(args.num_players, args.wild_ones, listener)
|
||
|
|
|
||
|
|
try:
|
||
|
|
engine.start_game()
|
||
|
|
except KeyboardInterrupt:
|
||
|
|
print("\nYou run away, cowardly...")
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
parser = argparse.ArgumentParser(
|
||
|
|
"Liar's dice", description="A classical dice game of chance and bluffing."
|
||
|
|
)
|
||
|
|
parser.add_argument(
|
||
|
|
"--num-players",
|
||
|
|
"-n",
|
||
|
|
type=int,
|
||
|
|
default=2,
|
||
|
|
help="The number of players (1 human, N-1 bots).",
|
||
|
|
)
|
||
|
|
parser.add_argument(
|
||
|
|
"--wild-ones",
|
||
|
|
"-w",
|
||
|
|
action="store_true",
|
||
|
|
help="If set, uses the advanced game rules, whereby the '1' die face is considered wild "
|
||
|
|
"(always matching the current bid).",
|
||
|
|
)
|
||
|
|
|
||
|
|
args = parser.parse_args()
|
||
|
|
|
||
|
|
play_game(args)
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|