summaryrefslogtreecommitdiff
path: root/lib/include/turns-turn-order.h
blob: 0f4236978c2f37123d0d6c39ba56d033aee2d2ce (plain)
1
2
3
4
5
6
7
8
9
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com>
 * SPDX-License-Identifier: LGPL-2.1-only
 */

#ifndef TURNS_TURN_ORDER_H
#define TURNS_TURN_ORDER_H

#include "turns-participant.h"

#include <glib-object.h>
#include <glib.h>
#include <glibconfig.h>

G_BEGIN_DECLS

/**
 * TurnsTurnOrderSortMode:
 * @TURNS_TURN_ORDER_SORT_MODE_DESCENDING: Sort higher priorities before lower ones
 * @TURNS_TURN_ORDER_SORT_MODE_ASCENDING: Sort higher priorities after lower ones
 *
 * Orderings that can be applied to the turn order.
 *
 * See [property@Turns.TurnOrder.sort-mode]
 */
typedef enum
{
  TURNS_TURN_ORDER_SORT_MODE_DESCENDING,
  TURNS_TURN_ORDER_SORT_MODE_ASCENDING,
} TurnsTurnOrderSortMode;

GType turns_turn_order_sort_mode_get_type(void) G_GNUC_CONST;
#define TURNS_TYPE_TURN_ORDER_SORT_MODE (turns_turn_order_sort_mode_get_type())

#define TURNS_TYPE_TURN_ORDER turns_turn_order_get_type()
G_DECLARE_FINAL_TYPE(TurnsTurnOrder, turns_turn_order, TURNS, TURN_ORDER, GObject)

/**
 * TurnsTurnOrder:
 *
 * Manages the order of turns for a given set of `TurnsParticipant`s.
 */

/**
 * turns_turn_order_new:
 *
 * Creates a new turn order.
 *
 * Returns: (transfer full): a new `TurnsTurnOrder`.
 */
G_GNUC_WARN_UNUSED_RESULT
TurnsTurnOrder * turns_turn_order_new(void);

/**
 * turns_turn_order_add:
 * @self: a turn order.
 * @participant: (transfer full): A participant to be added.
 *
 * Adds a participant to a turn-order.
 */
void turns_turn_order_add(TurnsTurnOrder * self, TurnsParticipant * participant);

/**
 * turns_turn_order_clear:
 * @self: a turn order
 *
 * Removes all participants from a turn order.
 */
void turns_turn_order_clear(TurnsTurnOrder * self);

/**
 * turns_turn_order_remove_at:
 * @self: a turn order
 *
 * Removes the participant at the given position.
 */
void turns_turn_order_remove_at(TurnsTurnOrder * self, guint position);

/**
 * turns_turn_order_get_empty: (get-property empty):
 * @self: a turn order.
 *
 * Gets whether the turn order is empty.
 */
G_GNUC_WARN_UNUSED_RESULT
gboolean turns_turn_order_get_empty(TurnsTurnOrder const * self);

/**
 * turns_turn_order_get_participant_count:
 * @self: a turn order.
 *
 * Gets the number of participants in the turn order.
 */
G_GNUC_WARN_UNUSED_RESULT
gsize turns_turn_order_get_participant_count(TurnsTurnOrder const * self);

/**
 * turns_turn_order_get_running: (get-property running):
 * @self: a turn order.
 *
 * Gets whether the turn order is currently running.
 */
G_GNUC_WARN_UNUSED_RESULT
gboolean turns_turn_order_get_running(TurnsTurnOrder const * self);

/**
 * turns_turn_order_get_round_progress: (get-property round-progress):
 * @self: a turn order.
 *
 * Gets the progress of the current round.
 */
G_GNUC_WARN_UNUSED_RESULT
gfloat turns_turn_order_get_round_progress(TurnsTurnOrder const * self);

/**
 * turns_turn_order_get_sort_mode: (get-property sort-mode):
 * @self: a turn order.
 *
 * Gets whether higher priority values are sorted before or after lower ones.
 */
G_GNUC_WARN_UNUSED_RESULT
TurnsTurnOrderSortMode turns_turn_order_get_sort_mode(TurnsTurnOrder const * self);

/**
 * turns_turn_order_set_sort_mode: (set-property sort-mode):
 * @self: a turn order.
 * @sort_mode: whether higher priorities should be sorted before or after lower ones.
 *
 * Sets whether higher priority values are sorted before or after lower ones.
 */
void turns_turn_order_set_sort_mode(TurnsTurnOrder * self, TurnsTurnOrderSortMode sort_mode);

G_END_DECLS

#endif