Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MissionManager {
- constructor() {
- this.currentMission = null;
- this.missionList = [];
- }
- addMission(mission) {
- this.missionList.push(mission);
- }
- startMission(missionName) {
- const mission = this.missionList.find((mission) => mission.name === missionName);
- if (!mission) {
- console.log(`Mission "${missionName}" not found!`);
- return;
- }
- this.currentMission = mission;
- console.log(`Starting mission "${mission.name}"...`);
- }
- completeMission() {
- if (!this.currentMission) {
- console.log(`No mission currently in progress!`);
- return;
- }
- console.log(`Completing mission "${this.currentMission.name}"...`);
- # Complete mission logic here...
- this.currentMission = null;
- }
- }
- const missionManager = new MissionManager();
- missionManager.addMission({ name: 'Collect 10 Gems' });
- missionManager.addMission({ name: 'Defeat the Boss' });
- missionManager.startMission('Collect 10 Gems');
- missionManager.completeMission();
- missionManager.startMission('Defeat the Boss');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement