From 7e4918e78fff924bcbe04cd9d5d8c747e80429df Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 13 Jan 2021 20:26:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=A3=E9=94=81=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E7=9A=84gm=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.json | 2 +- src/common/WebApi.ts | 11 +++++++++++ src/index.ts | 1 - src/rooms/GeneralRoom.ts | 1 + src/rooms/commands/GMCommand.ts | 27 +++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/config/config.json b/config/config.json index 8e21ddb..2157d87 100644 --- a/config/config.json +++ b/config/config.json @@ -1,5 +1,5 @@ { "redis": "redis://127.0.0.1:6379/15", "mongodb": "mongodb://127.0.0.1/card-development", - "info_svr": "http://127.0.0.1:2987/api" + "info_svr": "http://127.0.0.1:2987/svr" } diff --git a/src/common/WebApi.ts b/src/common/WebApi.ts index f6b1d48..236db53 100644 --- a/src/common/WebApi.ts +++ b/src/common/WebApi.ts @@ -22,4 +22,15 @@ export function getCardGroup(accountid: string, heroid: number, cardgroup: strin }) } +/** + * 解锁英雄 + * @param {string} accountid + * @param {number | string} heroid + * @return {Promise>} + */ +export function requestUnlockHero(accountid: string, heroid: number | string) { + let data = {"type": 0}; + return axios.post(`${config.info_svr}/${accountid}/hero/unlock/${heroid}`, data); +} + diff --git a/src/index.ts b/src/index.ts index 6ae8139..2082573 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,6 @@ initData(); const server = http.createServer(app); const gameServer = new Server({ server, - // driver: new MongooseDriver('mongodb://127.0.0.1/card-development'), // driver: new MongooseDriver(config.mongodb), // presence: new RedisPresence({url: config.redis}), }); diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index cabfbc1..e2bbc79 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -41,6 +41,7 @@ export class GeneralRoom extends Room { } onCreate (options: any) { let cs = new CardGameState(); + this.setMetadata({rank: 2}); this.setState(cs); this.battleMan.init(cs, this); this.clock.start(); diff --git a/src/rooms/commands/GMCommand.ts b/src/rooms/commands/GMCommand.ts index a249dcd..4cdcdd3 100644 --- a/src/rooms/commands/GMCommand.ts +++ b/src/rooms/commands/GMCommand.ts @@ -3,6 +3,7 @@ import {CardGameState} from "../schema/CardGameState"; import {Client} from "colyseus"; import {debugRoom, error} from "../../common/Debug"; import {GameResultCommand} from "./GameResultCommand"; +import {requestUnlockHero} from "../../common/WebApi"; export class GMCommand extends Command { @@ -35,6 +36,9 @@ export class GMCommand extends Command { + if (res.data.errcode == 0) { + debugRoom(`解锁英雄 ${msg} 成功`); + } else { + error(`解锁英雄 ${msg} 失败`); + } + + }) + .catch(err=> { + error(err); + }) + } /** * 将一个玩家的手牌全变成指定的效果卡 * changeeffect:玩家index|效果卡id