bugfix: safety against breaking the AI if you press undo while it's thinking
[kaya.git] / lib / kaya.rb
blobe3fa6542b3c3070844dbf53cee2d85576cabd7d5
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 #!/usr/bin/env ruby
9 $basedir = File.dirname(__FILE__)
10 $:.unshift($basedir)
11 require 'toolkit'
12 require 'mainwindow'
13 require 'require_bundle'
15 def version
16   "0.4"
17 end
19 def start_kaya
20   $version = version
21   default_game = :chess
23   app = KDE::Application.init(
24     :version => version,
25     :id => 'kaya',
26     :name => KDE.ki18n('Kaya'),
27     :description => KDE.ki18n('KDE Board Game Suite'),
28     :copyright => KDE.ki18n('(C) 2009 Paolo Capriotti'),
29     :authors => [[KDE.ki18n('Paolo Capriotti'), 'p.capriotti@gmail.com']],
30     :contributors => [[KDE.ki18n("Jani Huhtanen"), KDE.ki18n('Gaussian blur code')],
31                       [KDE.ki18n("Yann Dirson"), KDE.ki18n('Minishogi')]],
32     :bug_tracker => 'http://github.com/pcapriotti/kaya/issues',
33     :options => [['+[game]', KDE.ki18n('Initial game')],
34                  ['auto-reload', KDE.ki18n("Reload source files when modified")]])
35     
36   require 'plugins/loader'
37   require 'games/all'
38     
39   args = KDE::CmdLineArgs.parsed_args
40   
41   if args.is_set("auto-reload")
42     require 'auto_reload'
43     AutoReload.start($basedir)
44   end
45   
46   game = if args.count > 0
47     name = args[0]
48     g = Game.get(name.to_sym)
49     unless g
50       warn "No such game #{name}. Defaulting to #{default_game}"
51       nil
52     else
53       g
54     end
55   end
56   game ||= Game.get(default_game)
58   plugin_loader = PluginLoader.new
59   
60   main = MainWindow.new(plugin_loader, game)
61   
62   
63   
64   main.show
65   app.exec
66 end