9 require 'interaction/match'
11 require 'ics/protocol'
12 require 'ics/match_handler'
13 require 'ics/connection'
16 class MainWindow < KDE::XmlGuiWindow
19 def initialize(loader, game)
34 std_action(:open_new) { new_game(@default_game) }
35 std_action :quit, :slot => :close
36 regular_action :back, :icon => 'go-previous',
37 :text => KDE.i18n("&Back") do
40 regular_action :forward, :icon => 'go-next',
41 :text => KDE.i18n("&Forward") do
44 regular_action :connect, :icon => 'network-connect',
45 :text => KDE.i18n("&Connect to ICS") do
48 regular_action :disconnect, :icon => 'network-disconnect',
49 :text => KDE.i18n("&Disconnect from ICS") do
57 table = Table.new scene, @loader, self
58 @controller = Controller.new(table)
61 self.central_widget = table
65 protocol = ICS::Protocol.new(:debug)
66 c = ICS::Connection.new('freechess.org', 23)
67 protocol.add_observer ICS::AuthModule.new(c, 'ujjajja', '')
68 protocol.add_observer ICS::StartupModule.new(c)
71 console = Console.new(nil)
74 protocol.observe :text do |text|
78 console.observe :input do |text|
82 handler = ICS::MatchHandler.new(@controller, protocol)
84 protocol.observe :creating_game do |data|
85 puts "CREATING GAME: #{data.inspect}"
92 @controller.color = game.players.first
93 opponents = game.players[1..-1].map do |color|
94 DummyPlayer.new(color)
97 @controller.add_controlled_player(p)
100 match = Match.new(game)
101 @controller.controlled.values.each do |p|
104 @controller.controlled.values.each do |p|
108 @controller.reset(match)
117 def initialize(color)