From 6bb0c85eb9c42f37f8e857ed7eded2fb1c7f12c6 Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Sun, 1 Oct 2023 01:45:04 +0000 Subject: [PATCH] Move skillName logic to wasm --- src/Game.js | 17 +- src/rs/build.rs | 87 +++------ src/rs/src/game.rs | 28 +-- src/rs/src/skill.rs | 416 ++++++++++++++++++++++++++++++++++++++++++++ src/views/Match.jsx | 33 +--- 5 files changed, 462 insertions(+), 119 deletions(-) diff --git a/src/Game.js b/src/Game.js index 410a55f1..63bc57f7 100644 --- a/src/Game.js +++ b/src/Game.js @@ -5,17 +5,6 @@ import enums from './enum.json' assert { type: 'json' }; import { randint } from './util.js'; import * as wasm from './rs/pkg/etg.js'; -function decodeSkillName(cell) { - const skid = cell & 0xffff, - n = enums.Skill[skid], - c = enums.SkillParams[skid] ?? 0; - return c === 0 - ? n - : c === 1 - ? `${n} ${cell >> 16}` - : `${n} ${(((cell >> 16) & 0xff) << 24) >> 24} ${cell >> 24}`; -} - export default class Game { constructor(data) { this.game = new wasm.Game( @@ -138,11 +127,7 @@ export default class Game { ); } getSkill(id, k) { - const name = Array.from( - this.get_one_skill(id, enums.EventId[k]), - decodeSkillName, - ); - if (name.length) return name; + return this.get_one_skill(id, enums.EventId[k]); } tgtToPos(id, p1id) { const pos = this.tgt_to_pos(id, p1id); diff --git a/src/rs/build.rs b/src/rs/build.rs index 2c53d18f..46ce0339 100644 --- a/src/rs/build.rs +++ b/src/rs/build.rs @@ -9,14 +9,9 @@ use serde_json::Value; #[derive(Default, Serialize)] struct Enums { - Event: BTreeMap, EventId: BTreeMap, - Flag: BTreeMap, FlagId: BTreeMap, Fx: BTreeMap, - Skill: BTreeMap, - SkillParams: BTreeMap, - Stat: BTreeMap, StatId: BTreeMap, } @@ -182,35 +177,30 @@ fn process_cards(set: &'static str, path: &'static str, source: &mut String, enu if event.starts_with(b"Own") { event[3] -= b'a' - b'A'; } - if skill == b"static" { - skill.insert(0, b'r'); - skill.insert(1, b'#'); - } else { - let mut idx = 0; - loop { - let mut replaced = false; - while idx < skill.len() { - let ch = skill[idx]; - if ch == b' ' { - skill[idx] = if replaced { b',' } else { b'(' }; - replaced = true; - } else if ch == b',' { - idx += 1; - break; - } - idx += 1; - } - if replaced { - skill.insert(idx - (idx < skill.len()) as usize, b')'); + let mut idx = 0; + loop { + let mut replaced = false; + while idx < skill.len() { + let ch = skill[idx]; + if ch == b' ' { + skill[idx] = if replaced { b',' } else { b'(' }; + replaced = true; + } else if ch == b',' { idx += 1; - } - if idx < skill.len() { - skill.splice(idx..idx, b"Skill::".iter().cloned()); - idx += "Skill::".len(); - continue; - } else { break; } + idx += 1; + } + if replaced { + skill.insert(idx - (idx < skill.len()) as usize, b')'); + idx += 1; + } + if idx < skill.len() { + skill.splice(idx..idx, b"Skill::".iter().cloned()); + idx += "Skill::".len(); + continue; + } else { + break; } } write!( @@ -298,45 +288,12 @@ fn main() { eventid += 1; let mut ownname = String::from("own"); ownname.push_str(&name); - enums.Event.insert(id, name.clone()); - enums.Event.insert(id | 128, ownname.clone()); enums.EventId.insert(name, id); enums.EventId.insert(ownname, id | 128); } } } - source.push_str("pub fn id_skill(s:Skill)->i32{match s{\n"); - let skillskill = subsource(&skillrs, "pub enum Skill {\n"); - let mut skillid = 1; - for line in skillskill.lines() { - let line = line.trim(); - if let Some(end) = line.rfind(",") { - let start = if line.starts_with("r#") { 2 } else { 0 }; - let line = &line[start..end]; - let end = end - start; - let id = skillid; - skillid += 1; - let skillend = line.find("("); - let name = &line[..skillend.unwrap_or(end)]; - enums.Skill.insert(id, String::from(name)); - source.push_str("Skill::"); - if name == "static" { - source.push_str("r#"); - } - source.push_str(name); - if let Some(skillend) = skillend { - enums.SkillParams.insert( - id, - line[skillend..].bytes().filter(|&c| c == b',').count() as u16 + 1, - ); - source.push_str("(..)") - } - write!(source, "=>{},\n", id).ok(); - } - } - source.push_str("}}\n"); - source.push_str("pub fn id_stat(s:Stat)->i32{match s{\n"); let gamestat = subsource(&gamers, "pub enum Stat {\n"); let mut stat_source = String::from("pub fn stat_id(s:i32)->Option{Some(match s{\n"); @@ -347,7 +304,6 @@ fn main() { let name = line[start..end].trim(); let id = statid; statid += 1; - enums.Stat.insert(id, String::from(name)); enums.StatId.insert(String::from(name), id); write!(source, "Stat::{}=>{},\n", name, id).ok(); write!(stat_source, "{}=>Stat::{},\n", id, name).ok(); @@ -367,7 +323,6 @@ fn main() { let name = &line["pub const ".len()..colonidx]; let id = statid; statid += 1; - enums.Flag.insert(id, String::from(name)); enums.FlagId.insert(String::from(name), id); write!(source, "Flag::{}=>{},\n", name, id).ok(); write!(flag_source, "{}=>Flag::{},\n", id, name).ok(); diff --git a/src/rs/src/game.rs b/src/rs/src/game.rs index 64367630..ced0bb92 100644 --- a/src/rs/src/game.rs +++ b/src/rs/src/game.rs @@ -5,6 +5,7 @@ use alloc::borrow::Cow; use alloc::rc::Rc; +use alloc::string::String; use alloc::vec; use alloc::vec::Vec; use core::cmp; @@ -883,18 +884,25 @@ impl Game { } } - pub fn get_one_skill(&self, id: i32, k: u8) -> Vec { + pub fn get_one_skill(&self, id: i32, k: u8) -> Option { if let Ok(event) = Event::try_from(k) { - self.get_thing(id) - .skill - .get(event) - .map(|sk| sk.as_ref()) - .unwrap_or(&[]) - .iter() - .map(|&sk| generated::id_skill(sk) | sk.param1() << 16 | sk.param2() << 24) - .collect() + if let Some(sk) = self.get_thing(id).skill.get(event) { + if sk.is_empty() { + None + } else { + let mut name = String::new(); + for s in sk.iter() { + s.push_name(self, id, &mut name); + name.push(' '); + } + name.truncate(name.len() - 1); + Some(name) + } + } else { + None + } } else { - Vec::new() + None } } diff --git a/src/rs/src/skill.rs b/src/rs/src/skill.rs index 65db0eef..38fb0eb2 100644 --- a/src/rs/src/skill.rs +++ b/src/rs/src/skill.rs @@ -4,9 +4,11 @@ use alloc::borrow::Cow; use alloc::rc::Rc; +use alloc::string::String; use alloc::vec; use alloc::vec::Vec; use core::cmp; +use core::fmt::Write; use core::iter::once; use core::num::{NonZeroU32, NonZeroU8}; @@ -834,6 +836,420 @@ enum Soya { } impl Skill { + pub fn push_name(self, ctx: &Game, id: i32, out: &mut String) { + match self { + Self::r#_tracedeath => out.push_str("_tracedeath"), + Self::abomination => out.push_str("abomination"), + Self::absorbdmg => out.push_str("absorbdmg"), + Self::absorber => out.push_str("absorber"), + Self::acceleration => out.push_str("acceleration"), + Self::accretion => out.push_str("accretion"), + Self::accumulation => out.push_str("accumulation"), + Self::adrenaline => out.push_str("adrenaline"), + Self::aflatoxin => out.push_str("aflatoxin"), + Self::aggroskele => out.push_str("aggroskele"), + Self::alphawolf => out.push_str("alphawolf"), + Self::antimatter => out.push_str("antimatter"), + Self::appease => out.push_str("appease"), + Self::autoburrow => out.push_str("autoburrow"), + Self::autoburrowoff => out.push_str("autoburrowoff"), + Self::autoburrowproc => out.push_str("autoburrowproc"), + Self::axe => out.push_str("axe"), + Self::axedraw => out.push_str("axedraw"), + Self::bblood => out.push_str("bblood"), + Self::becomearctic => out.push_str("becomearctic"), + Self::beguile => out.push_str("beguile"), + Self::beguilestop => out.push_str("beguilestop"), + Self::bellweb => out.push_str("bellweb"), + Self::blackhole => out.push_str("blackhole"), + Self::bless => out.push_str("bless"), + Self::blockwithcharge => out.push_str("blockwithcharge"), + Self::bloodmoon => out.push_str("bloodmoon"), + Self::bolsterintodeck => out.push_str("bolsterintodeck"), + Self::boneyard => out.push_str("boneyard"), + Self::bounce => out.push_str("bounce"), + Self::bow => out.push_str("bow"), + Self::bravery => out.push_str("bravery"), + Self::brawl => out.push_str("brawl"), + Self::brew => out.push_str("brew"), + Self::brokenmirror => out.push_str("brokenmirror"), + Self::bubbleclear => out.push_str("bubbleclear"), + Self::burrow => out.push_str(if ctx.get(id, Flag::burrowed) { + "burrow" + } else { + "unburrow" + }), + Self::butterfly => out.push_str("butterfly"), + Self::catapult => out.push_str("catapult"), + Self::catlife => out.push_str("catlife"), + Self::cell => out.push_str("cell"), + Self::chaos => out.push_str("chaos"), + Self::chimera => out.push_str("chimera"), + Self::chromastat => out.push_str("chromastat"), + Self::clear => out.push_str("clear"), + Self::cold => out.push_str("cold"), + Self::corpseexplosion => out.push_str("corpseexplosion"), + Self::counter => out.push_str("counter"), + Self::countimmbur => out.push_str("countimmbur"), + Self::cpower => out.push_str("cpower"), + Self::creatureupkeep => out.push_str("creatureupkeep"), + Self::cseed => out.push_str("cseed"), + Self::cseed2 => out.push_str("cseed2"), + Self::dagger => out.push_str("dagger"), + Self::deadalive => out.push_str("deadalive"), + Self::deathwish => out.push_str("deathwish"), + Self::deckblast => out.push_str("deckblast"), + Self::decrsteam => out.push_str("decrsteam"), + Self::deepdive => out.push_str("deepdive"), + Self::deepdiveproc => out.push_str("deepdiveproc"), + Self::deepdiveproc2 => out.push_str("deepdiveproc2"), + Self::deja => out.push_str("deja"), + Self::deployblobs => out.push_str("deployblobs"), + Self::despair => out.push_str("despair"), + Self::destroy => out.push_str("destroy"), + Self::destroycard => out.push_str("destroycard"), + Self::detain => out.push_str("detain"), + Self::devour => out.push_str("devour"), + Self::die => out.push_str("die"), + Self::disarm => out.push_str("disarm"), + Self::disc => out.push_str("disc"), + Self::discping => out.push_str("discping"), + Self::disfield => out.push_str("disfield"), + Self::disshield => out.push_str("disshield"), + Self::dive => out.push_str("dive"), + Self::divinity => out.push_str("divinity"), + Self::dmgproduce => out.push_str("dmgproduce"), + Self::draft => out.push_str("draft"), + Self::drainlife => out.push_str("drainlife"), + Self::drawcopy => out.push_str("drawcopy"), + Self::drawequip => out.push_str("drawequip"), + Self::drawpillar => out.push_str("drawpillar"), + Self::dryspell => out.push_str("dryspell"), + Self::dshield => out.push_str("dshield"), + Self::dshieldoff => out.push_str("dshieldoff"), + Self::duality => out.push_str("duality"), + Self::earthquake => out.push_str("earthquake"), + Self::eatspell => out.push_str("eatspell"), + Self::elf => out.push_str("elf"), + Self::embezzle => out.push_str("embezzle"), + Self::embezzledeath => out.push_str("embezzledeath"), + Self::empathy => out.push_str("empathy"), + Self::enchant => out.push_str("enchant"), + Self::endow => out.push_str("endow"), + Self::envenom => out.push_str("envenom"), + Self::epidemic => out.push_str("epidemic"), + Self::epoch => out.push_str("epoch"), + Self::epochreset => out.push_str("epochreset"), + Self::equalize => out.push_str("equalize"), + Self::evade(x) => { + write!(out, "evade{}", x); + } + Self::evade100 => out.push_str("evade100"), + Self::evadecrea => out.push_str("evadecrea"), + Self::evadespell => out.push_str("evadespell"), + Self::evolve => out.push_str("evolve"), + Self::feed => out.push_str("feed"), + Self::fickle => out.push_str("fickle"), + Self::fiery => out.push_str("fiery"), + Self::firebolt => out.push_str("firebolt"), + Self::firebrand => out.push_str("firebrand"), + Self::firestorm(x) => { + write!(out, "firestorm{}", x); + } + Self::firewall => out.push_str("firewall"), + Self::flood => out.push_str("flood"), + Self::flooddeath => out.push_str("flooddeath"), + Self::flyingweapon => out.push_str("flyingweapon"), + Self::flyself => out.push_str("flyself"), + Self::foedraw => out.push_str("foedraw"), + Self::forcedraw => out.push_str("forcedraw"), + Self::forceplay => out.push_str("forceplay"), + Self::fractal => out.push_str("fractal"), + Self::freedom => out.push_str("freedom"), + Self::freeevade => out.push_str("freeevade"), + Self::freeze(x) => { + write!(out, "freeze{}", x); + } + Self::freezeperm => out.push_str("freezeperm"), + Self::fungusrebirth => out.push_str("fungusrebirth"), + Self::gaincharge2 => out.push_str("gaincharge2"), + Self::gaintimecharge => out.push_str("gaintimecharge"), + Self::gas => out.push_str("gas"), + Self::give => out.push_str("give"), + Self::golemhit => out.push_str("golemhit"), + Self::gpull => out.push_str("gpull"), + Self::gpullspell => out.push_str("gpullspell"), + Self::grave => out.push_str("grave"), + Self::growth(atk, hp) => { + write!(out, "growth{:+}{:+}", atk, hp); + } + Self::guard => out.push_str("guard"), + Self::halveatk => out.push_str("halveatk"), + Self::hammer => out.push_str("hammer"), + Self::hasten => out.push_str("hasten"), + Self::hatch => out.push_str("hatch"), + Self::heal => out.push_str("heal"), + Self::heatmirror => out.push_str("heatmirror"), + Self::hitownertwice => out.push_str("hitownertwice"), + Self::holylight => out.push_str("holylight"), + Self::hope => out.push_str("hope"), + Self::icebolt => out.push_str("icebolt"), + Self::icegrowth(atk, hp) => { + write!(out, "icegrowth{:+}{:+}", atk, hp); + } + Self::ignite => out.push_str("ignite"), + Self::ignitediscard => out.push_str("ignitediscard"), + Self::immolate(x) => { + write!(out, "immolate{}", x); + } + Self::improve => out.push_str("improve"), + Self::inertia => out.push_str("inertia"), + Self::inflation => out.push_str("inflation"), + Self::ink => out.push_str("ink"), + Self::innovation => out.push_str("innovation"), + Self::integrity => out.push_str("integrity"), + Self::jelly => out.push_str("jelly"), + Self::jetstream => out.push_str("jetstream"), + Self::lightning => out.push_str("lightning"), + Self::liquid => out.push_str("liquid"), + Self::livingweapon => out.push_str("livingweapon"), + Self::lobotomize => out.push_str("lobotomize"), + Self::locket => out.push_str("locket"), + Self::locketshift => out.push_str("locketshift"), + Self::loot => out.push_str("loot"), + Self::losecharge => out.push_str("losecharge"), + Self::luciferin => out.push_str("luciferin"), + Self::lycanthropy => out.push_str("lycanthropy"), + Self::martyr => out.push_str("martyr"), + Self::mend => out.push_str("mend"), + Self::metamorph => out.push_str("metamorph"), + Self::midas => out.push_str("midas"), + Self::mill => out.push_str("mill"), + Self::millpillar => out.push_str("millpillar"), + Self::mimic => out.push_str("mimic"), + Self::miracle => out.push_str("miracle"), + Self::mitosis => out.push_str("mitosis"), + Self::mitosisspell => out.push_str("mitosisspell"), + Self::momentum => out.push_str("momentum"), + Self::mummy => out.push_str("mummy"), + Self::mutant => out.push_str("mutant"), + Self::mutation => out.push_str("mutation"), + Self::neuro => out.push_str("neuro"), + Self::neuroify => out.push_str("neuroify"), + Self::nightmare => out.push_str("nightmare"), + Self::nightshade => out.push_str("nightshade"), + Self::noeatspell => out.push_str("noeatspell"), + Self::nothrottle => out.push_str("nothrottle"), + Self::nova => out.push_str("nova"), + Self::nova2 => out.push_str("nova2"), + Self::nullspell => out.push_str("nullspell"), + Self::nymph => out.push_str("nymph"), + Self::obsession => out.push_str("obsession"), + Self::ouija => out.push_str("ouija"), + Self::ouijadestroy => out.push_str("ouijadestroy"), + Self::ouijagrowth => out.push_str("ouijagrowth"), + Self::pacify => out.push_str("pacify"), + Self::pairproduce => out.push_str("pairproduce"), + Self::paleomagnetism => out.push_str("paleomagnetism"), + Self::pandemonium => out.push_str("pandemonium"), + Self::pandemonium2 => out.push_str("pandemonium2"), + Self::pandemonium3 => out.push_str("pandemonium3"), + Self::paradox => out.push_str("paradox"), + Self::parallel => out.push_str("parallel"), + Self::patience => out.push_str("patience"), + Self::pend => out.push_str("pend"), + Self::phoenix => out.push_str("phoenix"), + Self::photosynthesis => out.push_str("photosynthesis"), + Self::pillar => out.push_str("pillar"), + Self::pillar1 => out.push_str("pillar1"), + Self::quadpillar(_) => out.push_str("quadpillar"), + Self::quadpillar1(_) => out.push_str("quadpillar1"), + Self::plague => out.push_str("plague"), + Self::platearmor(x) => { + write!(out, "platearmor{}", x); + } + Self::poison(x) => { + write!(out, "poison{}", x); + } + Self::poisonfoe(x) => { + write!(out, "poisonfoe{}", x); + } + Self::powerdrain => out.push_str("powerdrain"), + Self::precognition => out.push_str("precognition"), + Self::predator => out.push_str("predator"), + Self::predatoroff => out.push_str("predatoroff"), + Self::protectall => out.push_str("protectall"), + Self::protectonce => out.push_str("protectonce"), + Self::protectoncedmg => out.push_str("protectoncedmg"), + Self::purify => out.push_str("purify"), + Self::quanta(x) => { + out.push_str(match x { + 0 => "chroma", + 1 => "entropy", + 2 => "death", + 3 => "gravity", + 4 => "earth", + 5 => "life", + 6 => "fire", + 7 => "water", + 8 => "light", + 9 => "air", + 10 => "time", + 11 => "darkness", + 12 => "aether", + _ => "", + }) + } + Self::quantagift => out.push_str("quantagift"), + Self::quint => out.push_str("quint"), + Self::quinttog => out.push_str("quinttog"), + Self::r#static => out.push_str("r"), + Self::rage => out.push_str("rage"), + Self::randomdr => out.push_str("randomdr"), + Self::readiness => out.push_str("readiness"), + Self::reap => out.push_str("reap"), + Self::rebirth => out.push_str("rebirth"), + Self::reducemaxhp => out.push_str("reducemaxhp"), + Self::regen => out.push_str("regen"), + Self::regenerate(x) => { + write!(out, "regenerate{}", x); + } + Self::regeneratespell => out.push_str("regeneratespell"), + Self::regrade => out.push_str("regrade"), + Self::reinforce => out.push_str("reinforce"), + Self::ren => out.push_str("ren"), + Self::resummon => out.push_str("resummon"), + Self::reveal => out.push_str("reveal"), + Self::rewind => out.push_str("rewind"), + Self::ricochet => out.push_str("ricochet"), + Self::sabbath => out.push_str("sabbath"), + Self::sadism => out.push_str("sadism"), + Self::salvage => out.push_str("salvage"), + Self::salvageoff => out.push_str("salvageoff"), + Self::sanctify => out.push_str("sanctify"), + Self::scatter => out.push_str("scatter"), + Self::scramble => out.push_str("scramble"), + Self::scramblespam => out.push_str("scramblespam"), + Self::serendipity => out.push_str("serendipity"), + Self::shardgolem => out.push_str("shardgolem"), + Self::shtriga => out.push_str("shtriga"), + Self::shuffle3 => out.push_str("shuffle3"), + Self::silence => out.push_str("silence"), + Self::sing => out.push_str("sing"), + Self::singularity => out.push_str("singularity"), + Self::sinkhole => out.push_str("sinkhole"), + Self::siphon => out.push_str("siphon"), + Self::siphonactive => out.push_str("siphonactive"), + Self::siphonstrength => out.push_str("siphonstrength"), + Self::skeleton => out.push_str("skeleton"), + Self::skull => out.push_str("skull"), + Self::skyblitz => out.push_str("skyblitz"), + Self::slow => out.push_str("slow"), + Self::snipe => out.push_str("snipe"), + Self::solar => out.push_str("solar"), + Self::sosa => out.push_str("sosa"), + Self::soulcatch => out.push_str("soulcatch"), + Self::spores => out.push_str("spores"), + Self::sskin => out.push_str("sskin"), + Self::staff => out.push_str("staff"), + Self::stasis => out.push_str("stasis"), + Self::stasisdraw => out.push_str("stasisdraw"), + Self::steal => out.push_str("steal"), + Self::steam => out.push_str("steam"), + Self::stoneform => out.push_str("stoneform"), + Self::storm(x) => { + write!(out, "storm{}", x); + } + Self::summon(code) => out.push_str(ctx.get_card(code as i32).name), + Self::swarm => out.push_str("swarm"), + Self::swave => out.push_str("swave"), + Self::tempering(x) => { + write!(out, "tempering{}", x); + } + Self::tesseractsummon => out.push_str("tesseractsummon"), + Self::thorn(x) => { + write!(out, "thorn{}", x); + } + Self::throwrock => out.push_str("throwrock"), + Self::tick => out.push_str("tick"), + Self::tidalhealing => out.push_str("tidalhealing"), + Self::tornado => out.push_str("tornado"), + Self::trick => out.push_str("trick"), + Self::turngolem => out.push_str("turngolem"), + Self::unappease => out.push_str("unappease"), + Self::unsanctify => out.push_str("unsanctify"), + Self::unsummon => out.push_str("unsummon"), + Self::unsummonquanta => out.push_str("unsummonquanta"), + Self::unvindicate => out.push_str("unvindicate"), + Self::upkeep => out.push_str("upkeep"), + Self::upload => out.push_str("upload"), + Self::vampire => out.push_str("vampire"), + Self::vend => out.push_str("vend"), + Self::vengeance => out.push_str("vengeance"), + Self::vindicate => out.push_str("vindicate"), + Self::virtue => out.push_str("virtue"), + Self::virusinfect => out.push_str("virusinfect"), + Self::virusplague => out.push_str("virusplague"), + Self::void => out.push_str("void"), + Self::voidshell => out.push_str("voidshell"), + Self::web => out.push_str("web"), + Self::weight => out.push_str("weight"), + Self::wind => out.push_str("wind"), + Self::wings => out.push_str("wings"), + Self::wisdom => out.push_str("wisdom"), + Self::yoink => out.push_str("yoink"), + Self::v_bblood => out.push_str("v_bblood"), + Self::v_blackhole => out.push_str("v_blackhole"), + Self::v_bow => out.push_str("v_bow"), + Self::v_cold => out.push_str("v_cold"), + Self::v_cseed => out.push_str("v_cseed"), + Self::v_dagger => out.push_str("v_dagger"), + Self::v_dessication => out.push_str("v_dessication"), + Self::v_divinity => out.push_str("v_divinity"), + Self::v_drainlife(_) => out.push_str("v_drainlife"), + Self::v_dshield => out.push_str("v_dshield"), + Self::v_endow => out.push_str("v_endow"), + Self::v_firebolt(_) => out.push_str("v_firebolt"), + Self::v_firewall => out.push_str("v_firewall"), + Self::v_flyingweapon => out.push_str("v_flyingweapon"), + Self::v_freedom => out.push_str("v_freedom"), + Self::v_freeevade => out.push_str("v_freeevade"), + Self::v_gratitude => out.push_str("v_gratitude"), + Self::v_hatch => out.push_str("v_hatch"), + Self::v_heal => out.push_str("v_heal"), + Self::v_holylight => out.push_str("v_holylight"), + Self::v_hope => out.push_str("v_hope"), + Self::v_hopedr => out.push_str("v_hopedr"), + Self::v_icebolt(_) => out.push_str("v_icebolt"), + Self::v_improve => out.push_str("v_improve"), + Self::v_integrity => out.push_str("v_integrity"), + Self::v_mutation => out.push_str("v_mutation"), + Self::v_noluci => out.push_str("v_noluci"), + Self::v_nymph => out.push_str("v_nymph"), + Self::v_obsession => out.push_str("v_obsession"), + Self::v_pandemonium => out.push_str("v_pandemonium"), + Self::v_plague => out.push_str("v_plague"), + Self::v_readiness => out.push_str("v_readiness"), + Self::v_relic => out.push_str("v_relic"), + Self::v_rewind => out.push_str("v_rewind"), + Self::v_salvage => out.push_str("v_salvage"), + Self::v_scramble => out.push_str("v_scramble"), + Self::v_serendipity => out.push_str("v_serendipity"), + Self::v_silence => out.push_str("v_silence"), + Self::v_singularity => out.push_str("v_singularity"), + Self::v_slow => out.push_str("v_slow"), + Self::v_steal => out.push_str("v_steal"), + Self::v_stoneform => out.push_str("v_stoneform"), + Self::v_storm(x) => { + write!(out, "v_storm{}", x); + } + Self::v_swarm => out.push_str("v_swarm"), + Self::v_swarmhp => out.push_str("v_swarmhp"), + Self::v_thorn => out.push_str("v_thorn"), + Self::v_virusplague => out.push_str("v_virusplague"), + }; + } + pub const fn passive(self) -> bool { matches!( self, diff --git a/src/views/Match.jsx b/src/views/Match.jsx index 634fc536..c6a8c410 100644 --- a/src/views/Match.jsx +++ b/src/views/Match.jsx @@ -133,34 +133,15 @@ const activetexts = [ 'shield', 'postauto', ]; -const activetextsRename = { - burrow: (game, id, x) => (game.get(id, 'burrowed') ? 'unburrow' : 'burrow'), - quanta: (game, id, x) => eleNames[x[1]].toLowerCase(), - summon: (game, id, x) => game.Cards.Codes[x[1] & 0xffff].name.toLowerCase(), -}; -function skillName(game, id, sk) { - const namelist = []; - for (const name of sk) { - const nsplit = name.split(' '); - const rename = activetextsRename[nsplit[0]]; - namelist.push(rename ? rename(game, id, nsplit) : name); - } - return namelist.join(' '); -} function activeText(game, id) { const acast = game.getSkill(id, 'cast'); if (acast) - return `${game.get(id, 'cast')}:${game.get(id, 'castele')}${skillName( - game, - id, - acast, - )}`; + return `${game.get(id, 'cast')}:${game.get(id, 'castele')}${acast}`; for (const akey of activetexts) { const a = game.getSkill(id, akey); - if (a) return `${akey} ${skillName(game, id, a)}`; + if (a) return `${akey} ${a}`; } - const aauto = game.getSkill(id, 'ownattack'); - return aauto ? skillName(game, id, aauto) : ''; + return game.getSkill(id, 'ownattack') ?? ''; } function Tween(props) { @@ -536,7 +517,7 @@ function Thing(props) { topText = ''; } else { const ownattack = props.game.getSkill(props.id, 'ownattack'); - if (ownattack?.length === 1 && ownattack[0] === 'locket') { + if (ownattack === 'locket') { const mode = props.game.get(props.id, 'mode'); statText = `1:${ ~mode ? mode : props.game.get_mark(props.game.get_owner(props.id)) @@ -974,9 +955,7 @@ export default function Match(props) { element: card.element, costele: game.get(id, isSpell ? 'costele' : 'castele'), cost: game.get(id, isSpell ? 'cost' : 'cast'), - name: isSpell - ? card.name - : skillName(game, id, game.getSkill(id, 'cast')), + name: isSpell ? card.name : game.getSkill(id, 'cast'), upped: card.upped, shiny: card.shiny, c: id, @@ -1302,7 +1281,7 @@ export default function Match(props) { cb(tgt); setTargeting(null); }, - text: skillName(game, id, game.getSkill(id, 'cast')), + text: game.getSkill(id, 'cast'), src: id, }); }