|
|
@ -6,11 +6,21 @@ import ( |
|
|
|
"hexmap-server/state" |
|
|
|
"hexmap-server/state" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var ErrNoOp error = errors.New("action's effects were already applied, or it's an empty action") |
|
|
|
var ( |
|
|
|
|
|
|
|
// ErrNoOp is returned when an action has no effect.
|
|
|
|
|
|
|
|
ErrNoOp = errors.New("action's effects were already applied, or it's an empty action") |
|
|
|
|
|
|
|
// ErrNoTransparentColors is returned when a user tries to set their active color or a cell color to transparent.
|
|
|
|
|
|
|
|
// Transparent here is defined as having an alpha component of less than 15 (0xF).
|
|
|
|
|
|
|
|
ErrNoTransparentColors = errors.New("transparent colors not allowed") |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type SyncableType string |
|
|
|
|
|
|
|
|
|
|
|
// Syncable is the interface for action that can be shared.
|
|
|
|
// Syncable is the interface for actions that can be shared between clients.
|
|
|
|
type Syncable interface { |
|
|
|
type Syncable interface { |
|
|
|
zapcore.ObjectMarshaler |
|
|
|
zapcore.ObjectMarshaler |
|
|
|
|
|
|
|
// Type gives the Javascript type that is sent over the wire.
|
|
|
|
|
|
|
|
Type() SyncableType |
|
|
|
// Apply causes the action's effects to be applied to s, mutating it in place.
|
|
|
|
// 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
|
|
|
|
// 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.
|
|
|
|
// have no effect, it returns an error without changing s.
|
|
|
@ -18,3 +28,4 @@ type Syncable interface { |
|
|
|
// If an action is correctly applied and has an effect, it should return nil.
|
|
|
|
// If an action is correctly applied and has an effect, it should return nil.
|
|
|
|
Apply(s *state.Synced) error |
|
|
|
Apply(s *state.Synced) error |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
type SyncableProducer func() |
|
|
|