增加解锁英雄的gm命令
This commit is contained in:
parent
97f1760958
commit
7e4918e78f
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"redis": "redis://127.0.0.1:6379/15",
|
"redis": "redis://127.0.0.1:6379/15",
|
||||||
"mongodb": "mongodb://127.0.0.1/card-development",
|
"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"
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,15 @@ export function getCardGroup(accountid: string, heroid: number, cardgroup: strin
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解锁英雄
|
||||||
|
* @param {string} accountid
|
||||||
|
* @param {number | string} heroid
|
||||||
|
* @return {Promise<AxiosResponse<any>>}
|
||||||
|
*/
|
||||||
|
export function requestUnlockHero(accountid: string, heroid: number | string) {
|
||||||
|
let data = {"type": 0};
|
||||||
|
return axios.post(`${config.info_svr}/${accountid}/hero/unlock/${heroid}`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ initData();
|
|||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
const gameServer = new Server({
|
const gameServer = new Server({
|
||||||
server,
|
server,
|
||||||
// driver: new MongooseDriver('mongodb://127.0.0.1/card-development'),
|
|
||||||
// driver: new MongooseDriver(config.mongodb),
|
// driver: new MongooseDriver(config.mongodb),
|
||||||
// presence: new RedisPresence({url: config.redis}),
|
// presence: new RedisPresence({url: config.redis}),
|
||||||
});
|
});
|
||||||
|
@ -41,6 +41,7 @@ export class GeneralRoom extends Room {
|
|||||||
}
|
}
|
||||||
onCreate (options: any) {
|
onCreate (options: any) {
|
||||||
let cs = new CardGameState();
|
let cs = new CardGameState();
|
||||||
|
this.setMetadata({rank: 2});
|
||||||
this.setState(cs);
|
this.setState(cs);
|
||||||
this.battleMan.init(cs, this);
|
this.battleMan.init(cs, this);
|
||||||
this.clock.start();
|
this.clock.start();
|
||||||
|
@ -3,6 +3,7 @@ import {CardGameState} from "../schema/CardGameState";
|
|||||||
import {Client} from "colyseus";
|
import {Client} from "colyseus";
|
||||||
import {debugRoom, error} from "../../common/Debug";
|
import {debugRoom, error} from "../../common/Debug";
|
||||||
import {GameResultCommand} from "./GameResultCommand";
|
import {GameResultCommand} from "./GameResultCommand";
|
||||||
|
import {requestUnlockHero} from "../../common/WebApi";
|
||||||
|
|
||||||
|
|
||||||
export class GMCommand extends Command<CardGameState, {client: Client, message: string}> {
|
export class GMCommand extends Command<CardGameState, {client: Client, message: string}> {
|
||||||
@ -35,6 +36,9 @@ export class GMCommand extends Command<CardGameState, {client: Client, message:
|
|||||||
case 'changehero':
|
case 'changehero':
|
||||||
this.changeHero(arr[1]);
|
this.changeHero(arr[1]);
|
||||||
break;
|
break;
|
||||||
|
case 'unlockhero':
|
||||||
|
this.unlockHero(client, arr[1]);
|
||||||
|
break;
|
||||||
case 'help':
|
case 'help':
|
||||||
this.sendHelp(client, arr[1]);
|
this.sendHelp(client, arr[1]);
|
||||||
break;
|
break;
|
||||||
@ -54,6 +58,7 @@ export class GMCommand extends Command<CardGameState, {client: Client, message:
|
|||||||
str += '生成几张特定效果的卡: addcard:玩家index|效果卡id|数量 例: addcard:0|20011|1\n';
|
str += '生成几张特定效果的卡: addcard:玩家index|效果卡id|数量 例: addcard:0|20011|1\n';
|
||||||
str += '将某一队设为赢家: setwin:队伍index 例: setwin:0\n';
|
str += '将某一队设为赢家: setwin:队伍index 例: setwin:0\n';
|
||||||
str += '替换一个玩家的英雄: changehero:玩家index|heroid 例: changehero:3|30032\n';
|
str += '替换一个玩家的英雄: changehero:玩家index|heroid 例: changehero:3|30032\n';
|
||||||
|
str += '解锁一个英雄: unlockhero:heroid 例: unlockhero:30142\n';
|
||||||
this.room.send(client,'notice_msg', str);
|
this.room.send(client,'notice_msg', str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +74,28 @@ export class GMCommand extends Command<CardGameState, {client: Client, message:
|
|||||||
this.room.addRobot();
|
this.room.addRobot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解锁英雄
|
||||||
|
* @param client
|
||||||
|
* @param {string} msg
|
||||||
|
*/
|
||||||
|
unlockHero(client: Client, msg: string) {
|
||||||
|
let heroId = msg;
|
||||||
|
let player = this.room.state.players.get(client.id);
|
||||||
|
requestUnlockHero(player.accountId, heroId)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data.errcode == 0) {
|
||||||
|
debugRoom(`解锁英雄 ${msg} 成功`);
|
||||||
|
} else {
|
||||||
|
error(`解锁英雄 ${msg} 失败`);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(err=> {
|
||||||
|
error(err);
|
||||||
|
})
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 将一个玩家的手牌全变成指定的效果卡
|
* 将一个玩家的手牌全变成指定的效果卡
|
||||||
* changeeffect:玩家index|效果卡id
|
* changeeffect:玩家index|效果卡id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user