|
1 | 1 | import BillboardMarkers from '@/services/BillboardMarkers' |
| 2 | +import Player from '@/services/enum/Player' |
| 3 | +import WindowSelection from '@/services/enum/WindowSelection' |
| 4 | +import WindowStates from '@/services/WindowStates' |
| 5 | +import { WindowState } from '@/store/state' |
2 | 6 | import { expect } from 'chai' |
3 | 7 |
|
4 | 8 | describe('services/BillboardMarkers', () => { |
@@ -69,4 +73,95 @@ describe('services/BillboardMarkers', () => { |
69 | 73 | expect(markers.getMarkerCount(2)).to.eq(2) |
70 | 74 | }) |
71 | 75 |
|
| 76 | + it('addMarkerToFloorWithLeastMarkers - all empty', () => { |
| 77 | + const markers = BillboardMarkers.new() |
| 78 | + const windowStates = WindowStates.fromPersistence([]) |
| 79 | + |
| 80 | + const floor = markers.addMarkerToFloorWithLeastMarkers(windowStates) |
| 81 | + |
| 82 | + // all floors tied at 0, highest floor wins |
| 83 | + expect(floor).to.eq(4) |
| 84 | + expect(markers.getMarkerCount(4)).to.eq(1) |
| 85 | + }) |
| 86 | + |
| 87 | + it('addMarkerToFloorWithLeastMarkers - billboard markers only', () => { |
| 88 | + const markers = BillboardMarkers.fromPersistence([ |
| 89 | + { floor: 3, count: 2 }, |
| 90 | + { floor: 4, count: 1 } |
| 91 | + ]) |
| 92 | + const windowStates = WindowStates.fromPersistence([]) |
| 93 | + |
| 94 | + const floor = markers.addMarkerToFloorWithLeastMarkers(windowStates) |
| 95 | + |
| 96 | + // floor 1=0, floor 2=0 → tied, highest floor wins → floor 2 |
| 97 | + expect(floor).to.eq(2) |
| 98 | + expect(markers.getMarkerCount(2)).to.eq(1) |
| 99 | + }) |
| 100 | + |
| 101 | + it('addMarkerToFloorWithLeastMarkers - bot deliveries counted', () => { |
| 102 | + const markers = BillboardMarkers.new() |
| 103 | + const windows: WindowState[] = [ |
| 104 | + { floor: 2, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT, Player.BOT] }, |
| 105 | + { floor: 2, windowSelection: WindowSelection.RIGHT, flowers: [], deliveries: [Player.BOT] }, |
| 106 | + { floor: 3, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT] } |
| 107 | + ] |
| 108 | + const windowStates = WindowStates.fromPersistence(windows) |
| 109 | + |
| 110 | + const floor = markers.addMarkerToFloorWithLeastMarkers(windowStates) |
| 111 | + |
| 112 | + // floor 1=0, floor 2=3, floor 3=1, floor 4=0 → tied 1&4 at 0, highest wins → floor 4 |
| 113 | + expect(floor).to.eq(4) |
| 114 | + expect(markers.getMarkerCount(4)).to.eq(1) |
| 115 | + }) |
| 116 | + |
| 117 | + it('addMarkerToFloorWithLeastMarkers - only bot deliveries count, not player', () => { |
| 118 | + const markers = BillboardMarkers.new() |
| 119 | + const windows: WindowState[] = [ |
| 120 | + { floor: 4, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.PLAYER, Player.PLAYER] }, |
| 121 | + { floor: 3, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT] } |
| 122 | + ] |
| 123 | + const windowStates = WindowStates.fromPersistence(windows) |
| 124 | + |
| 125 | + const floor = markers.addMarkerToFloorWithLeastMarkers(windowStates) |
| 126 | + |
| 127 | + // floor 1=0, floor 2=0, floor 3=1, floor 4=0 (player deliveries not counted) |
| 128 | + // tied 1,2,4 at 0, highest wins → floor 4 |
| 129 | + expect(floor).to.eq(4) |
| 130 | + }) |
| 131 | + |
| 132 | + it('addMarkerToFloorWithLeastMarkers - combined markers and deliveries', () => { |
| 133 | + const markers = BillboardMarkers.fromPersistence([ |
| 134 | + { floor: 1, count: 1 }, |
| 135 | + { floor: 4, count: 2 } |
| 136 | + ]) |
| 137 | + const windows: WindowState[] = [ |
| 138 | + { floor: 2, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT, Player.BOT] }, |
| 139 | + { floor: 3, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT] } |
| 140 | + ] |
| 141 | + const windowStates = WindowStates.fromPersistence(windows) |
| 142 | + |
| 143 | + const floor = markers.addMarkerToFloorWithLeastMarkers(windowStates) |
| 144 | + |
| 145 | + // floor 1=1, floor 2=2, floor 3=1, floor 4=2 → tied 1&3 at 1, highest wins → floor 3 |
| 146 | + expect(floor).to.eq(3) |
| 147 | + expect(markers.getMarkerCount(3)).to.eq(1) |
| 148 | + }) |
| 149 | + |
| 150 | + it('addMarkerToFloorWithLeastMarkers - ignores floor 5', () => { |
| 151 | + const markers = BillboardMarkers.new() |
| 152 | + const windows: WindowState[] = [ |
| 153 | + { floor: 1, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT] }, |
| 154 | + { floor: 2, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT] }, |
| 155 | + { floor: 3, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT] }, |
| 156 | + { floor: 4, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [Player.BOT] }, |
| 157 | + { floor: 5, windowSelection: WindowSelection.LEFT, flowers: [], deliveries: [] } |
| 158 | + ] |
| 159 | + const windowStates = WindowStates.fromPersistence(windows) |
| 160 | + |
| 161 | + const floor = markers.addMarkerToFloorWithLeastMarkers(windowStates) |
| 162 | + |
| 163 | + // all floors 1-4 tied at 1, highest wins → floor 4 (not floor 5) |
| 164 | + expect(floor).to.eq(4) |
| 165 | + }) |
| 166 | + |
72 | 167 | }) |
0 commit comments