This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplanet-wars.rb
110 lines (94 loc) · 3.17 KB
/
planet-wars.rb
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
require "bundler/setup"
require "gosu"
require "chroma"
require "humanize"
require "securerandom"
require "oj"
require "excon"
require "launchy"
require "time"
require_relative "lib/planet-wars/require_all"
require_all "lib/planet-wars/errors"
require_all "lib/planet-wars/game_info"
require_relative "lib/planet-wars/version"
require_relative "lib/planet-wars/logger"
require_relative "lib/planet-wars/game_info"
require_relative "lib/planet-wars/asset_manager"
require_relative "lib/planet-wars/config_manager"
require_relative "lib/planet-wars/game/game_state"
require_relative "lib/planet-wars/game/game_object"
require_relative "lib/planet-wars/gameui/gameui"
require_all "lib/planet-wars/ai"
require_relative "lib/planet-wars/game/engine"
require_relative "lib/planet-wars/game/achievement_manager"
require_relative "lib/planet-wars/game/hazard_manager"
require_relative "lib/planet-wars/game/music_manager"
require_relative "lib/planet-wars/game/name_gen"
require_relative "lib/planet-wars/game/world_gen"
require_relative "lib/planet-wars/game/minimap_gen"
require_all "lib/planet-wars/objects"
require_all "lib/planet-wars/game/achievements"
require_all "lib/planet-wars/game/state/helpers"
require_relative "lib/planet-wars/game/state/boot"
require_relative "lib/planet-wars/game/state/game"
require_relative "lib/planet-wars/game/state/gameover"
require_relative "lib/planet-wars/game/state/game_won"
require_relative "lib/planet-wars/game/state/planet_view"
require_relative "lib/planet-wars/game/state/ship_upgrades"
require_relative "lib/planet-wars/net/state/net_game"
require_all "lib/planet-wars/game/state/menus"
Thread.abort_on_exception = true if ARGV.join.include?('--debug')
Gosu::enable_undocumented_retrofication
if (Time.now.utc - Time.parse(ConfigManager.config['update_check'])) > 60*30 # check every 30 minutes
ConfigManager.update("update_check", "#{Time.now.utc.to_s}")
Thread.new do
t_s = Time.now
begin # version check
# Github API v3
puts "Checking for updates..."
request = Excon.get("https://api.github.com/repos/cyberarm/planet-wars/releases", nonblock: true)
data = Oj.load(request.body)[0]
if data
if data['name'] > GameInfo::VERSION
$latest_release_data = data
elsif data['name'] == GameInfo::VERSION
puts "#{GameInfo::NAME} is up to date. (version #{GameInfo::VERSION})"
end
end
rescue => e
puts "Couldn't query Github about releases, an error occurred:"
puts e
end
puts "Took #{Time.now-t_s} to query."
end
end
begin
build = Integer(open("#{Dir.pwd}/lib/planet-wars/dev_stats/build.dat").read)
build += 1
open("#{Dir.pwd}/lib/planet-wars/dev_stats/build.dat", 'w') do |file|
file.write build
end
BUILD = build
rescue => e
puts e
open("#{Dir.pwd}/lib/planet-wars/dev_stats/build.dat", 'w') do |file|
BUILD = 0
file.write BUILD
end
end
if ARGV.join.include?("--mute")
$mute = true
end
if ARGV.join.include?('--debug')
$debug = true
at_exit do
puts "==== Garbage Collection Stats ===="
GC.stat.each do |key, value|
puts "#{key}: #{value}"
end
end
end
if ARGV.join.include?("--heading")
$heading = true
end
Engine.new.show if not defined?(Ocra)