add places operations

This commit is contained in:
2026-07-14 01:25:57 +07:00
parent 2b11c49b3c
commit 7a657926f1
12 changed files with 502 additions and 175 deletions
+59
View File
@@ -1,6 +1,7 @@
package app
import (
"evening_detective_server/internal/modules/formatter_utils"
"evening_detective_server/internal/modules/storytelling"
"evening_detective_server/internal/services/scenarios_service"
proto "evening_detective_server/proto"
@@ -105,3 +106,61 @@ func mapKey(o *storytelling.Key) *proto.Key {
Name: o.Name,
}
}
func convertPlace(o *proto.Place) *storytelling.Place {
return &storytelling.Place{
Code: o.Code,
Name: formatter_utils.FormatString(o.Name),
Text: formatter_utils.FormatText(o.Text),
Image: o.Image,
Hidden: o.Hidden,
Applications: convertApplications(o.Applications),
Doors: convertDoors(o.Doors),
Keys: convertKeys(o.Keys),
}
}
func convertApplications(o []*proto.Application) []*storytelling.Application {
res := make([]*storytelling.Application, 0, len(o))
for _, item := range o {
res = append(res, convertApplication(item))
}
return res
}
func convertDoors(o []*proto.Door) []*storytelling.Door {
res := make([]*storytelling.Door, 0, len(o))
for _, item := range o {
res = append(res, convertDoor(item))
}
return res
}
func convertKeys(o []*proto.Key) []*storytelling.Key {
res := make([]*storytelling.Key, 0, len(o))
for _, item := range o {
res = append(res, convertKey(item))
}
return res
}
func convertApplication(o *proto.Application) *storytelling.Application {
return &storytelling.Application{
Name: formatter_utils.FormatString(o.Name),
Image: o.Image,
}
}
func convertDoor(o *proto.Door) *storytelling.Door {
return &storytelling.Door{
Code: o.Code,
Name: formatter_utils.FormatString(o.Name),
Keys: convertKeys(o.Keys),
}
}
func convertKey(o *proto.Key) *storytelling.Key {
return &storytelling.Key{
Name: formatter_utils.FormatString(o.Name),
}
}