Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configをどじょうすくいロボコンへ対応させた #454

Merged
merged 8 commits into from
Oct 10, 2024
50 changes: 18 additions & 32 deletions packages/config/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createConfig } from "./utility/createConfig";

export const config = createConfig(
{
contestName: "第2回 Matz葉がにロボコン",
contestName: "第1回 どじょうすくいロボコン",
robots: [
{
type: "leg",
Expand All @@ -18,11 +18,6 @@ export const config = createConfig(
{
type: "elementary",
name: "小学生部門",
robotTypes: ["wheel", "leg"],
},
{
type: "open",
name: "オープン部門",
robotTypes: ["leg"],
},
],
Expand All @@ -32,59 +27,50 @@ export const config = createConfig(
name: "予選",
limitSeconds: 180,
course: {
elementary: 2,
open: 1,
elementary: 1,
},
},
{
type: "main",
name: "本戦",
limitSeconds: 180,
course: {
elementary: 2,
open: 1,
elementary: 0,
},
},
],
rules: [
{
name: "multiWalk",
label: "歩行型",
type: "single",
initial: true, // conditionsの`scorable`で制御する
point: (done: boolean) => (done ? 2 : 0),
},
laminne marked this conversation as resolved.
Show resolved Hide resolved
{
name: "leaveBase",
label: "松江エリアを出た",
label: "水草エリアを出た",
type: "single",
initial: false,
point: (done: boolean) => (done ? 1 : 0),
},
{
name: "overMiddle",
label: "中間点を超えた",
label: "中間地点を超えた",
type: "single",
initial: false,
point: (done: boolean) => (done ? 1 : 0),
},
{
name: "enterDestination",
label: "金星エリアに入った",
label: "温暖化エリアに入った",
type: "single",
initial: false,
point: (done: boolean) => (done ? 1 : 0),
},
{
name: "placeBall",
label: "ボールを金星エリアに置いた",
label: "温暖化エリアに氷を置いた",
type: "single",
initial: false,
point: (done: boolean) => (done ? 1 : 0),
},
{
name: "returnBase",
label: "松江エリアに戻った",
label: "水草エリアに戻った",
type: "single",
initial: false,
point: (done: boolean) => (done ? 2 : 0),
Expand All @@ -98,7 +84,7 @@ export const config = createConfig(
},
laminne marked this conversation as resolved.
Show resolved Hide resolved
{
name: "bringBall",
label: "雲粒子の数",
label: "どじょうの数",
type: "countable",
initial: 0,
point: (count: number) => count,
laminne marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -115,15 +101,15 @@ export const config = createConfig(
sponsors: [],
},
{
multiWalk: {
visible: (state) => !state.matchInfo, // エキシビションモードでのみ表示
changeable: (state) =>
!state.matchInfo && // エキシビションモードでのみマニュアル変更可能
!state.matchState[state.side].getPointState().finish,
scorable: (state) =>
!state.matchInfo || // エキシビションモードでは通常通り加算可能
state.matchInfo.teams[state.side].robotType == "leg", // 通常の試合では歩行型のときのみ加算可能
},
// multiWalk: {
// visible: (state) => !state.matchInfo, // エキシビションモードでのみ表示
// changeable: (state) =>
// !state.matchInfo && // エキシビションモードでのみマニュアル変更可能
// !state.matchState[state.side].getPointState().finish,
// scorable: (state) =>
// !state.matchInfo || // エキシビションモードでは通常通り加算可能
// state.matchInfo.teams[state.side].robotType == "leg", // 通常の試合では歩行型のときのみ加算可能
// },
leaveBase: {
changeable: (state) =>
!state.matchState[state.side].getPointState().finish,
Expand Down
18 changes: 8 additions & 10 deletions packages/kcms/src/match/service/generatePre.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ describe('GeneratePreMatchService', () => {

const expectedTeamPair = [
[
['A1', 'B3'],
['A3', 'C2'],
['B1', 'N2'],
['A1', 'B2'],
['A2', 'B3'],
['A3', 'C1'],
['A4', 'C2'],
['B1', 'N1'],
['B2', 'N2'],
['B3', 'A1'],
['C2', 'A3'],
['N2', 'B1'],
],
[
['A2', 'B2'],
['A4', 'C1'],
['B2', 'N1'],
['C1', 'A2'],
['C2', 'A3'],
['N1', 'A4'],
['N2', 'B1'],
],
];

Expand Down
13 changes: 7 additions & 6 deletions packages/kcms/src/team/models/team.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { describe, expect, it } from 'vitest';
import { Team, TeamID } from './team.js';
import { config } from 'config';

describe('正しくインスタンスを生成できる', () => {
it('正しくインスタンスを生成できる', () => {
const actual = Team.reconstruct({
id: '123' as TeamID,
teamName: 'チーム1',
members: ['山田太郎', 'テスト大介'],
departmentType: 'open',
departmentType: config.departments[0].type,
robotType: 'leg',
isEntered: true,
});
Expand All @@ -16,15 +17,15 @@ describe('正しくインスタンスを生成できる', () => {
expect(actual.getTeamName()).toBe('チーム1');
expect(actual.getMembers()).toEqual(['山田太郎', 'テスト大介']);
expect(actual.getRobotType()).toBe('leg');
expect(actual.getDepartmentType()).toBe('open');
expect(actual.getDepartmentType()).toBe(config.departments[0].type);
});

it('正しくインスタンスを生成できる - クラブを含む場合', () => {
const actual = Team.reconstruct({
id: '123' as TeamID,
teamName: 'チーム1',
members: ['山田太郎', 'テスト大介'],
departmentType: 'open',
departmentType: config.departments[0].type,
robotType: 'leg',
isEntered: true,
clubName: 'テストクラブ',
Expand All @@ -34,7 +35,7 @@ describe('正しくインスタンスを生成できる', () => {
expect(actual.getTeamName()).toBe('チーム1');
expect(actual.getMembers()).toEqual(['山田太郎', 'テスト大介']);
expect(actual.getRobotType()).toBe('leg');
expect(actual.getDepartmentType()).toBe('open');
expect(actual.getDepartmentType()).toBe(config.departments[0].type);
expect(actual.getClubName()).toBe('テストクラブ');
});

Expand All @@ -43,7 +44,7 @@ describe('正しくインスタンスを生成できる', () => {
id: '1' as TeamID,
teamName: 'team1',
members: ['山田太郎', 'テスト大介'],
departmentType: 'open',
departmentType: config.departments[0].type,
robotType: 'leg',
});

Expand All @@ -57,7 +58,7 @@ describe('正しくインスタンスを生成できる', () => {
id: '1' as TeamID,
teamName: 'team1',
members: ['山田太郎', 'テスト大介'],
departmentType: 'open',
departmentType: config.departments[0].type,
robotType: 'leg',
});

Expand Down
6 changes: 1 addition & 5 deletions packages/kcms/src/team/service/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ describe('getEntryService', () => {
const repository = new DummyRepository();
const service = new FetchTeamService(repository);

const testEntryData = [
TestEntryData['ElementaryMultiWalk'],
TestEntryData['ElementaryWheel'],
TestEntryData['OpenMultiWalk'],
];
const testEntryData = [TestEntryData['ElementaryMultiWalk'], TestEntryData['ElementaryWheel']];

beforeEach(() => {
testEntryData.map((d) => repository.create(d));
Expand Down
23 changes: 0 additions & 23 deletions packages/kcms/src/testData/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ export const TestEntryData = {
robotType: 'wheel',
departmentType: 'elementary',
}),
// Openで車輪型は存在しない
OpenMultiWalk: Team.new({
id: '3' as TeamID,
teamName: 'TestTeam3',
members: ['TestTaro3'],
robotType: 'leg',
departmentType: 'open',
}),
OpenMultiWalk2: Team.new({
id: '4' as TeamID,
teamName: 'TestTeam4',
members: ['TestTaro4'],
robotType: 'leg',
departmentType: 'open',
}),
// 1の重複
ElementaryMultiWalkExists: Team.new({
id: '1' as TeamID,
Expand All @@ -47,14 +32,6 @@ export const TestEntryData = {
robotType: 'wheel',
departmentType: 'elementary',
}),
// 3の重複
OpenMultiWalkExists: Team.new({
id: '3' as TeamID,
teamName: 'TestTeam3',
members: ['TestTaro3'],
robotType: 'leg',
departmentType: 'open',
}),
NotEntered: Team.reconstruct({
id: '6' as TeamID,
teamName: 'TestTeam6',
Expand Down