Skip to content

Commit

Permalink
Rewrite the collectible printer
Browse files Browse the repository at this point in the history
  • Loading branch information
labordep committed Sep 5, 2023
1 parent c0a9497 commit 72ee139
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 12 deletions.
29 changes: 29 additions & 0 deletions Gameye-Tests/GameyeCollectionFactoryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,35 @@ GameyeCollectionFactoryTest >> createCollectionFromExportedSpreadsheet_1Controll
self assertWishAndForSellCollectionsAreEmpty: datas
]

{ #category : #'tests - common' }
GameyeCollectionFactoryTest >> createCollectionFromExportedSpreadsheet_1FoundVideoGameAnd1NotFoundVideoGame [
| collection foundCollectible notFoundCollectible col |

collection := datas at: GameyeCollection owned.
self assert: collection date equals: (Date newDay: 20 month: 2 year: 2023).
self assert: collection haveUnknowns equals: false.
self assert: collection haveVideoGames equals: true.
self assert: collection haveSystems equals: false.
self assert: collection havePeripherals equals: false.
self assert: collection haveToyToLife equals: false.
self assert: collection havePrintMedias equals: false.
self assert: collection numberOfCollectibles equals: 2.

foundCollectible := collection videoGamesCollectibles first.
self assert: foundCollectible dateAdded equals: (Date newDay: 24 month: 2 year: 2022).
self assert: foundCollectible isVideoGame.

notFoundCollectible := collection videoGamesCollectibles second.
self assert: notFoundCollectible dateAdded equals: (Date newDay: 22 month: 3 year: 2021).
self assert: notFoundCollectible isVideoGame.

col := collection videoGamesForCountry: nil.
self assert: col size equals: 1.
self assert: col first identicalTo: notFoundCollectible.

self assertWishAndForSellCollectionsAreEmpty: datas
]

{ #category : #'tests - common' }
GameyeCollectionFactoryTest >> createCollectionFromExportedSpreadsheet_1System [
| collection collectible |
Expand Down
18 changes: 18 additions & 0 deletions Gameye-Tests/GameyeCollectionFactoryV5Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ GameyeCollectionFactoryV5Test class >> exportedSpreadsheetSampleContentV5_1Contr
"Sega Master System","Controllers","Owned","Master System Controller","United States of America","Official","Sega","Missing Field","14/08/2023","Loose","36.07","?","44.40","36.07","-1.0","8","?","?"," "," ","Remplacer croix directionnelle ","A nettoyer,HS",'
]

{ #category : #samples }
GameyeCollectionFactoryV5Test class >> exportedSpreadsheetSampleContentV5_1FoundVideoGameAnd1NotFoundVideoGame [
"Two games : one found in the database and one not found in the database (red title)"

^self exportedSpreadsheetSampleHeadContentV5, '
"Sega Saturn","Games","Owned","SimCity 2000","United States of America","Official","Missing Field","Missing Field","24/02/2022","CIB","17.93","22.22","66.11","22.22","30.00","10","10","10"," "," ","","",
"Sony PlayStation","Games","Owned","Sim City 2000","","Official","Missing Field","Missing Field","22/03/2021","CIB","-1.0", "-1.0", "-1.0", "-1.0","-1.0","10","7","10"," "," ","","Remplacer boite",'
]

{ #category : #samples }
GameyeCollectionFactoryV5Test class >> exportedSpreadsheetSampleContentV5_1System [
"self exportedSpreadsheetSampleContentV5_1System"
Expand Down Expand Up @@ -96,6 +105,15 @@ GameyeCollectionFactoryV5Test >> testCreateCollectionFromExportedSpreadsheet_1Co
self createCollectionFromExportedSpreadsheet_1ControllerWithTags
]

{ #category : #tests }
GameyeCollectionFactoryV5Test >> testCreateCollectionFromExportedSpreadsheet_1FoundVideoGameAnd1NotFoundVideoGame [

datas := GameyeCollectionFactory createCollectionsFromExportedSpreadsheet: (self class
exportedSpreadsheetSampleFileReference: self class exportedSpreadsheetSampleContentV5_1FoundVideoGameAnd1NotFoundVideoGame).

self createCollectionFromExportedSpreadsheet_1FoundVideoGameAnd1NotFoundVideoGame
]

{ #category : #tests }
GameyeCollectionFactoryV5Test >> testCreateCollectionFromExportedSpreadsheet_1System [

Expand Down
26 changes: 23 additions & 3 deletions Gameye-Tests/GameyeCollectionTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ GameyeCollectionTest class >> createOwnedCollection [
| collection |
collection := GameyeCollection new.
collection name: 'OwnedTestCollection'.
collection addCollectible: (GameyeVideoGame new title: 'Game1'; platform: 'N64'; developer: 'Nintendo'; publisher: 'Nintendo'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: 5).
collection addCollectible: (GameyeVideoGame new title: 'Game2'; platform: 'PS2'; developer: 'Sony'; publisher: 'Sony'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: 0).
collection addCollectible: (GameyeVideoGame new title: 'Game3'; platform: 'Xbox 360'; developer: 'Microsoft'; publisher: 'Microsoft'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: 5).
collection addCollectible: (GameyeVideoGame new title: 'Game1'; platform: 'N64'; country: #'United States of America'; developer: 'Nintendo'; publisher: 'Nintendo'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: 5).
collection addCollectible: (GameyeVideoGame new title: 'Game2'; platform: 'PS2'; country: #'United Kingdom'; developer: 'Sony'; publisher: 'Sony'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: 0).
collection addCollectible: (GameyeVideoGame new title: 'Game3'; platform: 'Xbox 360'; country: #'Japan'; developer: 'Microsoft'; publisher: 'Microsoft'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: 5).
collection addCollectible: (GameyeVideoGame new title: 'Game4'; platform: 'Jaguar'; developer: 'Atari'; publisher: 'Atari'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: nil).
collection addCollectible: (GameyeVideoGame new title: 'Game5'; platform: 'CD-i'; developer: 'Philips'; publisher: 'Philips'; dateAdded: (Date newDay: 21 month: 1 year: 2023); pricePaid: 5).

Expand Down Expand Up @@ -266,6 +266,26 @@ GameyeCollectionTest >> testVideoGamesCollectibles [
self assert: collection videoGamesCollectibles first equals: collectible
]

{ #category : #tests }
GameyeCollectionTest >> testVideoGamesForCountry [

| collection n64Games |
collection := self class createOwnedCollection.
n64Games := collection videoGamesForCountry: #'United Kingdom'.
self assert: n64Games size equals: 1.
self assert: n64Games first country equals: #'United Kingdom'
]

{ #category : #tests }
GameyeCollectionTest >> testVideoGamesForDeveloper [

| collection n64Games |
collection := self class createOwnedCollection.
n64Games := collection videoGamesForDeveloper: 'Nintendo'.
self assert: n64Games size equals: 1.
self assert: n64Games first developer equals: 'Nintendo'
]

{ #category : #tests }
GameyeCollectionTest >> testVideoGamesForPlatform [

Expand Down
10 changes: 5 additions & 5 deletions Gameye/GameyeCollectible.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ GameyeCollectible >> pricePaid: anObject [
GameyeCollectible >> printIdentifierOn: aStream [

aStream
nextPutAll: self type;
nextPutAll: '-';
nextPutAll: (self title ifNil:[ 'Unknown Title' ]);
nextPutAll: '-';
nextPutAll: (self platform ifNil:[ 'Unknown Platform' ])
nextPutAll: (self title ifNil:[ '?' ]);
nextPutAll: ' (';
nextPutAll: (self type ifNil:[ '?' ]);
nextPutAll: ') ';
nextPutAll: (self platform ifNil:[ '?' ])
]

{ #category : #printing }
Expand Down
6 changes: 6 additions & 0 deletions Gameye/GameyeCollection.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ GameyeCollection >> videoGamesCollectibles [
^self videoGames asOrderedCollection
]

{ #category : #'collectibles - query' }
GameyeCollection >> videoGamesForCountry: aSymbol [

^ self videoGamesCollectibles select:[ :c | c country = aSymbol ]
]

{ #category : #'collectibles - query' }
GameyeCollection >> videoGamesForDeveloper: aString [

Expand Down
9 changes: 5 additions & 4 deletions Gameye/GameyeVideoGame.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ GameyeVideoGame >> playedCompletion: anObject [
GameyeVideoGame >> printIdentifierOn: aStream [

super printIdentifierOn: aStream.
aStream nextPutAll: '-';
nextPutAll: (self publisher ifNil:[ 'Unknown Publisher' ]);
nextPutAll: '-';
nextPutAll: (self developer ifNil:[ 'Unknown Developer' ])
(self developer notNil or:[self publisher notNil]) ifFalse:[ ^ self ].

aStream nextPutAll: ' - ';
nextPutAll: (self developer ifNil:[ '' ] ifNotNil:[ :e | e , ' / ']);
nextPutAll: (self publisher ifNil:[ '' ])
]

{ #category : #accessing }
Expand Down

0 comments on commit 72ee139

Please sign in to comment.