Skip to content

Instantly share code, notes, and snippets.

@TheOnlyArtz
Created December 26, 2019 13:56
Show Gist options
  • Save TheOnlyArtz/c2f73059683e86e6806e8ae9f88fc8f6 to your computer and use it in GitHub Desktop.
Save TheOnlyArtz/c2f73059683e86e6806e8ae9f88fc8f6 to your computer and use it in GitHub Desktop.
require "./CpuTypes.cr"
abstract struct Cybergarden::Items::Cpu
property price : Int32
property power : Int32
property mps : Int32 # money per second
property type : Int32
def initialize()
@price = 0
@power = 0
@mps = 0
@type = 0
end
def as_h()
{
type: @type
}
end
def from_h(payload : Hash(String, RethinkDB::QueryResult))
processor = Cybergarden::Items::CpuTypes[payload["type"].as_i].new
processor
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment