Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
249eb04ad6
@ -36,6 +36,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
|
||||
}
|
||||
dayMaxCount := this.configure.GetTrollRule(comm.TrollBuyCount)
|
||||
for k, v := range req.Items {
|
||||
|
||||
if v == 0 { // 过滤数量为0 的消息
|
||||
continue
|
||||
}
|
||||
@ -102,6 +103,12 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
|
||||
} else {
|
||||
sellPrice = int32(p.Coefficient) * goods.Goodsprice / 1000
|
||||
}
|
||||
// 校验是不是惊喜价格
|
||||
if d1, ok := trolltrain.SurpriseID[trolltrain.TarinPos-1]; ok {
|
||||
if d1 == k {
|
||||
sellPrice = this.configure.GetTrollRule(comm.TrollSurprise) / 1000
|
||||
}
|
||||
}
|
||||
if v < 0 { // 卖出
|
||||
if sellPrice > trolltrain.Price[k] { // 赚了
|
||||
earn += (sellPrice - trolltrain.Price[k]) * v
|
||||
|
@ -49,7 +49,9 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
|
||||
return
|
||||
}
|
||||
// 跨天 则清除 每日交易次数
|
||||
if !utils.IsToday(trolltrain.RefreshTime) {
|
||||
if !utils.IsToday(trolltrain.ResetTime) {
|
||||
trolltrain.ResetTime = time.Now().Unix()
|
||||
update["resetTime"] = trolltrain.ResetTime
|
||||
trolltrain.SellCount = 0
|
||||
update["sellCount"] = trolltrain.SellCount // 重置每日交易次数
|
||||
trolltrain.AiCount = 0
|
||||
@ -77,15 +79,19 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
|
||||
trolltrain.Shop = make(map[int32]int32) // 清空商人的购买数据
|
||||
update["shop"] = trolltrain.Shop
|
||||
circleCount = (int32(t) / circletime) // 经过的周期数
|
||||
if circleCount > 1 {
|
||||
trolltrain.Circle += circleCount
|
||||
|
||||
c := int32((time.Now().Unix() - trolltrain.Ctime)) / circletime
|
||||
if trolltrain.Circle != c {
|
||||
trolltrain.SurpriseID = make(map[int32]int32, 0)
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(trainNum)))
|
||||
n2, _ := rand.Int(rand.Reader, big.NewInt(int64(maxCoefficient)))
|
||||
trolltrain.SurpriseID[int32(n.Int64())+1] = int32(n2.Int64()) + 1
|
||||
update["surpriseID"] = trolltrain.SurpriseID
|
||||
trolltrain.Circle = c
|
||||
update["circle"] = trolltrain.Circle
|
||||
}
|
||||
leftTime = (int32(t) % circletime)
|
||||
// 循环次数
|
||||
|
||||
index += circleCount * trainNum // 计算火车的位置信息
|
||||
for _, v := range sz {
|
||||
if leftTime <= v {
|
||||
|
@ -50,6 +50,7 @@ func (this *modelTroll) getTrollList(uid string) (result *pb.DBTrollTrain, err e
|
||||
Ctime: time.Now().Unix(),
|
||||
Circle: 0,
|
||||
SurpriseID: map[int32]int32{},
|
||||
ResetTime: time.Now().Unix(),
|
||||
}
|
||||
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
|
||||
// 创建一条数据
|
||||
|
@ -40,11 +40,12 @@ type DBTrollTrain struct {
|
||||
TotalEarn int64 `protobuf:"varint,12,opt,name=totalEarn,proto3" json:"totalEarn" bson:"totalEarn"` //累计赚的钱
|
||||
SellCount int32 `protobuf:"varint,13,opt,name=sellCount,proto3" json:"sellCount" bson:"sellCount"` //今天已经卖出次数
|
||||
RefreshTime int64 `protobuf:"varint,14,opt,name=refreshTime,proto3" json:"refreshTime" bson:"refreshTime"` //最后一次刷新的时间 通过这个计算下一次刷新时间
|
||||
AiCount int32 `protobuf:"varint,15,opt,name=aiCount,proto3" json:"aiCount"` //@go_tags(`bson:"aiCount"` AI 交易次数
|
||||
AiCount int32 `protobuf:"varint,15,opt,name=aiCount,proto3" json:"aiCount" bson:"aiCount"` //AI 交易次数
|
||||
Shop map[int32]int32 `protobuf:"bytes,16,rep,name=shop,proto3" json:"shop" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 商人的限购数量
|
||||
Ctime int64 `protobuf:"varint,17,opt,name=ctime,proto3" json:"ctime"`
|
||||
Ctime int64 `protobuf:"varint,17,opt,name=ctime,proto3" json:"ctime"` // 创建时间
|
||||
Circle int32 `protobuf:"varint,18,opt,name=circle,proto3" json:"circle"` // 循环商人的次数
|
||||
SurpriseID map[int32]int32 `protobuf:"bytes,19,rep,name=surpriseID,proto3" json:"surpriseID" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //key商人id value惊喜货物ID
|
||||
SurpriseID map[int32]int32 `protobuf:"bytes,19,rep,name=surpriseID,proto3" json:"surpriseID" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"surpriseID"` //key商人id value惊喜货物ID
|
||||
ResetTime int64 `protobuf:"varint,20,opt,name=resetTime,proto3" json:"resetTime" bson:"resetTime"` //每日重置时间
|
||||
}
|
||||
|
||||
func (x *DBTrollTrain) Reset() {
|
||||
@ -212,11 +213,18 @@ func (x *DBTrollTrain) GetSurpriseID() map[int32]int32 {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *DBTrollTrain) GetResetTime() int64 {
|
||||
if x != nil {
|
||||
return x.ResetTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_troll_troll_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_troll_troll_db_proto_rawDesc = []byte{
|
||||
0x0a, 0x14, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x64, 0x62,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x94, 0x07, 0x0a, 0x0c, 0x44, 0x42, 0x54, 0x72, 0x6f,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x07, 0x0a, 0x0c, 0x44, 0x42, 0x54, 0x72, 0x6f,
|
||||
0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2e, 0x0a, 0x05, 0x69, 0x74, 0x65,
|
||||
@ -255,26 +263,28 @@ var file_troll_troll_db_proto_rawDesc = []byte{
|
||||
0x49, 0x44, 0x18, 0x13, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f,
|
||||
0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x2e, 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65,
|
||||
0x49, 0x44, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x73, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73,
|
||||
0x65, 0x49, 0x44, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03,
|
||||
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x38, 0x0a,
|
||||
0x0a, 0x50, 0x72, 0x69, 0x63, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61,
|
||||
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4e, 0x70, 0x63, 0x52, 0x65,
|
||||
0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
||||
0x65, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65,
|
||||
0x18, 0x14, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6d,
|
||||
0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
|
||||
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65,
|
||||
0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x38, 0x0a, 0x0a, 0x50,
|
||||
0x72, 0x69, 0x63, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
|
||||
0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x37, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x45, 0x6e, 0x74,
|
||||
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3d,
|
||||
0x0a, 0x0f, 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x44, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03,
|
||||
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4e, 0x70, 0x63, 0x52, 0x65, 0x77, 0x61,
|
||||
0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
|
||||
0x02, 0x38, 0x01, 0x1a, 0x37, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
||||
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3d, 0x0a, 0x0f,
|
||||
0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x44, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
|
||||
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65,
|
||||
0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user