mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 23:44:52 +01:00
add support for Festa Trial voting
This commit is contained in:
5
patch-schema/13-festa-trial-votes.sql
Normal file
5
patch-schema/13-festa-trial-votes.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.guild_characters ADD COLUMN trial_vote integer;
|
||||||
|
|
||||||
|
END;
|
||||||
@@ -96,7 +96,7 @@ func cleanupFesta(s *Session) {
|
|||||||
s.server.db.Exec("DELETE FROM events WHERE event_type='festa'")
|
s.server.db.Exec("DELETE FROM events WHERE event_type='festa'")
|
||||||
s.server.db.Exec("DELETE FROM festa_registrations")
|
s.server.db.Exec("DELETE FROM festa_registrations")
|
||||||
s.server.db.Exec("DELETE FROM festa_prizes_accepted")
|
s.server.db.Exec("DELETE FROM festa_prizes_accepted")
|
||||||
s.server.db.Exec("UPDATE guild_characters SET souls=0")
|
s.server.db.Exec("UPDATE guild_characters SET souls=0, trial_vote=NULL")
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateFestaTimestamps(s *Session, start uint32, debug bool) []uint32 {
|
func generateFestaTimestamps(s *Session, start uint32, debug bool) []uint32 {
|
||||||
@@ -147,7 +147,7 @@ type FestaTrial struct {
|
|||||||
TimesReq uint16 `db:"times_req"`
|
TimesReq uint16 `db:"times_req"`
|
||||||
Locale uint16 `db:"locale_req"`
|
Locale uint16 `db:"locale_req"`
|
||||||
Reward uint16 `db:"reward"`
|
Reward uint16 `db:"reward"`
|
||||||
Monopoly uint16
|
Monopoly FestivalColour `db:"monopoly"`
|
||||||
Unk uint16
|
Unk uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +205,19 @@ func handleMsgMhfInfoFesta(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
var trials []FestaTrial
|
var trials []FestaTrial
|
||||||
var trial FestaTrial
|
var trial FestaTrial
|
||||||
rows, _ = s.server.db.Queryx("SELECT * FROM festa_trials")
|
rows, _ = s.server.db.Queryx(`SELECT ft.*,
|
||||||
|
COALESCE(CASE
|
||||||
|
WHEN COUNT(gc.id) FILTER (WHERE fr.team = 'blue' AND gc.trial_vote = ft.id) >
|
||||||
|
COUNT(gc.id) FILTER (WHERE fr.team = 'red' AND gc.trial_vote = ft.id)
|
||||||
|
THEN CAST('blue' AS public.festival_colour)
|
||||||
|
WHEN COUNT(gc.id) FILTER (WHERE fr.team = 'red' AND gc.trial_vote = ft.id) >
|
||||||
|
COUNT(gc.id) FILTER (WHERE fr.team = 'blue' AND gc.trial_vote = ft.id)
|
||||||
|
THEN CAST('red' AS public.festival_colour)
|
||||||
|
END, CAST('none' AS public.festival_colour)) AS monopoly
|
||||||
|
FROM public.festa_trials ft
|
||||||
|
LEFT JOIN public.guild_characters gc ON ft.id = gc.trial_vote
|
||||||
|
LEFT JOIN public.festa_registrations fr ON gc.guild_id = fr.guild_id
|
||||||
|
GROUP BY ft.id`)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err := rows.StructScan(&trial)
|
err := rows.StructScan(&trial)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -221,8 +233,7 @@ func handleMsgMhfInfoFesta(s *Session, 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)
|
||||||
trial.Monopoly = 0xFFFF // NYI
|
bf.WriteInt16(int16(FestivalColourCodes[trial.Monopoly]))
|
||||||
bf.WriteUint16(trial.Monopoly)
|
|
||||||
bf.WriteUint16(trial.Unk)
|
bf.WriteUint16(trial.Unk)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,6 +406,7 @@ func handleMsgMhfEnumerateFestaMember(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
func handleMsgMhfVoteFesta(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfVoteFesta(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfVoteFesta)
|
pkt := p.(*mhfpacket.MsgMhfVoteFesta)
|
||||||
|
s.server.db.Exec(`UPDATE guild_characters SET trial_vote=$1 WHERE character_id=$2`, pkt.TrialID, s.charID)
|
||||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ type FestivalColour string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
FestivalColourNone FestivalColour = "none"
|
FestivalColourNone FestivalColour = "none"
|
||||||
FestivalColourRed FestivalColour = "red"
|
|
||||||
FestivalColourBlue FestivalColour = "blue"
|
FestivalColourBlue FestivalColour = "blue"
|
||||||
|
FestivalColourRed FestivalColour = "red"
|
||||||
)
|
)
|
||||||
|
|
||||||
var FestivalColourCodes = map[FestivalColour]uint8{
|
var FestivalColourCodes = map[FestivalColour]int8{
|
||||||
FestivalColourBlue: 0x00,
|
FestivalColourNone: -1,
|
||||||
FestivalColourRed: 0x01,
|
FestivalColourBlue: 0,
|
||||||
FestivalColourNone: 0xFF,
|
FestivalColourRed: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
type GuildApplicationType string
|
type GuildApplicationType string
|
||||||
@@ -967,7 +967,7 @@ func handleMsgMhfInfoGuild(s *Session, 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.WriteUint8(FestivalColourCodes[guild.FestivalColour])
|
bf.WriteInt8(FestivalColourCodes[guild.FestivalColour])
|
||||||
bf.WriteUint32(guild.RankRP)
|
bf.WriteUint32(guild.RankRP)
|
||||||
bf.WriteBytes(guildLeaderName)
|
bf.WriteBytes(guildLeaderName)
|
||||||
bf.WriteUint32(0) // Unk
|
bf.WriteUint32(0) // Unk
|
||||||
|
|||||||
Reference in New Issue
Block a user