【猫草大作战】-协议修改
This commit is contained in:
parent
9080c8870a
commit
baf4914f9b
@ -1,16 +1,25 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"server/GoUtil"
|
||||
"server/MergeConst"
|
||||
"server/conf"
|
||||
activityCfg "server/conf/activity"
|
||||
chargeCfg "server/conf/charge"
|
||||
passCfg "server/conf/pass"
|
||||
"server/db"
|
||||
"server/game/mod/activity"
|
||||
"server/game/mod/item"
|
||||
MsgMod "server/game/mod/msg"
|
||||
"server/game/mod/piggyBank"
|
||||
"server/game/mod/quest"
|
||||
"server/msg"
|
||||
proto "server/msg"
|
||||
"server/pkg/github.com/name5566/leaf/log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Charge(p *Player, ChargeId int) {
|
||||
@ -177,3 +186,92 @@ func EndlessFire(p *Player, ChargeId int) {
|
||||
p.PlayMod.save()
|
||||
p.PushClientRes(EndlessMod.BackData())
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
func CreateOrderSn(p *Player, req *proto.ReqCreateOrderSn) (string, error) {
|
||||
Uid := int(p.M_DwUin)
|
||||
OrderSn := GoUtil.CreateOrderSn(Uid)
|
||||
|
||||
Price, Currency := chargeCfg.GetChargeInfo(int(req.ChargeId))
|
||||
Extra := &ChargeExtra{
|
||||
Type: int(req.Type),
|
||||
Uid: req.Uid,
|
||||
}
|
||||
ExtraData, _ := json.Marshal(Extra)
|
||||
err := db.CreateOrderSn(Uid, int(req.ChargeId), OrderSn, req.PlatForm, req.Channel, Price, Currency, string(ExtraData))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return OrderSn, nil
|
||||
}
|
||||
|
||||
func GoogleVerify(p *Player, OrderSn, ProduceId, Token string) (*db.SqlChargeOrderStruct, error) {
|
||||
Order, err := db.GetPlayerChargeData(OrderSn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if Order.PayStatus == MergeConst.ORDER_STATUS_SHIP {
|
||||
return nil, fmt.Errorf("订单已经发货")
|
||||
}
|
||||
if !conf.Server.GoogleVerify {
|
||||
Order.PayStatus = MergeConst.ORDER_STATUS_PAY
|
||||
return Order, nil
|
||||
}
|
||||
if Order.PayStatus != MergeConst.ORDER_STATUS_IDLE {
|
||||
return nil, fmt.Errorf("订单已经支付")
|
||||
}
|
||||
cmd := exec.Command(conf.Server.AppPath+"/script/verifyOrder", ProduceId, Token)
|
||||
|
||||
// 获取命令的输出
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 将输出转换为字符串
|
||||
outputStr := string(output)
|
||||
|
||||
// 替换单引号为双引号
|
||||
outputStr = strings.Replace(outputStr, "'", "\"", -1)
|
||||
type VerifyData struct {
|
||||
PurchaseState int `json:"purchaseState"`
|
||||
DeveloperPayload string `json:"developerPayload"`
|
||||
OrderId string `json:"orderId"`
|
||||
ConsumptionState int `json:"consumptionState"`
|
||||
}
|
||||
r := &VerifyData{}
|
||||
err = json.Unmarshal([]byte(outputStr), &r)
|
||||
if err != nil {
|
||||
log.Debug("output %s", string(output))
|
||||
return nil, err
|
||||
}
|
||||
_, err = db.GetPlayerPayChannelOrderId(r.OrderId)
|
||||
if err == nil {
|
||||
return nil, fmt.Errorf("订单已支付发货 param: %v", r)
|
||||
}
|
||||
// if r.DeveloperPayload != OrderSn {
|
||||
// return nil, fmt.Errorf("订单号不匹配")
|
||||
// }
|
||||
if r.ConsumptionState != 1 {
|
||||
return nil, fmt.Errorf("订单未消费")
|
||||
}
|
||||
Order.PayStatus = MergeConst.ORDER_STATUS_PAY
|
||||
Order.PayChannelOrderId = r.OrderId
|
||||
Order.PayTime = GoUtil.Now()
|
||||
return Order, nil
|
||||
}
|
||||
|
||||
func CancelOrder(p *Player, OrderSn string) error {
|
||||
Order, err := db.GetPlayerChargeData(OrderSn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if Order.PayStatus != MergeConst.ORDER_STATUS_IDLE {
|
||||
return fmt.Errorf("订单已支付")
|
||||
}
|
||||
Order.PayStatus = MergeConst.ORDER_STATUS_CANCEL
|
||||
err = db.UpdatePlayerChargeData(Order)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
156
src/server/game/FriendFunc.go
Normal file
156
src/server/game/FriendFunc.go
Normal file
@ -0,0 +1,156 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"server/GoUtil"
|
||||
"server/db"
|
||||
"server/game/mod/msg"
|
||||
"server/pkg/github.com/name5566/leaf/log"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func GetVisitorPlayer(p *Player) int {
|
||||
PlayroomMod := p.PlayMod.getPlayroomMod()
|
||||
VisitorList := PlayroomMod.GetVisitor() // 到访用户
|
||||
TodayVisitedUsers := PlayroomMod.GetTodayVisitedUsers() // 今日已互动用户
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
type sortData struct {
|
||||
Uid int
|
||||
Time int64
|
||||
}
|
||||
PlayerList := make([]sortData, 0)
|
||||
PlayerList2 := make([]sortData, 0)
|
||||
Now := GoUtil.Now()
|
||||
/**
|
||||
排除当日玩家已对其发起过交互的用户
|
||||
优先选择24小时内曾经与玩家进行过宠物交互的好友
|
||||
若存在复数对象的情况下,优先选择交互发生时间与当前时间最近的好友
|
||||
若不存在符合条件的用户,则选择24小时内曾经与玩家进行过宠物交互的陌生用户
|
||||
若存在复数对象的情况下,优先选择交互发生时间与当前时间最近的用户
|
||||
若不存在符合条件的用户,则选择24小时内登入过游戏且上次登入时间与当前时间最近的好友
|
||||
若不存在符合条件的用户,则依据以上用户推荐算法,选择一位随机推荐用户,并且在下次触发式订单完成时,不再排除已发起过交互的用户
|
||||
*/
|
||||
for k, v := range VisitorList {
|
||||
if GoUtil.InArray(k, TodayVisitedUsers) {
|
||||
continue
|
||||
}
|
||||
if v.Time < Now-86400 {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckFriend(k) {
|
||||
PlayerList = append(PlayerList, sortData{k, v.Time})
|
||||
} else {
|
||||
PlayerList2 = append(PlayerList, sortData{k, v.Time})
|
||||
}
|
||||
}
|
||||
if len(PlayerList) != 0 {
|
||||
sort.Slice(PlayerList, func(i, j int) bool {
|
||||
return PlayerList[i].Time < PlayerList[j].Time
|
||||
})
|
||||
return PlayerList[0].Uid
|
||||
}
|
||||
if len(PlayerList2) != 0 {
|
||||
sort.Slice(PlayerList2, func(i, j int) bool {
|
||||
return PlayerList2[i].Time < PlayerList2[j].Time
|
||||
})
|
||||
return PlayerList2[0].Uid
|
||||
}
|
||||
// 若不存在符合条件的用户,则选择24小时内登入过游戏且上次登入时间与当前时间最近的好友
|
||||
var recentFriendUid int
|
||||
var recentLoginTime int64 = 0
|
||||
for uid := range FriendMod.GetFriendList() {
|
||||
if uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
if GoUtil.InArray(uid, TodayVisitedUsers) {
|
||||
continue
|
||||
}
|
||||
ps := G_GameLogicPtr.GetSimplePlayerByUid(uid)
|
||||
if ps == nil {
|
||||
continue
|
||||
}
|
||||
if GoUtil.Now()-ps.Loginout > 86400 { // 24小时内登录过
|
||||
continue
|
||||
}
|
||||
if ps.Loginout > recentLoginTime {
|
||||
recentLoginTime = ps.Loginout
|
||||
recentFriendUid = uid
|
||||
}
|
||||
}
|
||||
if recentFriendUid != 0 {
|
||||
return recentFriendUid
|
||||
}
|
||||
PlayerList3 := G_GameLogicPtr.RankMgr.getAllRank(RANK_TYPE_USER)
|
||||
PlayerList4 := make([]int, 0)
|
||||
for _, v := range PlayerList3 {
|
||||
if v.Uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(v.Uid)
|
||||
if PlayerSimpleData.Level < 15 {
|
||||
continue
|
||||
}
|
||||
PlayerList4 = append(PlayerList4, v.Uid)
|
||||
}
|
||||
L := GoUtil.RandSliceNum(PlayerList4, 1)
|
||||
if len(L) == 0 {
|
||||
return 0
|
||||
}
|
||||
return L[0]
|
||||
}
|
||||
|
||||
func GetRecommendPlayer(p *Player, Num int) []int {
|
||||
PlayerList := G_GameLogicPtr.RankMgr.getAllRank(RANK_TYPE_USER)
|
||||
PlayerList1 := make([]int, 0)
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
for _, v := range PlayerList {
|
||||
if v.Uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckSendApply(v.Uid) {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckFriend(v.Uid) {
|
||||
continue
|
||||
}
|
||||
PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(v.Uid)
|
||||
if GoUtil.Now()-PlayerSimpleData.Loginout > 86400 {
|
||||
continue
|
||||
}
|
||||
if PlayerSimpleData.Level < 4 {
|
||||
continue
|
||||
}
|
||||
PlayerList1 = append(PlayerList1, v.Uid)
|
||||
}
|
||||
if len(PlayerList1) == 0 {
|
||||
for _, v := range PlayerList {
|
||||
if v.Uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
PlayerList1 = append(PlayerList1, v.Uid)
|
||||
}
|
||||
}
|
||||
return GoUtil.RandSliceNum(PlayerList1, Num)
|
||||
}
|
||||
|
||||
func GetUidByFaceBook(Fb string) (int, error) {
|
||||
sqlStr := "SELECT dwUin FROM t_player_baseinfo WHERE FaceBookId = ?"
|
||||
type Result struct {
|
||||
Uid int `db:"dwUin"`
|
||||
}
|
||||
R := Result{}
|
||||
err := db.SqlDb.Get(&R, sqlStr, Fb)
|
||||
log.Debug("Fb :%s;Uid :%d", Fb, R.Uid)
|
||||
return R.Uid, err
|
||||
}
|
||||
|
||||
func NotifyAllFriend(p *Player, m1 *msg.Msg) {
|
||||
m := m1.Clone()
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
for k := range FriendMod.GetFriendList() {
|
||||
if k == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
m.To = k
|
||||
FriendMgrSend(m)
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,11 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"server/GoUtil"
|
||||
"server/MergeConst"
|
||||
mergeCluster "server/cluster"
|
||||
"server/conf"
|
||||
cardCfg "server/conf/card"
|
||||
catnipCfg "server/conf/catnip"
|
||||
chargeCfg "server/conf/charge"
|
||||
decorateCfg "server/conf/decorate"
|
||||
itemCfg "server/conf/item"
|
||||
limitedTimeEventCfg "server/conf/limitedTimeEvent"
|
||||
@ -19,7 +14,6 @@ import (
|
||||
orderCfg "server/conf/order"
|
||||
playroomCfg "server/conf/playroom"
|
||||
userCfg "server/conf/user"
|
||||
"server/db"
|
||||
"server/game/mod/activity"
|
||||
"server/game/mod/card"
|
||||
"server/game/mod/friend"
|
||||
@ -32,7 +26,6 @@ import (
|
||||
proto "server/msg"
|
||||
"server/pkg/github.com/name5566/leaf/log"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 处理玩家异步请求
|
||||
@ -514,103 +507,21 @@ func SyncMailMsg(p *Player) {
|
||||
p.PushClientRes(MailMod.BackData())
|
||||
}
|
||||
|
||||
// 返回好友信息
|
||||
func FriendListBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var fl []*proto.ResPlayerSimple
|
||||
for k, v := range FriendMod.GetFriendList() {
|
||||
if k == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(k)
|
||||
if ps != nil {
|
||||
ps.AddTime = v.AddTime
|
||||
ps.Interact = FriendMod.GetInteractTime(k)
|
||||
fl = append(fl, ps)
|
||||
}
|
||||
}
|
||||
ReqFriendList := make([]int64, 0)
|
||||
for k := range FriendMod.SendApply {
|
||||
ReqFriendList = append(ReqFriendList, int64(k))
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendList{
|
||||
FriendList: fl,
|
||||
ReqApplyList: ReqFriendList,
|
||||
Npc: GoUtil.IntToInt32(FriendMod.GetNpc()),
|
||||
Sponsor: int32(FriendMod.GetSponsor()),
|
||||
})
|
||||
}
|
||||
|
||||
func FriendApplyBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var al []*proto.ResFriendApplyInfo
|
||||
for k, v := range FriendMod.ApplyList {
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(k)
|
||||
if ps != nil {
|
||||
al = append(al, &proto.ResFriendApplyInfo{
|
||||
Player: ps,
|
||||
Time: int32(v),
|
||||
})
|
||||
}
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendApply{
|
||||
ApplyList: al,
|
||||
})
|
||||
}
|
||||
|
||||
func FriendLogBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var log []*proto.ResFriendLog
|
||||
for _, v := range FriendMod.Log {
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(v.Uid)
|
||||
if ps == nil {
|
||||
ps = &proto.ResPlayerSimple{
|
||||
Uid: int64(v.Uid),
|
||||
}
|
||||
}
|
||||
log = append(log, &proto.ResFriendLog{
|
||||
Player: ps,
|
||||
Type: int32(v.Type),
|
||||
Time: int32(v.Time),
|
||||
Param: v.Param,
|
||||
Id: int32(v.Id),
|
||||
Upvote: v.Upvote,
|
||||
})
|
||||
}
|
||||
var reply []*proto.ResFriendReply
|
||||
for _, v := range FriendMod.ReplyList {
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(v.Uid)
|
||||
if ps == nil {
|
||||
ps = &proto.ResPlayerSimple{
|
||||
Uid: int64(v.Uid),
|
||||
}
|
||||
}
|
||||
reply = append(reply, &proto.ResFriendReply{
|
||||
Player: ps,
|
||||
Type: int32(v.Type),
|
||||
Param: v.Param,
|
||||
Id: int32(v.Id),
|
||||
Status: int32(v.Status),
|
||||
AddTime: v.AddTime,
|
||||
EndTime: v.EndTime,
|
||||
})
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendTimeLine{
|
||||
Log: log,
|
||||
Reply: reply,
|
||||
})
|
||||
}
|
||||
|
||||
func FriendCardBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var msgList []*proto.ResFriendCard
|
||||
for _, v := range FriendMod.Card {
|
||||
m := GetCardInfoMsg(v)
|
||||
msgList = append(msgList, m)
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendCardMsg{
|
||||
MsgList: msgList,
|
||||
func (p *Player) CatnipGrowthMsg(To, Id, Growth, FriendItems int) error {
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
FriendMgrSend(&msg.Msg{
|
||||
From: int(p.M_DwUin),
|
||||
To: To,
|
||||
Type: msg.HANDLE_TYPE_CATNIP_GROWTH,
|
||||
SendT: GoUtil.Now(),
|
||||
Extra: CatnipMsg{
|
||||
ActivityId: ActivityId,
|
||||
GameId: Id,
|
||||
Growth: Growth,
|
||||
FriendItems: FriendItems,
|
||||
},
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// 发送消息给玩家
|
||||
@ -618,95 +529,6 @@ func ClusterSendMsg(ServerId int, m *msg.Msg) {
|
||||
mergeCluster.SendServerMsg(m, ServerId)
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
func CreateOrderSn(p *Player, req *proto.ReqCreateOrderSn) (string, error) {
|
||||
Uid := int(p.M_DwUin)
|
||||
OrderSn := GoUtil.CreateOrderSn(Uid)
|
||||
|
||||
Price, Currency := chargeCfg.GetChargeInfo(int(req.ChargeId))
|
||||
Extra := &ChargeExtra{
|
||||
Type: int(req.Type),
|
||||
Uid: req.Uid,
|
||||
}
|
||||
ExtraData, _ := json.Marshal(Extra)
|
||||
err := db.CreateOrderSn(Uid, int(req.ChargeId), OrderSn, req.PlatForm, req.Channel, Price, Currency, string(ExtraData))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return OrderSn, nil
|
||||
}
|
||||
|
||||
func GoogleVerify(p *Player, OrderSn, ProduceId, Token string) (*db.SqlChargeOrderStruct, error) {
|
||||
Order, err := db.GetPlayerChargeData(OrderSn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if Order.PayStatus == MergeConst.ORDER_STATUS_SHIP {
|
||||
return nil, fmt.Errorf("订单已经发货")
|
||||
}
|
||||
if !conf.Server.GoogleVerify {
|
||||
Order.PayStatus = MergeConst.ORDER_STATUS_PAY
|
||||
return Order, nil
|
||||
}
|
||||
if Order.PayStatus != MergeConst.ORDER_STATUS_IDLE {
|
||||
return nil, fmt.Errorf("订单已经支付")
|
||||
}
|
||||
cmd := exec.Command(conf.Server.AppPath+"/script/verifyOrder", ProduceId, Token)
|
||||
|
||||
// 获取命令的输出
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 将输出转换为字符串
|
||||
outputStr := string(output)
|
||||
|
||||
// 替换单引号为双引号
|
||||
outputStr = strings.Replace(outputStr, "'", "\"", -1)
|
||||
type VerifyData struct {
|
||||
PurchaseState int `json:"purchaseState"`
|
||||
DeveloperPayload string `json:"developerPayload"`
|
||||
OrderId string `json:"orderId"`
|
||||
ConsumptionState int `json:"consumptionState"`
|
||||
}
|
||||
r := &VerifyData{}
|
||||
err = json.Unmarshal([]byte(outputStr), &r)
|
||||
if err != nil {
|
||||
log.Debug("output %s", string(output))
|
||||
return nil, err
|
||||
}
|
||||
_, err = db.GetPlayerPayChannelOrderId(r.OrderId)
|
||||
if err == nil {
|
||||
return nil, fmt.Errorf("订单已支付发货 param: %v", r)
|
||||
}
|
||||
// if r.DeveloperPayload != OrderSn {
|
||||
// return nil, fmt.Errorf("订单号不匹配")
|
||||
// }
|
||||
if r.ConsumptionState != 1 {
|
||||
return nil, fmt.Errorf("订单未消费")
|
||||
}
|
||||
Order.PayStatus = MergeConst.ORDER_STATUS_PAY
|
||||
Order.PayChannelOrderId = r.OrderId
|
||||
Order.PayTime = GoUtil.Now()
|
||||
return Order, nil
|
||||
}
|
||||
|
||||
func CancelOrder(p *Player, OrderSn string) error {
|
||||
Order, err := db.GetPlayerChargeData(OrderSn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if Order.PayStatus != MergeConst.ORDER_STATUS_IDLE {
|
||||
return fmt.Errorf("订单已支付")
|
||||
}
|
||||
Order.PayStatus = MergeConst.ORDER_STATUS_CANCEL
|
||||
err = db.UpdatePlayerChargeData(Order)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetCardInfoMsg(CardInfo *card.CardInfo) *proto.ResFriendCard {
|
||||
Uid := 0
|
||||
if CardInfo.Type == card.TYPE_CARD_SEND {
|
||||
@ -746,137 +568,6 @@ func GetCardInfoMsg(CardInfo *card.CardInfo) *proto.ResFriendCard {
|
||||
}
|
||||
}
|
||||
|
||||
func BackChampship(p *Player) {
|
||||
ChampshipMod := p.PlayMod.getChampshipMod()
|
||||
MyRank := G_GameLogicPtr.ChampshipMgr.getMyRank(int(p.M_DwUin))
|
||||
MyPreRank := G_GameLogicPtr.ChampshipMgr.getLastMyRank(int(p.M_DwUin))
|
||||
p.PushClientRes(ChampshipMod.BackData(MyRank, MyPreRank))
|
||||
}
|
||||
|
||||
func GetVisitorPlayer(p *Player) int {
|
||||
PlayroomMod := p.PlayMod.getPlayroomMod()
|
||||
VisitorList := PlayroomMod.GetVisitor() // 到访用户
|
||||
TodayVisitedUsers := PlayroomMod.GetTodayVisitedUsers() // 今日已互动用户
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
type sortData struct {
|
||||
Uid int
|
||||
Time int64
|
||||
}
|
||||
PlayerList := make([]sortData, 0)
|
||||
PlayerList2 := make([]sortData, 0)
|
||||
Now := GoUtil.Now()
|
||||
/**
|
||||
排除当日玩家已对其发起过交互的用户
|
||||
优先选择24小时内曾经与玩家进行过宠物交互的好友
|
||||
若存在复数对象的情况下,优先选择交互发生时间与当前时间最近的好友
|
||||
若不存在符合条件的用户,则选择24小时内曾经与玩家进行过宠物交互的陌生用户
|
||||
若存在复数对象的情况下,优先选择交互发生时间与当前时间最近的用户
|
||||
若不存在符合条件的用户,则选择24小时内登入过游戏且上次登入时间与当前时间最近的好友
|
||||
若不存在符合条件的用户,则依据以上用户推荐算法,选择一位随机推荐用户,并且在下次触发式订单完成时,不再排除已发起过交互的用户
|
||||
*/
|
||||
for k, v := range VisitorList {
|
||||
if GoUtil.InArray(k, TodayVisitedUsers) {
|
||||
continue
|
||||
}
|
||||
if v.Time < Now-86400 {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckFriend(k) {
|
||||
PlayerList = append(PlayerList, sortData{k, v.Time})
|
||||
} else {
|
||||
PlayerList2 = append(PlayerList, sortData{k, v.Time})
|
||||
}
|
||||
}
|
||||
if len(PlayerList) != 0 {
|
||||
sort.Slice(PlayerList, func(i, j int) bool {
|
||||
return PlayerList[i].Time < PlayerList[j].Time
|
||||
})
|
||||
return PlayerList[0].Uid
|
||||
}
|
||||
if len(PlayerList2) != 0 {
|
||||
sort.Slice(PlayerList2, func(i, j int) bool {
|
||||
return PlayerList2[i].Time < PlayerList2[j].Time
|
||||
})
|
||||
return PlayerList2[0].Uid
|
||||
}
|
||||
// 若不存在符合条件的用户,则选择24小时内登入过游戏且上次登入时间与当前时间最近的好友
|
||||
var recentFriendUid int
|
||||
var recentLoginTime int64 = 0
|
||||
for uid := range FriendMod.GetFriendList() {
|
||||
if uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
if GoUtil.InArray(uid, TodayVisitedUsers) {
|
||||
continue
|
||||
}
|
||||
ps := G_GameLogicPtr.GetSimplePlayerByUid(uid)
|
||||
if ps == nil {
|
||||
continue
|
||||
}
|
||||
if GoUtil.Now()-ps.Loginout > 86400 { // 24小时内登录过
|
||||
continue
|
||||
}
|
||||
if ps.Loginout > recentLoginTime {
|
||||
recentLoginTime = ps.Loginout
|
||||
recentFriendUid = uid
|
||||
}
|
||||
}
|
||||
if recentFriendUid != 0 {
|
||||
return recentFriendUid
|
||||
}
|
||||
PlayerList3 := G_GameLogicPtr.RankMgr.getAllRank(RANK_TYPE_USER)
|
||||
PlayerList4 := make([]int, 0)
|
||||
for _, v := range PlayerList3 {
|
||||
if v.Uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(v.Uid)
|
||||
if PlayerSimpleData.Level < 15 {
|
||||
continue
|
||||
}
|
||||
PlayerList4 = append(PlayerList4, v.Uid)
|
||||
}
|
||||
L := GoUtil.RandSliceNum(PlayerList4, 1)
|
||||
if len(L) == 0 {
|
||||
return 0
|
||||
}
|
||||
return L[0]
|
||||
}
|
||||
|
||||
func GetRecommendPlayer(p *Player, Num int) []int {
|
||||
PlayerList := G_GameLogicPtr.RankMgr.getAllRank(RANK_TYPE_USER)
|
||||
PlayerList1 := make([]int, 0)
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
for _, v := range PlayerList {
|
||||
if v.Uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckSendApply(v.Uid) {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckFriend(v.Uid) {
|
||||
continue
|
||||
}
|
||||
PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(v.Uid)
|
||||
if GoUtil.Now()-PlayerSimpleData.Loginout > 86400 {
|
||||
continue
|
||||
}
|
||||
if PlayerSimpleData.Level < 4 {
|
||||
continue
|
||||
}
|
||||
PlayerList1 = append(PlayerList1, v.Uid)
|
||||
}
|
||||
if len(PlayerList1) == 0 {
|
||||
for _, v := range PlayerList {
|
||||
if v.Uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
PlayerList1 = append(PlayerList1, v.Uid)
|
||||
}
|
||||
}
|
||||
return GoUtil.RandSliceNum(PlayerList1, Num)
|
||||
}
|
||||
|
||||
// 发射器退役第一步 不再生成此发射器订单
|
||||
func EmitRetireTrigger1(p *Player) {
|
||||
ChessMod := p.PlayMod.getChessMod()
|
||||
@ -973,36 +664,6 @@ func EmitRetireTrigger2(p *Player) {
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark(player *Player) {
|
||||
ChampshipMod := player.PlayMod.getChampshipMod()
|
||||
ChampshipMod.AddScore([]int{949, 941, 10})
|
||||
player.HandleInChampshipRank()
|
||||
player.HandleInUserRank()
|
||||
}
|
||||
|
||||
func GetUidByFaceBook(Fb string) (int, error) {
|
||||
sqlStr := "SELECT dwUin FROM t_player_baseinfo WHERE FaceBookId = ?"
|
||||
type Result struct {
|
||||
Uid int `db:"dwUin"`
|
||||
}
|
||||
R := Result{}
|
||||
err := db.SqlDb.Get(&R, sqlStr, Fb)
|
||||
log.Debug("Fb :%s;Uid :%d", Fb, R.Uid)
|
||||
return R.Uid, err
|
||||
}
|
||||
|
||||
func NotifyAllFriend(p *Player, m1 *msg.Msg) {
|
||||
m := m1.Clone()
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
for k := range FriendMod.GetFriendList() {
|
||||
if k == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
m.To = k
|
||||
FriendMgrSend(m)
|
||||
}
|
||||
}
|
||||
|
||||
func NotifyChampshipResult(Uid, Rank int) {
|
||||
PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(Uid)
|
||||
if PlayerSimpleData == nil {
|
||||
@ -294,3 +294,109 @@ func (p *Player) ChargeBackData() {
|
||||
WeeklyEndTime: max(c.WeeklyEndTime, CatDaySaleEndTime),
|
||||
})
|
||||
}
|
||||
|
||||
func BackChampship(p *Player) {
|
||||
ChampshipMod := p.PlayMod.getChampshipMod()
|
||||
MyRank := G_GameLogicPtr.ChampshipMgr.getMyRank(int(p.M_DwUin))
|
||||
MyPreRank := G_GameLogicPtr.ChampshipMgr.getLastMyRank(int(p.M_DwUin))
|
||||
p.PushClientRes(ChampshipMod.BackData(MyRank, MyPreRank))
|
||||
}
|
||||
|
||||
// 返回好友信息
|
||||
func FriendListBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var fl []*proto.ResPlayerSimple
|
||||
for k, v := range FriendMod.GetFriendList() {
|
||||
if k == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(k)
|
||||
if ps != nil {
|
||||
ps.AddTime = v.AddTime
|
||||
ps.Interact = FriendMod.GetInteractTime(k)
|
||||
fl = append(fl, ps)
|
||||
}
|
||||
}
|
||||
ReqFriendList := make([]int64, 0)
|
||||
for k := range FriendMod.SendApply {
|
||||
ReqFriendList = append(ReqFriendList, int64(k))
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendList{
|
||||
FriendList: fl,
|
||||
ReqApplyList: ReqFriendList,
|
||||
Npc: GoUtil.IntToInt32(FriendMod.GetNpc()),
|
||||
Sponsor: int32(FriendMod.GetSponsor()),
|
||||
})
|
||||
}
|
||||
|
||||
func FriendApplyBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var al []*proto.ResFriendApplyInfo
|
||||
for k, v := range FriendMod.ApplyList {
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(k)
|
||||
if ps != nil {
|
||||
al = append(al, &proto.ResFriendApplyInfo{
|
||||
Player: ps,
|
||||
Time: int32(v),
|
||||
})
|
||||
}
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendApply{
|
||||
ApplyList: al,
|
||||
})
|
||||
}
|
||||
|
||||
func FriendLogBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var log []*proto.ResFriendLog
|
||||
for _, v := range FriendMod.Log {
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(v.Uid)
|
||||
if ps == nil {
|
||||
ps = &proto.ResPlayerSimple{
|
||||
Uid: int64(v.Uid),
|
||||
}
|
||||
}
|
||||
log = append(log, &proto.ResFriendLog{
|
||||
Player: ps,
|
||||
Type: int32(v.Type),
|
||||
Time: int32(v.Time),
|
||||
Param: v.Param,
|
||||
Id: int32(v.Id),
|
||||
Upvote: v.Upvote,
|
||||
})
|
||||
}
|
||||
var reply []*proto.ResFriendReply
|
||||
for _, v := range FriendMod.ReplyList {
|
||||
ps := G_GameLogicPtr.GetResSimplePlayerByUid(v.Uid)
|
||||
if ps == nil {
|
||||
ps = &proto.ResPlayerSimple{
|
||||
Uid: int64(v.Uid),
|
||||
}
|
||||
}
|
||||
reply = append(reply, &proto.ResFriendReply{
|
||||
Player: ps,
|
||||
Type: int32(v.Type),
|
||||
Param: v.Param,
|
||||
Id: int32(v.Id),
|
||||
Status: int32(v.Status),
|
||||
AddTime: v.AddTime,
|
||||
EndTime: v.EndTime,
|
||||
})
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendTimeLine{
|
||||
Log: log,
|
||||
Reply: reply,
|
||||
})
|
||||
}
|
||||
|
||||
func FriendCardBackData(p *Player) {
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
var msgList []*proto.ResFriendCard
|
||||
for _, v := range FriendMod.Card {
|
||||
m := GetCardInfoMsg(v)
|
||||
msgList = append(msgList, m)
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendCardMsg{
|
||||
MsgList: msgList,
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"server/GoUtil"
|
||||
"server/game/mod/activity"
|
||||
"server/game/mod/msg"
|
||||
)
|
||||
|
||||
func (p *Player) CatnipGrowthMsg(To, Id, Growth, FriendItems int) error {
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
FriendMgrSend(&msg.Msg{
|
||||
From: int(p.M_DwUin),
|
||||
To: To,
|
||||
Type: msg.HANDLE_TYPE_CATNIP_GROWTH,
|
||||
SendT: GoUtil.Now(),
|
||||
Extra: CatnipMsg{
|
||||
ActivityId: ActivityId,
|
||||
GameId: Id,
|
||||
Growth: Growth,
|
||||
FriendItems: FriendItems,
|
||||
},
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@ -5383,6 +5383,7 @@ func ReqCatnipInvite(player *Player, buf []byte) error {
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResCatnipInvite{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Uid: req.Uid,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@ -5435,6 +5436,7 @@ func ReqCatnipAgree(player *Player, buf []byte) error {
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResCatnipAgree{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Uid: req.Uid,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@ -5659,6 +5661,7 @@ func ReqCatnipRefuse(player *Player, buf []byte) error {
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResCatnipRefuse{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Uid: req.Uid,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -376,3 +376,10 @@ func UnitCatnip(p *Player) error {
|
||||
p.CatnipBackData()
|
||||
return nil
|
||||
}
|
||||
|
||||
func Benchmark(player *Player) {
|
||||
ChampshipMod := player.PlayMod.getChampshipMod()
|
||||
ChampshipMod.AddScore([]int{949, 941, 10})
|
||||
player.HandleInChampshipRank()
|
||||
player.HandleInUserRank()
|
||||
}
|
||||
|
||||
@ -26230,6 +26230,7 @@ type ResCatnipInvite struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code RES_CODE `protobuf:"varint,1,opt,name=Code,proto3,enum=tutorial.RES_CODE" json:"Code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
|
||||
Uid int64 `protobuf:"varint,3,opt,name=Uid,proto3" json:"Uid,omitempty"` // 好友id
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -26278,6 +26279,13 @@ func (x *ResCatnipInvite) GetMsg() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ResCatnipInvite) GetUid() int64 {
|
||||
if x != nil {
|
||||
return x.Uid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// 同意邀请
|
||||
type ReqCatnipAgree struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -26335,6 +26343,7 @@ type ResCatnipAgree struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code RES_CODE `protobuf:"varint,1,opt,name=Code,proto3,enum=tutorial.RES_CODE" json:"Code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
|
||||
Uid int64 `protobuf:"varint,3,opt,name=Uid,proto3" json:"Uid,omitempty"` // 好友id
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -26383,6 +26392,13 @@ func (x *ResCatnipAgree) GetMsg() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ResCatnipAgree) GetUid() int64 {
|
||||
if x != nil {
|
||||
return x.Uid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ReqCatnipRefuse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 游戏id
|
||||
@ -26439,6 +26455,7 @@ type ResCatnipRefuse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code RES_CODE `protobuf:"varint,1,opt,name=Code,proto3,enum=tutorial.RES_CODE" json:"Code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
|
||||
Uid int64 `protobuf:"varint,3,opt,name=Uid,proto3" json:"Uid,omitempty"` // 好友id
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -26487,6 +26504,13 @@ func (x *ResCatnipRefuse) GetMsg() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ResCatnipRefuse) GetUid() int64 {
|
||||
if x != nil {
|
||||
return x.Uid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// 设置游戏倍数
|
||||
type ReqCatnipMultiply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -29353,22 +29377,25 @@ const file_proto_Gameapi_proto_rawDesc = "" +
|
||||
"\x04Type\x18\x03 \x01(\x05R\x04Type\"3\n" +
|
||||
"\x0fReqCatnipInvite\x12\x0e\n" +
|
||||
"\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x10\n" +
|
||||
"\x03Uid\x18\x02 \x01(\x03R\x03Uid\"K\n" +
|
||||
"\x03Uid\x18\x02 \x01(\x03R\x03Uid\"]\n" +
|
||||
"\x0fResCatnipInvite\x12&\n" +
|
||||
"\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\"2\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x10\n" +
|
||||
"\x03Uid\x18\x03 \x01(\x03R\x03Uid\"2\n" +
|
||||
"\x0eReqCatnipAgree\x12\x0e\n" +
|
||||
"\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x10\n" +
|
||||
"\x03Uid\x18\x02 \x01(\x03R\x03Uid\"J\n" +
|
||||
"\x03Uid\x18\x02 \x01(\x03R\x03Uid\"\\\n" +
|
||||
"\x0eResCatnipAgree\x12&\n" +
|
||||
"\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\"3\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x10\n" +
|
||||
"\x03Uid\x18\x03 \x01(\x03R\x03Uid\"3\n" +
|
||||
"\x0fReqCatnipRefuse\x12\x0e\n" +
|
||||
"\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x10\n" +
|
||||
"\x03Uid\x18\x02 \x01(\x03R\x03Uid\"K\n" +
|
||||
"\x03Uid\x18\x02 \x01(\x03R\x03Uid\"]\n" +
|
||||
"\x0fResCatnipRefuse\x12&\n" +
|
||||
"\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\"/\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x10\n" +
|
||||
"\x03Uid\x18\x03 \x01(\x03R\x03Uid\"/\n" +
|
||||
"\x11ReqCatnipMultiply\x12\x1a\n" +
|
||||
"\bMultiply\x18\x01 \x01(\x05R\bMultiply\"M\n" +
|
||||
"\x11ResCatnipMultiply\x12&\n" +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user