Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/wormtql/yas
Browse files Browse the repository at this point in the history
  • Loading branch information
wormtql committed Nov 23, 2024
2 parents 438d491 + fd45a1c commit e7edfe4
Show file tree
Hide file tree
Showing 8 changed files with 568 additions and 460 deletions.
18 changes: 17 additions & 1 deletion yas-genshin/src/character/character_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,21 @@ lazy_static! {
"芙宁娜",
"那维莱特",
"娜维娅",
"绮良良",
"莱欧斯利",
"夏洛蒂",
"夏沃蕾",
"嘉明",
"闲云",
"千织",
"阿蕾奇诺",
"赛索斯",
"克洛琳德",
"希格雯",
"艾梅丽埃",
"卡齐娜",
"玛拉妮",
"基尼奇",
"希诺宁",
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ use std::sync::mpsc::Receiver;
use std::thread::JoinHandle;

use anyhow::Result;
use image::Rgb;
use image::{GenericImageView, RgbImage};
use log::{error, info, warn};

use yas::ocr::ImageToText;
use yas::ocr::yas_ocr_model;
use yas::positioning::{Pos, Rect};
use yas::utils::color_distance;

use crate::scanner::artifact_scanner::artifact_scanner_window_info::ArtifactScannerWindowInfo;
use crate::scanner::artifact_scanner::GenshinArtifactScannerConfig;
Expand Down Expand Up @@ -130,7 +132,7 @@ impl ArtifactScannerWorker {
let color = list_image
.get_pixel((pos_x as i32 + dx) as u32, (pos_y as i32 + dy) as u32);

if color.0[0] > 200 {
if color_distance(color, &Rgb([255, 138, 117])) < 30 {
locked = true;
break 'sq;
}
Expand Down
8 changes: 8 additions & 0 deletions yas-starrail/src/export/relic/hsr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ impl RelicSetName {
RelicSetName::PrisonerinDeepConfinement => "Prisoner in Deep Confinement",
RelicSetName::PioneerDiverofDeadWaters => "Pioneer Diver of Dead Waters",
RelicSetName::WatchmakerMasterofDreamMachinations => "Watchmaker, Master of Dream Machinations",
RelicSetName::IronCavalryAgainsttheScourge => "Iron Cavalry Against the Scourge",
RelicSetName::TheWindSoaringValorous => "The Wind-Soaring Valorous",
RelicSetName::SpaceSealingStation => "Space Sealing Station",
RelicSetName::FleetoftheAgeless => "Fleet of the Ageless",
RelicSetName::PanCosmicCommercialEnterprise => "Pan-Cosmic Commercial Enterprise",
Expand All @@ -95,6 +97,12 @@ impl RelicSetName {
RelicSetName::BrokenKeel => "Broken Keel",
RelicSetName::FirmamentFrontlineGlamoth => "Firmament Frontline: Glamoth",
RelicSetName::PenaconyLandoftheDreams => "Penacony, Land of the Dreams",
RelicSetName::SigoniatheUnclaimedDesolation => "Sigonia, the Unclaimed Desolation",
RelicSetName::IzumoGenseiandTakamaDivineRealm => "Izumo Gensei and Takama Divine Realm",
RelicSetName::DuranDynastyofRunningWolves => "Duran, Dynasty of Running Wolves",
RelicSetName::ForgeoftheKalpagniLantern => "Forge of the Kalpagni Lantern",
RelicSetName::LushakatheSunkenSeas => "Lushaka, the Sunken Seas",
RelicSetName::TheWondrousBananAmusementPark => "The Wondrous BananAmusement Park",
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions yas-starrail/src/export/relic/march7th.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ impl RelicSetName {
RelicSetName::PrisonerinDeepConfinement => "PrisonerinDeepConfinement",
RelicSetName::PioneerDiverofDeadWaters => "PioneerDiverofDeadWaters",
RelicSetName::WatchmakerMasterofDreamMachinations => "WatchmakerMasterofDreamMachinations",
RelicSetName::IronCavalryAgainsttheScourge => "IronCavalryAgainsttheScourge",
RelicSetName::TheWindSoaringValorous => "TheWindSoaringValorous",

RelicSetName::SpaceSealingStation => "SpaceSealingStation",
RelicSetName::FleetoftheAgeless => "FleetoftheAgeless",
Expand All @@ -70,6 +72,12 @@ impl RelicSetName {
RelicSetName::BrokenKeel => "BrokenKeel",
RelicSetName::FirmamentFrontlineGlamoth => "FirmamentFrontlineGlamoth",
RelicSetName::PenaconyLandoftheDreams => "PenaconyLandoftheDreams",
RelicSetName::SigoniatheUnclaimedDesolation => "SigoniatheUnclaimedDesolation",
RelicSetName::IzumoGenseiandTakamaDivineRealm => "IzumoGenseiandTakamaDivineRealm",
RelicSetName::DuranDynastyofRunningWolves => "DuranDynastyofRunningWolves",
RelicSetName::ForgeoftheKalpagniLantern => "ForgeoftheKalpagniLantern",
RelicSetName::LushakatheSunkenSeas => "LushakatheSunkenSeas",
RelicSetName::TheWondrousBananAmusementPark => "TheWondrousBananAmusementPark",
};
String::from(temp)
}
Expand Down
30 changes: 24 additions & 6 deletions yas-starrail/src/relic/relic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum RelicSlot {
LinkRope,
}

// https://github.com/Mar-7th/StarRailRes/blob/master/index_new/en/relic_sets.json
#[derive(Debug, Hash, Clone, PartialEq, Eq, Display)]
pub enum RelicSetName {
PasserbyofWanderingCloud,
Expand All @@ -59,6 +60,8 @@ pub enum RelicSetName {
PrisonerinDeepConfinement,
PioneerDiverofDeadWaters,
WatchmakerMasterofDreamMachinations,
IronCavalryAgainsttheScourge,
TheWindSoaringValorous,

SpaceSealingStation,
FleetoftheAgeless,
Expand All @@ -72,6 +75,12 @@ pub enum RelicSetName {
BrokenKeel,
FirmamentFrontlineGlamoth,
PenaconyLandoftheDreams,
SigoniatheUnclaimedDesolation,
IzumoGenseiandTakamaDivineRealm,
DuranDynastyofRunningWolves,
ForgeoftheKalpagniLantern,
LushakatheSunkenSeas,
TheWondrousBananAmusementPark,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -235,6 +244,7 @@ impl TryFrom<&StarRailRelicScanResult> for StarRailRelic {
}
}

// https://github.com/Mar-7th/StarRailRes/blob/master/index_new/cn/relics.json
impl RelicSetName {
#[rustfmt::skip]
pub fn from_zh_cn(s: &str) -> Option<RelicSetName> {
Expand All @@ -257,6 +267,8 @@ impl RelicSetName {
"系囚的合啮拘笼" | "系囚的铅石梏铐" | "系囚的幽闭缚束" | "系囚的绝足锁桎" => Some(RelicSetName::PrisonerinDeepConfinement),
"先驱的绝热围壳" | "先驱的虚极罗盘" | "先驱的密合铅衣" | "先驱的泊星桩锚" => Some(RelicSetName::PioneerDiverofDeadWaters),
"钟表匠的极目透镜" | "钟表匠的交运腕表" | "钟表匠的空幻礼服" | "钟表匠的隐梦革履" => Some(RelicSetName::WatchmakerMasterofDreamMachinations),
"铁骑的索敌战盔" | "铁骑的摧坚铁腕" | "铁骑的银影装甲" | "铁骑的行空护胫" => Some(RelicSetName::IronCavalryAgainsttheScourge),
"勇烈的玄枵面甲" | "勇烈的钩爪腕甲" | "勇烈的飞翎瓷甲" | "勇烈的逐猎腿甲" => Some(RelicSetName::TheWindSoaringValorous),

"「黑塔」的空间站点" | "「黑塔」的漫历轨迹" => Some(RelicSetName::SpaceSealingStation),
"罗浮仙舟的天外楼船" | "罗浮仙舟的建木枝蔓" => Some(RelicSetName::FleetoftheAgeless),
Expand All @@ -270,6 +282,12 @@ impl RelicSetName {
"伊须磨洲的残船鲸落" | "伊须磨洲的坼裂缆索" => Some(RelicSetName::BrokenKeel),
"格拉默的铁骑兵团" | "格拉默的寂静坟碑" => Some(RelicSetName::FirmamentFrontlineGlamoth),
"匹诺康尼的堂皇酒店" | "匹诺康尼的逐梦轨道" => Some(RelicSetName::PenaconyLandoftheDreams),
"茨冈尼亚的母神卧榻" | "茨冈尼亚的轮回纽结" => Some(RelicSetName::SigoniatheUnclaimedDesolation),
"出云的祸津众神" | "出云的终始一刀" => Some(RelicSetName::IzumoGenseiandTakamaDivineRealm),
"都蓝的穹窿金帐" | "都蓝的器兽缰辔" => Some(RelicSetName::DuranDynastyofRunningWolves),
"铸炼宫的莲华灯芯" | "铸炼宫的焰轮天绸" => Some(RelicSetName::ForgeoftheKalpagniLantern),
"露莎卡的水朽苍都" | "露莎卡的双生航道" => Some(RelicSetName::LushakatheSunkenSeas),
"蕉乐园的蕉芯广场" | "蕉乐园的模因线缆" => Some(RelicSetName::TheWondrousBananAmusementPark),
_ => None,
}
}
Expand All @@ -279,12 +297,12 @@ impl RelicSlot {
#[rustfmt::skip]
pub fn from_zh_cn(s: &str) -> Option<RelicSlot> {
match s {
"过客的逢春木簪" | "快枪手的野穗毡帽" | "圣骑的宽恕盔面" | "雪猎的荒神兜帽" | "拳王的冠军护头" | "铁卫的铸铁面盔" | "火匠的黑耀目镜" | "天才的超距遥感" | "乐队的偏光墨镜" | "翔鹰的长喙头盔" | "怪盗的千人假面" | "废土客的呼吸面罩" | "莳者的复明义眼" | "信使的全息目镜" | "大公的冥焰冠冕" | "系囚的合啮拘笼" | "先驱的绝热围壳" | "钟表匠的极目透镜" => Some(RelicSlot::Head),
"过客的游龙臂鞲" | "快枪手的粗革手套" | "圣骑的沉默誓环" | "雪猎的巨蜥手套" | "拳王的重炮拳套" | "铁卫的银鳞手甲" | "火匠的御火戒指" | "天才的频变捕手" | "乐队的巡演手绳" | "翔鹰的鹰击指环" | "怪盗的绘纹手套" | "废土客的荒漠终端" | "莳者的机巧木手" | "信使的百变义手" | "大公的绒火指套" | "系囚的铅石梏铐" | "先驱的虚极罗盘" | "钟表匠的交运腕表" => Some(RelicSlot::Hands),
"过客的残绣风衣" | "快枪手的猎风披肩" | "圣骑的肃穆胸甲" | "雪猎的冰龙披风" | "拳王的贴身护胸" | "铁卫的旧制军服" | "火匠的阻燃围裙" | "天才的元域深潜" | "乐队的钉刺皮衣" | "翔鹰的翼装束带" | "怪盗的纤钢爪钩" | "废土客的修士长袍" | "莳者的承露羽衣" | "信使的密信挎包" | "大公的蒙恩长袍" | "系囚的幽闭缚束" | "先驱的密合铅衣" | "钟表匠的空幻礼服" => Some(RelicSlot::Body),
"过客的冥途游履" | "快枪手的铆钉马靴" | "圣骑的秩序铁靴" | "雪猎的鹿皮软靴" | "拳王的弧步战靴" | "铁卫的白银护胫" | "火匠的合金义肢" | "天才的引力漫步" | "乐队的铆钉短靴" | "翔鹰的绒羽绑带" | "怪盗的流星快靴" | "废土客的动力腿甲" | "莳者的天人丝履" | "信使的酷跑板鞋" | "大公的绅雅礼靴" | "系囚的绝足锁桎" | "先驱的泊星桩锚" | "钟表匠的隐梦革履" => Some(RelicSlot::Feet),
"「黑塔」的空间站点" | "罗浮仙舟的天外楼船" | "公司的巨构总部" | "贝洛伯格的存护堡垒" | "螺丝星的机械烈阳" | "萨尔索图的移动城市" | "塔利亚的钉壳小镇" | "翁瓦克的诞生之岛" | "泰科铵的镭射球场" | "伊须磨洲的残船鲸落" | "格拉默的铁骑兵团" | "匹诺康尼的堂皇酒店" => Some(RelicSlot::PlanarSphere),
"「黑塔」的漫历轨迹" | "罗浮仙舟的建木枝蔓" | "公司的贸易航道" | "贝洛伯格的铁卫防线" | "螺丝星的环星孔带" | "萨尔索图的晨昏界线" | "塔利亚的裸皮电线" | "翁瓦克的环岛海岸" | "泰科铵的弧光赛道" | "伊须磨洲的坼裂缆索" | "格拉默的寂静坟碑" | "匹诺康尼的逐梦轨道" => Some(RelicSlot::LinkRope),
"过客的逢春木簪" | "快枪手的野穗毡帽" | "圣骑的宽恕盔面" | "雪猎的荒神兜帽" | "拳王的冠军护头" | "铁卫的铸铁面盔" | "火匠的黑耀目镜" | "天才的超距遥感" | "乐队的偏光墨镜" | "翔鹰的长喙头盔" | "怪盗的千人假面" | "废土客的呼吸面罩" | "莳者的复明义眼" | "信使的全息目镜" | "大公的冥焰冠冕" | "系囚的合啮拘笼" | "先驱的绝热围壳" | "钟表匠的极目透镜" | "铁骑的索敌战盔" | "勇烈的玄枵面甲" => Some(RelicSlot::Head),
"过客的游龙臂鞲" | "快枪手的粗革手套" | "圣骑的沉默誓环" | "雪猎的巨蜥手套" | "拳王的重炮拳套" | "铁卫的银鳞手甲" | "火匠的御火戒指" | "天才的频变捕手" | "乐队的巡演手绳" | "翔鹰的鹰击指环" | "怪盗的绘纹手套" | "废土客的荒漠终端" | "莳者的机巧木手" | "信使的百变义手" | "大公的绒火指套" | "系囚的铅石梏铐" | "先驱的虚极罗盘" | "钟表匠的交运腕表" | "铁骑的摧坚铁腕" | "勇烈的钩爪腕甲" => Some(RelicSlot::Hands),
"过客的残绣风衣" | "快枪手的猎风披肩" | "圣骑的肃穆胸甲" | "雪猎的冰龙披风" | "拳王的贴身护胸" | "铁卫的旧制军服" | "火匠的阻燃围裙" | "天才的元域深潜" | "乐队的钉刺皮衣" | "翔鹰的翼装束带" | "怪盗的纤钢爪钩" | "废土客的修士长袍" | "莳者的承露羽衣" | "信使的密信挎包" | "大公的蒙恩长袍" | "系囚的幽闭缚束" | "先驱的密合铅衣" | "钟表匠的空幻礼服" | "铁骑的银影装甲" | "勇烈的飞翎瓷甲" => Some(RelicSlot::Body),
"过客的冥途游履" | "快枪手的铆钉马靴" | "圣骑的秩序铁靴" | "雪猎的鹿皮软靴" | "拳王的弧步战靴" | "铁卫的白银护胫" | "火匠的合金义肢" | "天才的引力漫步" | "乐队的铆钉短靴" | "翔鹰的绒羽绑带" | "怪盗的流星快靴" | "废土客的动力腿甲" | "莳者的天人丝履" | "信使的酷跑板鞋" | "大公的绅雅礼靴" | "系囚的绝足锁桎" | "先驱的泊星桩锚" | "钟表匠的隐梦革履" | "铁骑的行空护胫" | "勇烈的逐猎腿甲" => Some(RelicSlot::Feet),
"「黑塔」的空间站点" | "罗浮仙舟的天外楼船" | "公司的巨构总部" | "贝洛伯格的存护堡垒" | "螺丝星的机械烈阳" | "萨尔索图的移动城市" | "塔利亚的钉壳小镇" | "翁瓦克的诞生之岛" | "泰科铵的镭射球场" | "伊须磨洲的残船鲸落" | "格拉默的铁骑兵团" | "匹诺康尼的堂皇酒店" | "茨冈尼亚的母神卧榻" | "出云的祸津众神" | "都蓝的穹窿金帐" | "铸炼宫的莲华灯芯" | "露莎卡的水朽苍都" | "蕉乐园的蕉芯广场" => Some(RelicSlot::PlanarSphere),
"「黑塔」的漫历轨迹" | "罗浮仙舟的建木枝蔓" | "公司的贸易航道" | "贝洛伯格的铁卫防线" | "螺丝星的环星孔带" | "萨尔索图的晨昏界线" | "塔利亚的裸皮电线" | "翁瓦克的环岛海岸" | "泰科铵的弧光赛道" | "伊须磨洲的坼裂缆索" | "格拉默的寂静坟碑" | "匹诺康尼的逐梦轨道" | "茨冈尼亚的轮回纽结" | "出云的终始一刀" | "都蓝的器兽缰辔" | "铸炼宫的焰轮天绸" | "露莎卡的双生航道" | "蕉乐园的模因线缆" => Some(RelicSlot::LinkRope),
_ => None,
}
}
Expand Down
23 changes: 15 additions & 8 deletions yas-starrail/src/scanner/relic_scanner/match_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ pub struct MatchColors {
pub match_colors_star: [Rgb<u8>; 5],
pub match_colors_lock: [Rgb<u8>; 3],
pub match_colors_discard: [Rgb<u8>; 3],
pub match_colors_equipper: [(&'static str, Rgb<u8>); 43],
pub match_colors_equipper: [(&'static str, Rgb<u8>); 50],
}

pub const MATCH_COLORS: MatchColors = MatchColors {
match_colors_star: [
Rgb([113, 119, 139]), // todo
Rgb([42, 143, 114]), // todo
Rgb([96, 142, 197]),
Rgb([157, 117, 206]),
Rgb([193, 158, 112]),
Rgb([144, 144, 154]), // 1
Rgb([75, 146, 146]), // 2
Rgb([96, 142, 197]), // 3
Rgb([157, 117, 206]), // 4
Rgb([193, 158, 112]), // 5
],
match_colors_lock: [
Rgb([18, 18, 18]), // locked
Expand All @@ -26,18 +26,24 @@ pub const MATCH_COLORS: MatchColors = MatchColors {
Rgb([115, 108, 98]), // locked
],
match_colors_equipper: [
("Acheron", Rgb([249, 246, 235])),
("Argenti", Rgb([216, 174, 161])),
("Arlan", Rgb([146, 134, 124])),
("Asta", Rgb([188, 130, 117])),
("Aventurine", Rgb([221, 206, 189])),
("Bailu", Rgb([160, 127, 174])),
("BlackSwan", Rgb([252, 242, 239])),
("Blade", Rgb([191, 162, 162])),
("Boothill", Rgb([127, 95, 94])),
("Bronya", Rgb([83, 66, 83])),
("Clara", Rgb([181, 107, 129])),
("DanHeng", Rgb([124, 100, 100])),
("DanHengImbibitorLunae", Rgb([181, 169, 163])),
("DrRatio", Rgb([134, 120, 143])),
("Feixiao", Rgb([69, 47, 47])),
("Firefly", Rgb([100, 100, 120])),
("FuXuan", Rgb([231, 166, 145])),
("Gallagher", Rgb([117, 77, 60])),
("Gepard", Rgb([192, 199, 223])),
("Guinaifen", Rgb([219, 137, 111])),
("Hanya", Rgb([247, 238, 232])),
Expand All @@ -51,20 +57,21 @@ pub const MATCH_COLORS: MatchColors = MatchColors {
("Luka", Rgb([218, 198, 183])),
("Luocha", Rgb([191, 160, 116])),
("Lynx", Rgb([247, 213, 197])),
("March7th", Rgb([251, 243, 243])),
("Misha", Rgb([234, 215, 213])),
("Moze", Rgb([243, 239, 234])),
("Natasha", Rgb([238, 208, 196])),
("Pela", Rgb([241, 217, 217])),
("Qingque", Rgb([18, 27, 11])),
("Robin", Rgb([247, 236, 232])),
("RuanMei", Rgb([129, 101, 101])),
("Sampo", Rgb([241, 217, 213])),
("Seele", Rgb([91, 65, 111])),
("Serval", Rgb([158, 141, 150])),
("SilverWolf", Rgb([222, 210, 210])),
("Sparkle", Rgb([227, 164, 196])),
("Sushang", Rgb([101, 65, 58])),
("Tingyun", Rgb([127, 116, 57])),
("TopazNumby", Rgb([254, 250, 246])),
("Trailblazer_Preservation", Rgb([153, 125, 111])),
("Welt", Rgb([158, 114, 99])),
("Xueyi", Rgb([250, 242, 230])),
("Yanqing", Rgb([255, 242, 232])),
Expand Down
Loading

0 comments on commit e7edfe4

Please sign in to comment.