Skip to content

Example Game Implementation

Bart Lantz edited this page Mar 2, 2021 · 1 revision

Example Game class definition for G18Example

this would be located in lib/engine/game/g_18_example/game.rb

require_relative "../base"
require_relative "meta"

module Engine
  module Game
    module G18Example
      class Game < Game::Base
        include_meta(G18Example::Meta)
        
        BANK_CASH = 10_000
        # define certificate limits at different player counts
        CERT_LIMIT = {}
        CURRENCY_FORMAT_STR = '$%d'
        # define player starting money at differenet player counts
        STARTING_CASH = {}
        # define tiles used in game, see TILES.md
        #   can define new ones or use standard
        TILES = {}
        # define the hexes of the map
        HEXES = {}
        # define cities on hexes on map
        LOCATION_NAMES = {}
        # define phases, what triggers them, what they affect
        PHASES = []
        # define the stock market 1D, 2D, etc
        MARKET = []
        # define the roster of trains: cost, name
        TRAINS = []
        # define privates: cost, name, abilities
        COMPANIES = []
        # define corporations: names, symbols, float, logo, tokens
        CORPORATIONS = []

        # define steps in Stock Round (if non-standard)
        #   Steps can be standard or
        #   new ones defined in this modules steps folder.
        def stock_round
        end

        # define steps in Operating Round (if non-standard)
        #   Steps can be standard or
        #   new ones defined in this modules steps folder.
        def operating_round(round_num)
        end

        # any extra setup tasks go here
        def setup
          super
        end

      end
    end
  end
end

Also create lib/engine/game/g_18_example.rb

module Engine
  module Game
    module G18Example
    end
  end
end 

Tests for the game would go in specs/fixtures/G18Example/. These can be json exported from running a game manually.

Clone this wiki locally