-
Notifications
You must be signed in to change notification settings - Fork 0
margaux/refactor typing and local buzzer games + tied scores managing #265
Conversation
/* the array must be declared explicitly (and not with buzzersToRows.keys) | ||
else the buzzers may not be ordered properly | ||
*/ | ||
private val buzIds = arrayListOf(R.id.buzzer_0, R.id.buzzer_1, R.id.buzzer_2, R.id.buzzer_3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
assertTrue(testUpdater.getWinnerId() == idArray[0]) | ||
testUpdater.updateScoresArray(-1, true) | ||
for (id in idArray) { | ||
assertTrue(testUpdater.getMap()[id]==0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for readability add space on both sides of "=="
val testWinner = testUpdater.computeWinner() | ||
assertTrue(testWinner.size==2) | ||
assertTrue(testWinner.contains(R.id.buzzer_0) && testWinner.contains(R.id.buzzer_2)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same in these tests, add spaces for readability
onView(withId(R.id.nb_players_selected)).check(matches(withEffectiveVisibility(Visibility.INVISIBLE))) | ||
onView(withId(R.id.missingNameAlert)).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) | ||
|
||
// click on "OK" button in alert => check alert disappears and next button reappears |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the comments here, good job 👍
@@ -175,7 +175,7 @@ class TypingGameActivityTest { | |||
|
|||
val intent = | |||
Intent(ApplicationProvider.getApplicationContext(), TypingGameActivity::class.java) | |||
// Do not put gameManager as an extra | |||
// Do not put gameManager as an extra: it causes a RuntimeException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good that you added an explanation
if (gameManager.playingMediaPlayer()) { | ||
gameManager.stopMediaPlayer() | ||
} | ||
checkAnswer(ctx, null, gameManager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a comment what null means here
@@ -49,8 +49,8 @@ class GameEndingActivity : AppCompatActivity() { | |||
if (intent.hasExtra("Winner Name")) { | |||
val winner = intent.getStringExtra("Winner Name") | |||
if (winner!=null) { | |||
findViewById<TextView>(R.id.winnerText).text="And the winner is... $winner!" | |||
} else {findViewById<TextView>(R.id.winnerText).text="Nobody won this game!"} | |||
findViewById<TextView>(R.id.winnerText).text=winner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just minor readability things here with "=="
*/ | ||
open class GameManager : Serializable { | ||
private var score = 0 | ||
private var score = 0 // we can yeet this and use the size of the correct song list instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "yeet"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a typo haha, fixed it and added to the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice work, added some small comments that will help with readability, if you take a look at them I'll approve :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Work 👍 Here are some comments :)
assertTrue(testUpdater.getWinnerId() == idArray[0]) | ||
testUpdater.updateScoresArray(-1, true) | ||
for (id in idArray) { | ||
assertTrue(testUpdater.getMap()[id] == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertTrue(testUpdater.getMap()[id] == 0) | |
assertEquals(0, testUpdater.getMap()[id]) |
It is maybe more precise to use assertEqual.
Indeed if there is an error, it will be able to say: Value received, Value Expected.
Whereas in your case it will just say, received false whereas expecting true
for (id in idArray) { | ||
assertTrue(testUpdater.getMap()[id]==0) | ||
testUpdater.updateScoresArray(id, false) | ||
assertTrue(testUpdater.getMap()[id] == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
val scoreArray = arrayOf(0, 0, 0, 0) | ||
val testUpdater = BuzzerScoreUpdater(idArray, scoreArray) | ||
val testWinner = testUpdater.computeWinner() | ||
assertTrue(testWinner.size == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
assertTrue(testWinner.size == 1) | ||
assertTrue(testWinner.get(0) == R.id.buzzer_2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
assertTrue(testWinner.size == 2) | ||
assertTrue(testWinner.contains(R.id.buzzer_0) && testWinner.contains(R.id.buzzer_2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
val scn: ActivityScenario<TypingGameActivity> = ActivityScenario.launch(intent) | ||
val ctx = ApplicationProvider.getApplicationContext() as Context | ||
createMockDataGetter() | ||
createMockAuthenticator() | ||
scn.onActivity { activity -> | ||
activity.checkAnswer(ctx, songTest, gameManager) | ||
} | ||
assertEquals(true, gameManager.getScore() == 0) | ||
assertEquals(true, gameManager.getCorrectSongs().size == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertEquals(true, gameManager.getCorrectSongs().size == 0) | |
assertEquals(0, gameManager.getCorrectSongs().size) |
Maybe simpler and easier to read
button.text = pName | ||
button.width = 100 | ||
button.height = 0 | ||
button.visibility=View.VISIBLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
button.visibility=View.VISIBLE | |
button.visibility = View.VISIBLE | |
setPressed(button.id) | ||
if (findViewById<ProgressBar>(R.id.progressBarBuzzer).progress>0 && findViewById<Button>(R.id.nextSongBuzzer).visibility==View.GONE) { | ||
answer.visibility = android.view.View.VISIBLE | ||
findViewById<Button>(R.id.go_to_end).visibility=View.INVISIBLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findViewById<Button>(R.id.go_to_end).visibility=View.INVISIBLE | |
findViewById<Button>(R.id.go_to_end).visibility = View.INVISIBLE | |
val view = map[pressedBuzzer]?.let { it1 -> findViewById<TextView>(it1) } | ||
if (view != null && updater.getMap().keys.contains(pressedBuzzer)) {view.text=updater.getMap()[pressedBuzzer].toString()} | ||
if (view != null && scoreUpdater.getMap().keys.contains(pressedBuzzer)) {view.text=scoreUpdater.getMap()[pressedBuzzer].toString()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (view != null && scoreUpdater.getMap().keys.contains(pressedBuzzer)) {view.text=scoreUpdater.getMap()[pressedBuzzer].toString()} | |
if (view != null && scoreUpdater.getMap().keys.contains(pressedBuzzer)) { | |
view.text = scoreUpdater.getMap()[pressedBuzzer].toString() | |
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will even improve coverage as tested code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Code Climate has analyzed commit 5e27836 and detected 4 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 99.1% (80% is the threshold). This pull request will bring the total coverage in the repository to 80.1%. View more on Code Climate. |
No description provided.