惊喜货物取值问题

This commit is contained in:
meixiongfeng 2022-11-07 23:19:20 +08:00
parent 695ca53690
commit 0223ae49c6
2 changed files with 4 additions and 4 deletions

View File

@ -111,7 +111,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
if sellPrice > trolltrain.Price[k] { // 赚了
earn += (sellPrice - trolltrain.Price[k]) * v
}
gold += sellPrice * v
gold -= sellPrice * v
} else { // 买入 计算平均价格
totalGold := trolltrain.Items[k] * trolltrain.Price[k]
totalGold += v * sellPrice

View File

@ -79,8 +79,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
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())
n2, _ := rand.Int(rand.Reader, big.NewInt(int64(maxCoefficient-1))) //算的是下标所以-1
trolltrain.SurpriseID[int32(n.Int64())+1] = int32(n2.Int64()) + 1
update["surpriseID"] = trolltrain.SurpriseID
trolltrain.Circle = c
update["circle"] = trolltrain.Circle
@ -90,7 +90,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
index += circleCount * trainNum // 计算火车的位置信息
for _, v := range sz {
if leftTime <= v {
trolltrain.RefreshTime = time.Now().Unix() + int64(leftTime-v)
trolltrain.RefreshTime = time.Now().Unix()
trolltrain.TarinPos += index
//if trolltrain.RangeId != 0 {
trolltrain.RangeId += index