Skip to content

Commit

Permalink
all: Added the ability to update towers
Browse files Browse the repository at this point in the history
Now towers can be updated thwough an interface
  • Loading branch information
xescugc committed Apr 30, 2024
1 parent a8db88f commit bd35a1d
Show file tree
Hide file tree
Showing 15 changed files with 680 additions and 215 deletions.
41 changes: 29 additions & 12 deletions action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package action
import (
"time"

"github.com/xescugc/maze-wars/tower"
"github.com/xescugc/maze-wars/unit"
"github.com/xescugc/maze-wars/utils"
"github.com/xescugc/maze-wars/utils/graph"
Expand All @@ -18,6 +19,7 @@ type Action struct {
RemoveUnit *RemoveUnitPayload `json:"remove_unit,omitempty"`
ChangeUnitLine *ChangeUnitLinePayload `json:"change_unit_line,omitempty"`
UpdateUnit *UpdateUnitPayload `json:"update_unit,omitempty"`
UpdateTower *UpdateTowerPayload `json:"update_tower,omitempty"`
StealLive *StealLivePayload `json:"steal_live,omitempty"`
CameraZoom *CameraZoomPayload `json:"camera_zoom,omitempty"`
SelectTower *SelectTowerPayload `json:"select_tower,omitempty"`
Expand Down Expand Up @@ -170,18 +172,16 @@ func NewPlaceTower(t, pid string, x, y int) *Action {
}

type RemoveTowerPayload struct {
PlayerID string
TowerID string
TowerType string
PlayerID string
TowerID string
}

func NewRemoveTower(pid, tid, tt string) *Action {
func NewRemoveTower(pid, tid string) *Action {
return &Action{
Type: RemoveTower,
RemoveTower: &RemoveTowerPayload{
PlayerID: pid,
TowerID: tid,
TowerType: tt,
PlayerID: pid,
TowerID: tid,
},
}
}
Expand Down Expand Up @@ -235,16 +235,16 @@ func NewWaitRoomCountdownTick() *Action {
}

type TowerAttackPayload struct {
TowerType string
UnitID string
TowerID string
UnitID string
}

func NewTowerAttack(uid, tt string) *Action {
func NewTowerAttack(uid, tid string) *Action {
return &Action{
Type: TowerAttack,
TowerAttack: &TowerAttackPayload{
UnitID: uid,
TowerType: tt,
UnitID: uid,
TowerID: tid,
},
}
}
Expand Down Expand Up @@ -518,6 +518,8 @@ type SyncStateTowerPayload struct {
Type string
LineID int
PlayerID string
Stats tower.Stats
Level int
}

type SyncStateUnitPayload struct {
Expand Down Expand Up @@ -589,3 +591,18 @@ func NewUpdateUnit(pid, t string) *Action {
},
}
}

type UpdateTowerPayload struct {
TowerID string
PlayerID string
}

func NewUpdateTower(pid, tid string) *Action {
return &Action{
Type: UpdateTower,
UpdateTower: &UpdateTowerPayload{
TowerID: tid,
PlayerID: pid,
},
}
}
1 change: 1 addition & 0 deletions action/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
CameraZoom
SummonUnit
UpdateUnit
UpdateTower
TPS
RemoveUnit
StealLive
Expand Down
Loading

0 comments on commit bd35a1d

Please sign in to comment.