mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +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 festa_registrations")
|
||||
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 {
|
||||
@@ -141,13 +141,13 @@ func generateFestaTimestamps(s *Session, start uint32, debug bool) []uint32 {
|
||||
}
|
||||
|
||||
type FestaTrial struct {
|
||||
ID uint32 `db:"id"`
|
||||
Objective uint16 `db:"objective"`
|
||||
GoalID uint32 `db:"goal_id"`
|
||||
TimesReq uint16 `db:"times_req"`
|
||||
Locale uint16 `db:"locale_req"`
|
||||
Reward uint16 `db:"reward"`
|
||||
Monopoly uint16
|
||||
ID uint32 `db:"id"`
|
||||
Objective uint16 `db:"objective"`
|
||||
GoalID uint32 `db:"goal_id"`
|
||||
TimesReq uint16 `db:"times_req"`
|
||||
Locale uint16 `db:"locale_req"`
|
||||
Reward uint16 `db:"reward"`
|
||||
Monopoly FestivalColour `db:"monopoly"`
|
||||
Unk uint16
|
||||
}
|
||||
|
||||
@@ -205,7 +205,19 @@ func handleMsgMhfInfoFesta(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
var trials []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() {
|
||||
err := rows.StructScan(&trial)
|
||||
if err != nil {
|
||||
@@ -221,8 +233,7 @@ func handleMsgMhfInfoFesta(s *Session, p mhfpacket.MHFPacket) {
|
||||
bf.WriteUint16(trial.TimesReq)
|
||||
bf.WriteUint16(trial.Locale)
|
||||
bf.WriteUint16(trial.Reward)
|
||||
trial.Monopoly = 0xFFFF // NYI
|
||||
bf.WriteUint16(trial.Monopoly)
|
||||
bf.WriteInt16(int16(FestivalColourCodes[trial.Monopoly]))
|
||||
bf.WriteUint16(trial.Unk)
|
||||
}
|
||||
|
||||
@@ -395,6 +406,7 @@ func handleMsgMhfEnumerateFestaMember(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
func handleMsgMhfVoteFesta(s *Session, p mhfpacket.MHFPacket) {
|
||||
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))
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ type FestivalColour string
|
||||
|
||||
const (
|
||||
FestivalColourNone FestivalColour = "none"
|
||||
FestivalColourRed FestivalColour = "red"
|
||||
FestivalColourBlue FestivalColour = "blue"
|
||||
FestivalColourRed FestivalColour = "red"
|
||||
)
|
||||
|
||||
var FestivalColourCodes = map[FestivalColour]uint8{
|
||||
FestivalColourBlue: 0x00,
|
||||
FestivalColourRed: 0x01,
|
||||
FestivalColourNone: 0xFF,
|
||||
var FestivalColourCodes = map[FestivalColour]int8{
|
||||
FestivalColourNone: -1,
|
||||
FestivalColourBlue: 0,
|
||||
FestivalColourRed: 1,
|
||||
}
|
||||
|
||||
type GuildApplicationType string
|
||||
@@ -967,7 +967,7 @@ func handleMsgMhfInfoGuild(s *Session, p mhfpacket.MHFPacket) {
|
||||
bf.WriteUint8(uint8(len(guildLeaderName)))
|
||||
bf.WriteBytes(guildName)
|
||||
bf.WriteBytes(guildComment)
|
||||
bf.WriteUint8(FestivalColourCodes[guild.FestivalColour])
|
||||
bf.WriteInt8(FestivalColourCodes[guild.FestivalColour])
|
||||
bf.WriteUint32(guild.RankRP)
|
||||
bf.WriteBytes(guildLeaderName)
|
||||
bf.WriteUint32(0) // Unk
|
||||
|
||||
Reference in New Issue
Block a user