bwmodel
A modeling environment for Minecraft Bedwars
Loading...
Searching...
No Matches
game.h
1// Copyright (C) 2024 Ethan Uppal. All rights reserved.
2
3#pragma once
4
5#include <memory>
6#include <vector>
7#include <array>
8#include <chrono>
9#include <cstdbool>
10#include <set>
11#include "game/map.h"
12#include "game/player.h"
13#include "game/gamedelegate.h"
14
15namespace bwmodel {
37 class Game {
38 std::unique_ptr<Map> _map;
39 PlayerColor _me;
40 std::array<bool, PLAYER_COUNT> _player_beds;
41 std::set<PlayerColor> _players_left;
42 std::vector<std::shared_ptr<GameDelegate>> delegates;
43 std::chrono::time_point<std::chrono::steady_clock> start_time;
44
45 public:
48 Game(std::unique_ptr<Map> map, PlayerColor me);
49
51 const Map& map() const;
52
54 uint64_t time() const;
55
57 PlayerColor me() const;
58
60 const std::set<PlayerColor>& players_left() const;
61
63 bool player_has_bed(PlayerColor color);
64
66 void attach(std::shared_ptr<GameDelegate> delegate);
67
69 void notify_start();
70
72 void notify_end();
73
75 bool should_end() const;
76
78 void cycle();
79
81 void notify_player_kill(PlayerColor victor, PlayerColor loser);
82
85 void notify_break_bed(PlayerColor breaker, PlayerColor bed);
86 };
87}
Definition game.h:37
void notify_break_bed(PlayerColor breaker, PlayerColor bed)
Definition game.cpp:91
Game(std::unique_ptr< Map > map, PlayerColor me)
Definition game.cpp:7
void attach(std::shared_ptr< GameDelegate > delegate)
Definition game.cpp:39
void cycle()
Definition game.cpp:64
bool should_end() const
Definition game.cpp:60
PlayerColor me() const
Definition game.cpp:27
const Map & map() const
Definition game.cpp:15
const std::set< PlayerColor > & players_left() const
Definition game.cpp:31
void notify_start()
Definition game.cpp:44
void notify_end()
Definition game.cpp:52
bool player_has_bed(PlayerColor color)
Definition game.cpp:35
uint64_t time() const
Definition game.cpp:19
void notify_player_kill(PlayerColor victor, PlayerColor loser)
Definition game.cpp:70
Definition map.h:62