Skip to content

Commit

Permalink
zgodnji začetek runde
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Oct 27, 2023
1 parent fb37086 commit 800e5a2
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
2 changes: 2 additions & 0 deletions messages/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ message Leave {}
message ReplayLink { string replay = 1; }
message ReplayMove {}
message ReplaySelectGame { int32 game = 1; }
message StartEarly {}

message GameInfo {
int32 gamesPlayed = 1;
Expand Down Expand Up @@ -251,5 +252,6 @@ message Message {
ReplayMove replay_move = 38;
ReplaySelectGame replay_select_game = 39;
GameInfo game_info = 40;
StartEarly start_early = 41;
}
}
11 changes: 11 additions & 0 deletions tarok/lib/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,17 @@ class Controller extends GetxController {
debugPrint("Sent the GameEnd packet");
}

Future<void> gameStartEarly() async {
debugPrint("Called gameStartEarly");
if (bots) return;
debugPrint("Sending the StartEarly packet");
requestedGameEnd.value = true;
final Uint8List message =
Messages.Message(startEarly: Messages.StartEarly()).writeToBuffer();
socket.send(message);
debugPrint("Sent the StartEarly packet");
}

Future<void> sendMessageString(String m) async {
if (bots) return;
final Uint8List message = Messages.Message(
Expand Down
14 changes: 14 additions & 0 deletions tarok/lib/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,20 @@ class Game extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (controller.gamesPlayed.value !=
controller.gamesRequired.value &&
!controller.bots &&
controller.gamesRequired.value != -1)
ElevatedButton(
onPressed: () async =>
await controller.gameStartEarly(),
child: const Text("Takoj naprej")),
if (controller.gamesPlayed.value !=
controller.gamesRequired.value &&
!controller.bots)
const SizedBox(
height: 10,
),
...controller.results.value!.user.map(
(e) => Column(
children: [
Expand Down
49 changes: 48 additions & 1 deletion tarok/lib/messages.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,35 @@ class ReplaySelectGame extends $pb.GeneratedMessage {
void clearGame() => clearField(1);
}

class StartEarly extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'StartEarly', createEmptyInstance: create)
..hasRequiredFields = false
;

StartEarly._() : super();
factory StartEarly() => create();
factory StartEarly.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory StartEarly.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
StartEarly clone() => StartEarly()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
StartEarly copyWith(void Function(StartEarly) updates) => super.copyWith((message) => updates(message as StartEarly)) as StartEarly; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static StartEarly create() => StartEarly._();
StartEarly createEmptyInstance() => create();
static $pb.PbList<StartEarly> createRepeated() => $pb.PbList<StartEarly>();
@$core.pragma('dart2js:noInline')
static StartEarly getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<StartEarly>(create);
static StartEarly? _defaultInstance;
}

class GameInfo extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GameInfo', createEmptyInstance: create)
..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'gamesPlayed', $pb.PbFieldType.O3, protoName: 'gamesPlayed')
Expand Down Expand Up @@ -3049,6 +3078,7 @@ enum Message_Data {
replayMove,
replaySelectGame,
gameInfo,
startEarly,
notSet
}

Expand Down Expand Up @@ -3085,10 +3115,11 @@ class Message extends $pb.GeneratedMessage {
38 : Message_Data.replayMove,
39 : Message_Data.replaySelectGame,
40 : Message_Data.gameInfo,
41 : Message_Data.startEarly,
0 : Message_Data.notSet
};
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Message', createEmptyInstance: create)
..oo(0, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])
..oo(0, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41])
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'username')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'playerId')
..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'silent')
Expand Down Expand Up @@ -3123,6 +3154,7 @@ class Message extends $pb.GeneratedMessage {
..aOM<ReplayMove>(38, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'replayMove', subBuilder: ReplayMove.create)
..aOM<ReplaySelectGame>(39, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'replaySelectGame', subBuilder: ReplaySelectGame.create)
..aOM<GameInfo>(40, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'gameInfo', subBuilder: GameInfo.create)
..aOM<StartEarly>(41, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'startEarly', subBuilder: StartEarly.create)
..hasRequiredFields = false
;

Expand Down Expand Up @@ -3162,6 +3194,7 @@ class Message extends $pb.GeneratedMessage {
ReplayMove? replayMove,
ReplaySelectGame? replaySelectGame,
GameInfo? gameInfo,
StartEarly? startEarly,
}) {
final _result = create();
if (username != null) {
Expand Down Expand Up @@ -3266,6 +3299,9 @@ class Message extends $pb.GeneratedMessage {
if (gameInfo != null) {
_result.gameInfo = gameInfo;
}
if (startEarly != null) {
_result.startEarly = startEarly;
}
return _result;
}
factory Message.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
Expand Down Expand Up @@ -3659,5 +3695,16 @@ class Message extends $pb.GeneratedMessage {
void clearGameInfo() => clearField(40);
@$pb.TagNumber(40)
GameInfo ensureGameInfo() => $_ensure(33);

@$pb.TagNumber(41)
StartEarly get startEarly => $_getN(34);
@$pb.TagNumber(41)
set startEarly(StartEarly v) { setField(41, v); }
@$pb.TagNumber(41)
$core.bool hasStartEarly() => $_has(34);
@$pb.TagNumber(41)
void clearStartEarly() => clearField(41);
@$pb.TagNumber(41)
StartEarly ensureStartEarly() => $_ensure(34);
}

10 changes: 9 additions & 1 deletion tarok/lib/messages.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ const ReplaySelectGame$json = const {

/// Descriptor for `ReplaySelectGame`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List replaySelectGameDescriptor = $convert.base64Decode('ChBSZXBsYXlTZWxlY3RHYW1lEhIKBGdhbWUYASABKAVSBGdhbWU=');
@$core.Deprecated('Use startEarlyDescriptor instead')
const StartEarly$json = const {
'1': 'StartEarly',
};

/// Descriptor for `StartEarly`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List startEarlyDescriptor = $convert.base64Decode('CgpTdGFydEVhcmx5');
@$core.Deprecated('Use gameInfoDescriptor instead')
const GameInfo$json = const {
'1': 'GameInfo',
Expand Down Expand Up @@ -529,11 +536,12 @@ const Message$json = const {
const {'1': 'replay_move', '3': 38, '4': 1, '5': 11, '6': '.ReplayMove', '9': 0, '10': 'replayMove'},
const {'1': 'replay_select_game', '3': 39, '4': 1, '5': 11, '6': '.ReplaySelectGame', '9': 0, '10': 'replaySelectGame'},
const {'1': 'game_info', '3': 40, '4': 1, '5': 11, '6': '.GameInfo', '9': 0, '10': 'gameInfo'},
const {'1': 'start_early', '3': 41, '4': 1, '5': 11, '6': '.StartEarly', '9': 0, '10': 'startEarly'},
],
'8': const [
const {'1': 'data'},
],
};

/// Descriptor for `Message`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List messageDescriptor = $convert.base64Decode('CgdNZXNzYWdlEhoKCHVzZXJuYW1lGAEgASgJUgh1c2VybmFtZRIbCglwbGF5ZXJfaWQYAiABKAlSCHBsYXllcklkEhYKBnNpbGVudBgEIAEoCFIGc2lsZW50Ei0KCmNvbm5lY3Rpb24YCiABKAsyCy5Db25uZWN0aW9uSABSCmNvbm5lY3Rpb24SMAoLbGljaXRpcmFuamUYCyABKAsyDC5MaWNpdGlyYW5qZUgAUgtsaWNpdGlyYW5qZRIbCgRjYXJkGAwgASgLMgUuQ2FyZEgAUgRjYXJkEkAKEWxpY2l0aXJhbmplX3N0YXJ0GA0gASgLMhEuTGljaXRpcmFuamVTdGFydEgAUhBsaWNpdGlyYW5qZVN0YXJ0EisKCmdhbWVfc3RhcnQYDiABKAsyCi5HYW1lU3RhcnRIAFIJZ2FtZVN0YXJ0EjQKDWxvZ2luX3JlcXVlc3QYDyABKAsyDS5Mb2dpblJlcXVlc3RIAFIMbG9naW5SZXF1ZXN0EisKCmxvZ2luX2luZm8YECABKAsyCi5Mb2dpbkluZm9IAFIJbG9naW5JbmZvEjcKDmxvZ2luX3Jlc3BvbnNlGBEgASgLMg4uTG9naW5SZXNwb25zZUgAUg1sb2dpblJlc3BvbnNlEisKCmNsZWFyX2Rlc2sYEiABKAsyCi5DbGVhckRlc2tIAFIJY2xlYXJEZXNrEiQKB3Jlc3VsdHMYEyABKAsyCC5SZXN1bHRzSABSB3Jlc3VsdHMSKAoJdXNlcl9saXN0GBQgASgLMgkuVXNlckxpc3RIAFIIdXNlckxpc3QSNwoOa2luZ19zZWxlY3Rp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