将创建机器人统一到webapi
This commit is contained in:
parent
a577f28ceb
commit
85998f3b35
@ -60,4 +60,19 @@ export function reportGameResult(data: any) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建机器人
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export function createRobot(data: any) {
|
||||||
|
axios.get('http://127.0.0.1:2500/robot/create', {
|
||||||
|
params: data
|
||||||
|
}).then((res) => {
|
||||||
|
debugRoom(res.status);
|
||||||
|
debugRoom(res.data);
|
||||||
|
}).catch((err) => {
|
||||||
|
error(err);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import {RobotClient} from "../robot/RobotClient";
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {wait} from "../decorators/cfg";
|
import {wait} from "../decorators/cfg";
|
||||||
import {ChangePetCommand} from "./commands/ChangePetCommand";
|
import {ChangePetCommand} from "./commands/ChangePetCommand";
|
||||||
|
import {createRobot} from "../common/WebApi";
|
||||||
|
|
||||||
export class GeneralRoom extends Room {
|
export class GeneralRoom extends Room {
|
||||||
dispatcher = new Dispatcher(this);
|
dispatcher = new Dispatcher(this);
|
||||||
@ -245,39 +246,7 @@ export class GeneralRoom extends Room {
|
|||||||
room: this.roomId,
|
room: this.roomId,
|
||||||
sessionId: playerId
|
sessionId: playerId
|
||||||
}
|
}
|
||||||
|
createRobot(data);
|
||||||
axios.get('http://127.0.0.1:2500/robot/create', {
|
|
||||||
params: data
|
|
||||||
}).then((res) => {
|
|
||||||
debugRoom(res.status);
|
|
||||||
debugRoom(res.data);
|
|
||||||
}).catch((err) => {
|
|
||||||
error(err);
|
|
||||||
})
|
|
||||||
|
|
||||||
// const sessionId = playerId || generateId();
|
|
||||||
// let client = new RobotClient(sessionId, this.state, this.clock, this['onMessageHandlers']);
|
|
||||||
// if (this.reservedSeatTimeouts[sessionId]) {
|
|
||||||
// clearTimeout(this.reservedSeatTimeouts[sessionId]);
|
|
||||||
// delete this.reservedSeatTimeouts[sessionId];
|
|
||||||
// }
|
|
||||||
// // get seat reservation options and clear it
|
|
||||||
// const options = this.reservedSeats[sessionId];
|
|
||||||
// delete this.reservedSeats[sessionId];
|
|
||||||
// this.clients.push(client);
|
|
||||||
// client.ref.once('close', this['_onLeave'].bind(this, client));
|
|
||||||
// // client.ref.on('message', this.onMessage.bind(this, client));
|
|
||||||
// const reconnection = this.reconnections[sessionId];
|
|
||||||
// if (reconnection) {
|
|
||||||
// reconnection.resolve(client);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// if (this.onJoin) {
|
|
||||||
// this.onJoin(client, options);
|
|
||||||
// }
|
|
||||||
// delete this.reservedSeats[sessionId];
|
|
||||||
// }
|
|
||||||
// this._events.emit('join', client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addAssistClient(sessionId: string) {
|
addAssistClient(sessionId: string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user