-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocation.js
105 lines (96 loc) · 4.47 KB
/
location.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// import { ImbissSoftware } from './InventoryManagement.js'; // Importiere Warenwirtschaft
// const inventory = new ImbissSoftware(); // Instanziere Warenwirtschaft
export class Location {
constructor(name, image, config) {
this.name = name;
this.image = image;
this.config = config; // Uhrzeitenslots und Wahrscheinlichkeiten
}
getImage() {
return this.image;
}
getCustomerProbability(currentTime) {
// Uhrzeit in Minuten berechnen
const hours = Math.floor(currentTime / 60).toString().padStart(2, '0');
const minutes = (currentTime % 60).toString().padStart(2, '0');
const currentHourMinute = `${hours}:${minutes}`;
// Konfiguration durchlaufen und passenden Slot finden
for (const slot of this.config) {
if (this.isTimeInRange(currentHourMinute, slot.start, slot.end)) {
return slot.probability;
}
}
return 0; // Standardwert, falls keine passende Zeit gefunden
}
isTimeInRange(current, start, end) {
return current >= start && current < end;
}
generateCustomerSchedule() {
const schedule = [];
for (let time = 0; time < 1440; time++) {
const probability = this.getCustomerProbability(time);
if (Math.random() < probability) {
schedule.push({ time });
}
}
return schedule;
}
}
// Beispielkonfiguration für verschiedene Locations
export const locations = [
new Location('Moon', './img/locations/moon.png', [
{ start: '00:00', end: '23:59', probability: 0.05 }
]),
new Location('Forest', './img/locations/forest.png', [
{ start: '00:00', end: '06:00', probability: 0.001 },
{ start: '06:00', end: '09:00', probability: 0.002 },
{ start: '09:00', end: '12:00', probability: 0.004 },
{ start: '12:00', end: '15:00', probability: 0.003 },
{ start: '15:00', end: '18:00', probability: 0.005 },
{ start: '18:00', end: '21:00', probability: 0.002 },
{ start: '21:00', end: '00:00', probability: 0.001 },
]),
new Location('Parc', './img/locations/parc.png', [
{ start: '00:00', end: '06:00', probability: 0.01 },
{ start: '06:00', end: '10:00', probability: 0.03 },
{ start: '10:00', end: '14:00', probability: 0.06 },
{ start: '14:00', end: '18:00', probability: 0.07 },
{ start: '18:00', end: '21:00', probability: 0.05 },
{ start: '21:00', end: '00:00', probability: 0.02 },
]),
new Location('City', './img/locations/city.png', [
{ start: '00:00', end: '06:00', probability: 0.01 },
{ start: '06:00', end: '09:00', probability: 0.05 },
{ start: '09:00', end: '12:00', probability: 0.07 },
{ start: '12:00', end: '15:00', probability: 0.08 },
{ start: '15:00', end: '18:00', probability: 0.09 },
{ start: '18:00', end: '21:00', probability: 0.06 },
{ start: '21:00', end: '00:00', probability: 0.04 },
]),
new Location('Altstadt', './img/locations/altstadt.png', [
{ start: '00:00', end: '06:00', probability: 0.005 },
{ start: '06:00', end: '10:00', probability: 0.04 },
{ start: '10:00', end: '14:00', probability: 0.07 },
{ start: '14:00', end: '18:00', probability: 0.08 },
{ start: '18:00', end: '21:00', probability: 0.06 },
{ start: '21:00', end: '00:00', probability: 0.03 },
]),
new Location('Fussballplatz_Amateur', './img/locations/fussballplatz_amateur.png', [
{ start: '00:00', end: '06:00', probability: 0.001 },
{ start: '06:00', end: '09:00', probability: 0.02 },
{ start: '09:00', end: '12:00', probability: 0.03 },
{ start: '12:00', end: '15:00', probability: 0.04 },
{ start: '15:00', end: '18:00', probability: 0.05 },
{ start: '18:00', end: '21:00', probability: 0.06 },
{ start: '21:00', end: '00:00', probability: 0.02 },
]),
new Location('Fussballplatz_Profi', './img/locations/fussballplatz_profi.png', [
{ start: '00:00', end: '06:00', probability: 0.001 },
{ start: '06:00', end: '10:00', probability: 0.002 },
{ start: '10:00', end: '14:00', probability: 0.003 },
{ start: '14:00', end: '17:00', probability: 0.005 },
{ start: '17:00', end: '20:00', probability: 0.08 },
{ start: '20:00', end: '23:00', probability: 0.09 },
{ start: '23:00', end: '00:00', probability: 0.005 },
])
];