193 lines
5.7 KiB
Go
193 lines
5.7 KiB
Go
![]() |
package room
|
||
|
|
||
|
import (
|
||
|
"samba/server/game/baseroom"
|
||
|
"samba/stub"
|
||
|
"samba/util/model"
|
||
|
"samba/util/util"
|
||
|
)
|
||
|
|
||
|
// import (
|
||
|
//
|
||
|
// "fmt"
|
||
|
// "samba/pkg/log"
|
||
|
// "samba/server/truco/poker"
|
||
|
// "samba/stub"
|
||
|
// "samba/util/model"
|
||
|
// "samba/util/util"
|
||
|
//
|
||
|
// )
|
||
|
//
|
||
|
// type ItemLog struct {
|
||
|
// Id int `json:"id"` // 物品id
|
||
|
// Num int64 `json:"num"` // 物品数量
|
||
|
// }
|
||
|
type PlayerLog struct {
|
||
|
baseroom.BasePlayerLog
|
||
|
Raise int `json:"truco"` // 叫分次数
|
||
|
GiveUp int `json:"correrr"` // 放弃次数
|
||
|
ContinueRaise int `json:"aumentar"` // 继续加注次数
|
||
|
Agree int `json:"aceitar"` // 同意次数
|
||
|
Color int `json:"color"` // 队伍颜色 0:红方 1:绿方
|
||
|
}
|
||
|
|
||
|
type TeamLog struct {
|
||
|
Color int `json:"color"` // 队伍颜色
|
||
|
Point int `json:"play_points"` // 累积得分
|
||
|
Deciding int `json:"player_key"` // 决胜手次数
|
||
|
BigPoker int `json:"player_king"` // 触发大牌次数
|
||
|
Show int `json:"player_show"` // 本局手牌展示次数
|
||
|
Concert int `json:"player_team"` // 行动一致次数
|
||
|
}
|
||
|
|
||
|
type TrucoGameLog struct {
|
||
|
*baseroom.BaseGameLog
|
||
|
Star int `json:"star"` // 团队数据
|
||
|
Teams []*TeamLog `json:"teams"` // 团队数据
|
||
|
TrucoPlayers []PlayerLog `json:"-"` // 玩家数据 游戏结束之后赋值(涉及到输赢金币)
|
||
|
}
|
||
|
|
||
|
func NewTrucoGameLog() *TrucoGameLog {
|
||
|
t := &TrucoGameLog{}
|
||
|
t.Teams = append(t.Teams, &TeamLog{Color: int(TcRed)})
|
||
|
t.Teams = append(t.Teams, &TeamLog{Color: int(TcGreen)})
|
||
|
return t
|
||
|
}
|
||
|
|
||
|
func (t *TrucoGameLog) GetBaseGameLog() *baseroom.BaseGameLog {
|
||
|
return t.BaseGameLog
|
||
|
}
|
||
|
|
||
|
func (t *TrucoGameLog) SetBaseGameLog(l *baseroom.BaseGameLog) {
|
||
|
t.BaseGameLog = l
|
||
|
}
|
||
|
|
||
|
func (t *TrucoGameLog) StartGame(startTime int64, gameNo string) {
|
||
|
t.BaseGameLog.StartGame(startTime, gameNo)
|
||
|
}
|
||
|
|
||
|
func (t *TrucoGameLog) EndGame(endTime int64, players []interface{}) {
|
||
|
t.BaseGameLog.EndGame(endTime, players)
|
||
|
}
|
||
|
|
||
|
func (t *TrucoGameLog) AddPlayers(room *TrucoRoom) {
|
||
|
for _, seat := range room.Seats {
|
||
|
if seat.Empty() {
|
||
|
continue
|
||
|
}
|
||
|
player := seat.Player()
|
||
|
robot := util.Tie(player.IsRobot(), 1, 0)
|
||
|
color := int(room.teamColor(seat.No()))
|
||
|
temper := int(stub.RteUnknown)
|
||
|
if player.IsRobot() {
|
||
|
temper = int(player.Robot.Cnf())
|
||
|
}
|
||
|
logPlayer := PlayerLog{
|
||
|
BasePlayerLog: baseroom.BasePlayerLog{
|
||
|
UId: player.UID,
|
||
|
Seat: seat.No(),
|
||
|
TakeCoin: player.TakeCoin,
|
||
|
WinCoin: 0,
|
||
|
EndCoin: 0,
|
||
|
Tip: 0,
|
||
|
CostItem: nil,
|
||
|
Robot: robot,
|
||
|
RobotTemper: temper,
|
||
|
EmoteNum: 0,
|
||
|
},
|
||
|
Raise: 0,
|
||
|
GiveUp: 0,
|
||
|
ContinueRaise: 0,
|
||
|
Agree: 0,
|
||
|
Color: color,
|
||
|
}
|
||
|
t.TrucoPlayers = append(t.TrucoPlayers, logPlayer)
|
||
|
//t.Players = append(t.Players, &logPlayer)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (t *TrucoGameLog) Flush() {
|
||
|
for _, logPlayer := range t.TrucoPlayers {
|
||
|
t.Players = append(t.Players, logPlayer)
|
||
|
}
|
||
|
model.AddRoomGameLog(t.BaseGameLog.PlayType, t)
|
||
|
}
|
||
|
|
||
|
//
|
||
|
//func NewTrucoGameLog(room *TrucoRoom) *TrucoGameLog {
|
||
|
// t := &TrucoGameLog{RoomId: room.Id(), Level: room.RoomCnf.Level, RoomType: room.Type(), PlayType: room.PlayType(), GetGameNo: room.gameNo,
|
||
|
// StartTime: room.startTime.Unix(), Blind: room.RoomCnf.Blind, ClubId: room.ClubId()}
|
||
|
// for _, seat := range room.Seats {
|
||
|
// player := seat.Player()
|
||
|
// robot := util.Tie(player.IsRobot(), 1, 0)
|
||
|
// color := int(room.teamColor(seat.No()))
|
||
|
// temper := int(stub.RteUnknown)
|
||
|
// if player.IsRobot() {
|
||
|
// temper = int(player.Robot.Cnf())
|
||
|
// }
|
||
|
// t.Players = append(t.Players, &BasePlayerLog{UId: player.UID, Seat: seat.No(), TakeCoin: player.TakeCoin, Color: color, Robot: robot, RobotTemper: temper})
|
||
|
// }
|
||
|
// t.Teams = append(t.Teams, &TeamLog{Color: int(TcRed)})
|
||
|
// t.Teams = append(t.Teams, &TeamLog{Color: int(TcGreen)})
|
||
|
// return t
|
||
|
//}
|
||
|
//
|
||
|
//func (t *TrucoGameLog) Team(color TeamColor) *TeamLog {
|
||
|
// for _, team := range t.Teams {
|
||
|
// if team.Color == int(color) {
|
||
|
// return team
|
||
|
// }
|
||
|
// }
|
||
|
// log.Error(fmt.Sprintf("room:%v type:%v game log error.team:%v is nil", t.RoomId, t.RoomType, color))
|
||
|
// return &TeamLog{}
|
||
|
//}
|
||
|
//
|
||
|
//func (t *TrucoGameLog) Player(seatNo int) *BasePlayerLog {
|
||
|
// if seatNo < 0 || seatNo > len(t.Players) {
|
||
|
// log.Error(fmt.Sprintf("room:%v type:%v game log error.seat:%v is nil", t.RoomId, t.RoomType, seatNo))
|
||
|
// return &BasePlayerLog{}
|
||
|
// }
|
||
|
// return t.Players[seatNo]
|
||
|
//}
|
||
|
//
|
||
|
//func (t *TrucoGameLog) RecordOutPoker(room *TrucoRoom, color TeamColor, _ int, outPoker *poker.Poker) {
|
||
|
// if room.pokers.IsBigPoker(outPoker, stub.GGlobalAI.TrucoBiggerPoker) {
|
||
|
// t.Team(color).BigPoker++
|
||
|
// }
|
||
|
//}
|
||
|
//
|
||
|
//func (t *TrucoGameLog) UpdatePlayerWin(room *TrucoRoom, seat *TrucoSeat, endCoin, winCoin int64) {
|
||
|
// if t.Player(seat.No()) == nil {
|
||
|
// log.Error(room.SeatLog(seat, "player is nil"))
|
||
|
// return
|
||
|
// }
|
||
|
// t.Player(seat.No()).EndCoin = endCoin
|
||
|
// t.Player(seat.No()).WinCoin = winCoin
|
||
|
// log.Debug(room.SeatLog(seat, "win:%v end coin:%v", t.Player(seat.No()).WinCoin, t.Player(seat.No()).EndCoin))
|
||
|
//}
|
||
|
//
|
||
|
//// RecordPlayerSendEmote 记录玩家发送表情
|
||
|
//func (t *TrucoGameLog) RecordPlayerSendEmote(room *TrucoRoom, seat *TrucoSeat) {
|
||
|
// pLog := t.Player(seat.No())
|
||
|
// if pLog == nil {
|
||
|
// log.Error(room.SeatLog(seat, "player is nil"))
|
||
|
// return
|
||
|
// }
|
||
|
// pLog.EmoteNum++
|
||
|
// log.Debug(room.SeatLog(seat, "emote num:%v", pLog.EmoteNum))
|
||
|
//}
|
||
|
//
|
||
|
//func (t *TrucoGameLog) UpdateClubAndPlatformFee(clubFee, platformFee int64) {
|
||
|
// t.ClubFee = clubFee
|
||
|
// t.PlatformFee = platformFee
|
||
|
// //log.Debug(room.Log("club fee:%v", t.ClubFee))
|
||
|
//}
|
||
|
//
|
||
|
//func (t *TrucoGameLog) Flush(room *TrucoRoom) {
|
||
|
// t.EndTime = room.endTime.Unix()
|
||
|
// t.Star = room.star
|
||
|
// t.Team(TcGreen).Point = room.points[TcGreen]
|
||
|
// t.Team(TcRed).Point = room.points[TcRed]
|
||
|
// model.AddRoomGameLog(room.PlayType(), t)
|
||
|
//}
|