mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 16:04:38 +01:00
Add more constants to central place
This commit is contained in:
15
internal/constant/festa.go
Normal file
15
internal/constant/festa.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
import "erupe-ce/internal/model"
|
||||||
|
|
||||||
|
const (
|
||||||
|
FestivalColorNone model.FestivalColor = "none"
|
||||||
|
FestivalColorBlue model.FestivalColor = "blue"
|
||||||
|
FestivalColorRed model.FestivalColor = "red"
|
||||||
|
)
|
||||||
|
|
||||||
|
var FestivalColorCodes = map[model.FestivalColor]int16{
|
||||||
|
FestivalColorNone: -1,
|
||||||
|
FestivalColorBlue: 0,
|
||||||
|
FestivalColorRed: 1,
|
||||||
|
}
|
||||||
8
internal/constant/guild.go
Normal file
8
internal/constant/guild.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
import "erupe-ce/internal/model"
|
||||||
|
|
||||||
|
const (
|
||||||
|
GuildApplicationTypeApplied model.GuildApplicationType = "applied"
|
||||||
|
GuildApplicationTypeInvited model.GuildApplicationType = "invited"
|
||||||
|
)
|
||||||
@@ -2,7 +2,9 @@ package channelserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"erupe-ce/config"
|
"erupe-ce/config"
|
||||||
|
"erupe-ce/internal/constant"
|
||||||
"erupe-ce/internal/model"
|
"erupe-ce/internal/model"
|
||||||
|
|
||||||
"erupe-ce/network/mhfpacket"
|
"erupe-ce/network/mhfpacket"
|
||||||
"erupe-ce/utils/byteframe"
|
"erupe-ce/utils/byteframe"
|
||||||
"erupe-ce/utils/db"
|
"erupe-ce/utils/db"
|
||||||
@@ -229,7 +231,7 @@ func handleMsgMhfInfoFesta(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
|
|||||||
bf.WriteUint16(trial.TimesReq)
|
bf.WriteUint16(trial.TimesReq)
|
||||||
bf.WriteUint16(trial.Locale)
|
bf.WriteUint16(trial.Locale)
|
||||||
bf.WriteUint16(trial.Reward)
|
bf.WriteUint16(trial.Reward)
|
||||||
bf.WriteInt16(FestivalColorCodes[trial.Monopoly])
|
bf.WriteInt16(constant.FestivalColorCodes[trial.Monopoly])
|
||||||
if config.GetConfig().ClientID >= config.F4 { // Not in S6.0
|
if config.GetConfig().ClientID >= config.F4 { // Not in S6.0
|
||||||
bf.WriteUint16(trial.Unk)
|
bf.WriteUint16(trial.Unk)
|
||||||
}
|
}
|
||||||
@@ -294,7 +296,7 @@ func handleMsgMhfInfoFesta(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
|
|||||||
for i := uint16(0); i < 4; i++ {
|
for i := uint16(0); i < 4; i++ {
|
||||||
var guildID uint32
|
var guildID uint32
|
||||||
var guildName string
|
var guildName string
|
||||||
var guildTeam = FestivalColorNone
|
var guildTeam = constant.FestivalColorNone
|
||||||
db.QueryRow(`
|
db.QueryRow(`
|
||||||
SELECT fs.guild_id, g.name, fr.team, SUM(fs.souls) as _
|
SELECT fs.guild_id, g.name, fr.team, SUM(fs.souls) as _
|
||||||
FROM festa_submissions fs
|
FROM festa_submissions fs
|
||||||
@@ -306,14 +308,14 @@ func handleMsgMhfInfoFesta(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
|
|||||||
`, i+1).Scan(&guildID, &guildName, &guildTeam, &temp)
|
`, i+1).Scan(&guildID, &guildName, &guildTeam, &temp)
|
||||||
bf.WriteUint32(guildID)
|
bf.WriteUint32(guildID)
|
||||||
bf.WriteUint16(i + 1)
|
bf.WriteUint16(i + 1)
|
||||||
bf.WriteInt16(FestivalColorCodes[guildTeam])
|
bf.WriteInt16(constant.FestivalColorCodes[guildTeam])
|
||||||
ps.Uint8(bf, guildName, true)
|
ps.Uint8(bf, guildName, true)
|
||||||
}
|
}
|
||||||
bf.WriteUint16(7)
|
bf.WriteUint16(7)
|
||||||
for i := uint16(0); i < 7; i++ {
|
for i := uint16(0); i < 7; i++ {
|
||||||
var guildID uint32
|
var guildID uint32
|
||||||
var guildName string
|
var guildName string
|
||||||
var guildTeam = FestivalColorNone
|
var guildTeam = constant.FestivalColorNone
|
||||||
offset := 86400 * uint32(i)
|
offset := 86400 * uint32(i)
|
||||||
db.QueryRow(`
|
db.QueryRow(`
|
||||||
SELECT fs.guild_id, g.name, fr.team, SUM(fs.souls) as _
|
SELECT fs.guild_id, g.name, fr.team, SUM(fs.souls) as _
|
||||||
@@ -326,7 +328,7 @@ func handleMsgMhfInfoFesta(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
|
|||||||
`, timestamps[1]+offset, timestamps[1]+offset+86400).Scan(&guildID, &guildName, &guildTeam, &temp)
|
`, timestamps[1]+offset, timestamps[1]+offset+86400).Scan(&guildID, &guildName, &guildTeam, &temp)
|
||||||
bf.WriteUint32(guildID)
|
bf.WriteUint32(guildID)
|
||||||
bf.WriteUint16(i + 1)
|
bf.WriteUint16(i + 1)
|
||||||
bf.WriteInt16(FestivalColorCodes[guildTeam])
|
bf.WriteInt16(constant.FestivalColorCodes[guildTeam])
|
||||||
ps.Uint8(bf, guildName, true)
|
ps.Uint8(bf, guildName, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"erupe-ce/config"
|
"erupe-ce/config"
|
||||||
|
"erupe-ce/internal/constant"
|
||||||
"erupe-ce/internal/model"
|
"erupe-ce/internal/model"
|
||||||
"erupe-ce/internal/service"
|
"erupe-ce/internal/service"
|
||||||
|
|
||||||
@@ -60,23 +61,6 @@ type GuildIcon struct {
|
|||||||
Parts []model.GuildIconPart
|
Parts []model.GuildIconPart
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
FestivalColorNone model.FestivalColor = "none"
|
|
||||||
FestivalColorBlue model.FestivalColor = "blue"
|
|
||||||
FestivalColorRed model.FestivalColor = "red"
|
|
||||||
)
|
|
||||||
|
|
||||||
var FestivalColorCodes = map[model.FestivalColor]int16{
|
|
||||||
FestivalColorNone: -1,
|
|
||||||
FestivalColorBlue: 0,
|
|
||||||
FestivalColorRed: 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
GuildApplicationTypeApplied model.GuildApplicationType = "applied"
|
|
||||||
GuildApplicationTypeInvited model.GuildApplicationType = "invited"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (gi *GuildIcon) Scan(val interface{}) (err error) {
|
func (gi *GuildIcon) Scan(val interface{}) (err error) {
|
||||||
switch v := val.(type) {
|
switch v := val.(type) {
|
||||||
case []byte:
|
case []byte:
|
||||||
@@ -709,7 +693,7 @@ func HandleMsgMhfOperateGuild(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
|
|||||||
guild.Save(s)
|
guild.Save(s)
|
||||||
}
|
}
|
||||||
case mhfpacket.OperateGuildApply:
|
case mhfpacket.OperateGuildApply:
|
||||||
err = guild.CreateApplication(s, s.CharID, GuildApplicationTypeApplied, nil)
|
err = guild.CreateApplication(s, s.CharID, constant.GuildApplicationTypeApplied, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
bf.WriteUint32(guild.LeaderCharID)
|
bf.WriteUint32(guild.LeaderCharID)
|
||||||
} else {
|
} else {
|
||||||
@@ -1019,7 +1003,7 @@ func HandleMsgMhfInfoGuild(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
|
|||||||
bf.WriteUint8(uint8(len(guildLeaderName)))
|
bf.WriteUint8(uint8(len(guildLeaderName)))
|
||||||
bf.WriteBytes(guildName)
|
bf.WriteBytes(guildName)
|
||||||
bf.WriteBytes(guildComment)
|
bf.WriteBytes(guildComment)
|
||||||
bf.WriteInt8(int8(FestivalColorCodes[guild.FestivalColor]))
|
bf.WriteInt8(int8(constant.FestivalColorCodes[guild.FestivalColor]))
|
||||||
bf.WriteUint32(guild.RankRP)
|
bf.WriteUint32(guild.RankRP)
|
||||||
bf.WriteBytes(guildLeaderName)
|
bf.WriteBytes(guildLeaderName)
|
||||||
bf.WriteUint32(0) // Unk
|
bf.WriteUint32(0) // Unk
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package channelserver
|
package channelserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"erupe-ce/internal/constant"
|
||||||
"erupe-ce/internal/service"
|
"erupe-ce/internal/service"
|
||||||
|
|
||||||
"erupe-ce/network/mhfpacket"
|
"erupe-ce/network/mhfpacket"
|
||||||
"erupe-ce/utils/byteframe"
|
"erupe-ce/utils/byteframe"
|
||||||
"erupe-ce/utils/gametime"
|
"erupe-ce/utils/gametime"
|
||||||
@@ -53,7 +55,7 @@ func HandleMsgMhfPostGuildScout(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = guildInfo.CreateApplication(s, pkt.CharID, GuildApplicationTypeInvited, transaction)
|
err = guildInfo.CreateApplication(s, pkt.CharID, constant.GuildApplicationTypeInvited, transaction)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rollbackTransaction(s, transaction)
|
rollbackTransaction(s, transaction)
|
||||||
@@ -130,7 +132,7 @@ func HandleMsgMhfAnswerGuildScout(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
app, err := guild.GetApplicationForCharID(s, s.CharID, GuildApplicationTypeInvited)
|
app, err := guild.GetApplicationForCharID(s, s.CharID, constant.GuildApplicationTypeInvited)
|
||||||
|
|
||||||
if app == nil || err != nil {
|
if app == nil || err != nil {
|
||||||
s.Logger.Warn(
|
s.Logger.Warn(
|
||||||
|
|||||||
Reference in New Issue
Block a user