Improve functionality.

master
an 2018-06-25 13:01:45 -04:00
parent 1a669e7834
commit 6077058fd4
No known key found for this signature in database
GPG Key ID: 6F175273601C59F2
2 changed files with 51 additions and 49 deletions

View File

@ -14,9 +14,6 @@ class Mod_DoomRLA < Vrobot4::Module::Module
def self.type() "DoomRLA" end def self.type() "DoomRLA" end
Vrobot4::Module.add_module_type self, server: "Discord" Vrobot4::Module.add_module_type self, server: "Discord"
@@winfo = nil
@@minfo = nil
AType = ["Melee", "Ranged", "Special"].freeze AType = ["Melee", "Ranged", "Special"].freeze
DType = ["Melee", "Bullet", "Fire", "Plasma", DType = ["Melee", "Bullet", "Fire", "Plasma",
"Piercing", "Holy", "Unholy", "Special"].freeze "Piercing", "Holy", "Unholy", "Special"].freeze
@ -24,84 +21,89 @@ class Mod_DoomRLA < Vrobot4::Module::Module
def initialize info def initialize info
super super
register :c_assemblyinfo, "assemblyinfo", "Prints DRLA assembly info." register :c_assemblyinfo, "assemblyinfo", "Prints DRLA assembly info."
register :c_weaponinfo, "weaponinfo", "Prints DRLA weapon info." register :c_weaponinfo, "weaponinfo", "Prints DRLA weapon info."
register :c_monsterinfo, "monsterinfo", "Prints DRLA monster info." register :c_monsterinfo, "monsterinfo", "Prints DRLA monster info."
register :c_reloadinfo, "reloadinfo", "", roles: "h" register :c_reloadinfo, "reloadinfo", "Reload DRLA info.", roles: "h"
reload_info false reload_info
end
def expldamage a
"#{a["ExplosionDamage"]} explosion damage, #{a["ExplosionRadius"]} radius\n"
end end
def c_assemblyinfo m, argv def c_assemblyinfo m, argv
w = @@winfo.select do |wep|
wep if wep["Assembly"] and wep["AssemblyItem"].casecmp? argv
end
t = "" t = ""
w = @winfo.select {|wep| wep if wep["Assembly"] and wep["AssemblyItem"].casecmp? argv}
raise ArgumentError, "No assemblies found" if w == nil || w.empty?
w.each {|wep| t << wep["Assembly"] + " - " + wep["Name"] + "\n"} w.each {|wep| t << wep["Assembly"] + " - " + wep["Name"] + "\n"}
m.chan.real.send_embed {|embed| embed.description = t} if t != "" m.chan.real.send_embed {|embed| embed.description = t} if t != ""
end end
def c_weaponinfo m, argv def c_weaponinfo m, argv
w = @@winfo.find {|wep| wep if wep["Name"].casecmp? argv} w = @winfo.find {|wep| wep if wep["Name"].casecmp? argv}
raise ArgumentError, "Weapon not found" if w == nil raise ArgumentError, "Weapon not found" if w == nil
t = "%s %s damage\n" % [w["Damage"], w["DamageType"]]
t << "%s shots\n" % [w["Shots"]] if w["Shots"].to_i > 1 t = "#{w["Damage"]} #{w["DamageType"]} damage\n"
t << "Uses %s %s\n" % [w["AmmoUsage"], w["AmmoType"]] \ t << "#{w["Shots"]} shots\n" if w["Shots"].to_i > 1
if w["AmmoType"] != "None" t << "Uses #{w["AmmoUsage"]} #{w["AmmoType"]}\n" if w["AmmoType"] != "None"
t << "%s capacity\n" % [w["Capacity"]] if w["Capacity"] t << "#{w["Capacity"]} capacity\n" if w["Capacity"]
t << "\n" t << "\n"
t << "%s explosion damage, %s radius\n" %
[w["ExplosionDamage"], w["ExplosionRadius"]] if w["ExplosionDamage"] t << expldamage(w) if w["ExplosionDamage"]
t << "Traits: %s\n" % [w["Traits"]] if w["Traits"] != "N/A" t << "Traits: #{w["Traits"]}\n" if w["Traits"] != "N/A"
t << "Assembly: %s with %s\n" % [w["Assembly"], w["AssemblyItem"]] \ t << "Assembly: #{w["Assembly"]} with #{w["AssemblyItem"]}\n" if w["Assembly"]
if w["Assembly"] t << w["Description"] if w["Description"]
t << "%s" % [w["Description"]] if w["Description"]
m.chan.real.send_embed do |embed| m.chan.real.send_embed do |embed|
embed.title = "[%s] %s" % [w["Rarity"], w["Name"]] embed.title = "[#{w["Rarity"]}] #{w["Name"]}"
embed.description = t embed.description = t
end end
end end
def c_monsterinfo m, argv def c_monsterinfo m, argv
mi = @@minfo.select do |mon| mi = @minfo.select do |mon|
mon if mon["Name"].casecmp? argv or mon if mon["Name"].casecmp? argv or mon["Tags"].split(", ").include? argv
mon["Tags"].split(", ").include? argv
end end
raise ArgumentError, "No monsters found" if mi == nil raise ArgumentError, "No monsters found" if mi == nil || mi.empty?
mi.first(3).each do |w| mi.first(3).each do |w|
t = "%i Health\n" % [w["Health"]] t = "#{w["Health"]} Health\n"
t << "Resistances: %s\n" % [w["Resistances"]] t << "Resistances: #{w["Resistances"]}\n"
t << "Drops: %s\n" % [w["ItemDrops"]] if w["ItemDrops"] t << "Drops: #{w["ItemDrops"]}\n" if w["ItemDrops"]
t << "%s" % [w["Description"]] if w["Description"] t << w["Description"] if w["Description"]
t << "\n" t << "\n"
w["Attacks"].each do |a| w["Attacks"].each do |a|
t << "\n[%s] %s\n" % [AType[a["AttackType"]], a["Name"]] t << "\n[#{AType[a["AttackType"].to_i]}] #{a["Name"]}\n"
t << "%s %s damage\n" % [a["Damage"], DType[a["DamageType"]]] t << "#{a["Damage"]} #{DType[a["DamageType"].to_i]} damage\n"
t << "%s explosion damage, %s radius\n" % t << expldamage(a) if a["ExplosionDamage"]
[a["ExplosionDamage"], a["ExplosionRadius"]] \ t << "#{a["Shots"]} shots\n" if a["Shots"].to_i > 1
if a["ExplosionDamage"] t << "#{a["Description"]}\n" if a["Description"]
t << "%s shots\n" % [a["Shots"]] if a["Shots"].to_i > 1
t << "%s\n" % a["Description"] if a["Description"]
end end
m.chan.real.send_embed do |embed| m.chan.real.send_embed do |embed|
embed.title = "[%s] %s" % [w["Difficulty"], w["Name"]] embed.title = "[#{w["Difficulty"]}] #{w["Name"]}"
embed.title << " %s" % [w["Weapon"]] if w["Weapon"] embed.title << " #{w["Weapon"]}" if w["Weapon"]
embed.image = Discordrb::Webhooks::EmbedImage.new \ embed.image = Discordrb::Webhooks::EmbedImage.new url: w["Sprite"] if w["Sprite"]
url: w["Sprite"] if w["Sprite"]
embed.description = t embed.description = t
end end
end end
end end
def c_reloadinfo m, argv def c_reloadinfo m, argv
reload_info true m.reply "Reloading info..."
reload_info
m.reply "Done."
end end
private private
def reload_info force def reload_info
if not @@winfo or not @@minfo or force @winfo = []
@@winfo = JSON.parse(open(@info["wep_info"]).read) @minfo = []
@@minfo = JSON.parse(open(@info["mon_info"]).read) @info["wep_info"].each {|wi| @winfo += JSON.parse(open(wi).read)}
end @info["mon_info"].each {|mi| @minfo += JSON.parse(open(mi).read)}
end end
end end

View File

@ -11,7 +11,7 @@ class Mod_RoleChooser < Vrobot4::Module::Module
def c_setcolor m, argv def c_setcolor m, argv
roles = m.chan.real.server.roles roles = m.chan.real.server.roles
role = roles.find {|r| r.name == argv} role = roles.find {|r| r.name.casecmp? argv}
unless role and @info.any? {|id| role.id == id} unless role and @info.any? {|id| role.id == id}
raise ArgumentError, "Invalid color, use .listcolors for a list." raise ArgumentError, "Invalid color, use .listcolors for a list."
end end