s.our_score = 0;
s.their_score = 0;
s.attack_state = Status::NOT_STARTED;
+ s.offensive_formation = 0;
+ s.defensive_formation = 0;
s.stoppage = false;
s.pull_state = Status::SHOULD_PULL;
uint64_t last_gained_possession = 0;
last_stoppage = 0;
}
}
+ if (e.type == "formation_offense") {
+ if (e.formation_id) {
+ s.offensive_formation = *e.formation_id;
+ } else {
+ s.offensive_formation = 0;
+ }
+ }
+ if (e.type == "formation_defense") {
+ if (e.formation_id) {
+ s.defensive_formation = *e.formation_id;
+ } else {
+ s.defensive_formation = 0;
+ }
+ }
}
if (s.stoppage && last_stoppage != 0) {
time_spent_in_stoppage += (t - last_stoppage);
struct Status {
unsigned our_score, their_score;
enum { NOT_STARTED, OFFENSE, DEFENSE } attack_state;
+ unsigned offensive_formation, defensive_formation;
bool stoppage;
enum { NOT_PULLING, SHOULD_PULL, PULL_IN_AIR } pull_state;
unsigned num_passes;
}
return formations[row - 1].formation_id;
}
- std::string get_formation_name_by_id(unsigned formation_id);
+ std::string get_formation_name_by_id(unsigned formation_id) {
+ for (unsigned i = 0; i < formations.size(); ++i) {
+ if (formations[i].formation_id == formation_id) {
+ return formations[i].name;
+ }
+ }
+ abort();
+ }
unsigned get_row_from_id(unsigned formation_id) {
for (unsigned i = 0; i < formations.size(); ++i) {
if (formations[i].formation_id == formation_id) {
{
EventsModel::Status s = events->get_status_at(t);
char buf[256];
- const char *offense = "not started";
+ std::string formation = "Not started";
if (s.attack_state == EventsModel::Status::OFFENSE) {
- offense = "offense";
+ if (s.offensive_formation != 0) {
+ formation = offensive_formations->get_formation_name_by_id(s.offensive_formation);
+ } else {
+ formation = "Offense";
+ }
} else if (s.attack_state == EventsModel::Status::DEFENSE) {
- offense = "defense";
+ if (s.defensive_formation != 0) {
+ formation = defensive_formations->get_formation_name_by_id(s.defensive_formation);
+ } else {
+ formation = "Defense";
+ }
}
snprintf(buf, sizeof(buf), "%d–%d | %s | %d passes, %d sec possession",
- s.our_score, s.their_score, offense, s.num_passes, s.possession_sec);
+ s.our_score, s.their_score, formation.c_str(), s.num_passes, s.possession_sec);
if (s.stoppage_sec > 0) {
char buf2[256];
snprintf(buf2, sizeof(buf2), "%s (plus %d sec stoppage)", buf, s.stoppage_sec);