Skip to content

fix minor bugs for server logic#10

Merged
edge2992 merged 7 commits intomainfrom
feature/fix_scoreCalcLogic
Nov 13, 2025
Merged

fix minor bugs for server logic#10
edge2992 merged 7 commits intomainfrom
feature/fix_scoreCalcLogic

Conversation

@edge2992
Copy link
Owner

@edge2992 edge2992 commented Nov 13, 2025

  1. ✅ スコア計算のバグ修正 (abf6f0c)
  • Three/Four of a Kindが全ダイスの合計を返すように修正
  • 正しいヤッツィールールに準拠
  1. ✅ リロール回数制限のバグ修正 (3bd667a)
  • NumberOfDice(5)からMaxRolls(3)に変更
  • 正しく3回までのロールに制限
  1. ✅ 勝者表示機能の実装 (f89ebda)
  • ゲーム終了時に勝者を表示
  • 同点の場合も対応
  • カラフルなUI(トロフィー絵文字付き)
  1. ✅ Upper Sectionボーナスの実装 (ee230a3)
  • Ones~Sixesの合計が63点以上で+35点のボーナス
  • 公式ルール準拠
  1. ✅ エラーメッセージシステムの実装 (8ed99ff)
  • リロール回数超過時にエラーメッセージを表示
  • クライアント・サーバー間のエラー通信機能
  1. ✅ テスト修正 (fc4afe3, 3ffde8e)
  • MockIOHandlerの更新
  • 全テストが正常に通過

Three of a Kind and Four of a Kind should return the sum of ALL dice,
not just the matching dice multiplied by their count.

Example:
- Before: Three 3s = 9 points (3 * 3)
- After: Three 3s + two other dice = sum of all 5 dice

This aligns with official Yahtzee rules.
Changed from comparing with NumberOfDice (5) to MaxRolls (3).
Players should be limited to 3 rolls per turn, not 5.
Added DisplayGameOver method to IOHandler interface and ConsoleIOHandler.
The game over screen now displays:
- Final scoreboard
- Winner announcement with trophy emoji
- Handles tie situations

Resolves TODO in client.go:178
Added 35-point bonus when Upper Section (Ones through Sixes)
totals 63 or more points, following official Yahtzee rules.

The CalculateTotalScore function now:
- Calculates Upper Section total separately
- Applies bonus if threshold is met
- Adds Lower Section scores
Added Error message type and ErrorMessage field to messages package.
Server now sends error messages to clients when they exceed the
maximum number of rerolls.

Changes:
- Added messages.Error type and ErrorMessage field
- Server sends error when reroll limit exceeded
- Client displays error messages to user

Resolves TODO in server/gameplay_controller.go:112
- Fixed player.Conn to player.Connection in gameplay_controller.go
- Added DisplayGameOver method to MockIOHandler to satisfy IOHandler interface
Corrected method call to use the proper Connection interface method.
All tests now pass successfully.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes several bugs in the Yahtzee game server logic and implements missing features to align with official Yahtzee rules.

Key Changes:

  • Fixed score calculation for Three/Four of a Kind to return the sum of all dice instead of just the matching dice
  • Corrected reroll limit from NumberOfDice (5) to MaxRolls (3)
  • Implemented upper section bonus (35 points when upper section total ≥ 63 points)
  • Added winner display feature with tie handling and error message system

Reviewed Changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/gameplay_controller.go Updated reroll validation to use MaxRolls constant and implemented error message sending to client when reroll limit is exceeded
messages/messages.go Added Error message type and ErrorMessage field to support server-to-client error communication
game/score.go Fixed Three/Four of a Kind to return sum of all dice; implemented upper section bonus calculation in total score
client/mock_iohandler.go Added DisplayGameOver method to mock for testing winner display functionality
client/iohandler.go Added DisplayGameOver interface method for game over display
client/console_io_handler.go Implemented DisplayGameOver with winner determination, tie handling, and colorful UI output
client/client.go Added error message handler and updated game over handler to display winners using the new DisplayGameOver method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@edge2992 edge2992 merged commit f6f2f27 into main Nov 13, 2025
7 checks passed
@edge2992 edge2992 deleted the feature/fix_scoreCalcLogic branch November 13, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants