-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.js
122 lines (101 loc) · 2.57 KB
/
game.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include objects.js;
// game.js
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
// Class definitions for Hotel, Room, Guest, and Staff
class Hotel {
constructor(name) {
this.name = name;
this.rooms = [];
this.staff = [];
this.budget = 10000;
this.reputation = 5;
}
cleanRoom(room) {
room.status = 'clean';
room.guest = null;
}
}
class Room {
constructor(number, type) {
this.number = number;
this.type = type;
this.status = 'clean';
this.guest = null;
}
}
class Guest {
constructor(name, arrivalTime, departureTime, preferences) {
this.name = name;
this.arrivalTime = arrivalTime;
this.departureTime = departureTime;
this.preferences = preferences;
}
}
class Staff {
constructor(name, role, salary) {
this.name = name;
this.role = role;
this.salary = salary;
}
}
// Game scenes
var MainScene = new Phaser.Scene('MainScene');
MainScene.preload = function () {
// Load assets
};
MainScene.create = function () {
// Create game objects and initialize the game
};
MainScene.update = function () {
// Update game logic
// Guest arrival
if (Math.random() < 0.2) { // Adjust probability as needed
let guest = new Guest('Guest ' + (guestCount++), Date.now(), Date.now() + 3600000, ['cleanliness']); // 1 hour stay
this.hotel.guests.push(guest);
}
// Room assignment
this.hotel.guests.forEach(guest => {
if (!guest.room) {
let availableRoom = this.hotel.rooms.find(room => room.status === 'clean');
if (availableRoom) {
availableRoom.status = 'occupied';
availableRoom.guest = guest;
guest.room = availableRoom;
}
}
});
// Room cleaning
this.hotel.staff.forEach(staff => {
if (staff.role === 'housekeeping') {
let dirtyRoom = this.hotel.rooms.find(room => room.status === 'dirty');
if (dirtyRoom) {
this.hotel.cleanRoom(dirtyRoom);
}
}
});
};
// Add the scene to the game
game.scene.add('MainScene', MainScene);
game.scene.start('MainScene');
function preload ()
{
// Load assets here, e.g., images, sounds
}
function create ()
{
// Create game objects here, e.g., sprites, text
}
function update ()
{
// Update game logic here
}