forked from phenom/healer-man
Release Healer Man 0.1.16
This commit is contained in:
1 parent
f49e54f35f
commit
b57d2b2839
89 files changed
+6055
-17
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { GameDatabaseError, openGameDatabase } from "./database.mjs";
|
||||
|
||||
test("arena loadouts are character-owned, tank-free, and matches settle exactly once", async () => {
|
||||
const directory = mkdtempSync(path.join(os.tmpdir(), "healer-man-arena-db-test-"));
|
||||
const database = openGameDatabase({ dataDir: directory });
|
||||
try {
|
||||
const left = await database.register("ArenaLeft", "arena-left-pass");
|
||||
const right = await database.register("ArenaRight", "arena-right-pass");
|
||||
database.putCloudSave(left.account.id, { version: 1, characters: [{ id: "left-priest", name: "Left", classId: "priest", categoryId: "wow" }] });
|
||||
database.putCloudSave(right.account.id, { version: 1, characters: [{ id: "right-mage", name: "Right", classId: "mage", categoryId: "wow" }] });
|
||||
const loadout = database.putArenaLoadout(left.account.id, "left-priest", 1, {
|
||||
name: "Disc Control", classId: "priest", specializationId: "priest:discipline",
|
||||
role: "healer", ruleset: "wow", talents: { "priest:discipline:1": 5 }, actions: { "1": "heal" }, selected: true,
|
||||
});
|
||||
assert.equal(loadout.level, 80);
|
||||
assert.equal(loadout.version, 1);
|
||||
assert.equal(database.getArenaState(left.account.id, "left-priest").loadouts.length, 1);
|
||||
assert.throws(() => database.putArenaLoadout(right.account.id, "right-mage", 1, {
|
||||
name: "Protection", classId: "mage", specializationId: "warrior:protection", ruleset: "wow", talents: {}, actions: {},
|
||||
}), (error) => error instanceof GameDatabaseError);
|
||||
|
||||
database.createArenaMatch({
|
||||
id: "arena-idempotent", bracket: "2v2", mode: "rated-ai", ruleset: "wow", stageId: "warnorken-arena", startedAt: Date.now(),
|
||||
participants: [
|
||||
{ actorId: "left", accountId: left.account.id, characterId: "left-priest", team: 0, role: "healer", isBot: false, rating: 0 },
|
||||
{ actorId: "left-bot", team: 0, role: "damage", isBot: true, rating: 0 },
|
||||
{ actorId: "right", accountId: right.account.id, characterId: "right-mage", team: 1, role: "damage", isBot: false, rating: 0 },
|
||||
{ actorId: "right-bot", team: 1, role: "healer", isBot: true, rating: 0 },
|
||||
],
|
||||
});
|
||||
const first = database.settleArenaMatch("arena-idempotent", 0);
|
||||
const retry = database.settleArenaMatch("arena-idempotent", 0);
|
||||
assert.equal(first.ratingUpdates.find((update) => update.characterId === "left-priest").after, 32);
|
||||
assert.deepEqual(retry.ratingUpdates, first.ratingUpdates);
|
||||
assert.equal(database.getArenaRating(left.account.id, "left-priest", "2v2").rating, 32);
|
||||
assert.equal(database.getArenaRating(left.account.id, "left-priest", "3v3").rating, 0);
|
||||
} finally {
|
||||
database.close();
|
||||
rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user