MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / updateCanSalesFor

Method updateCanSalesFor

plugin/mcfish/main.go:810–825  ·  view source on GitHub ↗

更新买卖鱼上限,假定sales变量已经在 checkCanSalesFor 进行了防护

(uid int64, saleName string, sales int)

Source from the content-addressed store, hash-verified

808
809// 更新买卖鱼上限,假定sales变量已经在 checkCanSalesFor 进行了防护
810func (sql *fishdb) updateCanSalesFor(uid int64, saleName string, sales int) error {
811 sql.Lock()
812 defer sql.Unlock()
813 userInfo := buffInfo{ID: uid}
814 err := sql.db.Create("buff", &userInfo)
815 if err != nil {
816 return err
817 }
818 _ = sql.db.Find("buff", &userInfo, "WHERE ID = ?", uid)
819 if strings.Contains(saleName, "竿") {
820 userInfo.SalesPole++
821 } else if !checkIsWaste(saleName) {
822 userInfo.BuyTing += sales
823 }
824 return sql.db.Insert("buff", &userInfo)
825}
826
827// 检测物品是否是垃圾
828func checkIsWaste(thing string) bool {

Callers 1

initFunction · 0.80

Calls 1

checkIsWasteFunction · 0.85

Tested by

no test coverage detected