Обеспечение всемирной трансляции спортивных шахматных соревнований с применением разработанного в ходе проекта законченного программного продукта

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование

ame.white_player.to_s, { :controller => players, :action => show, :id => @game.white_player.id} %>

moves,:url=>{:action=>game_moves,:id=>@game.id}%>">

 

main/logo.rhtml

---

rDGT,:width=>400px,:height=>280px%>">

 

main/online.rhtml

---

 

">

 

Модель (model)

---

class Cities < ActiveRecord::Base

end

 

class City < ActiveRecord::Base

end

 

class ClockReglament < ActiveRecord::Base

end

 

class Country < ActiveRecord::Base

end

 

class CurrentGame < ActiveRecord::Base

 

def init

@game = Game.find(self.game_id) if @game.nil?

end

def tournament

init

@game.tournament

end

def white

init

@game.white_player

end

def black

init

@game.black_player

end

end

 

class Game < ActiveRecord::Base

def moves

result = ""

@moves = Move.find_all_by_game_id self.id

moveb.number}.eachdo|move|"> @moves.sort { |movea, moveb| movea.number moveb.number }.each do |move|

result += move.to_s + "|"

end

result

end

def tournament

info = GameInfo.find self.game_info_id unless self.game_info_id.nil?

t = Tournament.find info.tournament_id

end

def white_player

player = Player.new

player.id= 1

player.first_name = "Иван"

player.second_name = "Рыков"

player

end

def black_player

player = Player.new

player.id= 1

player.first_name = "Сергей"

player.second_name = "Бедарев"

player

end

end

 

class GameInfo < ActiveRecord::Base

end

 

class LastMove < ActiveRecord::Base

end

 

class Move < ActiveRecord::Base

def to_s

((self.white_move.nil? or self.white_move == "") ? "******" : self.white_move) +

((self.black_move.nil? or self.black_move == "") ? "******" : self.black_move) + ":" +

(self.white_clock.nil? ? "" : self.white_clock) + "-" + (self.black_clock.nil? ? "" : self.black_clock)

end

end

 

class Player < ActiveRecord::Base

def full_name

return self.second_name + " " + self.first_name

end

def to_s

full_name

end

end

 

class Tournament < ActiveRecord::Base

def to_s

self.name

end

end

 

class TournamentView < ActiveRecord::Base

end

require digest/md5

class User < ActiveRecord::Base

validates_presence_of :login

validates_uniqueness_of :login

def self.authenticate(login, password)

user = User.find_by_name(login)

if user

expected_password = encrypted_password(password)

if user.password != expected_password

user = nil

end

end

user

end

def self.encrypted_password(password)

Digest::MD5.hexdigest("sdjkvkjeho2ijij2o3d2kn3dl2kn3dn23dkn2ld3n" + password)

end

end

 

Миграция (db migration)

---

12)do">ActiveRecord::Schema.define(:version => 12) do

 

create_table "cities", :force => true do |t|

30"> t.column "name", :string, :limit => 30

t.column "country_id", :integer

t.column "description", :text

t.column "image", :binary

end

 

create_table "clock_reglaments", :force => true do |t|

30"> t.column "title", :string, :limit => 30

t.column "total_time", :integer

nil,:default=>false"> t.column "add", :boolean, :limit => nil, :default => false

0"> t.column "add_time", :integer, :default => 0

t.column "desciprion", :text

end

 

create_table "countries", :force => true do |t|

30"> t.column "name", :string, :limit => 30

30"> t.column "code", :string, :limit => 30

t.column "image", :binary

t.column "description", :text

end

 

create_table "current_games", :force => true do |t|

t.column "game_id", :integer

t.column "begin", :datetime

t.column "end", :datetime

t.column "description", :text

end

 

create_table "game_infos", :force => true do |t|

t.column "game_id", :integer

t.column "white_id", :integer

t.column "black_id", :integer

t.column "tournament_id", :integer

t.column "result", :integer

t.column "clock_reglament_id", :integer

t.column "round", :