Add DoomRLA module

master
Marrub 2017-08-09 03:52:45 -04:00
parent aadd43f69f
commit b06deee8c5
1 changed files with 79 additions and 0 deletions

79
source/mod_doomrla.rb Normal file
View File

@ -0,0 +1,79 @@
require 'open-uri'
require 'json'
#
# ===== WARNING =====
#
# !!! INCOMING SPAGHETTI !!!
#
# - BE PRAYING
# - BE PRAYING
# - BE PRAYING
#
class Mod_DoomRLA < Vrobot4::Module::Module
Vrobot4::Module.add_module_type self, "DoomRLA", server: "Discord"
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."
@winfo = JSON.parse(open(info["wep_info"]).read)
@minfo = JSON.parse(open(info["mon_info"]).read)
end
def c_weaponinfo m, argv
name = argv.join(" ")
w = @winfo.select {|wep| wep if wep["Name"].casecmp? name}[0]
t = "%s %s damage\n" % [w["Damage"], w["DamageType"]]
t << "%s shots" % [w["Shots"]] if w["Shots"].to_i > 1
t << ", uses %s %s" % [w["AmmoUsage"], w["AmmoType"]] \
if w["AmmoType"] != "None"
t << ", %s capacity" % [w["Capacity"]] if w["Capacity"]
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
name = argv.join(" ")
@minfo.select do |mon|
mon if mon["Name"].casecmp? name or
mon["Tags"].split(", ").include? name
end .first(3).each do |w|
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"]
embed.description = t
end
end
end
end
## EOF