| 293 | |
| 294 | |
| 295 | class Player(User): |
| 296 | def __init__(self, name, amount): |
| 297 | super().__init__(name=name, chips_amount=amount, role="Player", color="CYAN") |
| 298 | self.refresh_prompt() |
| 299 | |
| 300 | def refresh_prompt(self): |
| 301 | self.prompt = "{role} [ ${remain} ] >> ({name}) : ".format( |
| 302 | role="Player", name=self.name, remain=self.chips.current_amount() |
| 303 | ) |
| 304 | |
| 305 | def select_choice(self, pattern): |
| 306 | my_turn = "My turn now." |
| 307 | self.speak(content=my_turn) |
| 308 | operation = { |
| 309 | "I": "Insurance", |
| 310 | "H": "Hit", |
| 311 | "S": "Stand", |
| 312 | "D": "Double-down", |
| 313 | "U": "Surrender", |
| 314 | } |
| 315 | enu_choice = enumerate((operation.get(p) for p in pattern), 1) |
| 316 | dict_choice = dict(enu_choice) |
| 317 | for index, operator in dict_choice.items(): |
| 318 | choice_fmt = "\t[{index}] {operation}" |
| 319 | print(choice_fmt.format(index=index, operation=operator)) |
| 320 | return dict_choice |
| 321 | |
| 322 | |
| 323 | class Recorder: |