Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #153 from CPCTF2022/fix-path
Browse files Browse the repository at this point in the history
Fix path
  • Loading branch information
Forenard authored May 1, 2022
2 parents 1f9172b + df30dcf commit 283e449
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 43 deletions.
2 changes: 1 addition & 1 deletion public/circuit.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions server/Basis.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
CircuitBasisInfo,
CircuitPartsInfo,
CircuitWiresInfo
} from '../src/circuit/BothScript/CircuitInfo'
CircuitServerBasisInfo,
CircuitServerPartsInfo,
CircuitServerWiresInfo
} from './CircuitServerInfo'
import { Cell, WireExtendInfo } from './Cell'
import type { CircuitParts } from './CircuitParts'

Expand Down Expand Up @@ -98,16 +98,16 @@ export class Basis {
}

convertToCircuitInfos(): [
CircuitBasisInfo,
CircuitPartsInfo[],
CircuitWiresInfo[]
CircuitServerBasisInfo,
CircuitServerPartsInfo[],
CircuitServerWiresInfo[]
] {
const basisInfo: CircuitBasisInfo = new CircuitBasisInfo(
const basisInfo: CircuitServerBasisInfo = new CircuitServerBasisInfo(
this.sizeX,
this.sizeY
)
const partsInfos: CircuitPartsInfo[] = new Array(0)
const wiresInfos: CircuitWiresInfo[] = new Array(0)
const partsInfos: CircuitServerPartsInfo[] = new Array(0)
const wiresInfos: CircuitServerWiresInfo[] = new Array(0)
//wire追加
this.cells.forEach(v => {
const wires = new Array<[number, number]>(0)
Expand All @@ -122,14 +122,14 @@ export class Basis {
}
})
if (wires.length != 0) {
wiresInfos.push(new CircuitWiresInfo(v.x, v.y, wires))
wiresInfos.push(new CircuitServerWiresInfo(v.x, v.y, wires))
}
})
//parts追加
this.parts.forEach(v => {
const [x, y] = v.getPosition()
partsInfos.push(
new CircuitPartsInfo(
new CircuitServerPartsInfo(
x,
y,
v.isBig,
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Basis } from './Basis'
import { CircuitParts } from './CircuitParts'
import type { CircuitParts } from './CircuitParts'
import { Condenser } from './CircuitParts/Condenser'
import { CPU } from './CircuitParts/CPU'
import { GraphicBoard } from './CircuitParts/GraphicBoard'
Expand All @@ -11,7 +11,7 @@ import { TipSet } from './CircuitParts/TipSet'
import { PowerSupply } from './CircuitParts/PowerSupply'
import { Audio } from './CircuitParts/Audio'
import { CircuitUtils } from './CircuitUtils'
import { Genre, ServerResponse } from './ServerMain'
import type { Genre, ServerResponse } from './ServerMain'

export class CircuitBuilder {
//単位提出数(subUnit毎に一つパーツがおかれる)
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { QuestionGenre } from '../src/system/ResponseType'
import type { Genre } from './ServerMain'

export abstract class CircuitParts {
public sizeX = 0
Expand All @@ -11,7 +11,7 @@ export abstract class CircuitParts {
}
public wirePointsInts: number[][] = []
public bigWirePointsInts: number[][] = []
public abstract problemCategory: QuestionGenre | undefined
public abstract problemCategory: Genre | undefined
public id: number
static counter = 0
public isBig: boolean
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/Audio.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class Audio extends CircuitParts {
public sizeX = 5
public sizeY = 2
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'Misc'
public problemCategory: Genre = 'Misc'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/Condenser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class Condenser extends CircuitParts {
public sizeX = 1
public sizeY = 7
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'Forensics'
public problemCategory: Genre = 'Forensics'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/GraphicBoard.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class GraphicBoard extends CircuitParts {
public sizeX = 1
public sizeY = 6
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'OSINT'
public problemCategory: Genre = 'OSINT'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/HDD.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class HDD extends CircuitParts {
public sizeX = 4
public sizeY = 2
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'Binary'
public problemCategory: Genre = 'Binary'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/Memory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class Memory extends CircuitParts {
public sizeX = 8
public sizeY = 4
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'Web'
public problemCategory: Genre = 'Web'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/Ports.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class Ports extends CircuitParts {
public sizeX = 2
public sizeY = 3
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'Pwn'
public problemCategory: Genre = 'Pwn'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/PowerSupply.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class PowerSupply extends CircuitParts {
public sizeX = 3
public sizeY = 2
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'Crypto'
public problemCategory: Genre = 'Crypto'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/SSD.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class SSD extends CircuitParts {
public sizeX = 6
public sizeY = 5
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'Shell'
public problemCategory: Genre = 'Shell'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
4 changes: 2 additions & 2 deletions server/CircuitParts/TipSet.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { QuestionGenre } from '../../src/system/ResponseType'
import { CircuitParts } from '../CircuitParts'
import type { Genre } from '../ServerMain'
export class TipSet extends CircuitParts {
public sizeX = 2
public sizeY = 2
public wirePointsInts: number[][] = new Array(this.sizeY * this.sizeX)
public problemCategory: QuestionGenre = 'PPC'
public problemCategory: Genre = 'PPC'
constructor(isBig: boolean) {
super(isBig)
this.wirePointsInts.forEach(
Expand Down
79 changes: 79 additions & 0 deletions server/CircuitServerInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
export class CircuitServerBasisInfo {
constructor(public sizeX: number, public sizeY: number) {}
}

export class CircuitServerPartsInfo {
constructor(
public x: number,
public z: number,
public isBig: boolean,
public category: string
) {}
}

export class CircuitServerWiresInfo {
constructor(
public x: number,
public z: number,
public wires: [number, number][]
) {}
}

export class CircuitServerInfoUtils {
static jsonToInfo(
json: string
): [
CircuitServerBasisInfo,
CircuitServerPartsInfo[],
CircuitServerWiresInfo[]
] {
const objs = JSON.parse(json) as ICircuitServer[]
let basisInfo: CircuitServerBasisInfo = new CircuitServerBasisInfo(0, 0)
const partsInfos: CircuitServerPartsInfo[] = new Array(0)
const wiresInfos: CircuitServerWiresInfo[] = new Array(0)
objs.forEach(obj => {
if (obj.class == 'basis') {
const basis = obj as IBasisInfo
basisInfo = new CircuitServerBasisInfo(basis.sizeX, basis.sizeY)
} else if (obj.class == 'parts') {
const parts = obj as IPartsInfo
partsInfos.push(
new CircuitServerPartsInfo(
parts.x,
parts.z,
parts.isBig,
parts.category
)
)
} else if (obj.class == 'wires') {
const wires = obj as IWiresInfo
wiresInfos.push(
new CircuitServerWiresInfo(wires.x, wires.z, wires.wires)
)
}
})
return [basisInfo, partsInfos, wiresInfos]
}
}

interface ICircuitServer {
class: string
}

interface IBasisInfo extends ICircuitServer {
sizeX: number
sizeY: number
}

interface IPartsInfo extends ICircuitServer {
x: number
z: number
isBig: boolean
category: string
}

interface IWiresInfo extends ICircuitServer {
x: number
z: number
wires: [number, number][]
}
16 changes: 8 additions & 8 deletions server/CircuitUtils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
CircuitBasisInfo,
CircuitPartsInfo,
CircuitWiresInfo
} from '../src/circuit/BothScript/CircuitInfo'
import type {
CircuitServerBasisInfo,
CircuitServerPartsInfo,
CircuitServerWiresInfo
} from './CircuitServerInfo'

export class CircuitUtils {
static infoToJson(
circuitBasisInfo: CircuitBasisInfo,
circuitPartsInfos: CircuitPartsInfo[],
circuitWiresInfos: CircuitWiresInfo[]
circuitBasisInfo: CircuitServerBasisInfo,
circuitPartsInfos: CircuitServerPartsInfo[],
circuitWiresInfos: CircuitServerWiresInfo[]
): string {
const objs = new Array<ICircuit>(0)
const basisObj: IBasisInfo = {
Expand Down

0 comments on commit 283e449

Please sign in to comment.