You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
757 B
21 lines
757 B
3 years ago
|
package action
|
||
3 years ago
|
|
||
|
import (
|
||
|
"errors"
|
||
3 years ago
|
"go.uber.org/zap/zapcore"
|
||
3 years ago
|
"hexmap-server/state"
|
||
|
)
|
||
|
|
||
3 years ago
|
var ErrNoOp error = errors.New("action's effects were already applied, or it's an empty action")
|
||
3 years ago
|
|
||
3 years ago
|
// Syncable is the interface for action that can be shared.
|
||
|
type Syncable interface {
|
||
|
zapcore.ObjectMarshaler
|
||
3 years ago
|
// Apply causes the action's effects to be applied to s, mutating it in place.
|
||
|
// All syncable.Actions must conform to the standard that if an action can't be correctly applied, or if it would
|
||
|
// have no effect, it returns an error without changing s.
|
||
3 years ago
|
// If an action can be correctly applied but would have no effect, it should return ErrNoOp.
|
||
3 years ago
|
// If an action is correctly applied and has an effect, it should return nil.
|
||
|
Apply(s *state.Synced) error
|
||
|
}
|