Skip to content

Commit

Permalink
Fix GotP text, fix card svg cost rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Sep 28, 2023
1 parent a355ad3 commit 055d4ed
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
42 changes: 41 additions & 1 deletion src/rs/server/src/svg/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,47 @@ pub fn card(code: i32) -> Option<String> {
))
});
result.push_str(".webp' style='position:absolute;top:-130px;left:0px'/>");
result.push_str(&etg::text::rawCardText(cards, card).replace('&', "&amp;"));
let mut text = etg::text::rawCardText(cards, card).replace('&', "&amp;");
let colons = text.rmatch_indices(':').map(|m| m.0).collect::<Vec<_>>();
for colon_idx in colons {
let start = if matches!(text.as_bytes().get(colon_idx - 1), Some(b'0'..=b'9')) {
if matches!(text.as_bytes().get(colon_idx - 2), Some(b'0'..=b'9')) {
colon_idx - 2
} else {
colon_idx - 1
}
} else {
continue;
};
let end = if matches!(text.as_bytes().get(colon_idx + 1), Some(b'0'..=b'9')) {
if matches!(text.as_bytes().get(colon_idx + 2), Some(b'0'..=b'2')) {
colon_idx + 2
} else {
colon_idx + 1
}
} else {
continue;
};
let num = text[start..colon_idx].parse::<i8>().unwrap();
let ele = text[colon_idx + 1..=end].parse::<i8>().unwrap();
let end = if text.as_bytes().get(end + 1) == Some(&b' ') {
end + 1
} else {
end
};
match num {
0 => text.replace_range(start..=end, "0"),
1 | 2 | 3 => text.replace_range(
start..=end,
&format!("<span class='ico te{}'></span>", ele).repeat(num as usize),
),
_ => text.replace_range(
start..=end,
&format!("{}<span class='ico te{}'></span>", num, ele),
),
}
}
result.push_str(&text);
if card.rarity != 0 {
write!(
result,
Expand Down
7 changes: 5 additions & 2 deletions src/rs/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,11 @@ impl<'a> SkillThing<'a> {
Cow::from("Until your next turn, the next spell any player casts is nullified. If this ability nullifies a spell, this creature gains 1|1"),
Skill::nymph =>
Cow::from("Transform target pillar, pendulum, or tower into a Nymph matching target's element"),
Skill::obsession =>
Cow::from("When discarded, its owner receives ${c.upped ? 13 : 10} spell damage"),
Skill::obsession => Cow::from(if self.upped() {
"When discarded, its owner receives 13 spell damage"
} else {
"When discarded, its owner receives 10 spell damage"
}),
Skill::ouija => Cow::from("Whenever a creature dies, add an Ouija Essence to opponent's hand"),
Skill::ouijadestroy => Cow::from("When destroyed, add 1 to opponent's maximum health"),
Skill::ouijagrowth => Cow::from("Summon an Ouija Essence on opponent's side of the field"),
Expand Down

0 comments on commit 055d4ed

Please sign in to comment.