Skip to content

Commit

Permalink
feat: Marathon animation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakShearman committed Sep 27, 2024
1 parent 39f2d87 commit 0709c46
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module game-player-data
go 1.23

require (
github.com/emortalmc/proto-specs/gen/go v0.0.0-20240920201852-8d931ec7a9aa
github.com/emortalmc/proto-specs/gen/go v0.0.0-20240927103241-2584fd28e0f9
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/segmentio/kafka-go v0.4.39
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ github.com/emortalmc/proto-specs/gen/go v0.0.0-20240909152322-b05808d73899 h1:iz
github.com/emortalmc/proto-specs/gen/go v0.0.0-20240909152322-b05808d73899/go.mod h1:se+tHcK9FWxeadkxLF5uj+SPauEye0X+Iq6cGczXGJY=
github.com/emortalmc/proto-specs/gen/go v0.0.0-20240920201852-8d931ec7a9aa h1:twr+Yjdt3DCPnawjyEzi9ij/SXHk0IUY8i/EkVxNoew=
github.com/emortalmc/proto-specs/gen/go v0.0.0-20240920201852-8d931ec7a9aa/go.mod h1:se+tHcK9FWxeadkxLF5uj+SPauEye0X+Iq6cGczXGJY=
github.com/emortalmc/proto-specs/gen/go v0.0.0-20240927103241-2584fd28e0f9 h1:6xOnWrTvG2oJR1J6+B+tdZV5GdlbIgdQixdCCyfj4nA=
github.com/emortalmc/proto-specs/gen/go v0.0.0-20240927103241-2584fd28e0f9/go.mod h1:se+tHcK9FWxeadkxLF5uj+SPauEye0X+Iq6cGczXGJY=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down
3 changes: 3 additions & 0 deletions internal/kafka/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,14 @@ func (c *consumer) handleMarathonUpdate(ctx context.Context, pId uuid.UUID, msg
gameData.BlockPalette = msgData.BlockPalette
case "time":
gameData.Time = msgData.Time
case "animation":
gameData.Animation = *msgData.Animation
}
}

return c.repos.Marathon.Save(ctx, gameData)
}

func (c *consumer) handleBlockSumoUpdate(ctx context.Context, pId uuid.UUID, msg *pbmsg.UpdateGamePlayerDataMessage) error {
gameData, err := c.repos.BlockSumo.GetOrDefault(ctx, pId, &model.BlockSumoData{BaseGameData: model.BaseGameData{PlayerId: pId}})
if err != nil {
Expand Down
18 changes: 10 additions & 8 deletions internal/repository/model/model.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package model

import (
"game-player-data/internal/utils"
"github.com/emortalmc/proto-specs/gen/go/model/gameplayerdata"
"github.com/google/uuid"
"google.golang.org/protobuf/types/known/anypb"
Expand Down Expand Up @@ -33,24 +34,25 @@ func (d *BlockSumoData) ToAnyProto() (*anypb.Any, error) {
})
}

func (d *BlockSumoData) FromProto(pId uuid.UUID, data *gameplayerdata.V1BlockSumoPlayerData) {
d.PlayerId = pId
d.BlockSlot = data.BlockSlot
d.ShearsSlot = data.ShearsSlot
}

type MarathonData struct {
BaseGameData `bson:",inline"`

Time string
BlockPalette string
Animation string `bson:",omitempty"`
}

func (d *MarathonData) ToAnyProto() (*anypb.Any, error) {
return anypb.New(&gameplayerdata.V1MarathonData{
pb := &gameplayerdata.V1MarathonData{
Time: d.Time,
BlockPalette: d.BlockPalette,
})
}

if d.Animation != "" {
pb.Animation = utils.PointerOf(d.Animation)
}

return anypb.New(pb)
}

// MinesweeperData TODO
Expand Down

0 comments on commit 0709c46

Please sign in to comment.