Factor common code out of xboard and gnushogi engines.
[kaya/ydirson.git] / lib / board / theme_loader.rb
blobfa6ec18c3ccc53794b00fb0510fb4db3cebef9d5
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 module ThemeLoader
9   attr_reader :loader
11   Theme = Struct.new(:pieces, :board, :layout)
12   
13   def load_theme
14     Theme.new.tap do |theme|
15       theme.pieces = loader.
16         get_matching(:pieces, game.keywords || []).
17         new(:game => game, :shadow => true)
18       theme.board = loader.
19         get_matching(:board, game.keywords || []).
20         new(:game => game)
21       theme.layout = loader.
22         get_matching(:layout, game.keywords || []).
23         new(game)
24     end
25   end
26 end