Skip to content

Commit

Permalink
First commmit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Miller committed May 18, 2012
0 parents commit 9dd2fb1
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.bundle
*.tar.bz2
df
5 changes: 5 additions & 0 deletions Gemfile
@@ -0,0 +1,5 @@
source 'http://rubygems.org'
gem 'mechanize'
gem 'os'
gem 'debugger'
gem 'rake'
41 changes: 41 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,41 @@
GEM
remote: http://rubygems.org/
specs:
columnize (0.3.6)
debugger (1.1.3)
columnize (>= 0.3.1)
debugger-linecache (~> 1.1.1)
debugger-ruby_core_source (~> 1.1.2)
debugger-linecache (1.1.1)
debugger-ruby_core_source (>= 1.1.1)
debugger-ruby_core_source (1.1.2)
domain_name (0.5.3)
unf (~> 0.0.3)
mechanize (2.5.1)
domain_name (~> 0.5, >= 0.5.1)
mime-types (~> 1.17, >= 1.17.2)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (~> 0.0, >= 0.0.9)
mime-types (1.18)
net-http-digest_auth (1.2)
net-http-persistent (2.6)
nokogiri (1.5.2)
ntlm-http (0.1.1)
os (0.9.6)
rake (0.9.2.2)
unf (0.0.5)
unf_ext
unf_ext (0.0.4)
webrobots (0.0.13)

PLATFORMS
ruby

DEPENDENCIES
debugger
mechanize
os
rake
77 changes: 77 additions & 0 deletions Rakefile
@@ -0,0 +1,77 @@
require 'rubygems'
require 'bundler'
Bundler.require
require 'rake/clean'

CLEAN.include('df', '*.tar.bz2')
CLOBBER.include('df')

TILESET = 'vidumec-12x12.png'
COLOR_SCHEME = 'another_natural_scheme.txt'

module DwarfConfig
def config(settings={})
settings.each do |k,v|
v = if v.class == Array
v.join(':')
else
v.to_s.sub('true', 'yes').sub('false', 'no')
end
v = v.upcase unless v == TILESET
sub! /^\[(#{k.to_s.upcase}):[^\]]+\]/, "[\\1:#{v}]"
end
end
end

def read_config(filename)
File.read(filename).extend DwarfConfig
end

def write_config(filename, settings={})
puts "Configuring #{filename}"
file = read_config "df/data/init/#{filename}"
file.config settings
File.open("df/data/init/#{filename}", 'w') do |f|
f << file
end
end

task :default => [:config, :setup]

task :config => 'df' do

write_config 'init.txt', {
intro: false,
font: TILESET
}

write_config 'd_init.txt', {
embark_rectangle: [6, 6],
coffin_no_pets_default: true,
idlers: 'top',
population_cap: 100,
baby_child_cap: [20, 20],
varied_ground_tiles: false,
show_flow_ammounts: true
}
end

task :setup => 'df' do
cp "colors/#{COLOR_SCHEME}", 'df/data/init/colors.txt'
cp "tilesets/#{TILESET}", "df/data/art/#{TILESET}"
end

file 'df' => ['df.tar.bz2'] do |t|
sh "tar -xzf #{t.prerequisites.first}"
mv FileList['df_{osx,linux}'].first, t.name
end

file 'df.tar.bz2' do
url = 'http://bay12games.com/dwarves/'
link_text = case
when OS.mac? then 'Mac (Intel)'
when OS.linux? then 'Linux'
end
filename = Mechanize.new.get(url).link_with(text: link_text).href
sh "curl -# #{url}#{filename} -o df.tar.bz2" unless filename.empty?
end
48 changes: 48 additions & 0 deletions colors/another_natural_scheme.txt
@@ -0,0 +1,48 @@
[BLACK_R:0]
[BLACK_G:0]
[BLACK_B:0]
[BLUE_R:73]
[BLUE_G:95]
[BLUE_B:157]
[GREEN_R:89]
[GREEN_G:117]
[GREEN_B:55]
[CYAN_R:101]
[CYAN_G:144]
[CYAN_B:158]
[RED_R:146]
[RED_G:0]
[RED_B:0]
[MAGENTA_R:165]
[MAGENTA_G:54]
[MAGENTA_B:101]
[BROWN_R:138]
[BROWN_G:105]
[BROWN_B:59]
[LGRAY_R:128]
[LGRAY_G:128]
[LGRAY_B:128]
[DGRAY_R:80]
[DGRAY_G:80]
[DGRAY_B:80]
[LBLUE_R:111]
[LBLUE_G:138]
[LBLUE_B:165]
[LGREEN_R:160]
[LGREEN_G:200]
[LGREEN_B:82]
[LCYAN_R:159]
[LCYAN_G:196]
[LCYAN_B:210]
[LRED_R:206]
[LRED_G:73]
[LRED_B:1]
[LMAGENTA_R:239]
[LMAGENTA_G:150]
[LMAGENTA_B:207]
[YELLOW_R:255]
[YELLOW_G:198]
[YELLOW_B:0]
[WHITE_R:255]
[WHITE_G:255]
[WHITE_B:255]
Binary file added tilesets/vidumec-12x12.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9dd2fb1

Please sign in to comment.