将上报游戏结果的接口统一到webapi中
This commit is contained in:
parent
17ea5b847e
commit
a577f28ceb
@ -1,5 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {Config} from "../cfg/Config";
|
import {Config} from "../cfg/Config";
|
||||||
|
import {debugRoom, error} from "./Debug";
|
||||||
|
|
||||||
let config: Config = require('../../config/config.json');
|
let config: Config = require('../../config/config.json');
|
||||||
|
|
||||||
@ -33,4 +34,30 @@ export function requestUnlockHero(accountid: string, heroid: number | string) {
|
|||||||
return axios.post(`${config.info_svr}/${accountid}/hero/unlock/${heroid}`, data);
|
return axios.post(`${config.info_svr}/${accountid}/hero/unlock/${heroid}`, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上报游戏结果
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export function reportGameResult(data: any) {
|
||||||
|
let dataStr = JSON.stringify(data);
|
||||||
|
|
||||||
|
let reqConfig = {
|
||||||
|
method: 'post',
|
||||||
|
url: `${config.info_svr}/record/save`,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
data : dataStr
|
||||||
|
};
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
axios(reqConfig)
|
||||||
|
.then(function (response) {
|
||||||
|
debugRoom(JSON.stringify(response.data));
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
error(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,11 +9,9 @@ import gameUtil from "../../utils/game.util";
|
|||||||
import {Card} from "../schema/Card";
|
import {Card} from "../schema/Card";
|
||||||
import {MapSchema, SetSchema} from "@colyseus/schema";
|
import {MapSchema, SetSchema} from "@colyseus/schema";
|
||||||
import {StateTypeEnum} from "../enums/StateTypeEnum";
|
import {StateTypeEnum} from "../enums/StateTypeEnum";
|
||||||
import axios from "axios";
|
import {reportGameResult} from "../../common/WebApi";
|
||||||
import {Config} from "../../cfg/Config";
|
|
||||||
|
|
||||||
|
|
||||||
let config: Config = require('../../../config/config.json');
|
|
||||||
/**
|
/**
|
||||||
* 游戏结束
|
* 游戏结束
|
||||||
*/
|
*/
|
||||||
@ -207,25 +205,7 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
data.players = players;
|
data.players = players;
|
||||||
let dataStr = JSON.stringify(data);
|
reportGameResult(data);
|
||||||
|
|
||||||
let reqConfig = {
|
|
||||||
method: 'post',
|
|
||||||
url: `${config.info_svr}/record/save`,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
data : dataStr
|
|
||||||
};
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
axios(reqConfig)
|
|
||||||
.then(function (response) {
|
|
||||||
debugRoom(JSON.stringify(response.data));
|
|
||||||
})
|
|
||||||
.catch(function (err) {
|
|
||||||
error(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user