Skip to content

Commit cb8aa3b

Browse files
committed
Fix pande3, chimera
1 parent f277eb1 commit cb8aa3b

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

server.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const userEvents = {
124124
broadcast({ x: 'clear' });
125125
}),
126126
modmotd: roleck('Mod', function (data, user) {
127-
const match = data.m.match(/^(\d+) ?(.*)$/);
127+
const match = data.m.match(/^(\d+) *(.*)$/);
128128
if (match) {
129129
const num = match[1],
130130
text = match[2];
@@ -215,7 +215,6 @@ const userEvents = {
215215
if (!user.ocard || !data.d) {
216216
return;
217217
}
218-
const au = `${data.lv ? 'B:' : 'A:'}${data.u}`;
219218
if (data.mod) {
220219
return pg.pool.query({
221220
text: `update arena set deck = $3, hp = $4, draw = $5, mark = $6 where user_id = $1 and arena_id = $2`,
@@ -331,7 +330,7 @@ from arena where user_id = $1`,
331330
idx = RngMock.upto(len);
332331
}
333332
const ares = await pg.pool.query({
334-
text: `select u.name, a.score, a.deck, a.hp, a.mark, a.draw, a.day, a.won, a.loss, a.code from arena a join users u on u.id = a.user_id where a.arena_id = $1 order by a."rank" limit 1 offset $2`,
333+
text: `select u.name, a.deck, a.hp, a.mark, a.draw, a.day, a.won, a.loss, a.code from arena a join users u on u.id = a.user_id where a.arena_id = $1 order by a."rank" limit 1 offset $2`,
335334
values: [arenaId, idx],
336335
});
337336
if (ares.rows.length == 0) {
@@ -607,7 +606,7 @@ where mr1.user_id = $1 and mr2.user_id = $2 and not mr1.accepted and mr2.accepte
607606
typeof data.forcards === 'string' &&
608607
typeof data.forg === 'number'
609608
) {
610-
const acceptResult = await pg.pool.query({
609+
const acceptResult = await sql.query({
611610
text: `select 1 from trade_request where user_id = $2 and for_user_id = $1 and cards = $5 and g = $6 and forcards = $3 and forg = $4`,
612611
values: [
613612
userId,
@@ -650,14 +649,14 @@ where mr1.user_id = $1 and mr2.user_id = $2 and not mr1.accepted and mr2.accepte
650649
data.cards,
651650
);
652651
foe.gold += p2gdelta;
653-
return pg.pool.query({
652+
return sql.query({
654653
text:
655654
'delete from trade_request where (user_id = $1 and for_user_id = $2) or (user_id = $2 and for_user_id = $1)',
656655
values: [userId, foe.id],
657656
});
658657
}
659658
}
660-
await pg.pool.query({
659+
await sql.query({
661660
text: `insert into trade_request (user_id, for_user_id, cards, g, forcards, forg, expire_at)
662661
values ($1, $2, $3, $4, $5, $6, now() + interval '1 hour')
663662
on conflict (user_id, for_user_id) do update set user_id = $1, for_user_id = $2, cards = $3, g = $4, forcards = $5, forg = $6, expire_at = now() + interval '1 hour'`,

src/rs/src/game.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,10 @@ impl Game {
939939
}
940940

941941
impl Game {
942+
pub fn shuffle<T>(&mut self, slice: &mut [T]) {
943+
slice.shuffle(&mut self.rng);
944+
}
945+
942946
pub fn props_len(&self) -> usize {
943947
self.props.len()
944948
}

src/rs/src/skill.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,8 @@ impl Skill {
12821282
let owner = ctx.get_owner(c);
12831283
for &cr in ctx.get_player(owner).creatures.iter() {
12841284
if cr != 0 {
1285-
hp += ctx.get(cr, Stat::hp);
1286-
atk += ctx.get(cr, Stat::atk);
1285+
hp += ctx.truehp(cr);
1286+
atk += ctx.trueatk(cr);
12871287
}
12881288
}
12891289
let chim = ctx.new_thing(
@@ -2919,10 +2919,27 @@ impl Skill {
29192919
});
29202920
}
29212921
Self::pandemonium3 => {
2922-
let owner = ctx.get_owner(c);
2923-
ctx.masscc(ctx.get_foe(owner), owner, |ctx, cr| {
2924-
Skill::cseed2.proc(ctx, c, cr, &mut ProcData::default());
2925-
});
2922+
let mut ids = Vec::new();
2923+
for &pid in ctx.players().iter() {
2924+
let pl = ctx.get_player(pid);
2925+
ids.extend(
2926+
once(pid)
2927+
.chain(once(pl.weapon))
2928+
.chain(once(pl.shield))
2929+
.chain(pl.creatures.clone().iter().cloned())
2930+
.chain(pl.permanents.clone().iter().cloned())
2931+
.chain(pl.hand.clone().iter().cloned())
2932+
.filter(|&id| id != 0),
2933+
);
2934+
}
2935+
ctx.shuffle(&mut ids[..]);
2936+
for &id in ids.iter() {
2937+
if ctx.get(id, Stat::cloak) != 0 {
2938+
ctx.die(id);
2939+
} else {
2940+
Skill::cseed2.proc(ctx, c, id, data);
2941+
}
2942+
}
29262943
}
29272944
Self::paradox | Self::v_paradox => {
29282945
ctx.fx(t, Fx::Paradox);

0 commit comments

Comments
 (0)