Skip to content

Commit

Permalink
feat: improve fight packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceat committed Jul 9, 2024
1 parent 6770e01 commit edb9377
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions generated/ares_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,26 @@ export const FightSpawn = /*@__PURE__*/ proto3.makeMessageType(
{ no: 7, name: 'started', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
{ no: 8, name: 'locked', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
{ no: 9, name: 'need_help', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
{
no: 10,
name: 'team1_positions',
kind: 'message',
T: Position,
repeated: true,
},
{
no: 11,
name: 'team2_positions',
kind: 'message',
T: Position,
repeated: true,
},
{
no: 12,
name: 'start_time',
kind: 'scalar',
T: 4 /* ScalarType.UINT64 */,
},
],
)

Expand Down
3 changes: 3 additions & 0 deletions proto/ares.proto
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ message FightSpawn {
bool started = 7;
bool locked = 8;
bool need_help = 9;
repeated Position team1_positions = 10;
repeated Position team2_positions = 11;
uint64 start_time = 12;
}

// ======================================== [CLIENT -> SERVER]
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function create_client({ socket_write, socket_end }) {
const raw_packet = Packets.Packet.fromBinary(
new Uint8Array(message),
).toJson({
useProtoFieldName: true,
emitDefaultValues: true,
})
const [[type, value]] = Object.entries(raw_packet)
Expand Down
3 changes: 3 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ type Fight = {
id: string
team1: Entity[]
team2: Entity[]
team1_positions: Position[]
team2_positions: Position[]
spectators: string[]
top_left: Position
bottom_right: Position
started: boolean
locked: boolean
need_help: boolean
start_time: number
}

type Packets = {
Expand Down

0 comments on commit edb9377

Please sign in to comment.