123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, NetBase, NetPlayer, _crd;
- function _reportPossibleCrUseOfNetBase(extras) {
- _reporterNs.report("NetBase", "./NetBase", _context.meta, extras);
- }
- _export("NetPlayer", void 0);
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- }, function (_unresolved_2) {
- NetBase = _unresolved_2.NetBase;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "6fc05FzfGNCnJsa3eEcsw94", "NetPlayer", undefined);
- /**网络玩家*/
- _export("NetPlayer", NetPlayer = class NetPlayer extends (_crd && NetBase === void 0 ? (_reportPossibleCrUseOfNetBase({
- error: Error()
- }), NetBase) : NetBase) {
- constructor(...args) {
- super(...args);
- this.evt = chsdk.get_new_event();
- this._location = 0;
- this._online = true;
- this._ready = false;
- this._score = 0;
- this._rank = 0;
- this._totalRank = 0;
- this._ishost = true;
- this._userData = void 0;
- this._rankInfo = void 0;
- this._canAI = false;
- this._finsh_tag = false;
- }
- get score() {
- return this._score;
- }
- get rank() {
- return this._rank;
- }
- get totalRank() {
- return this._totalRank;
- }
- /**房间位置0开头*/
- get location() {
- return this._location;
- }
- get gid() {
- return this._userData.gid;
- }
- get head() {
- return this._userData.head;
- }
- get hid() {
- return this._userData.hid;
- }
- get province() {
- var _chsdk$provinceCode2N;
- return (_chsdk$provinceCode2N = chsdk.provinceCode2Name(this._userData.hid)) != null ? _chsdk$provinceCode2N : '其它';
- }
- get ip() {
- return this._userData.ip;
- }
- get loginTime() {
- return this._userData.loginTime;
- }
- get nickName() {
- return this._userData.nickName || '玩家' + this._userData.userId;
- }
- get openId() {
- return this._userData.openId;
- }
- get option() {
- return this._userData.option;
- }
- get pf() {
- return this._userData.pf;
- }
- get userId() {
- return this._userData.userId;
- }
- get registerTime() {
- return this._userData.registerTime;
- }
- /**是否是主机*/
- get isHost() {
- return this._ishost;
- }
- /**是否准备*/
- get ready() {
- return this._ready;
- }
- /**是否在线*/
- get online() {
- return this._online;
- }
- /**是否能开启匹配*/
- get canMatch() {
- return this.online && this.ready;
- }
- /**段位信息*/
- get level() {
- return this._rankInfo;
- }
- /**是否是当前玩家自己 */
- get isOwn() {
- return chsdk.get_uid() === this.userId;
- }
- /**是否是AI */
- get isAI() {
- return this._userData.userId < 8888;
- }
- /**是否有控制当前AI权限*/
- get canAI() {
- return this._canAI;
- }
- /**是否有此玩家数据权限*/
- get isPermission() {
- return this.isOwn || this._canAI;
- }
- init(pd) {
- var _pd$status;
- this._location = pd.location;
- this._online = (_pd$status = pd.status) != null ? _pd$status : true;
- this._ready = pd.teamReady;
- this._score = pd.score;
- this._rank = pd.rank;
- this._totalRank = pd.TotalRank;
- this._userData = pd.userData;
- this._userData.hid = Number.parseInt(pd.userData.hid);
- this._userData.loginTime = Number.parseInt(pd.userData.loginTime);
- this._userData.registerTime = Number.parseInt(pd.userData.registerTime);
- this._userData.userId = Number.parseInt(pd.userData.userId);
- this._rankInfo = pd.userRank;
- if (pd.gameData) this.initValue(pd.gameData);
- }
- set_level(level, rank, score, totalRank) {
- this._rankInfo = level;
- this._rank = rank;
- this._totalRank = totalRank;
- this._score = score;
- }
- set_host(isHost, ownHost) {
- this._ishost = isHost;
- this._canAI = this.isAI && ownHost;
- }
- change_online(ol) {
- this._online = ol;
- this.evt._emit('online', this._online);
- }
- change_ready(ready) {
- this._ready = ready;
- this.evt._emit('ready', this._ready);
- }
- /**修改某个键的值*/
- setValue(key, data) {
- if (!this.isPermission) return;
- let old = super.getValue(key);
- if (old) {
- if (typeof old === "object") {//old = JSON.parse(JSON.stringify(old));
- } else if (data === old) {
- return;
- }
- }
- super.setValue(key, data);
- super.setValueDirty(key, data);
- this.evt._emit(key, data, old);
- }
- /**获取数据的值*/
- getValue(key) {
- return super.getValue(key);
- } //服务器发送过来的数据
- server_change(data) {
- if (this.isPermission) return;
- Object.keys(data).forEach(key => {
- const old = super.getValue(key);
- super.setValue(key, data[key]);
- this.evt._emit(key, data[key], old);
- });
- }
- setFinish(rank) {
- this._rank = rank;
- this.evt._emit('finish', this._rank);
- }
- /**玩家完成游戏 不是自己或主机没有权限*/
- finishGame() {
- if (!this.isPermission) return;
- this._finsh_tag = true;
- }
- doFinishGame(f) {
- if (this._finsh_tag) f(this.Id);
- this._finsh_tag = false;
- }
- dispose() {
- super.dispose();
- this.evt.clearAll();
- }
- });
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=3992b8f5aeffb73132ac910c2ae7b76d02a98b94.js.map
|