-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
54 lines (47 loc) · 1.76 KB
/
index.js
File metadata and controls
54 lines (47 loc) · 1.76 KB
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
import { Configuration } from "./config/configuration.js";
import { CommunicationManager } from "./communication/communication-manager.js";
import { Registration } from "./communication/registration.js";
import { GameManager } from "./communication/game-manager.js";
import { Bot } from "./bot.js";
global.logLevel = "info";
const TEAMID = "team-id-1";
const BOTNAME = "Warlock";
const config = new Configuration();
const communicationMgr = new CommunicationManager(config);
const registration = new Registration(communicationMgr);
const gameMgr = new GameManager(communicationMgr);
const bot = new Bot();
//déclaration de notre bot
registration.registerBot(TEAMID, BOTNAME)
.then( (bot_id)=> {
bot.id = bot_id;
//vérification de l'ensemble des connexions
return registration.checkConnexions(bot.id);
}).then(() => {
//récupération des données technique du bot (vitalité, vitesse, ...)
return gameMgr.loadBotConfiguration(bot.id);
}).then((botConfig) => {
bot.config = botConfig;
bot.init(communicationMgr);
//attente du démarrage du jeux
return gameMgr.waitGameStarting(bot.id);
}).then(() => {
bot.startWatchers( (type,value) => {
console.log("**** STATUS *****");
console.log(type + " : " + value);
}, (scanItems) => {
console.log("**** DETECTION *****");
scanItems.forEach(items => {
console.log(items)
});
}, () => {
//fin de partie
});
//Exemple d'action
// bot.action.turnLeft()
// bot.action.turnStop();
// bot.action.turnRight();
// bot.action.moveForward()
// bot.action.moveStop();
// bot.action.fire(0);
});