-
Notifications
You must be signed in to change notification settings - Fork 0
Sharedmvp #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nonebula
wants to merge
44
commits into
main
Choose a base branch
from
sharedmvp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sharedmvp #9
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
5da07f0
Tests
f98df9a
Merge pull request #6 from nonebula/playground
nonebula 680da61
Tests
ad25235
Added planning notes for today's actions
nonebula 8b7d7f5
Take2
7aca382
Take 3
9be750e
Testing suite debugging
nonebula 569c5ea
Code for selecting character from gameboard added
nonebula d157660
GameLogic tweaked
nonebula abff432
Question handling refactored
nonebula 44b8c65
Tests added
06490d1
Merging conflicts
nonebula 30d7adf
Refactor attempted
nonebula ddb3df2
Merge pull request #7 from nonebula/type-mismatch-debug
nonebula 3571f98
Team refactoring
69c1f53
Initialisation tests
8e7a773
Handles questions test
3fcdfcf
Testing tests
f856506
BoardSpec hair colour test fixed
151cb53
new tests added
6fb9000
File cleanup
nonebula 9ad8fa4
Added type to characters
nonebula 6fd6ad8
Test refactor
nonebula 1496ec2
Presentation notes
nonebula 2679ef7
Moved one note to bottom of board
nonebula 1764ed0
few changes
8e71f0a
last commit
de39d12
Ext1 (#8)
nonebula 7002bba
Minor styling
nonebula 4507c39
Final touches
nonebula 286cc46
Notes from presentation added
nonebula aab8b75
Character refactoring (Chunky)
nonebula 851ee31
Board logic refactored
nonebula 2c78d5c
Game object refactored
nonebula 7060122
Game refactor
nonebula f313ae0
update
nonebula a28e99e
tests added
c90cb80
Test edit
nonebula c0cc4c5
EyeColor.Blue
31d73e5
Testing for new elements
nonebula 432854f
Merge branch 'sharedmvp' of github.com:nonebula/GuessWho into sharedmvp
nonebula 3ce5ae1
note added
nonebula 9745878
Testing refinement (boardspec unfinished)
nonebula 28c3fa4
space
nonebula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,116 @@ | ||
| package GuessWhoGame | ||
|
|
||
| case class Board (Characters: List[Character]) { | ||
| import scala.util.Random | ||
|
|
||
| //values could be more domain specific, name/selecting could be within character case class, then able to test separately | ||
| case class Board(characters: List[Character]) { | ||
| def printCharacterNames(): Unit = { | ||
| Characters.foreach(Character => println(Character.name)) | ||
| characters.foreach(Character => println(Character.name)) | ||
| } | ||
|
|
||
| val selectedCharacter: Character = selectRandomCharacter(characters) | ||
| var remainingCharacters: List[Character] = characters | ||
|
|
||
| def printRemainingCharacters(): Unit = { | ||
| remainingCharacters.foreach(Character => println(Character.name)) | ||
| } | ||
nonebula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def selectRandomCharacter(characters: List[Character]): Character = { | ||
| characters(Random.nextInt(characters.size)) | ||
nonebula marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| //Testing purposes | ||
| def getSelectedCharacter: Character = selectedCharacter | ||
|
|
||
| def printSelectedCharacter(): Unit = { | ||
| println(selectedCharacter.name) | ||
| } | ||
nonebula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def getRemainingCharacters: List[Character] = remainingCharacters | ||
nonebula marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def checkWinCondition: Boolean = getRemainingCharacters.size == 1 | ||
|
|
||
| //Future development | ||
| // def resetBoard(): Unit = { | ||
| // remainingCharacters = characters | ||
| // } | ||
|
|
||
| // def eliminateCharacter(character: Character): Unit = { | ||
| // var remainingCharacters = characters.filterNot(_ == character) | ||
| // } | ||
|
|
||
| def handleQuestion(attribute: String, value: Either[String, Boolean]): Unit = { | ||
| remainingCharacters = attribute match { | ||
| case "name" => | ||
| value match { | ||
| case Left(value) => | ||
| if (selectedCharacter.name == value) { | ||
| remainingCharacters.filter(_.name == value) | ||
| } else { | ||
| remainingCharacters.filterNot(_.name == value) | ||
| } | ||
| case _ => println("Invalid name value added. Try again") | ||
| remainingCharacters | ||
| } | ||
| case "gender" => | ||
| value match { | ||
| case Left(value) => | ||
| if (selectedCharacter.gender == value) { | ||
| remainingCharacters.filter(_.gender == value) | ||
| } else { | ||
| remainingCharacters.filterNot(_.gender == value) | ||
| } | ||
| case _ => println("Invalid gender value added. Try again") | ||
| remainingCharacters | ||
| } | ||
| case "hairColor" => | ||
| value match { | ||
| case Left(value) => | ||
| if (selectedCharacter.hairColor == value) { | ||
| remainingCharacters.filter(_.hairColor == value) | ||
| } | ||
| else { | ||
| remainingCharacters.filterNot(_.hairColor == value) | ||
| } | ||
| case _ => println("Invalid hair colour value added. Try again") | ||
| remainingCharacters | ||
| } | ||
| case "eyeColor" => | ||
| value match { | ||
| case Left(value) => | ||
| if (selectedCharacter.eyeColor == value) { | ||
| remainingCharacters.filter(_.eyeColor == value) | ||
| } | ||
| else { | ||
| remainingCharacters.filterNot(_.eyeColor == value) | ||
| } | ||
| case _ => println("Invalid eye colour value added. Try again") | ||
| remainingCharacters | ||
| } | ||
| case "wearsGlasses" => | ||
| value match { | ||
| case Right(value) => | ||
| if (selectedCharacter.wearsGlasses == value) { | ||
| remainingCharacters.filter(_.wearsGlasses == value) | ||
| } | ||
| else { | ||
| remainingCharacters.filterNot(_.wearsGlasses == value) | ||
| } | ||
| case _ => println("Invalid glasses value added. Try again") | ||
| remainingCharacters | ||
| } | ||
| case "hasFacialHair" => | ||
| value match { | ||
| case Right(value) => | ||
| if (selectedCharacter.facialHair == value) { | ||
| remainingCharacters.filter(_.facialHair == value) | ||
| } | ||
| else { | ||
| remainingCharacters.filterNot(_.facialHair == value) | ||
| } | ||
| case _ => println("Invalid facial hair value added. Try again") | ||
| remainingCharacters | ||
| } | ||
| } | ||
nonebula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.