Refactor collectible handling and scoring system
- Introduced `CollectiblePickupContext` and `CollectiblePickupEffect` to streamline the collectible pickup logic in the Player class. - Updated the `tryPickup` method in the Player class to utilize the new effect system for health, ammo, score, keys, and weapons. - Refactored collectible classes to implement the new `tryCollect` method, returning a `CollectiblePickupEffect`. - Enhanced enemy classes to expose score values based on their type. - Added unit tests for scoring ownership and shareware menu module functionality. - Updated rendering logic in various renderer classes to use the new mapped picture retrieval system. - Improved the `WolfClassicMenuArt` class to utilize a more structured approach for image retrieval based on registry keys. Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import 'package:test/test.dart';
|
||||
import 'package:wolf_3d_dart/wolf_3d_data_types.dart';
|
||||
import 'package:wolf_3d_dart/wolf_3d_entities.dart';
|
||||
|
||||
void main() {
|
||||
group('Scoring ownership', () {
|
||||
test('treasure collectibles expose score values', () {
|
||||
final cross = TreasureCollectible(x: 1, y: 1, mapId: MapObject.cross);
|
||||
final chalice = TreasureCollectible(
|
||||
x: 1,
|
||||
y: 1,
|
||||
mapId: MapObject.chalice,
|
||||
);
|
||||
final chest = TreasureCollectible(x: 1, y: 1, mapId: MapObject.chest);
|
||||
final crown = TreasureCollectible(x: 1, y: 1, mapId: MapObject.crown);
|
||||
final extraLife = TreasureCollectible(
|
||||
x: 1,
|
||||
y: 1,
|
||||
mapId: MapObject.extraLife,
|
||||
);
|
||||
|
||||
expect(cross.scoreValue, 100);
|
||||
expect(chalice.scoreValue, 500);
|
||||
expect(chest.scoreValue, 1000);
|
||||
expect(crown.scoreValue, 5000);
|
||||
expect(extraLife.scoreValue, 0);
|
||||
});
|
||||
|
||||
test('enemy instances expose score values from enemy type metadata', () {
|
||||
final guard = Guard(x: 1, y: 1, angle: 0, mapId: MapObject.guardStart);
|
||||
final dog = Dog(x: 1, y: 1, angle: 0, mapId: MapObject.dogStart);
|
||||
final ss = SS(x: 1, y: 1, angle: 0, mapId: MapObject.ssStart);
|
||||
|
||||
expect(guard.scoreValue, 100);
|
||||
expect(dog.scoreValue, 200);
|
||||
expect(ss.scoreValue, 100);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user