Skip to content

Commit

Permalink
SilenceFx for silence, sabbath, & hush
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Jan 23, 2024
1 parent 8341e6e commit b7780ca
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 32 deletions.
5 changes: 0 additions & 5 deletions scripts/initdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ create table user_data (
name text not null,
data json not null
);
create table roles (
id int not null primary key,
val text not null unique
);
create table user_role (
user_id bigint not null references users(id),
role_id userrole not null,
Expand Down Expand Up @@ -93,7 +89,6 @@ create table match_request (

create index ix_users_wealth on users (wealth);
create index ix_users_name on users using hash (name);
create index ix_roles_val on roles using hash (val);
create index ix_arena_score on arena (arena_id, score desc, day desc, "rank");
create index ix_arena_user_id on arena using hash (user_id);
create index ix_bazaar_user_id on bazaar using hash (user_id);
Expand Down
1 change: 1 addition & 0 deletions src/rs/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ pub enum Fx {
Sfx(Sfx),
Shatter,
Shuffled,
Silence,
Sinkhole,
Siphon,
StartPos(i16),
Expand Down
4 changes: 4 additions & 0 deletions src/rs/src/skill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,7 @@ impl Skill {
}
Self::hush => {
if !ctx.get(t, Flag::ranged) {
ctx.fx(t, Fx::Silence);
ctx.set(t, Stat::casts, 0);
}
}
Expand Down Expand Up @@ -3992,6 +3993,7 @@ impl Skill {
let owner = ctx.get_owner(c);
for cr in ctx.get_player(ctx.get_foe(owner)).creatures {
if cr != 0 {
ctx.fx(cr, Fx::Silence);
ctx.set(cr, Stat::casts, 0);
}
}
Expand Down Expand Up @@ -4128,6 +4130,7 @@ impl Skill {
}
Self::silence => {
if !ctx.sanctified(t) {
ctx.fx(t, Fx::Silence);
ctx.set(t, Stat::casts, 0);
}
}
Expand Down Expand Up @@ -4413,6 +4416,7 @@ impl Skill {
}
}
Self::throwrock => {
ctx.fx(c, Fx::EndPos(t));
let card = ctx.get(c, Stat::card);
ctx.dmg(t, if card::Upped(card) { 4 } else { 3 });
let town = ctx.get_owner(t);
Expand Down
2 changes: 1 addition & 1 deletion src/rs/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl<'a> SkillThing<'a> {
"Remove statuses (positive & negative) from target creature or permanent. Heal target creature or player 10. If target creature is nocturnal, instead deal 10 spell damage to target creature"
}),
Skill::hope => Cow::from("Blocks one additional damage for each creature you control that gain 1:8 when attacking"),
Skill::hush => Cow::from("Silence attackers"),
Skill::hush => Cow::from("Silence non-ranged attackers"),
Skill::icebolt =>
Cow::from("Deal 2 spell damage plus one per 5:7 you have after playing this card. 25% plus 5% per point of damage chance to freeze target"),
Skill::ignite =>
Expand Down
94 changes: 68 additions & 26 deletions src/views/Match.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,30 @@ function LightningFx(props) {
);
}

function SilenceFx(props) {
const time = useAnimation();
createEffect(() => {
if (time() > 512) props.setEffects(removeFx(props.self));
});
return (
<svg
height={time() / 4}
width={time() / 4}
viewBox="0 0 64 64"
style={`position:absolute;left:${props.pos.x}px;top:${
props.pos.y
}px;transform:translate(-50%,-50%);opacity:${(
1 -
time() ** 1.5 / 11584
).toFixed(2)};pointer-events:none;z-index:4`}>
<rect x="24" y="16" width="16" height="32" rx="8" fill="#048" />
<rect x="30" y="48" width="4" height="8" fill="#048" />
<rect x="26" y="56" width="12" height="2" rx="1" fill="#048" />
<line x1="20" y1="56" x2="44" y2="8" stroke="#048" />
</svg>
);
}

function BoltFx(props) {
const time = useAnimation();
createEffect(() => {
Expand Down Expand Up @@ -910,23 +934,25 @@ export default function Match(props) {
break;
case 'Bolt': {
newstate.effects ??= new Set(state.effects);
const pos = getIdTrack(id) ?? { x: -99, y: -99 },
color = strcols[param2],
upcolor = strcols[param2 + 13],
bolts = param + 1,
duration = 96 + bolts * 32;
const BoltEffect = () => (
<BoltFx
self={BoltEffect}
setEffects={setEffects}
duration={duration}
bolts={bolts}
color={color}
upcolor={upcolor}
pos={pos}
/>
);
newstate.effects.add(BoltEffect);
const pos = getIdTrack(id);
if (pos) {
const color = strcols[param2],
upcolor = strcols[param2 + 13],
bolts = param + 1,
duration = 96 + bolts * 32;
const BoltEffect = () => (
<BoltFx
self={BoltEffect}
setEffects={setEffects}
duration={duration}
bolts={bolts}
color={color}
upcolor={upcolor}
pos={pos}
/>
);
newstate.effects.add(BoltEffect);
}
break;
}
case 'Card':
Expand Down Expand Up @@ -967,15 +993,17 @@ export default function Match(props) {
break;
case 'Lightning': {
newstate.effects ??= new Set(state.effects);
const pos = getIdTrack(id) ?? { x: -99, y: -99 };
const LightningEffect = () => (
<LightningFx
pos={pos}
setEffects={setEffects}
self={LightningEffect}
/>
);
newstate.effects.add(LightningEffect);
const pos = getIdTrack(id);
if (pos) {
const LightningEffect = () => (
<LightningFx
pos={pos}
setEffects={setEffects}
self={LightningEffect}
/>
);
newstate.effects.add(LightningEffect);
}
break;
}
case 'Lives':
Expand All @@ -990,6 +1018,20 @@ export default function Match(props) {
mkText(state, newstate, id, `${param}:${param2}`),
);
break;
case 'Silence':
newstate.effects ??= new Set(state.effects);
const pos = getIdTrack(id);
if (pos) {
const SilenceEffect = () => (
<SilenceFx
pos={pos}
setEffects={setEffects}
self={SilenceEffect}
/>
);
newstate.effects.add(SilenceEffect);
}
break;
case 'Sfx':
playSound(Sfx[param]);
break;
Expand Down

0 comments on commit b7780ca

Please sign in to comment.