From 09a36afd0731b4565dc4628114e6cd76a42e8893 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 1 Mar 2018 16:11:34 -0500 Subject: Renamed "moon image" to color Also moved color sprites to a resources directory. --- database.cpp | 4 ++-- database.h | 2 +- moons/README.md | 1 - moons/blue.png | Bin 37618 -> 0 bytes moons/brown.png | Bin 38150 -> 0 bytes moons/cyan.png | Bin 33139 -> 0 bytes moons/green.png | Bin 36760 -> 0 bytes moons/orange.png | Bin 36465 -> 0 bytes moons/pink.png | Bin 30838 -> 0 bytes moons/purple.png | Bin 32331 -> 0 bytes moons/red.png | Bin 37165 -> 0 bytes moons/star.png | Bin 27829 -> 0 bytes moons/white.png | Bin 29878 -> 0 bytes moons/yellow.png | Bin 32939 -> 0 bytes res/README.md | 1 + res/blue.png | Bin 0 -> 37618 bytes res/brown.png | Bin 0 -> 38150 bytes res/cyan.png | Bin 0 -> 33139 bytes res/green.png | Bin 0 -> 36760 bytes res/orange.png | Bin 0 -> 36465 bytes res/pink.png | Bin 0 -> 30838 bytes res/purple.png | Bin 0 -> 32331 bytes res/red.png | Bin 0 -> 37165 bytes res/star.png | Bin 0 -> 27829 bytes res/white.png | Bin 0 -> 29878 bytes res/yellow.png | Bin 0 -> 32939 bytes schema.sql | 2 +- scrape.rb | 26 ++++++++++++++++++-------- 28 files changed, 23 insertions(+), 13 deletions(-) delete mode 100644 moons/README.md delete mode 100644 moons/blue.png delete mode 100644 moons/brown.png delete mode 100644 moons/cyan.png delete mode 100644 moons/green.png delete mode 100644 moons/orange.png delete mode 100644 moons/pink.png delete mode 100644 moons/purple.png delete mode 100644 moons/red.png delete mode 100644 moons/star.png delete mode 100644 moons/white.png delete mode 100644 moons/yellow.png create mode 100644 res/README.md create mode 100644 res/blue.png create mode 100644 res/brown.png create mode 100644 res/cyan.png create mode 100644 res/green.png create mode 100644 res/orange.png create mode 100644 res/pink.png create mode 100644 res/purple.png create mode 100644 res/red.png create mode 100644 res/star.png create mode 100644 res/white.png create mode 100644 res/yellow.png diff --git a/database.cpp b/database.cpp index f8b5016..2885d1f 100644 --- a/database.cpp +++ b/database.cpp @@ -44,7 +44,7 @@ database::~database() achievement database::getRandomAchievement() const { - 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"; + 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"; sqlite3_stmt* ppstmt; if (sqlite3_prepare_v2( @@ -73,7 +73,7 @@ achievement database::getRandomAchievement() const result.achievementId = sqlite3_column_int(ppstmt, 0); result.gameId = sqlite3_column_int(ppstmt, 1); result.title = reinterpret_cast(sqlite3_column_text(ppstmt, 2)); - result.moonImage = reinterpret_cast(sqlite3_column_text(ppstmt, 3)); + result.color = reinterpret_cast(sqlite3_column_text(ppstmt, 3)); sqlite3_finalize(ppstmt); diff --git a/database.h b/database.h index 560eeda..a616318 100644 --- a/database.h +++ b/database.h @@ -9,7 +9,7 @@ struct achievement { int achievementId; int gameId; std::string title; - std::string moonImage; + std::string color; }; class database { diff --git a/moons/README.md b/moons/README.md deleted file mode 100644 index 876f0db..0000000 --- a/moons/README.md +++ /dev/null @@ -1 +0,0 @@ -The images in this directory are originally from the game Super Mario Odyssey, which is copyrighted by Nintendo. \ No newline at end of file diff --git a/moons/blue.png b/moons/blue.png deleted file mode 100644 index 5e4ca02..0000000 Binary files a/moons/blue.png and /dev/null differ diff --git a/moons/brown.png b/moons/brown.png deleted file mode 100644 index 6a31b16..0000000 Binary files a/moons/brown.png and /dev/null differ diff --git a/moons/cyan.png b/moons/cyan.png deleted file mode 100644 index 8984126..0000000 Binary files a/moons/cyan.png and /dev/null differ diff --git a/moons/green.png b/moons/green.png deleted file mode 100644 index 5e7d311..0000000 Binary files a/moons/green.png and /dev/null differ diff --git a/moons/orange.png b/moons/orange.png deleted file mode 100644 index 06ca595..0000000 Binary files a/moons/orange.png and /dev/null differ diff --git a/moons/pink.png b/moons/pink.png deleted file mode 100644 index 3b1521b..0000000 Binary files a/moons/pink.png and /dev/null differ diff --git a/moons/purple.png b/moons/purple.png deleted file mode 100644 index 9eeacf9..0000000 Binary files a/moons/purple.png and /dev/null differ diff --git a/moons/red.png b/moons/red.png deleted file mode 100644 index 2c0ef77..0000000 Binary files a/moons/red.png and /dev/null differ diff --git a/moons/star.png b/moons/star.png deleted file mode 100644 index 29263d5..0000000 Binary files a/moons/star.png and /dev/null differ diff --git a/moons/white.png b/moons/white.png deleted file mode 100644 index fae666b..0000000 Binary files a/moons/white.png and /dev/null differ diff --git a/moons/yellow.png b/moons/yellow.png deleted file mode 100644 index 8c012df..0000000 Binary files a/moons/yellow.png and /dev/null differ diff --git a/res/README.md b/res/README.md new file mode 100644 index 0000000..876f0db --- /dev/null +++ b/res/README.md @@ -0,0 +1 @@ +The images in this directory are originally from the game Super Mario Odyssey, which is copyrighted by Nintendo. \ No newline at end of file diff --git a/res/blue.png b/res/blue.png new file mode 100644 index 0000000..5e4ca02 Binary files /dev/null and b/res/blue.png differ diff --git a/res/brown.png b/res/brown.png new file mode 100644 index 0000000..6a31b16 Binary files /dev/null and b/res/brown.png differ diff --git a/res/cyan.png b/res/cyan.png new file mode 100644 index 0000000..8984126 Binary files /dev/null and b/res/cyan.png differ diff --git a/res/green.png b/res/green.png new file mode 100644 index 0000000..5e7d311 Binary files /dev/null and b/res/green.png differ diff --git a/res/orange.png b/res/orange.png new file mode 100644 index 0000000..06ca595 Binary files /dev/null and b/res/orange.png differ diff --git a/res/pink.png b/res/pink.png new file mode 100644 index 0000000..3b1521b Binary files /dev/null and b/res/pink.png differ diff --git a/res/purple.png b/res/purple.png new file mode 100644 index 0000000..9eeacf9 Binary files /dev/null and b/res/purple.png differ diff --git a/res/red.png b/res/red.png new file mode 100644 index 0000000..2c0ef77 Binary files /dev/null and b/res/red.png differ diff --git a/res/star.png b/res/star.png new file mode 100644 index 0000000..29263d5 Binary files /dev/null and b/res/star.png differ diff --git a/res/white.png b/res/white.png new file mode 100644 index 0000000..fae666b Binary files /dev/null and b/res/white.png differ diff --git a/res/yellow.png b/res/yellow.png new file mode 100644 index 0000000..8c012df Binary files /dev/null and b/res/yellow.png 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`); CREATE TABLE `games` ( `game_id` INTEGER PRIMARY KEY, `steam_appid` INTEGER NOT NULL, - `moon_image` VARCHAR(255) NOT NULL + `color` VARCHAR(255) NOT NULL ); 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' require 'bundler/setup' Bundler.require :default +MOON_COLORS = [ + :blue, + :brown, + :cyan, + :green, + :orange, + :pink, + :purple, + :red, + :star, + :white, + :yellow +] + @config = YAML.load(open(ARGV[0])) db_existed = File.exists?(@config["database"]) db = Sequel.connect("sqlite://" + @config["database"]) @@ -47,10 +61,6 @@ class Did < Sequel::Model many_to_one :achievement end -@moonimgs = Dir.entries(@config["moon_images"]).select do |img| - img.end_with? ".png" -end - def scrape_profile(profile, full) if full url = "https://steamcommunity.com/#{profile.profile_path}/games/?tab=all" @@ -76,9 +86,9 @@ def scrape_profile(profile, full) if Game.where(steam_appid: id).count > 0 game = Game.where(steam_appid: id).first else - moon_index = Random.rand(@moonimgs.size) + moon_index = Random.rand(MOON_COLORS.size) - game = Game.new(steam_appid: id, moon_image: @moonimgs[moon_index]) + game = Game.new(steam_appid: id, color: MOON_COLORS[moon_index]) game.save storepage = Nokogiri::HTML( @@ -167,9 +177,9 @@ elsif ARGV[1] == "full" end elsif ARGV[1] == "recolor" Game.all.each do |game| - moon_index = Random.rand(@moonimgs.size) + moon_index = Random.rand(MOON_COLORS.size) - game.moon_image = @moonimgs[moon_index] + game.color = MOON_COLORS[moon_index] game.save end end -- cgit 1.4.1