@@ -165,7 +165,7 @@ func init() {
165
165
stauts = "完全没有饱"
166
166
}
167
167
ctx .SendChain (message .Reply (id ), message .Text (userInfo .Name , "当前信息如下:\n " ),
168
- message .Image (userInfo .Avatar ()),
168
+ message .Image (userInfo .avatar ()),
169
169
message .Text ("品种: " + userInfo .Type ,
170
170
"\n 饱食度: " , strconv .FormatFloat (userInfo .Satiety , 'f' , 0 , 64 ),
171
171
"\n 心情: " , userInfo .Mood ,
@@ -288,63 +288,63 @@ func init() {
288
288
}
289
289
290
290
// 饱食度结算
291
- func (data * catInfo ) settleOfSatiety (food float64 ) catInfo {
292
- if food > 0 && data .Satiety < 30 && rand .Intn (100 ) <= data .Mood / 3 {
291
+ func (inf * catInfo ) settleOfSatiety (food float64 ) catInfo {
292
+ if food > 0 && inf .Satiety < 30 && rand .Intn (100 ) <= inf .Mood / 3 {
293
293
food *= 4
294
294
}
295
- data .Satiety += (food * 100 / math .Max (1 , data .Weight / 2 ))
296
- return * data
295
+ inf .Satiety += (food * 100 / math .Max (1 , inf .Weight / 2 ))
296
+ return * inf
297
297
}
298
298
299
299
// 体重结算
300
- func (data * catInfo ) settleOfWeight () catInfo {
301
- if data .Weight < 0 {
302
- satiety := math .Min ((- data .Weight )* 7 , data .Satiety )
303
- data .Weight += satiety
304
- data .Satiety -= satiety
300
+ func (inf * catInfo ) settleOfWeight () catInfo {
301
+ if inf .Weight < 0 {
302
+ satiety := math .Min ((- inf .Weight )* 7 , inf .Satiety )
303
+ inf .Weight += satiety
304
+ inf .Satiety -= satiety
305
305
}
306
306
switch {
307
- case data .Satiety > 100 :
308
- data .Weight += (data .Satiety - 50 ) / 100
309
- case data .Satiety < 0 :
310
- data .Weight += data .Satiety / 10
311
- if data .Weight < 0 {
312
- needFood := math .Min (- data .Weight * 5 , data .Food )
313
- data .Food -= needFood
314
- data .Weight += needFood / 5
307
+ case inf .Satiety > 100 :
308
+ inf .Weight += (inf .Satiety - 50 ) / 100
309
+ case inf .Satiety < 0 :
310
+ inf .Weight += inf .Satiety / 10
311
+ if inf .Weight < 0 {
312
+ needFood := math .Min (- inf .Weight * 5 , inf .Food )
313
+ inf .Food -= needFood
314
+ inf .Weight += needFood / 5
315
315
}
316
316
}
317
- return * data
317
+ return * inf
318
318
}
319
319
320
320
// 整体数据结算
321
- func (data * catInfo ) settleOfData () catInfo {
322
- if data .Satiety > 100 {
323
- data .Satiety = 100
324
- } else if data .Satiety < 0 {
325
- data .Satiety = 0
321
+ func (inf * catInfo ) settleOfData () catInfo {
322
+ if inf .Satiety > 100 {
323
+ inf .Satiety = 100
324
+ } else if inf .Satiety < 0 {
325
+ inf .Satiety = 0
326
326
}
327
- if data .Mood > 100 {
328
- data .Mood = 100
329
- } else if data .Mood < 0 {
330
- data .Mood = 0
327
+ if inf .Mood > 100 {
328
+ inf .Mood = 100
329
+ } else if inf .Mood < 0 {
330
+ inf .Mood = 0
331
331
}
332
- if data .Weight < 0 {
333
- data .Weight = - 5
332
+ if inf .Weight < 0 {
333
+ inf .Weight = - 5
334
334
}
335
- if data .Food < 0 {
336
- data .Food = 0
335
+ if inf .Food < 0 {
336
+ inf .Food = 0
337
337
}
338
- return * data
338
+ return * inf
339
339
}
340
340
341
341
// 打工结算
342
- func (data * catInfo ) settleOfWork (gid string ) (int , bool ) {
343
- workTime := data .Work % 10
342
+ func (inf * catInfo ) settleOfWork (gid string ) (int , bool ) {
343
+ workTime := inf .Work % 10
344
344
if workTime <= 0 {
345
345
return 0 , true
346
346
}
347
- lastTime := time .Unix (data .Work / 10 , 0 )
347
+ lastTime := time .Unix (inf .Work / 10 , 0 )
348
348
subtime := time .Since (lastTime ).Hours ()
349
349
if subtime < float64 (workTime ) {
350
350
return 0 , false
@@ -355,15 +355,15 @@ func (data *catInfo) settleOfWork(gid string) (int, bool) {
355
355
getFood = - (getFood + float64 (workTime )* rand .Float64 ())
356
356
mood *= - 3
357
357
}
358
- data .Satiety += getFood * 100 / math .Max (1 , data .Weight )
359
- data .Mood += mood
360
- data .Work = time .Now ().Unix () * 10
361
- data .LastTime = time .Unix (data .LastTime , 0 ).Add (time .Duration (workTime ) * time .Hour ).Unix ()
362
- if catdata .insert (gid , data ) != nil {
358
+ inf .Satiety += getFood * 100 / math .Max (1 , inf .Weight )
359
+ inf .Mood += mood
360
+ inf .Work = time .Now ().Unix () * 10
361
+ inf .LastTime = time .Unix (inf .LastTime , 0 ).Add (time .Duration (workTime ) * time .Hour ).Unix ()
362
+ if catdata .insert (gid , inf ) != nil {
363
363
return 0 , true
364
364
}
365
365
getmoney := 10 + rand .Intn (10 * int (workTime ))
366
- if wallet .InsertWalletOf (data .User , getmoney ) != nil {
366
+ if wallet .InsertWalletOf (inf .User , getmoney ) != nil {
367
367
return 0 , true
368
368
}
369
369
return getmoney , true
0 commit comments