import { GMatchInsSer } from "../../../../Common/Service/MatchInstanceService"; import { CardSeat, CardSeatInfo, CardRecordSeatInfo, _ECardSeatState } from "../../../../GameCard/Logic/Table/CardSeat"; import { ECardType } from "../TexasTool"; import { TexasTable } from "./TexasTable"; class _ETexasSeatState extends _ECardSeatState { AllIn=10 Fold=11 } export let ETexasSeatState=new _ETexasSeatState() export enum ETexasAction { None = 0, Raise, Call, Allin, Check, Fold } export class TexasRecordSeatInfo extends CardRecordSeatInfo { //总共下注 bet=0 cards:number[]=[] cardtype=ECardType.None state=ETexasSeatState.Waiting publen=0 showcards=false } export class TexasSeatInfo extends CardSeatInfo { //玩家手中的牌 cards: number[] = [] //玩家操作 action=ETexasAction.None bet=0 //当前局 total_bet=0 win=0 cardtype=ECardType.None } export class TexasSeat extends CardSeat { protected _cards:number[]=[] get cards() { return this._cards } set cards(cards: number[]) { this._cards = cards } protected _action=ETexasAction.None get action() { return this._action } set action(value) { this._action=value } //一轮中的下注,_totalbet 是 当前局的总下注 protected _bet=0 get bet() { return this._bet } //当前局的bet protected _totalbet=0 get totalBet() { return this._totalbet } protected _card_type=ECardType.None get cardtype() { return this._card_type } set cardtype(value:ECardType) { this._card_type=value } protected _showcards=false set showcards(value:boolean) { this._showcards=value } protected _foldpubcards:number[]=[] clear() { //清理数据 super.clear() this._cards = [] this._bet = 0 this._card_type = ECardType.None } onStart() { super.onStart() this._state=ETexasSeatState.Playing this._totalbet=0 this._foldpubcards=[] this._showcards=false } //一轮结束 onTurnEnd() { this._bet = 0 this._action = ETexasAction.None } //下注 onBet(bet: number,action:ETexasAction,isAnte=false) { if (this.point >= bet) { this.point -= bet } else { bet = this.point this.point=0 } if(!isAnte) { this._bet+=bet } this._totalbet+=bet if(action==ETexasAction.Allin||this.point==0) { this.state=ETexasSeatState.AllIn } if(action==ETexasAction.Fold) { this.state=ETexasSeatState.Fold let tb=this._table as TexasTable this._foldpubcards = tb.cards.concat() } this._action=action return bet } onEnd() { super.onEnd() let key = "players."+this._playerinfo.id let model = {} model[key]=this._playerinfo let tb = this.table as TexasTable GMatchInsSer.updateOne(model,{id:tb.match.matchInsId}) } getSeatInfo(self?:boolean) { let info = super.getSeatInfo() as TexasSeatInfo if(self) { info.cards=this._cards info.cardtype = this._card_type } info.bet = this._bet info.total_bet=this._totalbet info.action = this._action return info } getGameEndRecordSeatInfo() { let record_seat_info = super.getGameEndRecordSeatInfo() //总共下注 record_seat_info.bet=this._bet record_seat_info.cards=this._cards.concat() record_seat_info.cardtype=this._card_type record_seat_info.state=this._state record_seat_info.publen=this._foldpubcards.length record_seat_info.showcards=this._showcards return record_seat_info } }