Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Marker Events #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def create_event(params)
def event_params(params)
params.require(:event).permit(
:timestamp,
marker: [:id, :alpha, :brush, :color, :shape, :text, :type, position: [:dir, :x, :y, :z], size: [:height, :width]],
player: [:name, :uid],
projectile: [:id, :side, :simulation, position: [:dir, :x, :y, :z]],
unit: [:id, :life_state, :name, :side, :vehicle_id, position: [:dir, :x, :y, :z]],
Expand Down
5 changes: 5 additions & 0 deletions app/models/events/marker_created.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Events::MarkerCreated < Event
embeds_one :marker, class_name: 'Schemas::Marker'

validates_presence_of :marker
end
5 changes: 5 additions & 0 deletions app/models/events/marker_deleted.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Events::MarkerDeleted < Event
embeds_one :marker, class_name: 'Schemas::Marker'

validates_presence_of :marker
end
5 changes: 5 additions & 0 deletions app/models/events/marker_position.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Events::MarkerPosition < Event
embeds_one :marker, class_name: 'Schemas::Marker'

validates_presence_of :marker
end
15 changes: 15 additions & 0 deletions app/models/schemas/marker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Schemas::Marker
include ArDocStore::EmbeddableModel

json_attribute :id, as: :string
json_attribute :alpha, as: :string
json_attribute :brush, as: :string
json_attribute :color, as: :string
embeds_one :position, class_name: 'Schemas::Position'
json_attribute :shape, as: :string
embeds_one :size, class_name: 'Schemas::MarkerSize'
json_attribute :text, as: :string
json_attribute :type, as: :string

validates_presence_of :id, :alpha, :brush, :color, :position, :shape, :size, :text, :type
end
8 changes: 8 additions & 0 deletions app/models/schemas/marker_size.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Schemas::MarkerSize
include ArDocStore::EmbeddableModel

json_attribute :height, as: :float
json_attribute :width, as: :float

validates_presence_of :height, :width
end
3 changes: 3 additions & 0 deletions app/serializers/events/marker_created_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Events::MarkerCreatedSerializer < EventSerializer
has_one :marker
end
3 changes: 3 additions & 0 deletions app/serializers/events/marker_deleted_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Events::MarkerDeletedSerializer < EventSerializer
has_one :marker
end
3 changes: 3 additions & 0 deletions app/serializers/events/marker_position_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Events::MarkerPositionSerializer < EventSerializer
has_one :marker
end