示例#1
0
 def test_score_bull_winning_hand(self):
     """Score using BULL as a wildcard is correct"""
     commodity = 'oats'
     cards = [commodity] * (config.COMMODITIES_PER_HAND - 1)
     cards.append(config.BULL)
     score = util.score_hand(cards)
     self.assertEqual(score, config.COMMODITY_VALUES[commodity])
示例#2
0
 def test_score_bonus_winning_hand(self):
     """Score with a double bonus for BULL is correct"""
     commodity = 'coffee'
     cards = [commodity] * config.COMMODITIES_PER_HAND
     cards.append(config.BULL)
     score = util.score_hand(cards)
     self.assertEqual(score, config.COMMODITY_VALUES[commodity] * 2)
示例#3
0
文件: test_util.py 项目: roblacy/pit
 def test_score_bonus_winning_hand(self):
     """Score with a double bonus for BULL is correct"""
     commodity = 'coffee'
     cards = [commodity] * config.COMMODITIES_PER_HAND
     cards.append(config.BULL)
     score = util.score_hand(cards)
     self.assertEqual(score, config.COMMODITY_VALUES[commodity] * 2)
示例#4
0
文件: test_util.py 项目: roblacy/pit
 def test_score_bull_winning_hand(self):
     """Score using BULL as a wildcard is correct"""
     commodity = 'oats'
     cards = [commodity] * (config.COMMODITIES_PER_HAND - 1)
     cards.append(config.BULL)
     score = util.score_hand(cards)
     self.assertEqual(score, config.COMMODITY_VALUES[commodity])
示例#5
0
 def update_scores(self):
     """Updates player scores at end of a round, sets winner if any."""
     for player in self.players:
         score = util.score_hand(self.player_info[player]['cards'])
         self.player_info[player]['score'] += score
         if self.player_info[player]['score'] >= config.WINNING_SCORE:
             self.winner = player
示例#6
0
文件: gameengine.py 项目: roblacy/pit
 def update_scores(self):
     """Updates player scores, checks if there is a game winner.
     """
     for uid, data in self.player_data.iteritems():
         data['score'] += util.score_hand(data['cards'])
         if data['score'] >= config.WINNING_SCORE:
             self.game_winner = self.round_winner
     print 'ROUND WINNER IS {0}'.format(self.player_data[self.round_winner]['name'])
     self.debug()
示例#7
0
 def update_scores(self):
     """Updates player scores, checks if there is a game winner.
     """
     for uid, data in self.player_data.iteritems():
         data['score'] += util.score_hand(data['cards'])
         if data['score'] >= config.WINNING_SCORE:
             self.game_winner = self.round_winner
     print 'ROUND WINNER IS {0}'.format(
         self.player_data[self.round_winner]['name'])
     self.debug()
示例#8
0
 def test_score_dual_penalty(self):
     """A non-winning hand with both bull and bear is super penalized"""
     cards = ['barley'] * 4 + ['oranges'] * 3 + [config.BULL, config.BEAR]
     score = util.score_hand(cards)
     self.assertEqual(score, -(config.BEAR_PENALTY + config.BULL_PENALTY))
示例#9
0
 def test_score_bear_penalty(self):
     """A non-winning hand with a bear has a negative score"""
     cards = ['barley'] * 4 + ['oranges'] * 3 + ['soybeans', config.BEAR]
     score = util.score_hand(cards)
     self.assertEqual(score, -config.BEAR_PENALTY)
示例#10
0
 def test_score_neutral_hand(self):
     """A neutral hand has a score of 0"""
     cards = ['barley'] * 4 + ['oranges'] * 3 + ['soybeans', 'oats']
     score = util.score_hand(cards)
     self.assertEqual(score, 0)
示例#11
0
 def test_score_regular_winning_hand(self):
     """Score for a regular winning hand is correct"""
     commodity = 'wheat'
     cards = [commodity] * config.COMMODITIES_PER_HAND
     score = util.score_hand(cards)
     self.assertEqual(score, config.COMMODITY_VALUES[commodity])
示例#12
0
文件: test_util.py 项目: roblacy/pit
 def test_score_dual_penalty(self):
     """A non-winning hand with both bull and bear is super penalized"""
     cards = ['barley'] * 4 + ['oranges'] * 3 + [config.BULL, config.BEAR]
     score = util.score_hand(cards)
     self.assertEqual(score, -(config.BEAR_PENALTY+config.BULL_PENALTY))
示例#13
0
文件: test_util.py 项目: roblacy/pit
 def test_score_bear_penalty(self):
     """A non-winning hand with a bear has a negative score"""
     cards = ['barley'] * 4 + ['oranges'] * 3 + ['soybeans', config.BEAR]
     score = util.score_hand(cards)
     self.assertEqual(score, -config.BEAR_PENALTY)
示例#14
0
文件: test_util.py 项目: roblacy/pit
 def test_score_neutral_hand(self):
     """A neutral hand has a score of 0"""
     cards = ['barley'] * 4 + ['oranges'] * 3 + ['soybeans', 'oats']
     score = util.score_hand(cards)
     self.assertEqual(score, 0)
示例#15
0
文件: test_util.py 项目: roblacy/pit
 def test_score_regular_winning_hand(self):
     """Score for a regular winning hand is correct"""
     commodity = 'wheat'
     cards = [commodity] * config.COMMODITIES_PER_HAND
     score = util.score_hand(cards)
     self.assertEqual(score, config.COMMODITY_VALUES[commodity])