@@ -28,7 +28,7 @@ type fishdb struct {
2828const FishLimit = 50
2929
3030// version 规则版本号
31- const version = "5.4.2 "
31+ const version = "5.5.8 "
3232
3333// 各物品信息
3434type jsonInfo struct {
@@ -101,7 +101,7 @@ type buffInfo struct {
101101 Coupon int `db:"Buff1"` // 优惠卷
102102 SalesPole int `db:"Buff2"` // 卖鱼竿上限
103103 BuyTing int `db:"Buff3"` // 购买上限
104- Buff4 int `db:"Buff4"` // 暂定
104+ SalesFish int `db:"Buff4"` // 卖鱼次数
105105 Buff5 int `db:"Buff5"` // 暂定
106106 Buff6 int `db:"Buff6"` // 暂定
107107 Buff7 int `db:"Buff7"` // 暂定
@@ -149,7 +149,7 @@ var (
149149 "8.合成:\n -> 铁竿 : 3x木竿\n -> 金竿 : 3x铁竿\n -> 钻石竿 : 3x金竿\n -> 下界合金竿 : 3x钻石竿\n -> 三叉戟 : 3x下界合金竿\n 注:合成成功率90%(包括梭哈),合成鱼竿的附魔等级=(附魔等级合/合成鱼竿数量)\n " +
150150 "9.杂项:\n -> 无装备的情况下,每人最多可以购买3次100块钱的鱼竿\n -> 默认状态钓鱼上钩概率为60%(理论值!!!)\n -> 附魔的鱼竿会因附魔变得昂贵,每个附魔最高3级\n -> 三叉戟不算鱼竿,修复时可直接满耐久\n " +
151151 "-> 鱼竿数量大于50的不能买东西;\n 鱼竿数量大于30的不能钓鱼;\n 每购/售10次鱼竿获得1层宝藏诅咒;\n 每购买20次物品将获得3次价格减半福利;\n 每钓鱼75次获得1本净化书;\n " +
152- " 每天最多只可出售5个鱼竿和购买15次物品;" ,
152+ " 每天最多只可出售5个鱼竿和购买15次物品;鱼类交易每天最多100条. " ,
153153 PublicDataFolder : "McFish" ,
154154 }).ApplySingle (ctxext .DefaultSingle )
155155 getdb = fcext .DoOnceOnSuccess (func (ctx * zero.Ctx ) bool {
@@ -562,6 +562,10 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
562562 if err != nil {
563563 return false , err
564564 }
565+ err = sql .db .Create ("store" , & store {})
566+ if err != nil {
567+ return false , err
568+ }
565569 lastTime := storeDiscount {}
566570 _ = sql .db .Find ("stroeDiscount" , & lastTime , "where Name = 'lastTime'" )
567571 refresh := false
@@ -586,6 +590,12 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
586590 Name : name ,
587591 Discount : thingDiscount ,
588592 }
593+ thingInfo := store {}
594+ _ = sql .db .Find ("store" , & thingInfo , "where Name = '" + name + "'" )
595+ if thingInfo .Number > 150 {
596+ // 通货膨胀
597+ thing .Discount = (1000 - 5 * (thingInfo .Number - 150 )) / 10
598+ }
589599 err = sql .db .Insert ("stroeDiscount" , & thing )
590600 if err != nil {
591601 return
@@ -611,10 +621,6 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
611621 _ = sql .db .Del ("stroeDiscount" , "where Duration = " + strconv .FormatInt (info .Duration , 10 ))
612622 }
613623 if refresh {
614- err = sql .db .Create ("store" , & store {})
615- if err != nil {
616- return
617- }
618624 // 每天调控1种鱼
619625 fish := fishList [rand .Intn (len (fishList ))]
620626 thingInfo := store {
@@ -770,7 +776,7 @@ func (sql *fishdb) useCouponAt(uid int64, times int) (int, error) {
770776 return useTimes , sql .db .Insert ("buff" , & userInfo )
771777}
772778
773- // 检测上限
779+ // 检测卖鱼竿上限
774780func (sql * fishdb ) checkCanSalesFor (uid int64 , sales bool ) (int , error ) {
775781 residue := 0
776782 sql .Lock ()
@@ -782,15 +788,52 @@ func (sql *fishdb) checkCanSalesFor(uid int64, sales bool) (int, error) {
782788 }
783789 _ = sql .db .Find ("buff" , & userInfo , "where ID = " + strconv .FormatInt (uid , 10 ))
784790 if time .Now ().Day () != time .Unix (userInfo .Duration , 0 ).Day () {
791+ userInfo .Duration = time .Now ().Unix ()
785792 userInfo .SalesPole = 0
786793 userInfo .BuyTing = 0
787794 }
788795 if sales && userInfo .SalesPole < 5 {
789796 residue = 5 - userInfo .SalesPole
790797 userInfo .SalesPole ++
791798 } else if userInfo .BuyTing < 15 {
792- residue = 15 - userInfo .SalesPole
793- userInfo .SalesPole ++
799+ residue = 15 - userInfo .BuyTing
800+ userInfo .BuyTing ++
794801 }
795802 return residue , sql .db .Insert ("buff" , & userInfo )
796803}
804+
805+ // 检测物品是否是鱼
806+ func checkIsFish (thing string ) bool {
807+ for _ , v := range fishList {
808+ if v == thing {
809+ return true
810+ }
811+ }
812+ return false
813+ }
814+
815+ // 检测买卖鱼上限
816+ func (sql * fishdb ) checkCanSalesFishFor (uid int64 , sales int ) (int , error ) {
817+ residue := 0
818+ sql .Lock ()
819+ defer sql .Unlock ()
820+ userInfo := buffInfo {ID : uid }
821+ err := sql .db .Create ("buff" , & userInfo )
822+ if err != nil {
823+ return residue , err
824+ }
825+ _ = sql .db .Find ("buff" , & userInfo , "where ID = " + strconv .FormatInt (uid , 10 ))
826+ if time .Now ().Day () != time .Unix (userInfo .Duration , 0 ).Day () {
827+ userInfo .Duration = time .Now ().Unix ()
828+ userInfo .SalesFish = 0
829+ }
830+ maxSales := 100 - userInfo .SalesFish
831+ if maxSales < 0 {
832+ maxSales = 0
833+ }
834+ if sales > maxSales {
835+ sales = maxSales
836+ }
837+ userInfo .SalesFish += sales
838+ return sales , sql .db .Insert ("buff" , & userInfo )
839+ }
0 commit comments