diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-03-01 16:11:34 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-03-01 16:11:34 -0500 |
commit | 09a36afd0731b4565dc4628114e6cd76a42e8893 (patch) | |
tree | 764026074a42bbed1b7ed97e018550e039107b4d | |
parent | 473b327ceed3afb5e5683002b39fd9c1947cb25a (diff) | |
download | lunatic-09a36afd0731b4565dc4628114e6cd76a42e8893.tar.gz lunatic-09a36afd0731b4565dc4628114e6cd76a42e8893.tar.bz2 lunatic-09a36afd0731b4565dc4628114e6cd76a42e8893.zip |
Renamed "moon image" to color
Also moved color sprites to a resources directory.
-rw-r--r-- | database.cpp | 4 | ||||
-rw-r--r-- | database.h | 2 | ||||
-rw-r--r-- | res/README.md (renamed from moons/README.md) | 0 | ||||
-rw-r--r-- | res/blue.png (renamed from moons/blue.png) | bin | 37618 -> 37618 bytes | |||
-rw-r--r-- | res/brown.png (renamed from moons/brown.png) | bin | 38150 -> 38150 bytes | |||
-rw-r--r-- | res/cyan.png (renamed from moons/cyan.png) | bin | 33139 -> 33139 bytes | |||
-rw-r--r-- | res/green.png (renamed from moons/green.png) | bin | 36760 -> 36760 bytes | |||
-rw-r--r-- | res/orange.png (renamed from moons/orange.png) | bin | 36465 -> 36465 bytes | |||
-rw-r--r-- | res/pink.png (renamed from moons/pink.png) | bin | 30838 -> 30838 bytes | |||
-rw-r--r-- | res/purple.png (renamed from moons/purple.png) | bin | 32331 -> 32331 bytes | |||
-rw-r--r-- | res/red.png (renamed from moons/red.png) | bin | 37165 -> 37165 bytes | |||
-rw-r--r-- | res/star.png (renamed from moons/star.png) | bin | 27829 -> 27829 bytes | |||
-rw-r--r-- | res/white.png (renamed from moons/white.png) | bin | 29878 -> 29878 bytes | |||
-rw-r--r-- | res/yellow.png (renamed from moons/yellow.png) | bin | 32939 -> 32939 bytes | |||
-rw-r--r-- | schema.sql | 2 | ||||
-rw-r--r-- | scrape.rb | 26 |
16 files changed, 22 insertions, 12 deletions
diff --git a/database.cpp b/database.cpp index f8b5016..2885d1f 100644 --- a/database.cpp +++ b/database.cpp | |||
@@ -44,7 +44,7 @@ database::~database() | |||
44 | 44 | ||
45 | achievement database::getRandomAchievement() const | 45 | achievement database::getRandomAchievement() const |
46 | { | 46 | { |
47 | std::string queryString = "SELECT achievements.achievement_id, achievements.game_id, achievements.title, games.moon_image FROM achievements INNER JOIN games ON games.game_id = achievements.game_id ORDER BY RANDOM() LIMIT 1"; | 47 | std::string queryString = "SELECT achievements.achievement_id, achievements.game_id, achievements.title, games.color FROM achievements INNER JOIN games ON games.game_id = achievements.game_id ORDER BY RANDOM() LIMIT 1"; |
48 | 48 | ||
49 | sqlite3_stmt* ppstmt; | 49 | sqlite3_stmt* ppstmt; |
50 | if (sqlite3_prepare_v2( | 50 | if (sqlite3_prepare_v2( |
@@ -73,7 +73,7 @@ achievement database::getRandomAchievement() const | |||
73 | result.achievementId = sqlite3_column_int(ppstmt, 0); | 73 | result.achievementId = sqlite3_column_int(ppstmt, 0); |
74 | result.gameId = sqlite3_column_int(ppstmt, 1); | 74 | result.gameId = sqlite3_column_int(ppstmt, 1); |
75 | result.title = reinterpret_cast<const char*>(sqlite3_column_text(ppstmt, 2)); | 75 | result.title = reinterpret_cast<const char*>(sqlite3_column_text(ppstmt, 2)); |
76 | result.moonImage = reinterpret_cast<const char*>(sqlite3_column_text(ppstmt, 3)); | 76 | result.color = reinterpret_cast<const char*>(sqlite3_column_text(ppstmt, 3)); |
77 | 77 | ||
78 | sqlite3_finalize(ppstmt); | 78 | sqlite3_finalize(ppstmt); |
79 | 79 | ||
diff --git a/database.h b/database.h index 560eeda..a616318 100644 --- a/database.h +++ b/database.h | |||
@@ -9,7 +9,7 @@ struct achievement { | |||
9 | int achievementId; | 9 | int achievementId; |
10 | int gameId; | 10 | int gameId; |
11 | std::string title; | 11 | std::string title; |
12 | std::string moonImage; | 12 | std::string color; |
13 | }; | 13 | }; |
14 | 14 | ||
15 | class database { | 15 | class database { |
diff --git a/moons/README.md b/res/README.md index 876f0db..876f0db 100644 --- a/moons/README.md +++ b/res/README.md | |||
diff --git a/moons/blue.png b/res/blue.png index 5e4ca02..5e4ca02 100644 --- a/moons/blue.png +++ b/res/blue.png | |||
Binary files differ | |||
diff --git a/moons/brown.png b/res/brown.png index 6a31b16..6a31b16 100644 --- a/moons/brown.png +++ b/res/brown.png | |||
Binary files differ | |||
diff --git a/moons/cyan.png b/res/cyan.png index 8984126..8984126 100644 --- a/moons/cyan.png +++ b/res/cyan.png | |||
Binary files differ | |||
diff --git a/moons/green.png b/res/green.png index 5e7d311..5e7d311 100644 --- a/moons/green.png +++ b/res/green.png | |||
Binary files differ | |||
diff --git a/moons/orange.png b/res/orange.png index 06ca595..06ca595 100644 --- a/moons/orange.png +++ b/res/orange.png | |||
Binary files differ | |||
diff --git a/moons/pink.png b/res/pink.png index 3b1521b..3b1521b 100644 --- a/moons/pink.png +++ b/res/pink.png | |||
Binary files differ | |||
diff --git a/moons/purple.png b/res/purple.png index 9eeacf9..9eeacf9 100644 --- a/moons/purple.png +++ b/res/purple.png | |||
Binary files differ | |||
diff --git a/moons/red.png b/res/red.png index 2c0ef77..2c0ef77 100644 --- a/moons/red.png +++ b/res/red.png | |||
Binary files differ | |||
diff --git a/moons/star.png b/res/star.png index 29263d5..29263d5 100644 --- a/moons/star.png +++ b/res/star.png | |||
Binary files differ | |||
diff --git a/moons/white.png b/res/white.png index fae666b..fae666b 100644 --- a/moons/white.png +++ b/res/white.png | |||
Binary files differ | |||
diff --git a/moons/yellow.png b/res/yellow.png index 8c012df..8c012df 100644 --- a/moons/yellow.png +++ b/res/yellow.png | |||
Binary files differ | |||
diff --git a/schema.sql b/schema.sql index 61fdc45..ade7522 100644 --- a/schema.sql +++ b/schema.sql | |||
@@ -8,7 +8,7 @@ CREATE UNIQUE INDEX `profile_by_path` ON `profiles`(`profile_path`); | |||
8 | CREATE TABLE `games` ( | 8 | CREATE TABLE `games` ( |
9 | `game_id` INTEGER PRIMARY KEY, | 9 | `game_id` INTEGER PRIMARY KEY, |
10 | `steam_appid` INTEGER NOT NULL, | 10 | `steam_appid` INTEGER NOT NULL, |
11 | `moon_image` VARCHAR(255) NOT NULL | 11 | `color` VARCHAR(255) NOT NULL |
12 | ); | 12 | ); |
13 | 13 | ||
14 | CREATE UNIQUE INDEX `game_by_appid` ON `games`(`steam_appid`); | 14 | CREATE UNIQUE INDEX `game_by_appid` ON `games`(`steam_appid`); |
diff --git a/scrape.rb b/scrape.rb index 6f3a8e4..dfeb356 100644 --- a/scrape.rb +++ b/scrape.rb | |||
@@ -6,6 +6,20 @@ require 'rubygems' | |||
6 | require 'bundler/setup' | 6 | require 'bundler/setup' |
7 | Bundler.require :default | 7 | Bundler.require :default |
8 | 8 | ||
9 | MOON_COLORS = [ | ||
10 | :blue, | ||
11 | :brown, | ||
12 | :cyan, | ||
13 | :green, | ||
14 | :orange, | ||
15 | :pink, | ||
16 | :purple, | ||
17 | :red, | ||
18 | :star, | ||
19 | :white, | ||
20 | :yellow | ||
21 | ] | ||
22 | |||
9 | @config = YAML.load(open(ARGV[0])) | 23 | @config = YAML.load(open(ARGV[0])) |
10 | db_existed = File.exists?(@config["database"]) | 24 | db_existed = File.exists?(@config["database"]) |
11 | db = Sequel.connect("sqlite://" + @config["database"]) | 25 | db = Sequel.connect("sqlite://" + @config["database"]) |
@@ -47,10 +61,6 @@ class Did < Sequel::Model | |||
47 | many_to_one :achievement | 61 | many_to_one :achievement |
48 | end | 62 | end |
49 | 63 | ||
50 | @moonimgs = Dir.entries(@config["moon_images"]).select do |img| | ||
51 | img.end_with? ".png" | ||
52 | end | ||
53 | |||
54 | def scrape_profile(profile, full) | 64 | def scrape_profile(profile, full) |
55 | if full | 65 | if full |
56 | url = "https://steamcommunity.com/#{profile.profile_path}/games/?tab=all" | 66 | url = "https://steamcommunity.com/#{profile.profile_path}/games/?tab=all" |
@@ -76,9 +86,9 @@ def scrape_profile(profile, full) | |||
76 | if Game.where(steam_appid: id).count > 0 | 86 | if Game.where(steam_appid: id).count > 0 |
77 | game = Game.where(steam_appid: id).first | 87 | game = Game.where(steam_appid: id).first |
78 | else | 88 | else |
79 | moon_index = Random.rand(@moonimgs.size) | 89 | moon_index = Random.rand(MOON_COLORS.size) |
80 | 90 | ||
81 | game = Game.new(steam_appid: id, moon_image: @moonimgs[moon_index]) | 91 | game = Game.new(steam_appid: id, color: MOON_COLORS[moon_index]) |
82 | game.save | 92 | game.save |
83 | 93 | ||
84 | storepage = Nokogiri::HTML( | 94 | storepage = Nokogiri::HTML( |
@@ -167,9 +177,9 @@ elsif ARGV[1] == "full" | |||
167 | end | 177 | end |
168 | elsif ARGV[1] == "recolor" | 178 | elsif ARGV[1] == "recolor" |
169 | Game.all.each do |game| | 179 | Game.all.each do |game| |
170 | moon_index = Random.rand(@moonimgs.size) | 180 | moon_index = Random.rand(MOON_COLORS.size) |
171 | 181 | ||
172 | game.moon_image = @moonimgs[moon_index] | 182 | game.color = MOON_COLORS[moon_index] |
173 | game.save | 183 | game.save |
174 | end | 184 | end |
175 | end | 185 | end |