import { CardTable } from './CardTable'; import { GWhitelistSvc, WhitelistModel } from '../../../Common/Service/WhitlistService'; import { core } from 'cgserver'; import { UserModel } from 'cgserver/dist/types/Service/UserService'; import { ns_card } from '../../Config/_ini_'; import { GClubSer } from '../../../Common/Service/ClubService'; export let ECardSeatState:_ECardSeatState=null export class _ECardSeatState { Waiting=0 Preparing=1 Playing=2 Leaving=3 constructor() { ECardSeatState=this } } /** * 玩家的基础信息 */ export class PlayerInfo { id=-1 //用户id nickname="" //名称 logo="" //头像 sex=-1 //性别 ip="" //登陆ip with_point=0 //带入分数 point=0 //当前分数 crystal=0 is_robot=0 constructor(user:UserModel,point:number=-1) { if(point<0) { point=user["coin"] } this.id=user.id this.nickname=user.nickname this.logo=user.logo this.sex=user.sex this.ip="" this.with_point=point this.point=point this.crystal=user["crystal"]||0 this.is_robot=0 } } export class CardRecordSeatInfo { playerinfo:PlayerInfo=null index=-1 //座位号 table_id=-1 dtpoint=0 constructor(seat:CardSeat) { this.playerinfo=seat.playerInfo this.index=seat.index this.table_id=seat.table.id this.dtpoint=seat.dtpoint } } export class CardSeatInfo { playerinfo:PlayerInfo=null index=-1 //座位号 table_id=-1 state=ECardSeatState.Waiting dt_point=0 //当前局分数 auto=false agree_dismiss=null constructor(seat:CardSeat) { this.playerinfo=seat.playerInfo this.index=seat.index this.table_id=seat.table.id this.state=seat.state this.dt_point=seat.dtpoint this.auto=seat.auto this.agree_dismiss=seat.agreeDismiss } } export class CardSeat { protected _last_action_time=-1 /** * 最近操作的时间 */ get lastActionTime() { return this._last_action_time } refreshLastActionTime() { this._last_action_time = Date.now() } protected _playerinfo:PlayerInfo=null get playerInfo() { return this._playerinfo } protected _index:number=-1//座位号 get index() { return this._index } get id() { return this._playerinfo.id } /** * 是否已经付费 */ protected _is_fee:boolean=true /** * 获取或设置是否付费 */ get isFee() { return this._is_fee } /** * 获取或设置是否付费 */ set isFee(value) { this._is_fee = value } protected _continous_timeout_num:number=0 get continousTimeoutNum() { return this._continous_timeout_num; } set continousTimeoutNum(value) { this._continous_timeout_num = value } protected _dt_point=0 get dtpoint() { return this._dt_point } get point() { return this._playerinfo.point } set point(value:number) { this._dt_point+=(value-this._playerinfo.point) this._playerinfo.point = value } protected _state=ECardSeatState.Waiting get state() { return this._state } set state(value:number) { this._state=value } get isRobot() { return this._playerinfo.is_robot&&this._playerinfo.is_robot>0 } protected _auto:boolean = false get auto() { return this._auto } set auto(value) { if(this._auto == value) { return } this._auto = value if(!this._auto) { this._continous_timeout_num=0 } } protected _table:CardTable=null //是否同意解散 protected _agree_dismiss:boolean=false /** * 是否同意解散 */ get agreeDismiss() { return this._agree_dismiss } set agreeDismiss(value) { this._agree_dismiss = value } /** * 所在牌桌 */ get table() { return this._table } protected _wm:WhitelistModel=null /** * 白名单权限 */ get wm() { if(!this._wm ||this._wm.stop) { return } let now=Date.now() if(nowthis._wm.end_time) { return } return this._wm } constructor(playerinfo:PlayerInfo,table:CardTable) { this._playerinfo=playerinfo this._table = table this.refreshLastActionTime() } isState(state:number|number[]) { if(core.isArray(state)) { let states = state as number[] return states.indexOf(this._state)>=0 } return this._state==state } init(index:number) { this._index = index if(this._table.ctdm.table_type==ns_card.ETableType.Match) { return } if(this._table.ctdm.virtual_coin>0) { this._playerinfo.point = this._table.ctdm.virtual_coin } else { //默认就是用户里面的钱 } //机器人不设置白名单、积分场不触发作弊 if(!this.isRobot &&this._table.ctdm.table_type!=ns_card.ETableType.Score) { GWhitelistSvc.get({user_id:this.id,game_name:this._table.server.name}).then((wm)=> { this._wm=wm }) } this._playerinfo.with_point=this._playerinfo.point } onStart() { this.clear() this._state=ECardSeatState.Playing } onEnd() { } //清除动态信息 clear() { this._continous_timeout_num=0 this._state=ECardSeatState.Waiting this._agree_dismiss = null this._dt_point = 0 } getSeatInfo(self?:boolean) { let seat=new CardSeatInfo(this) return seat } getGameEndRecordSeatInfo() { let seat_info = new CardRecordSeatInfo(this) return seat_info } }