]> git.sesse.net Git - pkanalytics/blobdiff - events.cpp
Tweak formation backdating.
[pkanalytics] / events.cpp
index 92ca3271188154e13e914642836052cf7592da43..cbdb30344e21e2c221b0ae7a7ca7cbba8e76dc08 100644 (file)
@@ -58,7 +58,30 @@ QVariant EventsModel::data(const QModelIndex &index, int role) const
                        return QVariant();
                }
        } else if (index.column() == 2) {
-               return QString::fromUtf8(events[index.row()].type);
+               string type = e.type;
+               type[0] = toupper(e.type[0]);
+               for (char &ch : type) {
+                       if (ch == '_') {
+                               ch = ' ';
+                       }
+               }
+
+               // Various fixups.
+               if (type == "Pull oob") {
+                       type = "Pull OOB";
+               } else if (type == "Formation defense") {
+                       type = "Defensive formation";
+               } else if (type == "Formation offense") {
+                       type = "Offensive formation";
+               } else if (type == "Set offense") {
+                       type = "On offense";
+               } else if (type == "Set defense") {
+                       type = "On defense";
+               } else if (type == "Catch") {
+                       type = "Catch/take";
+               }
+
+               return QString::fromUtf8(type);
        }
        return QVariant();
 }
@@ -291,6 +314,8 @@ EventsModel::Status EventsModel::get_status_at(uint64_t t)
        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;
@@ -365,6 +390,20 @@ EventsModel::Status EventsModel::get_status_at(uint64_t t)
                                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);
@@ -440,7 +479,7 @@ void EventsModel::set_team_at(uint64_t t, const set<int> &new_team)
 
 void EventsModel::set_formation_at(uint64_t t, bool offense, unsigned formation)
 {
-       // If there's another goal/stoppage no more than 20 seconds ago,
+       // If there's another goal/stoppage/turnover no more than 20 seconds ago,
        // we assume that the formation started at that point (it just took
        // the operator a bit of time to see it). If not, we assume we
        // changed in the middle of a point.
@@ -449,7 +488,14 @@ void EventsModel::set_formation_at(uint64_t t, bool offense, unsigned formation)
                if (e.t > t) {
                        break;
                }
-               if (e.type == "goal" || e.type == "their_goal" || e.type == "stoppage" || e.type == "reset" || e.type == "set_offense" || e.type == "set_defense" || e.type == "in" || e.type == "out" || e.type == "pull" || e.type == "their_pull") {
+               if (e.type == "goal" || e.type == "their_goal" ||
+                   e.type == "in" || e.type == "out" ||
+                   e.type == "stoppage" || e.type == "reset" ||
+                   e.type == "set_defense" || e.type == "set_offense" ||
+                   e.type == "throwaway" || e.type == "their_throwaway" ||
+                   e.type == "drop" || e.type == "defense" || e.type == "interception" ||
+                   e.type == "pull" || e.type == "pull_landed" || e.type == "pull_oob" || e.type == "their_pull" ||
+                   e.type == "formation_offense" || e.type == "formation_defense") {
                        backdate_point = e.t + 1;
                }
                if (e.type == "formation_offense" || e.type == "formation_defense") {