Initial Release of IGNCore version 2.5
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
# noinspection LongLineForFile
|
||||
|
||||
DROP TABLE IF EXISTS trickle;
|
||||
CREATE TABLE IF NOT EXISTS trickle
|
||||
(
|
||||
id INT NOT NULL PRIMARY KEY,
|
||||
group_name VARCHAR(20) NOT NULL,
|
||||
name VARCHAR(30) NOT NULL,
|
||||
amount_agility DECIMAL(3, 1) NOT NULL,
|
||||
amount_intelligence DECIMAL(3, 1) NOT NULL,
|
||||
amount_psychic DECIMAL(3, 1) NOT NULL,
|
||||
amount_stamina DECIMAL(3, 1) NOT NULL,
|
||||
amount_strength DECIMAL(3, 1) NOT NULL,
|
||||
amount_sense DECIMAL(3, 1) NOT NULL
|
||||
);
|
||||
INSERT INTO trickle (id, group_name, name, amount_agility, amount_intelligence, amount_psychic, amount_stamina,
|
||||
amount_strength, amount_sense)
|
||||
VALUES (1, 'Body & Defense', 'Body Dev.', 0, 0, 0, 1, 0, 0),
|
||||
(2, 'Body & Defense', 'Nano Pool', 0, .1, .7, .1, 0, .1),
|
||||
(3, 'Body & Defense', 'Evade-ClsC', .5, .2, 0, 0, 0, .3),
|
||||
(4, 'Body & Defense', 'Dodge-Rng', .5, .2, 0, 0, 0, .3),
|
||||
(5, 'Body & Defense', 'Duck-Exp', .5, .2, 0, 0, 0, .3),
|
||||
(6, 'Body & Defense', 'Nano Resist', 0, .2, .8, 0, 0, 0),
|
||||
(7, 'Body & Defense', 'Deflect', .2, 0, 0, 0, .5, .3),
|
||||
(8, 'Melee Weapons', '1h Blunt', .1, 0, 0, .4, .5, 0),
|
||||
(9, 'Melee Weapons', '1h Edged', .4, 0, 0, .3, .3, 0),
|
||||
(10, 'Melee Weapons', 'Piercing', .5, 0, 0, .3, .2, 0),
|
||||
(11, 'Melee Weapons', '2h Blunt', 0, 0, 0, .5, .5, 0),
|
||||
(12, 'Melee Weapons', '2h Edged', 0, 0, 0, .4, .6, 0),
|
||||
(13, 'Melee Weapons', 'Melee Ener.', 0, .5, 0, .5, 0, 0),
|
||||
(14, 'Melee Weapons', 'Martial Arts', .5, 0, .3, 0, .2, 0),
|
||||
(15, 'Melee Weapons', 'Multi. Melee', .6, 0, 0, .1, .3, 0),
|
||||
(16, 'Melee Weapons', 'Melee. Init.', .1, .1, .2, 0, 0, .6),
|
||||
(17, 'Melee Weapons', 'Physic. Init', .1, .1, .2, 0, 0, .6),
|
||||
(18, 'Melee Specials', 'Sneak Atck', .5, .3, 0, 0, 0, .2),
|
||||
(19, 'Melee Specials', 'Brawling', 0, 0, 0, .4, .6, 0),
|
||||
(20, 'Melee Specials', 'Fast Attack', .6, 0, 0, 0, 0, .4),
|
||||
(21, 'Melee Specials', 'Dimach', 0, 0, .2, 0, 0, .8),
|
||||
(22, 'Melee Specials', 'Riposte', .5, 0, 0, 0, 0, .5),
|
||||
(23, 'Ranged Weapons', 'Pistol', .6, 0, 0, 0, 0, .4),
|
||||
(24, 'Ranged Weapons', 'Bow', .4, 0, 0, 0, .2, .4),
|
||||
(25, 'Ranged Weapons', 'MG / SMG', .3, 0, 0, .3, .3, .1),
|
||||
(26, 'Ranged Weapons', 'Assault Rif', .3, 0, 0, .4, .1, .2),
|
||||
(27, 'Ranged Weapons', 'Shotgun', .6, 0, 0, 0, .4, 0),
|
||||
(28, 'Ranged Weapons', 'Rifle', .6, 0, 0, 0, 0, .4),
|
||||
(29, 'Ranged Weapons', 'Ranged Ener', 0, .2, .4, 0, 0, .4),
|
||||
(30, 'Ranged Weapons', 'Grenade', .4, .2, 0, 0, 0, .4),
|
||||
(31, 'Ranged Weapons', 'Heavy Weapons', .6, 0, 0, 0, .4, 0),
|
||||
(32, 'Ranged Weapons', 'Multi Ranged', .6, .4, 0, 0, 0, 0),
|
||||
(33, 'Ranged Weapons', 'Ranged. Init.', .1, .1, .2, 0, 0, .6),
|
||||
(34, 'Ranged Specials', 'Fling Shot', 1, 0, 0, 0, 0, 0),
|
||||
(35, 'Ranged Specials', 'Aimed Shot', 0, 0, 0, 0, 0, 1),
|
||||
(36, 'Ranged Specials', 'Burst', .5, 0, 0, .2, .3, 0),
|
||||
(37, 'Ranged Specials', 'Full Auto', 0, 0, 0, .4, .6, 0),
|
||||
(38, 'Ranged Specials', 'Bow Spc Att', .5, 0, 0, 0, .1, .4),
|
||||
(39, 'Ranged Specials', 'Sharp Obj', .6, 0, 0, 0, .2, .2),
|
||||
(40, 'Nanos & Casting', 'Matt.Metam', 0, .8, .2, 0, 0, 0),
|
||||
(41, 'Nanos & Casting', 'Bio Metamor', 0, .8, .2, 0, 0, 0),
|
||||
(42, 'Nanos & Casting', 'Psycho Modi', 0, .8, 0, 0, 0, .2),
|
||||
(43, 'Nanos & Casting', 'Sensory Impr', 0, .8, 0, 0, .2, 0),
|
||||
(44, 'Nanos & Casting', 'Time&Space', .2, .8, 0, 0, 0, 0),
|
||||
(45, 'Nanos & Casting', 'Matter Crea', 0, .8, 0, .2, 0, 0),
|
||||
(46, 'Nanos & Casting', 'NanoC. Init.', .4, 0, 0, 0, 0, .6),
|
||||
(47, 'Exploring', 'Vehicle Air', .2, .2, 0, 0, 0, .6),
|
||||
(48, 'Exploring', 'Vehicle Ground', .2, .2, 0, 0, 0, .6),
|
||||
(49, 'Exploring', 'Vehicle Water', .2, .2, 0, 0, 0, .6),
|
||||
(50, 'Exploring', 'Run Speed', .4, 0, 0, .4, .2, 0),
|
||||
(51, 'Exploring', 'Adventuring', .5, 0, 0, .3, .2, 0),
|
||||
(52, 'Combat & Healing', 'Perception', 0, .3, 0, 0, 0, .7),
|
||||
(53, 'Combat & Healing', 'Concealment', .3, 0, 0, 0, 0, .7),
|
||||
(54, 'Combat & Healing', 'Psychology', 0, .5, 0, 0, 0, .5),
|
||||
(55, 'Combat & Healing', 'Trap Disarm.', .2, .2, 0, 0, 0, .6),
|
||||
(56, 'Combat & Healing', 'First Aid', .3, .3, 0, 0, 0, .4),
|
||||
(57, 'Combat & Healing', 'Treatment', .3, .5, 0, 0, 0, .2),
|
||||
(58, 'Trade & Repair', 'Mech. Engi', .5, .5, 0, 0, 0, 0),
|
||||
(59, 'Trade & Repair', 'Elec. Engi', .3, .5, 0, .2, 0, 0),
|
||||
(60, 'Trade & Repair', 'Quantum FT', 0, .5, .5, 0, 0, 0),
|
||||
(61, 'Trade & Repair', 'Chemistry', 0, .5, 0, .5, 0, 0),
|
||||
(62, 'Trade & Repair', 'Weapon Smt', 0, .5, 0, 0, .5, 0),
|
||||
(63, 'Trade & Repair', 'Nano Progra', 0, 1, 0, 0, 0, 0),
|
||||
(64, 'Trade & Repair', 'Tutoring', 0, .7, .1, 0, 0, .2),
|
||||
(65, 'Trade & Repair', 'Break&Entry', .4, 0, .3, 0, 0, .3),
|
||||
(66, 'Trade & Repair', 'Comp. Liter', 0, 1, 0, 0, 0, 0),
|
||||
(67, 'Trade & Repair', 'Pharma Tech', .2, .8, 0, 0, 0, 0),
|
||||
(68, 'Disabled / Legacy', 'Swimming', .2, 0, 0, .6, .2, 0),
|
||||
(69, 'Disabled / Legacy', 'Map Navig.', 0, .4, .1, 0, 0, .5);
|
||||
@@ -0,0 +1,186 @@
|
||||
import re
|
||||
|
||||
from core.chat_blob import ChatBlob
|
||||
from core.command_param_types import Any, CommandParam
|
||||
from core.db import DB
|
||||
from core.decorators import instance, command
|
||||
from core.dict_object import DictObject
|
||||
from core.text import Text
|
||||
|
||||
|
||||
class TrickleParam(CommandParam):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.ability_first = re.compile(r"\s+([a-z]+)\s+([0-9]+)")
|
||||
self.amount_first = re.compile(r"\s+([0-9]+)\s+([a-z]+)")
|
||||
|
||||
def get_regex(self):
|
||||
regex = r"((\s+[a-z]+\s+[0-9]+|\s+[0-9]+\s+[a-z]+)+)"
|
||||
return regex
|
||||
|
||||
def get_name(self):
|
||||
return "<highlight>ability</highlight> <highlight>amount</highlight>"
|
||||
|
||||
def process_matches(self, params):
|
||||
i = params.pop(0)
|
||||
matches_amount_first = self.amount_first.findall(i)
|
||||
matches_ability_first = self.ability_first.findall(i)
|
||||
params.pop(0)
|
||||
|
||||
result = []
|
||||
if len(matches_amount_first) > len(matches_ability_first):
|
||||
for match in matches_amount_first:
|
||||
result.append(DictObject({
|
||||
"ability": match[1],
|
||||
"amount": int(match[0])
|
||||
}))
|
||||
else:
|
||||
for match in matches_ability_first:
|
||||
result.append(DictObject({
|
||||
"ability": match[0],
|
||||
"amount": int(match[1])
|
||||
}))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@instance()
|
||||
class TrickleController:
|
||||
def __init__(self):
|
||||
self.ability_first = re.compile(" ([a-z]+) ([0-9]+)")
|
||||
self.amount_first = re.compile(" ([0-9]+) ([a-z]+)")
|
||||
|
||||
def inject(self, registry):
|
||||
self.db: DB = registry.get_instance("db")
|
||||
self.text: Text = registry.get_instance("text")
|
||||
self.util = registry.get_instance("util")
|
||||
|
||||
def pre_start(self):
|
||||
self.db.load_sql_file(self.module_dir + "/" + "trickle.sql", pre_optimized=True)
|
||||
self.db.create_view("trickle")
|
||||
|
||||
@command(command="trickle", params=[TrickleParam()], access_level="member",
|
||||
description="Show skill increases due to trickle")
|
||||
def trickle_ability_cmd(self, _, trickle_params):
|
||||
abilities_map = {}
|
||||
|
||||
# initialize map with 0s
|
||||
for ability in self.util.get_all_abilities():
|
||||
abilities_map[ability] = 0
|
||||
|
||||
for p in trickle_params:
|
||||
ability = self.util.get_ability(p.ability)
|
||||
if not ability:
|
||||
return "Unknown ability <highlight>%s</highlight>." % p.ability
|
||||
|
||||
abilities_map[ability] = p.amount
|
||||
|
||||
trickle_amounts = self.get_trickle_amounts(abilities_map)
|
||||
return self.format_trickle_output(abilities_map, trickle_amounts)
|
||||
|
||||
@command(command="trickle", params=[Any("skill")], access_level="member",
|
||||
description="Show how much ability is needed to trickle a skill")
|
||||
def trickle_skill_cmd(self, _, search):
|
||||
data = self.db.query("SELECT * FROM trickle WHERE name <EXTENDED_LIKE=0> ?", [search], extended_like=True)
|
||||
count = len(data)
|
||||
|
||||
if count == 0:
|
||||
return "Could not find any skills for <highlight>%s</highlight>." % search
|
||||
elif count == 1:
|
||||
row = data[0]
|
||||
return self.format_trickle_amounts(row)
|
||||
else:
|
||||
blob = ""
|
||||
for row in data:
|
||||
blob += self.format_trickle_amounts(row) + "\n"
|
||||
return ChatBlob("Trickle Info for <highlight>%s</highlight>" % search, blob)
|
||||
|
||||
def format_trickle_amounts(self, row):
|
||||
msg = "<highlight>%s</highlight> " % row.name
|
||||
for ability in self.util.get_all_abilities():
|
||||
amount = row["amount_" + ability.lower()]
|
||||
if amount > 0:
|
||||
value = 4 / amount
|
||||
msg += "(%s: %s) " % (ability, round(value, 2))
|
||||
return msg
|
||||
|
||||
def get_abilities_map(self, search, is_reversed):
|
||||
if is_reversed:
|
||||
matches = self.amount_first.findall(search)
|
||||
else:
|
||||
matches = self.ability_first.findall(search)
|
||||
|
||||
m = {}
|
||||
|
||||
# initialize map with 0s
|
||||
for ability in self.util.get_all_abilities():
|
||||
m[ability] = 0
|
||||
|
||||
# add values that for abilities that were passed in
|
||||
for val in matches:
|
||||
if is_reversed:
|
||||
ability = self.util.get_ability(val[1])
|
||||
amount = int(val[0])
|
||||
else:
|
||||
ability = self.util.get_ability(val[0])
|
||||
amount = int(val[1])
|
||||
m[ability] += amount
|
||||
|
||||
return m
|
||||
|
||||
def get_trickle_amounts(self, abilities_map):
|
||||
# noinspection SqlAggregates
|
||||
sql = """
|
||||
SELECT
|
||||
group_name,
|
||||
name,
|
||||
amount_agility,
|
||||
amount_intelligence,
|
||||
amount_psychic,
|
||||
amount_stamina,
|
||||
amount_strength,
|
||||
amount_sense,
|
||||
(amount_agility * %d
|
||||
+ amount_intelligence * %d
|
||||
+ amount_psychic * %d
|
||||
+ amount_stamina * %d
|
||||
+ amount_strength * %d
|
||||
+ amount_sense * %d) AS amount
|
||||
FROM
|
||||
trickle
|
||||
GROUP BY
|
||||
group_name,
|
||||
name,
|
||||
amount_agility,
|
||||
amount_intelligence,
|
||||
amount_psychic,
|
||||
amount_stamina,
|
||||
amount_strength,
|
||||
amount_sense
|
||||
HAVING
|
||||
amount > 0
|
||||
ORDER BY
|
||||
id""" % \
|
||||
(abilities_map["Agility"], abilities_map["Intelligence"], abilities_map["Psychic"],
|
||||
abilities_map["Stamina"], abilities_map["Strength"], abilities_map["Sense"])
|
||||
|
||||
return self.db.query(sql)
|
||||
|
||||
def format_trickle_output(self, abilities_map, trickle_amounts):
|
||||
# create blob
|
||||
blob = ""
|
||||
group_name = ""
|
||||
for row in trickle_amounts:
|
||||
if row.group_name != group_name:
|
||||
blob += f"\n<header2>{row.group_name}</header2>\n"
|
||||
group_name = row.group_name
|
||||
|
||||
blob += f"{row.name} <highlight>{row.amount / 4:g}</highlight>\n"
|
||||
|
||||
# create title
|
||||
def trickle(x):
|
||||
return f"{x[0]} <highlight>{x[1]:d}</highlight>"
|
||||
|
||||
title = "Trickle Results: " + ", ".join(map(trickle, filter(lambda x: x[1] > 0, abilities_map.items())))
|
||||
|
||||
return ChatBlob(title, blob)
|
||||
Reference in New Issue
Block a user