diff options
| author | RblSb <msrblsb@gmail.com> | 2020-02-13 16:28:18 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-02-15 19:45:40 +0300 |
| commit | 07d1955cefc093ffb12002902ed45e963030746e (patch) | |
| tree | 8833eca2dc2ef07891aa8eb66daf7ad90f2ab0ce /src/ClientTools.hx | |
Initial commit
Diffstat (limited to 'src/ClientTools.hx')
| -rw-r--r-- | src/ClientTools.hx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ClientTools.hx b/src/ClientTools.hx new file mode 100644 index 0000000..4503ada --- /dev/null +++ b/src/ClientTools.hx @@ -0,0 +1,26 @@ +package; + +class ClientTools { + + public static function setLeader(clients:Array<Client>, name:String):Void { + for (client in clients) { + if (client.name == name) client.isLeader = true; + else if (client.isLeader) client.isLeader = false; + } + } + + public static function hasLeader(clients:Array<Client>):Bool { + for (client in clients) { + if (client.isLeader) return true; + } + return false; + } + + public static function getByName(clients:Array<Client>, name:String):Null<Client> { + for (client in clients) { + if (client.name == name) return client; + } + return null; + } + +} |
