vrobot4/source/modules/mod_doomrla.rb

97 lines
3.2 KiB
Ruby
Raw Normal View History

2017-08-09 00:52:45 -07:00
require 'open-uri'
require 'json'
#--
2017-08-09 00:52:45 -07:00
# ===== WARNING =====
#
# !!! INCOMING SPAGHETTI !!!
#
# - BE PRAYING
# - BE PRAYING
# - BE PRAYING
#
class Mod_DoomRLA < Vrobot4::Module::Module
2017-08-09 02:57:31 -07:00
def self.type
"DoomRLA"
end
Vrobot4::Module.add_module_type self, server: "Discord"
2017-08-09 00:52:45 -07:00
AType = ["Melee", "Ranged", "Special"].freeze
DType = ["Melee", "Bullet", "Fire", "Plasma",
"Piercing", "Holy", "Unholy", "Special"].freeze
def initialize info
super
register :c_weaponinfo, "weaponinfo", "Prints DRLA weapon info."
register :c_monsterinfo, "monsterinfo", "Prints DRLA monster info."
2017-08-09 02:58:21 -07:00
register :c_reloadinfo, "reloadinfo", "", roles: "h"
2017-08-09 00:52:45 -07:00
2017-08-09 02:58:21 -07:00
reload_info
2017-08-09 00:52:45 -07:00
end
def c_weaponinfo m, argv
w = @winfo.select {|wep| wep if wep["Name"].casecmp? argv}[0]
2017-08-11 15:16:16 -07:00
raise ArgumentError, "Weapon not found" if w == nil
2017-08-09 00:52:45 -07:00
t = "%s %s damage\n" % [w["Damage"], w["DamageType"]]
2017-08-09 23:30:35 -07:00
t << "%s shots\n" % [w["Shots"]] if w["Shots"].to_i > 1
t << "Uses %s %s\n" % [w["AmmoUsage"], w["AmmoType"]] \
2017-08-09 00:52:45 -07:00
if w["AmmoType"] != "None"
2017-08-09 23:30:35 -07:00
t << "%s capacity\n" % [w["Capacity"]] if w["Capacity"]
2017-08-09 00:52:45 -07:00
t << "\n"
t << "%s explosion damage, %s radius\n" %
[w["ExplosionDamage"], w["ExplosionRadius"]] if w["ExplosionDamage"]
t << "Traits: %s\n" % [w["Traits"]] if w["Traits"] != "N/A"
t << "Assembly: %s with %s\n" % [w["Assembly"], w["AssemblyItem"]] \
if w["Assembly"]
t << "%s" % [w["Description"]] if w["Description"]
m.chan.real.send_embed do |embed|
embed.title = "[%s] %s" % [w["Rarity"], w["Name"]]
embed.description = t
end
end
def c_monsterinfo m, argv
2017-08-11 15:16:16 -07:00
mi = @minfo.select do |mon|
mon if mon["Name"].casecmp? argv or
mon["Tags"].split(", ").include? argv
2017-08-11 15:16:16 -07:00
end
raise ArgumentError, "No monsters found" if mi == nil
mi.first(3).each do |w|
2017-08-09 00:52:45 -07:00
t = "%i Health\n" % [w["Health"]]
t << "Resistances: %s\n" % [w["Resistances"]]
t << "Drops: %s\n" % [w["ItemDrops"]] if w["ItemDrops"]
t << "%s" % [w["Description"]] if w["Description"]
t << "\n"
w["Attacks"].each do |a|
t << "\n[%s] %s\n" % [AType[a["AttackType"]], a["Name"]]
t << "%s %s damage\n" % [a["Damage"], DType[a["DamageType"]]]
t << "%s explosion damage, %s radius\n" %
[a["ExplosionDamage"], a["ExplosionRadius"]] \
if a["ExplosionDamage"]
t << "%s shots\n" % [a["Shots"]] if a["Shots"].to_i > 1
t << "%s\n" % a["Description"] if a["Description"]
end
m.chan.real.send_embed do |embed|
embed.title = "[%s] %s" % [w["Difficulty"], w["Name"]]
embed.title << " %s" % [w["Weapon"]] if w["Weapon"]
2017-08-09 02:58:21 -07:00
embed.image = Discordrb::Webhooks::EmbedImage.new \
url: w["Sprite"] if w["Sprite"]
2017-08-09 00:52:45 -07:00
embed.description = t
end
end
end
2017-08-09 02:58:21 -07:00
def c_reloadinfo m, argv
reload_info
end
private
def reload_info
@winfo = JSON.parse(open(@info["wep_info"]).read)
@minfo = JSON.parse(open(@info["mon_info"]).read)
end
2017-08-09 00:52:45 -07:00
end
## EOF