mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 07:55:33 +01:00
add exchanged tkts to warehouse gift box
This commit is contained in:
@@ -697,11 +697,19 @@ func handleMsgMhfCheckWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfExchangeWeeklyStamp)
|
pkt := p.(*mhfpacket.MsgMhfExchangeWeeklyStamp)
|
||||||
var total, redeemed uint16
|
var total, redeemed uint16
|
||||||
|
var tktStack mhfpacket.WarehouseStack
|
||||||
if pkt.Unk1 == 0xA { // Yearly Sub Ex
|
if pkt.Unk1 == 0xA { // Yearly Sub Ex
|
||||||
s.server.db.QueryRow("UPDATE stamps SET hl_total=hl_total-48, hl_redeemed=hl_redeemed-48 WHERE character_id=$1 RETURNING hl_total, hl_redeemed", s.charID).Scan(&total, &redeemed)
|
s.server.db.QueryRow("UPDATE stamps SET hl_total=hl_total-48, hl_redeemed=hl_redeemed-48 WHERE character_id=$1 RETURNING hl_total, hl_redeemed", s.charID).Scan(&total, &redeemed)
|
||||||
|
tktStack = mhfpacket.WarehouseStack{ItemID: 0x08A2, Quantity: 1}
|
||||||
} else {
|
} else {
|
||||||
s.server.db.QueryRow(fmt.Sprintf("UPDATE stamps SET %s_redeemed=%s_redeemed+8 WHERE character_id=$1 RETURNING %s_total, %s_redeemed", pkt.StampType, pkt.StampType, pkt.StampType, pkt.StampType), s.charID).Scan(&total, &redeemed)
|
s.server.db.QueryRow(fmt.Sprintf("UPDATE stamps SET %s_redeemed=%s_redeemed+8 WHERE character_id=$1 RETURNING %s_total, %s_redeemed", pkt.StampType, pkt.StampType, pkt.StampType, pkt.StampType), s.charID).Scan(&total, &redeemed)
|
||||||
|
if pkt.StampType == "hl" {
|
||||||
|
tktStack = mhfpacket.WarehouseStack{ItemID: 0x065E, Quantity: 5}
|
||||||
|
} else {
|
||||||
|
tktStack = mhfpacket.WarehouseStack{ItemID: 0x065F, Quantity: 5}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
addWarehouseGift(s, "item", tktStack)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
bf.WriteUint16(total)
|
bf.WriteUint16(total)
|
||||||
bf.WriteUint16(redeemed)
|
bf.WriteUint16(redeemed)
|
||||||
|
|||||||
@@ -426,6 +426,26 @@ func handleMsgMhfOperateWarehouse(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addWarehouseGift(s *Session, boxType string, giftStack mhfpacket.WarehouseStack) {
|
||||||
|
giftBox := getWarehouseBox(s, boxType, 10)
|
||||||
|
if boxType == "item" {
|
||||||
|
exists := false
|
||||||
|
for i, stack := range giftBox {
|
||||||
|
if stack.ItemID == giftStack.ItemID {
|
||||||
|
exists = true
|
||||||
|
giftBox[i].Quantity += giftStack.Quantity
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if exists == false {
|
||||||
|
giftBox = append(giftBox, giftStack)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
giftBox = append(giftBox, giftStack)
|
||||||
|
}
|
||||||
|
s.server.db.Exec(fmt.Sprintf("UPDATE warehouse SET %s10=$1 WHERE character_id=$2", boxType), boxToBytes(giftBox, boxType), s.charID)
|
||||||
|
}
|
||||||
|
|
||||||
func getWarehouseBox(s *Session, boxType string, boxIndex uint8) []mhfpacket.WarehouseStack {
|
func getWarehouseBox(s *Session, boxType string, boxIndex uint8) []mhfpacket.WarehouseStack {
|
||||||
var data []byte
|
var data []byte
|
||||||
s.server.db.QueryRow(fmt.Sprintf("SELECT %s%d FROM warehouse WHERE character_id=$1", boxType, boxIndex), s.charID).Scan(&data)
|
s.server.db.QueryRow(fmt.Sprintf("SELECT %s%d FROM warehouse WHERE character_id=$1", boxType, boxIndex), s.charID).Scan(&data)
|
||||||
|
|||||||
Reference in New Issue
Block a user