Commit Graph

34 Commits

Author SHA1 Message Date
Sebastian Crane bfd321cdb3 Add build system
This commit adds support for generating POM files and builds of matchbot
as JAR or uberjar (standalone JAR) files.

Resolves issue LibreGaming/matchbot#3

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-04-09 21:48:42 +01:00
Sebastian Crane 7fc472c269 Remove superfluous utilisation of 'do' forms
Since defn evaluates the expressions it its body in the same way as do,
this commit removes the superfluous uses of do where it appears directly
as a function body.

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-04-09 22:46:18 +02:00
Sebastian Crane 6a594c5ad3 Use strings instead of keywords for game names
This commit changes the internal representation of game names in the
state data to be strings instead of keywords. This fixes a potential
memory leak relating to games that no longer have any players, since
strings, unlike keywords, are garbage collected when no longer in use.

Resolves issue LibreGaming/matchbot#2

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-03-30 12:11:10 +01:00
Sebastian Crane 6cce43f137 Move processing out of clojure.data.json/read call
This commit removes from the call to clojure.data.json/read the
conversion of the serialised list of players into a Clojure set, and
adds an independent function to do this task instead.

Since the structure of the serialised data is known in advance, the
recursive characteristics of clojure.data.json are not needed.

Resolves issue LibreGaming/matchbot#4

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-03-28 21:52:52 +01:00
Sebastian Crane 91cbdb69da Simplify the system start and restart functions
This commit changes the binding name of system/start's argument to
_ (since it is currently not used within the function), and simplifies
the system/restart function by not swapping the system Var's content
with nil before filling it with the new-created system state.

Eventually, these changes will be reverted when the initialisation of
the system is separated from the starting of that system, which will
mean that system/start will read its argument and that system/restart
will have to reinitialise the system state before restarting it.

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-03-24 21:51:06 +00:00
Sebastian Crane fecd09c656 Remove unnecessary system/system function
A nil value acts as an empty map wherever a map value is expected. For
this reason, this commit removes the system/system function (which
returns an empty map), since a call to it can safely be replaced with a
nil value.

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-03-22 22:51:59 +00:00
Sebastian Crane 0abd793fe7 Use a Var instead of an Atom for system state
The Atom's swap! function may run its provided function multiple
times. Because of this, using an Atom for the system state can
occasionally result in duplicate TCP connections being opened when the
system is started. These connections remain open until they
timeout (this is typically 5 minutes for IRC).

This commit changes the container for the system state from an Atom to a
Var, whose alter-var-root function (analogous to swap!) does not have
this issue.

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-03-22 22:47:00 +00:00
Sebastian Crane 56094478db Remove use of state container in main function
Since the main function will only ever start and stop one system, this
commit simplifies the main function to use a single lexical binding for
the system state rather than creating an Atom.

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-03-22 22:38:30 +00:00
Sebastian Crane 293fa41d3b Fix exception when dispatch-command returns nil
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-28 21:09:05 +00:00
Sebastian Crane a180f7927e Use IRC nick as default IRC 'real name'
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-28 17:38:35 +00:00
Sebastian Crane 71deb2c91d Add !help IRC command
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-27 21:53:45 +00:00
Sebastian Crane 55379e1e81 Add support for sending multi-line IRC messages
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-27 21:52:07 +00:00
Sebastian Crane 2f27cb8a86 Omit sender of !match command from players list
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-26 23:34:38 +00:00
Sebastian Crane d9dc7acd34 Refactor response functions to use 'as->' macro
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-26 23:18:19 +00:00
Sebastian Crane e4df11f12d Use case-insensitive sorting when listing players
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-23 21:30:57 +00:00
Sebastian Crane c5a70954c3 Factor out keywordise-game function
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-23 21:23:34 +00:00
Sebastian Crane 7857a1acf5 Add main function
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-19 23:33:01 +00:00
Sebastian Crane a2a041c9d1 Add 'Reloaded' system for interactive development
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-19 23:18:53 +00:00
Sebastian Crane aacf1cad28 Add IRC connection functionality
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-19 22:32:43 +00:00
Sebastian Crane fe660a8929 Add support for loading state and config files
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-19 21:42:35 +00:00
Sebastian Crane c1572ed121 Use keyword arguments for response functions
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-18 22:08:22 +00:00
Sebastian Crane 77b022455e Add !list IRC command to dispatch-command function
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-18 22:08:22 +00:00
Sebastian Crane f891299236 Add response function with tests to list games
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-09 21:46:07 +00:00
Sebastian Crane 083d51a879 Rename !list IRC command to !players
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-09 21:45:03 +00:00
Sebastian Crane ae06d012ea Prune empty game if removing its only player
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-09 21:25:20 +00:00
Sebastian Crane 5c0918f990 Add function with tests to dispatch IRC commands
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-09 15:47:24 +00:00
Sebastian Crane ac1a8d9c94 Make signatures of response functions match
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-09 14:20:06 +00:00
Sebastian Crane 977ab9ea3a Ensure that add-player-of-game function is idempotent
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-09 14:05:04 +00:00
Sebastian Crane 6e0f0237b3 Add functions with tests for generating responses
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-02-09 14:04:30 +00:00
Sebastian Crane 905c6ada4c Add function with tests to get list of games
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-01-03 14:27:19 +00:00
Sebastian Crane 242873a713 Rename players-of-game function to start with verb
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-01-03 14:25:15 +00:00
Sebastian Crane f85458340c Add function with tests to remove game
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-01-01 18:29:19 +00:00
Sebastian Crane e224e02e86 Add function with tests to remove player from game
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-01-01 17:57:47 +00:00
Sebastian Crane f15c08e2cd Initial commit
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
2022-01-01 17:45:51 +00:00