-
-
Save TheOnlyArtz/c2f73059683e86e6806e8ae9f88fc8f6 to your computer and use it in GitHub Desktop.
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
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