Skip to content

Commit

Permalink
code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
piaohua committed Aug 19, 2018
1 parent 737f53e commit ffd4981
Show file tree
Hide file tree
Showing 24 changed files with 172 additions and 172 deletions.
10 changes: 5 additions & 5 deletions data/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func StatActivity(actLog *LogActivity, act Activity) (int64, error) {
switch act.Type {
case int32(pb.ACT_TYPE0):
endTime := utils.TimestampTodayTime()
startTime := actLog.Jtime //参加开始时间
if endTime.Sub(actLog.Jtime).Hours() > 7 * 24 { //参加超过7天,统计7日内
startTime := actLog.Jtime //参加开始时间
if endTime.Sub(actLog.Jtime).Hours() > 7*24 { //参加超过7天,统计7日内
startTime = endTime.AddDate(0, 0, -7)
}
q := bson.M{"agentid": actLog.Userid}
Expand All @@ -166,8 +166,8 @@ func StatActivity(actLog *LogActivity, act Activity) (int64, error) {
return 0, err
}
endTime := utils.TimestampTodayTime()
startTime := actLog.Jtime //参加开始时间
if endTime.Sub(actLog.Jtime).Hours() > 30 * 24 { //参加超过30天,统计30日内
startTime := actLog.Jtime //参加开始时间
if endTime.Sub(actLog.Jtime).Hours() > 30*24 { //参加超过30天,统计30日内
startTime = endTime.AddDate(0, 0, -30)
}
q := bson.M{"agentid": bson.M{"$in": ids}}
Expand Down Expand Up @@ -240,4 +240,4 @@ func getAgentChildsCount(q bson.M) (int64, error) {
func GetLogActivityList(arg *pb.AgentActivityNotice) ([]*LogActivity, error) {
q := bson.M{"actid": arg.GetActid(), "type": arg.GetType()}
return getLogActivityList(int(arg.GetPage()), q)
}
}
6 changes: 3 additions & 3 deletions data/lucky.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
//Lucky 幸运星
type Lucky struct {
ID string `bson:"_id" json:"id"` //unique ID
Luckyid int32 `bson:"luckyid" json:"luckyid"` //unique
Luckyid int32 `bson:"luckyid" json:"luckyid"` //unique
Gtype int32 `bson:"gtype" json:"gtype"` //游戏类型1 niu,2 san,3 jiu
Name string `bson:"name" json:"name"` //名称
Count uint32 `bson:"count" json:"count"` //任务数值
Expand All @@ -28,8 +28,8 @@ func GetLuckyList() []Lucky {

//LuckyInfo 幸运星信息
type LuckyInfo struct {
Luckyid int32 `bson:"luckyid" json:"luckyid"` //unique
Num uint32 `bson:"num" json:"num"` //完成数值
Luckyid int32 `bson:"luckyid" json:"luckyid"` //unique
Num uint32 `bson:"num" json:"num"` //完成数值
}

//Save 写入数据库
Expand Down
2 changes: 1 addition & 1 deletion data/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ type TaskInfo struct {
func (t *Task) Save() bool {
//t.Ctime = bson.Now()
return Insert(Tasks, t)
}
}
6 changes: 3 additions & 3 deletions dbms/role_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (a *RoleActor) agentBuildUpdate(arg *pb.AgentBuildUpdate) {
}
handler.AgentBuildUpdate2(arg, user) //暂时实时写入, TODO 异步数据更新
//邀请每10人,奖励100豆子
if arg.Build != 0 && (user.Build % 10 == 0) {
if arg.Build != 0 && (user.Build%10 == 0) {
a.sendCurrency(user.GetUserid(), 0, 100, int32(pb.LOG_TYPE55))
//消息提醒
record, msg2 := handler.BuildNotice(100, user.Build, user.GetUserid())
Expand Down Expand Up @@ -469,7 +469,7 @@ func (a *RoleActor) agentOauth2Build(arg *pb.AgentOauth2Build, ctx actor.Context
}
msg2 := &pb.SetAgentBuild{
Userid: user.GetUserid(),
Agent: arg.GetAgentid(),
Agent: arg.GetAgentid(),
}
handler.SetAgentBuild(msg2, user)
user.UpdateAgent()
Expand Down Expand Up @@ -500,4 +500,4 @@ func (a *RoleActor) agentActivityProfit(arg *pb.AgentActivityProfit, ctx actor.C
return
}
a.syncCurrency(0, arg.GetProfit(), 0, 0, arg.GetType(), arg.GetUserid())
}
}
6 changes: 3 additions & 3 deletions dbms/role_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"time"

"gohappy/data"
"gohappy/game/login"
"gohappy/game/handler"
"gohappy/game/login"
"gohappy/glog"
"gohappy/pb"
"utils"
Expand Down Expand Up @@ -642,7 +642,7 @@ func (a *RoleActor) luckyUpdate(arg *pb.LuckyUpdate) {
} else {
luckyInfo := data.LuckyInfo{
Luckyid: int32(arg.GetLuckyid()),
Num: arg.Num,
Num: arg.Num,
}
user.Lucky[luckyidStr] = luckyInfo
}
Expand Down Expand Up @@ -696,4 +696,4 @@ func (a *RoleActor) send2userid(userid string, msg interface{}) {
if v, ok := a.roles[userid]; ok {
v.Pid.Tell(msg)
}
}
}
68 changes: 34 additions & 34 deletions ebg/desk_coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,47 +617,47 @@ func (t *Desk) deal() {
//(通比牛牛 | 牛牛坐庄)前4张牌不广播
switch t.DeskData.Dtype {
case int32(pb.DESK_TYPE3): //疯狂,抢庄
hand = 1
//发牌消息
cards := make([]uint32, hand, hand)
copy(cards, t.DeskGame.Cards[:hand])
t.DeskGame.Cards = t.DeskGame.Cards[hand:]
v.Cards = append(v.Cards, cards...)
switch t.state {
case int32(pb.STATE_DEALER):
//一明一暗
hand = 1
//发牌消息
cards := make([]uint32, hand, hand)
copy(cards, t.DeskGame.Cards[:hand])
t.DeskGame.Cards = t.DeskGame.Cards[hand:]
v.Cards = append(v.Cards, cards...)
switch t.state {
case int32(pb.STATE_DEALER):
//一明一暗
cards2 := make([]uint32, hand+1, hand+1)
msg2 := resDraw(k, t.state, cards2)
t.broadcast3(k, msg2)
//可看到自己牌值
//可看到自己牌值
cards3 := append(v.Cards, 0)
msg := resDraw(k, t.state, cards3)
t.send2seat(k, msg)
case int32(pb.STATE_BET):
//可看到自己牌值
msg := resDraw(k, t.state, v.Cards)
t.send2seat(k, msg)
}
msg := resDraw(k, t.state, cards3)
t.send2seat(k, msg)
case int32(pb.STATE_BET):
//可看到自己牌值
msg := resDraw(k, t.state, v.Cards)
t.send2seat(k, msg)
}
case int32(pb.DESK_TYPE2), //
int32(pb.DESK_TYPE1), //
int32(pb.DESK_TYPE0): //普通,随机庄、固定庄、轮流庄
hand = 2
switch t.state {
case int32(pb.STATE_DEALER):
//二暗,看不到牌值,发牌消息
cards2 := make([]uint32, hand, hand)
msg2 := resDraw(k, t.state, cards2)
t.broadcast(msg2)
case int32(pb.STATE_BET):
//发牌
cards := make([]uint32, hand, hand)
copy(cards, t.DeskGame.Cards[:hand])
t.DeskGame.Cards = t.DeskGame.Cards[hand:]
v.Cards = append(v.Cards, cards...)
//自己可看到牌值
msg := resDraw(k, t.state, cards)
t.send2seat(k, msg)
}
hand = 2
switch t.state {
case int32(pb.STATE_DEALER):
//二暗,看不到牌值,发牌消息
cards2 := make([]uint32, hand, hand)
msg2 := resDraw(k, t.state, cards2)
t.broadcast(msg2)
case int32(pb.STATE_BET):
//发牌
cards := make([]uint32, hand, hand)
copy(cards, t.DeskGame.Cards[:hand])
t.DeskGame.Cards = t.DeskGame.Cards[hand:]
v.Cards = append(v.Cards, cards...)
//自己可看到牌值
msg := resDraw(k, t.state, cards)
t.send2seat(k, msg)
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions ebg/desk_ebg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ package main

import (
"gohappy/game/algo"
"gohappy/game/config"
"gohappy/game/handler"
"gohappy/glog"
"gohappy/pb"
"utils"
"gohappy/game/config"
)

//'进入房间响应消息
Expand Down Expand Up @@ -603,7 +603,7 @@ func (t *Desk) pailiOver1(score map[uint32]int64) map[uint32]int64 {
case v.Power == a:
//麻将牌:庄家跟闲家为0点时闲家赢,否则庄家赢
if a != algo.EBG0 {
//if t.pailiCompare(dealerSeat, k) {
//if t.pailiCompare(dealerSeat, k) {
val := int64(v.Bet * int64(algo.EbgMultiple(t.DeskData.Mode, a)) * ante)
score = t.over3(dealerSeat, k, val, score)
} else {
Expand Down Expand Up @@ -646,7 +646,7 @@ func (t *Desk) pailiOver3(score map[uint32]int64) (uint32, map[uint32]int64) {
case v == val:
//麻将牌:庄家跟闲家为0点时闲家赢,否则庄家赢
if val == algo.EBG0 {
//if !t.pailiCompare(seat, a[0]) {
//if !t.pailiCompare(seat, a[0]) {
seat = a[0]
val = v
}
Expand Down Expand Up @@ -871,7 +871,7 @@ func (t *Desk) powerAward() {
}
var num = t.DeskData.Ante
switch v.Power {
case algo.EBG10, algo.EBGDui, algo.BAIBAN:
case algo.EBG10, algo.EBGDui, algo.BAIBAN:
num += algo.EbgMultiple(t.DeskData.Mode, v.Power)
default:
continue
Expand Down
2 changes: 1 addition & 1 deletion game/config/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ func GetActivity1(id string) data.Activity {
}
}
return data.Activity{}
}
}
42 changes: 21 additions & 21 deletions game/handler/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ package handler

import (
"errors"
"time"

"gohappy/data"
"gohappy/game/config"
"gohappy/glog"
"gohappy/pb"
"utils"
"time"

"github.com/globalsign/mgo/bson"
)

func packLogActivityMsg(v *data.LogActivity) (msg *pb.Activity) {
msg = &pb.Activity{
Id: v.Actid,
JoinTime: utils.Time2LocalStr(v.Jtime),
Id: v.Actid,
JoinTime: utils.Time2LocalStr(v.Jtime),
}
switch v.Type {
case int32(pb.ACT_TYPE0):
Expand Down Expand Up @@ -91,9 +92,9 @@ func JoinActivity(arg *pb.CJoinActivity) (msg *pb.SJoinActivity) {
return
}
joinAct := &data.LogActivity{
Actid: act.Id,
Type: act.Type,
Etime: act.EndTime,
Actid: act.Id,
Type: act.Type,
Etime: act.EndTime,
Userid: arg.GetSelfid(),
}
if joinAct.Has() {
Expand Down Expand Up @@ -181,10 +182,10 @@ func statActivityMsg(userid, actid, title string, Type int32,
msg = &pb.AgentActivityProfit{
Userid: userid,
Profit: profit,
Type: Type,
Actid: actid,
Title: title,
Num: num,
Type: Type,
Actid: actid,
Title: title,
Num: num,
}
return
}
Expand All @@ -193,16 +194,15 @@ func statActivityMsg(userid, actid, title string, Type int32,
func StatActivityUpdate(arg *pb.AgentActivityProfit) {
d := &data.LogActivity{
Userid: arg.GetUserid(),
Actid: arg.GetActid(),
Prize: arg.GetProfit(),
Num: arg.GetNum(),
Actid: arg.GetActid(),
Prize: arg.GetProfit(),
Num: arg.GetNum(),
}
if !d.Update() {
glog.Errorf("StatActivityUpdate filed %#v", d)
}
}


//SetActivityList 配置活动数据,测试数据
func SetActivityList() {
var startTime, endTime time.Time
Expand All @@ -219,13 +219,13 @@ func SetActivityList() {
func NewActivity(Type int32, title, content string, startTime, endTime time.Time) {
t := data.Activity{
//Id: bson.NewObjectId().String(),
Id: data.ObjectIdString(bson.NewObjectId()),
Ctime: bson.Now(),
Type: Type,
Title: title,
Content: content,
Id: data.ObjectIdString(bson.NewObjectId()),
Ctime: bson.Now(),
Type: Type,
Title: title,
Content: content,
StartTime: startTime,
EndTime: endTime,
EndTime: endTime,
}
config.SetActivity(t)
t.Save()
Expand All @@ -245,4 +245,4 @@ func NoticeActivity(arg *pb.AgentActivityNotice) (recordList []*pb.LogNotice,
msgList = append(msgList, msg)
}
return
}
}
Loading

0 comments on commit ffd4981

Please sign in to comment.