Skip to content

Commit

Permalink
fix: DB exp
Browse files Browse the repository at this point in the history
修复内置表达式未更新格式的问题
优化掉mExpression
  • Loading branch information
mystringEmpty committed Oct 11, 2023
1 parent 3b904c7 commit 691a40a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 49 deletions.
20 changes: 4 additions & 16 deletions Dice/CharacterCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ int loadCardTemp(const std::filesystem::path& fpPath, dict_ci<CardTemp>& m) {
}
}
}
else if (tag == "diceexp") {
if (auto text{ elem->GetText() })readini(Text2GBK(text), tp.mExpression);
}
else if (tag == "presets") {
for (auto kid = elem->FirstChildElement(); kid; kid = kid->NextSiblingElement()) {
if (auto opt{ kid->Attribute("name") })tp.presets[Text2GBK(opt)] = CardPreset(kid, isUTF8);
Expand Down Expand Up @@ -177,13 +174,6 @@ string CardTemp::show() {
}
res << "预设属性:" + resVar.show("/");
}
if (!mExpression.empty()) {
ResList resExp;
for (const auto& [key, val] : mExpression) {
resExp << key;
}
res << "掷骰公式:" + resExp.show();
}
return "pc模板:" + type + res.show();
}

Expand Down Expand Up @@ -254,16 +244,14 @@ string CharaCard::getExp(string& key, std::unordered_set<string> sRef){
auto temp{ getTemplet() };
auto val = dict->find("&" + key);
if (val != dict->end())return escape(val->second.to_str(), sRef);
if (auto exp = temp->mExpression.find(key); exp != temp->mExpression.end()) return escape(exp->second, sRef);
if ((val = dict->find(key)) != dict->end())return escape(val->second.to_str(), sRef);
if (auto exp = temp->AttrShapes.find("&" + key); exp != temp->AttrShapes.end())return escape(exp->second.init(this).to_str(), sRef);
else if ((val = dict->find(key)) != dict->end())return escape(val->second.to_str(), sRef);
else if (auto exp = temp->AttrShapes.find("&" + key); exp != temp->AttrShapes.end())return escape(exp->second.init(this).to_str(), sRef);
else if (auto exp = temp->AttrShapes.find(key); exp != temp->AttrShapes.end())return escape(exp->second.init(this).to_str(), sRef);
return "0";
}
bool CharaCard::countExp(const string& key)const {
return (key[0] == '&' && has(key))
|| (has("&" + key))
|| getTemplet()->mExpression.count(key);
return key[0] == '&' ? (has(key) || getTemplet()->canGet(key))
: (has("&" + key) || getTemplet()->canGet("&" + key));
}
std::optional<int> CharaCard::cal(string exp)const {
if (exp[0] == '&'){
Expand Down
8 changes: 4 additions & 4 deletions Dice/CharacterCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ class CardTemp
vector<vector<string>> vBasicList = {};
//元表
fifo_dict_ci<AttrShape> AttrShapes;
//表达式
fifo_dict_ci<> mExpression = {};
//生成参数
dict_ci<CardPreset> presets = {};
CardTemp() = default;

CardTemp(const string& type, const fifo_dict_ci<>& replace, vector<vector<string>> basic,
const fifo_dict_ci<>& dynamic, const fifo_dict_ci<>& exp,
const fifo_dict_ci<>& dynamic, const fifo_dict_ci<>& exps,
const fifo_dict_ci<int>& def_skill, const dict_ci<CardPreset>& option = {}) : type(type),
replaceName(replace),
vBasicList(basic),
mExpression(exp),
presets(option)
{
for (auto& [attr, exp] : dynamic) {
AttrShapes[attr] = AttrShape(exp, AttrShape::TextType::Dicexp);
}
for (auto& [attr, exp] : exps) {
AttrShapes["&" + attr] = AttrShape(exp, AttrShape::TextType::Plain);
}
for (auto& [attr, val] : def_skill) {
AttrShapes[attr] = val;
}
Expand Down
58 changes: 29 additions & 29 deletions Dice/RDConstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,46 +136,46 @@ static fifo_dict_ci<std::string> ExpressionCOC7 = {
{"__DefaultDiceExp", "1D"},
{"医学回复", "1D3"},
{"精神分析回复", "1D3"},
{"徒手伤害", "1D3+[DB]"},
{"徒手伤害", "1D3+{DB}"},
{"徒手", "&徒手伤害"},
{"空手", "&徒手伤害"},
{"弓箭", "1D6+[DB]/2"},
{"指虎", "1D3+1+[DB]"},
{"长鞭", "1D3+[DB]/2"},
{"弓箭", "1D6+{DB}/2"},
{"指虎", "1D3+1+{DB}"},
{"长鞭", "1D3+{DB}/2"},
{"火把", "1D6"},
{"电锯", "2D8"},
{"包皮铁棍", "1D8+[DB]"},
{"甩棍", "1D8+[DB]"},
{"大型棍", "1D8+[DB]"},
{"小型棍", "1D6+[DB]"},
{"警棍", "1D6+[DB]"},
{"包皮铁棍", "1D8+{DB}"},
{"甩棍", "1D8+{DB}"},
{"大型棍", "1D8+{DB}"},
{"小型棍", "1D6+{DB}"},
{"警棍", "1D6+{DB}"},
{"", "1D8+2"},
{"绞索", "1D6+[DB]"},
{"手斧", "1D6+1+[DB]"},
{"手镰", "1D6+1+[DB]"},
{"镰刀", "1D6+1+[DB]"},
{"大型刀", "1D8+[DB]"},
{"中型刀", "1D4+2+[DB]"},
{"小型刀", "1D4+[DB]"},
{"绞索", "1D6+{DB}"},
{"手斧", "1D6+1+{DB}"},
{"手镰", "1D6+1+{DB}"},
{"镰刀", "1D6+1+{DB}"},
{"大型刀", "1D8+{DB}"},
{"中型刀", "1D4+2+{DB}"},
{"小型刀", "1D4+{DB}"},
{"通电导线", "&220v通电导线"},
{"220v通电导线", "2D8"},
{"双节棍", "1D8+[DB]"},
{"投石", "1D4+[DB]/2"},
{"手里剑", "1D3+[DB]/2"},
{"双节棍", "1D8+{DB}"},
{"投石", "1D4+{DB}/2"},
{"手里剑", "1D3+{DB}/2"},
{"", "1D8+1"},
{"骑士长枪", "1D8+1"},
{"掷矛", "1D8+[DB]/2"},
{"大型剑", "1D8+1+[DB]"},
{"中型剑", "1D6+1+[DB]"},
{"佩剑", "1D6+1+[DB]"},
{"重剑", "1D6+1+[DB]"},
{"轻型剑", "1D6+[DB]"},
{"剑杖", "1D6+[DB]"},
{"掷矛", "1D8+{DB}/2"},
{"大型剑", "1D8+1+{DB}"},
{"中型剑", "1D6+1+{DB}"},
{"佩剑", "1D6+1+{DB}"},
{"重剑", "1D6+1+{DB}"},
{"轻型剑", "1D6+{DB}"},
{"剑杖", "1D6+{DB}"},
{"电棍", "1D3"},
{"电击枪", "1D3"},
{"回旋镖", "1D8+[DB]/2"},
{"战斗回力镖", "1D8+[DB]/2"},
{"伐木斧", "1D8+2+[DB]"},
{"回旋镖", "1D8+{DB}/2"},
{"战斗回力镖", "1D8+{DB}/2"},
{"伐木斧", "1D8+2+{DB}"},
{"燧发枪", "1D6+1"},
{"5.6mm小型自动手枪", "1D6"},
{"6.35mm短口手枪", "1D6"},
Expand Down

0 comments on commit 691a40a

Please sign in to comment.