Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ type Insert interface {
}

type Turn interface {
// Returns a list of TargetIDs sorted by their AV
TurnOrder() []key.TargetID

// Returns the ID of the target that is active/is taking the turn
GetActiveTarget() key.TargetID

// Sets the gauge for the given target. The amount is specified in gauge units (base = 10,000)
SetGauge(data info.ModifyAttribute) error

Expand Down
5 changes: 5 additions & 0 deletions pkg/engine/turn/turn.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func (mgr *manager) TurnOrder() []key.TargetID {
return targetOrder
}

// GetActiveTarget returns the ID of the target that is active/is taking the turn from the Manager.
func (mgr *manager) GetActiveTarget() key.TargetID {
return mgr.activeTarget
}

// EventTurnStatus returns an array of event.TurnStatus structs populated with the current ID, Gauge, and AV of each target in the Manager's turnOrder.
func (mgr *manager) EventTurnStatus() []event.TurnStatus {
turnStatus := make([]event.TurnStatus, mgr.orderHandler.Len())
Expand Down
8 changes: 8 additions & 0 deletions pkg/simulation/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ func (sim *Simulation) ModifyEnergyFixed(data info.ModifyAttribute) error {
return sim.Attr.ModifyEnergyFixed(data)
}

func (sim *Simulation) TurnOrder() []key.TargetID {
return sim.Turn.TurnOrder()
}

func (sim *Simulation) GetActiveTarget() key.TargetID {
return sim.Turn.GetActiveTarget()
}

func (sim *Simulation) SetGauge(data info.ModifyAttribute) error {
sim.ActionTargets[data.Target] = true
return sim.Turn.SetGauge(data)
Expand Down
28 changes: 28 additions & 0 deletions tests/mock/mock_engine.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions tests/teststub/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
type mockTurnManager struct {
t *testing.T
turnSequence []key.TargetID
activeTarget key.TargetID
}

type TurnCommand struct {
Expand All @@ -22,6 +23,7 @@ func newMockManager(t *testing.T) *mockTurnManager {
return &mockTurnManager{
t: t,
turnSequence: nil,
activeTarget: 0,
}
}

Expand Down Expand Up @@ -51,6 +53,7 @@ func (m *mockTurnManager) StartTurn() (key.TargetID, float64, []event.TurnStatus
return 1, 100000, nil, nil
}
tgt := m.turnSequence[0]
m.activeTarget = tgt
m.turnSequence = m.turnSequence[1:]
return tgt, 0, nil, nil
}
Expand All @@ -63,6 +66,10 @@ func (m *mockTurnManager) ResetTurn() error {
return nil
}

func (m *mockTurnManager) GetActiveTarget() key.TargetID {
return m.activeTarget
}

func (m *mockTurnManager) SetGauge(data info.ModifyAttribute) error {
return nil
}
Expand Down