
class ReviewObserver

def initialize

@windows= []
@mode=''
end

def receive(line)
	toks= line.split(' ')
	nb= toks[2].to_i
	case toks[1]
	when 'CREATE'
		@windows[nb]= Reviewer.new(toks[2])
		@windows[nb].create_game
	when 'DATA'
	  if @windows[nb].data_fill
		@mode= 'DATABIS'
	  else
		@mode= 'DATA'
	  end
	when 'DATAEND'
		@windows[nb].set_position if @mode == 'DATA'
		@mode= nil
	when 'NODE'
		if @mode == 'DATA'
			@windows[nb].data_node(toks)
		  elsif @mode.nil?
			@windows[nb].one_node(toks)
		end
	when 'COMMENT'
	  if @mode != 'DATABIS'
		@windows[nb].comment(line)
	#	@windows[nb].refresh unless @mode
	  end
	when 'MARK','TRIANGLE','SQUARE','CROSS'
	  if @mode != 'DATABIS'
		@windows[nb].mark(toks) 
		@windows[nb].refresh unless @mode
	  end
	when 'DELETENODE'	
		@windows[nb].delete_node(toks)
	when 'CONTROL','GOODBYE','DONT_OBSERVE'
		@windows[nb].info(toks) if @windows.at(nb)
	when 'GAMES'
#		$reviewslist.add(toks[2..-1])
		$wlist.rec_review(toks[2..-1])
	when 'GAMES_END'
#		$reviewslist.refresh
		$wlist.refresh
	when 'SAVED'
	else 
		if @mode == 'DATA'
			@windows[nb].set_data(toks[1..-1])
		  elsif @mode.nil? 
			#debug line
		end
		
	end
	end

def delete(nb)
	@windows.delete_at(nb)
end

	end
