mirror of Walter-Sparrow / lunar-tear
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support granting companions and parts from the shop

+66 -56
+14 -5
server/internal/questflow/handler.go
··· 59 59 } 60 60 releaseConditions[groupId] = conds 61 61 } 62 + partsById := make(map[int32]store.PartsRef, len(catalog.PartsById)) 63 + for id, p := range catalog.PartsById { 64 + partsById[id] = store.PartsRef{ 65 + PartsGroupId: p.PartsGroupId, 66 + PartsStatusMainLotteryGroupId: p.PartsStatusMainLotteryGroupId, 67 + } 68 + } 62 69 return &store.PossessionGranter{ 63 - CostumeById: costumeById, 64 - WeaponById: weaponById, 65 - WeaponSkillSlots: catalog.WeaponSkillSlots, 66 - WeaponAbilitySlots: catalog.WeaponAbilitySlots, 67 - ReleaseConditions: releaseConditions, 70 + CostumeById: costumeById, 71 + WeaponById: weaponById, 72 + WeaponSkillSlots: catalog.WeaponSkillSlots, 73 + WeaponAbilitySlots: catalog.WeaponAbilitySlots, 74 + ReleaseConditions: releaseConditions, 75 + PartsById: partsById, 76 + DefaultPartsStatusMainByLotteryGroup: catalog.DefaultPartsStatusMainByLotteryGroup, 68 77 } 69 78 }
+2 -51
server/internal/questflow/rewards.go
··· 4 4 "fmt" 5 5 "log" 6 6 7 - "github.com/google/uuid" 8 - 9 7 "lunar-tear/server/internal/gameutil" 10 8 "lunar-tear/server/internal/masterdata" 11 9 "lunar-tear/server/internal/model" ··· 262 260 } 263 261 264 262 func (h *QuestHandler) applyRewardPossession(user *store.UserState, possType model.PossessionType, possId, count int32, nowMillis int64) { 265 - switch possType { 266 - case model.PossessionTypeCompanion: 267 - h.grantCompanion(user, possId, nowMillis) 268 - case model.PossessionTypeParts: 269 - h.grantParts(user, possId, nowMillis) 270 - default: 271 - h.Granter.GrantFull(user, possType, possId, count, nowMillis) 272 - } 273 - } 274 - 275 - func (h *QuestHandler) grantCompanion(user *store.UserState, companionId int32, nowMillis int64) { 276 - for _, row := range user.Companions { 277 - if row.CompanionId == companionId { 278 - return 279 - } 280 - } 281 - key := uuid.New().String() 282 - user.Companions[key] = store.CompanionState{ 283 - UserCompanionUuid: key, 284 - CompanionId: companionId, 285 - Level: 1, 286 - HeadupDisplayViewId: 1, 287 - AcquisitionDatetime: nowMillis, 288 - } 289 - } 290 - 291 - func (h *QuestHandler) grantParts(user *store.UserState, partsId int32, nowMillis int64) { 292 - var mainStatId int32 293 - if partsDef, ok := h.PartsById[partsId]; ok { 294 - mainStatId = h.DefaultPartsStatusMainByLotteryGroup[partsDef.PartsStatusMainLotteryGroupId] 295 - 296 - if _, exists := user.PartsGroupNotes[partsDef.PartsGroupId]; !exists { 297 - user.PartsGroupNotes[partsDef.PartsGroupId] = store.PartsGroupNoteState{ 298 - PartsGroupId: partsDef.PartsGroupId, 299 - FirstAcquisitionDatetime: nowMillis, 300 - LatestVersion: nowMillis, 301 - } 302 - } 303 - } 304 - 305 - key := uuid.New().String() 306 - user.Parts[key] = store.PartsState{ 307 - UserPartsUuid: key, 308 - PartsId: partsId, 309 - Level: 1, 310 - PartsStatusMainId: mainStatId, 311 - AcquisitionDatetime: nowMillis, 312 - } 263 + h.Granter.GrantFull(user, possType, possId, count, nowMillis) 313 264 } 314 265 315 266 func (h *QuestHandler) grantWeaponStoryUnlock(user *store.UserState, weaponId, storyIndex int32, nowMillis int64) bool { ··· 338 289 log.Printf("[QuestHandler] unknown companion tutorial choiceId=%d", choiceId) 339 290 return nil 340 291 } 341 - h.grantCompanion(user, companionId, nowMillis) 292 + h.Granter.GrantCompanion(user, companionId, nowMillis) 342 293 return []RewardGrant{{ 343 294 PossessionType: model.PossessionTypeCompanion, 344 295 PossessionId: companionId,
+50
server/internal/store/helpers.go
··· 100 100 ConditionValue int32 101 101 } 102 102 103 + type PartsRef struct { 104 + PartsGroupId int32 105 + PartsStatusMainLotteryGroupId int32 106 + } 107 + 103 108 type PossessionGranter struct { 104 109 CostumeById map[int32]CostumeRef 105 110 WeaponById map[int32]WeaponRef ··· 107 112 WeaponAbilitySlots map[int32][]int32 108 113 ReleaseConditions map[int32][]WeaponStoryReleaseCond 109 114 115 + PartsById map[int32]PartsRef 116 + DefaultPartsStatusMainByLotteryGroup map[int32]int32 117 + 110 118 LastChangedStoryWeaponIds []int32 111 119 } 112 120 ··· 122 130 g.GrantCostume(user, possessionId, nowMillis) 123 131 case model.PossessionTypeWeapon, model.PossessionTypeWeaponEnhanced: 124 132 g.GrantWeapon(user, possessionId, nowMillis) 133 + case model.PossessionTypeCompanion, model.PossessionTypeCompanionEnhanced: 134 + g.GrantCompanion(user, possessionId, nowMillis) 135 + case model.PossessionTypeParts, model.PossessionTypePartsEnhanced: 136 + g.GrantParts(user, possessionId, nowMillis) 125 137 default: 126 138 GrantPossession(user, possessionType, possessionId, count) 127 139 } ··· 152 164 user.CostumeActiveSkills[key] = CostumeActiveSkillState{ 153 165 UserCostumeUuid: key, 154 166 Level: 1, 167 + AcquisitionDatetime: nowMillis, 168 + } 169 + } 170 + 171 + func (g *PossessionGranter) GrantCompanion(user *UserState, companionId int32, nowMillis int64) { 172 + for _, row := range user.Companions { 173 + if row.CompanionId == companionId { 174 + return 175 + } 176 + } 177 + key := uuid.New().String() 178 + user.Companions[key] = CompanionState{ 179 + UserCompanionUuid: key, 180 + CompanionId: companionId, 181 + Level: 1, 182 + HeadupDisplayViewId: 1, 183 + AcquisitionDatetime: nowMillis, 184 + } 185 + } 186 + 187 + func (g *PossessionGranter) GrantParts(user *UserState, partsId int32, nowMillis int64) { 188 + var mainStatId int32 189 + if ref, ok := g.PartsById[partsId]; ok { 190 + mainStatId = g.DefaultPartsStatusMainByLotteryGroup[ref.PartsStatusMainLotteryGroupId] 191 + if _, exists := user.PartsGroupNotes[ref.PartsGroupId]; !exists { 192 + user.PartsGroupNotes[ref.PartsGroupId] = PartsGroupNoteState{ 193 + PartsGroupId: ref.PartsGroupId, 194 + FirstAcquisitionDatetime: nowMillis, 195 + LatestVersion: nowMillis, 196 + } 197 + } 198 + } 199 + key := uuid.New().String() 200 + user.Parts[key] = PartsState{ 201 + UserPartsUuid: key, 202 + PartsId: partsId, 203 + Level: 1, 204 + PartsStatusMainId: mainStatId, 155 205 AcquisitionDatetime: nowMillis, 156 206 } 157 207 }