MCPcopy Index your code
hub / github.com/geekcomputers/Python / calculate_point

Method calculate_point

BlackJack_game/blackjack_simulate.py:229–246  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

227 self.show_card()
228
229 def calculate_point(self):
230 def _extract_rank():
231 raw_ranks = [card.rank for card in self.hand]
232 cook_ranks = [10 if rank > 10 else rank for rank in raw_ranks]
233 return cook_ranks
234
235 def _sum_up(ranks):
236 rank_one = sum(ranks)
237 rank_eleven = sum([11 if rank == 1 else rank for rank in ranks])
238 # Over or has 2 Ace
239 if (ranks[::-1] == ranks) and (1 in ranks):
240 return 11 + len(ranks) - 1
241 if rank_eleven <= BLACK_JACK:
242 return rank_eleven
243 return rank_one
244
245 points = _extract_rank()
246 self.point = _sum_up(points)
247
248 def is_point(self, opt, point):
249 self.calculate_point()

Callers 3

is_pointMethod · 0.95
unveilingMethod · 0.95
get_winnerMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected