-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
151 lines (122 loc) · 3.91 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
teams = %w[spike smiley mutant monster hiss robo]
task :default => [:build]
task :clean do
`rm -r build`
end
task :build do
main_file = "src/main.coffee"
src_files = (Dir["src/*.coffee"] - [main_file]) + [main_file]
sh "mkdir -p build"
sh "coffee", "-bcj", "build/src.js", *src_files
sh "cat build/data.js lib/*.js build/src.js > game.js"
end
task :build_data do
require 'json'
sh "mkdir -p build"
data_files = Dir["data/*.json"]
data = {}
data_files.each do |filename|
name = File.basename(filename, ".json")
data[name] = JSON.parse(File.read(filename))
end
File.open "build/data.js", "w" do |f|
f << "Data = "
f << JSON.dump(data)
f << ";\n"
end
end
task :dist => [:build_data, :build] do
`rm -r #{dist_dir}`
sh "mkdir -p #{dist_dir}"
sh "cp run.html #{dist_dir}/index.html"
%w[images music stylesheets sounds].each do |dir|
sh "cp -R #{dir} #{dist_dir}/#{dir}"
end
# Remove larger source images
sh "find #{dist_dir}/images -name '*@[248]x.png' -delete"
%w[jquery.min.js game.js].each do |file|
sh "cp #{file} #{dist_dir}/#{file}"
end
# Minify js
# require 'uglifier'
# File.open "#{dist_dir}/game.js", "w" do |f|
# f << Uglifier.compile(File.read("game.js"))
# end
end
task :chrome_webstore => :dist do
sh "mkdir -p #{dist_dir}/webstore && cp -r webstore/* #{dist_dir}/webstore"
sh "cp manifest.json #{dist_dir}"
# Remove old zip
`rm build/#{dist_name}.zip`
# Zip
sh "cd #{dist_dir} && zip -r #{dist_name}.zip . && mv #{dist_name}.zip ../chrome-webstore.zip"
end
namespace :package do
task :download do
`rm build/#{dist_name}.zip`
sh "cd #{dist_dir} && zip -r #{dist_name}.zip . && mv #{dist_name}.zip .."
end
task :newgrounds do
require "shellwords"
# TODO Limit to two team demo mode
# Delete some files for demo
# TODO: Copy directory before deleting so it doesn't affect other distributions
files = [
"Paint",
"Snake Or Die",
"Carpe Mutante",
"Monsters Don't Get Cold",
"Pure Robot Love Connection",
"Slightly Sumo",
"Substantially Sumo",
].each do |music|
`cd #{dist_dir}/music && rm #{music.shellescape}.ogg`
end
# Package for newgrounds
`rm build/#{dist_name}.zip`
sh "cd #{dist_dir} && zip -r #{dist_name}.zip . && mv #{dist_name}.zip ../newgrounds.zip"
end
end
# Compiles all sources separately to tmp so we can see good line numbers for errors
task :compile_for_errors do
sh "coffee -o tmp -c src/*.coffee"
end
task :team_image_rename do
teams.each do |team|
`cd images && mkdir -p #{team}; for f in #{team}_*; do mv -f $f #{team}/${f/#{team}_}; done`
end
end
task :team_image_resize do
teams.each do |team|
# Rename images to @2x
sh "for f in images/#{team}/*.png; do mv -f $f ${f/.png}@2x.png; done"
sh "for f in images/#{team}/*.png; do convert -resize 50% $f ${f/@2x.png}.png; done"
end
end
task :gib_image_resize do
%w[floor_decals blood_particles ice_particles].each do |type|
# Rename images to @4x
sh "for f in images/gibs/#{type}/*.png; do mv -f $f ${f/.png}@4x.png; done"
sh "for f in images/gibs/#{type}/*.png; do convert -resize 25% $f ${f/@4x.png}.png; done"
end
%w[zamboni_parts].each do |type|
# Rename images to @2x
sh "for f in images/gibs/#{type}/*.png; do mv -f $f ${f/.png}@2x.png; done"
sh "for f in images/gibs/#{type}/*.png; do convert -resize 50% $f ${f/@2x.png}.png; done"
end
%w[wall_decals].each do |type|
# Rename images to @8x
sh "for f in images/gibs/#{type}/*.png; do mv -f $f ${f/.png}@8x.png; done"
sh "for f in images/gibs/#{type}/*.png; do convert -resize 12.5% $f ${f/@8x.png}.png; done"
end
end
task :fan_image_resize do
sh "for f in images/crowd/*.png; do mv -f $f ${f/.png}@4x.png; done"
sh "for f in images/crowd/*.png; do convert -resize 25% $f ${f/@4x.png}.png; done"
end
def dist_name
"Red-Ice"
end
def dist_dir
"build/#{dist_name}"
end