diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-23 07:08:18 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-23 07:08:18 +0100 |
commit | 5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e (patch) | |
tree | 982ca2e7f9ac4e8c350dfb5c4f60bcfdfff5afaf /learn-you-some-erlang/curling_scoreboard.erl | |
parent | 05ae56e5e89abf2993f84e6d52b250131f247c35 (diff) | |
download | erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.gz erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.bz2 erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.xz erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.zip |
wip
Diffstat (limited to 'learn-you-some-erlang/curling_scoreboard.erl')
-rw-r--r-- | learn-you-some-erlang/curling_scoreboard.erl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/learn-you-some-erlang/curling_scoreboard.erl b/learn-you-some-erlang/curling_scoreboard.erl new file mode 100644 index 0000000..34ff48d --- /dev/null +++ b/learn-you-some-erlang/curling_scoreboard.erl @@ -0,0 +1,32 @@ +-module(curling_scoreboard). +-behaviour(gen_event). + +-export([init/1, handle_event/2, handle_call/2, handle_info/2, code_change/3, + terminate/2]). + +init([]) -> + {ok, []}. + +handle_event({set_teams, TeamA, TeamB}, State) -> + curling_scoreboard_hw:set_teams(TeamA, TeamB), + {ok, State}; +handle_event({add_points, Team, N}, State) -> + [curling_scoreboard_hw:add_point(Team) || _ <- lists:seq(1,N)], + {ok, State}; +handle_event(next_round, State) -> + curling_scoreboard_hw:next_round(), + {ok, State}; +handle_event(_, State) -> + {ok, State}. + +handle_call(_, State) -> + {ok, ok, State}. + +handle_info(_, State) -> + {ok, State}. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +terminate(_Reason, _State) -> + ok. |