-
-
Save paegun/8d5950f7c0c523669c8b to your computer and use it in GitHub Desktop.
Naughty Beginnings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Viewport | |
def initialize(opts = {}) | |
@elements = {} | |
end | |
def add(element) | |
element.send(:viewport=, self) | |
elements[element.id] = element | |
end | |
def remove(element) | |
elements.delete(element.id) | |
end | |
private | |
attr_accessor :elements | |
end | |
class ViewportElement | |
attr_reader :viewport, :id | |
attr_accessor :type, :x, :y, :z, :height, :width, :depth | |
def initialize(opts = {}) | |
@type = opts[:type] | |
@id = "#{type}#{next_id}" | |
@x = opts[:x] | |
@y = opts[:y] | |
@z = opts[:z] | |
@height = opts[:height] | |
@width = opts[:width] | |
end | |
private | |
attr_writer :id, :viewport | |
def next_id | |
@@ids ||= {} | |
type_ids = @@ids[type] | |
type_ids = 0 if type_ids.nil? | |
type_ids += 1 | |
end | |
end | |
class HumanObserver | |
def display(viewport) | |
# TODO: implement display for a command-line interface (CLI) form of the | |
# game "naughts and crosses" aka tic-tac-toe. | |
# if you are more familiar or comfortable with HTML + CSS, feel free | |
# to render HTML + CSS. | |
end | |
end | |
class HumanPlayer | |
end | |
class ComputerPlayer | |
end | |
class Lobby | |
end | |
class Match | |
end | |
class LeaderBoard | |
end | |
class PlayerMatchHistory | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment