<commit_before>/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

gorcon/track (lee8oi)

*/

//
package track

import (
	"fmt"
	"strings"
)

type game struct {
	Name, Ranked, Balance, Map, Mode, Round, Players, Joining,
	Ntickets, Nsize, Rtickets, Rsize, Elapsed, Remaining string
}

//update parses the data string and updates the server data in the current game object.
func (g *game) update(data string) {
	if len(data) > 1 {
		splitLine := strings.Split(data, "\t")
		mode := strings.Split(splitLine[20], "_")[1]
		if len(splitLine) < 27 {
			return
		}
		*g = game{
			Name:      splitLine[7],
			Ranked:    splitLine[25],
			Balance:   splitLine[24],
			Map:       mapName(splitLine[5]),
			Mode:      strings.ToUpper(mode),
			Round:     splitLine[31],
			Players:   splitLine[3],
			Joining:   splitLine[4],
			Ntickets:  splitLine[11],
			Nsize:     splitLine[26],
			Rtickets:  splitLine[16],
			Rsize:     splitLine[27],
			Elapsed:   splitLine[18],
			Remaining: splitLine[19],
		}
	}
	if err := writeJSON("game.json", g); err != nil {
		fmt.Println(err)
	}
}

//MapName returns the full name for the specified map.
func mapName(name string) string {<commit_msg>Modified game.update in attempt to fix an elusive index out of range error.<commit_after>/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

gorcon/track (lee8oi)

*/

//
package track

import (
	"fmt"
	"strings"
)

type game struct {
	Name, Ranked, Balance, Map, Mode, Round, Players, Joining,
	Ntickets, Nsize, Rtickets, Rsize, Elapsed, Remaining string
}

//update parses the data string and updates the server data in the current game object.
func (g *game) update(data string) {
	splitLine := strings.Split(data, "\t")
	if len(splitLine) >= 27 {
		mode := strings.Split(splitLine[20], "_")[1]
		*g = game{
			Name:      splitLine[7],
			Ranked:    splitLine[25],
			Balance:   splitLine[24],
			Map:       mapName(splitLine[5]),
			Mode:      strings.ToUpper(mode),
			Round:     splitLine[31],
			Players:   splitLine[3],
			Joining:   splitLine[4],
			Ntickets:  splitLine[11],
			Nsize:     splitLine[26],
			Rtickets:  splitLine[16],
			Rsize:     splitLine[27],
			Elapsed:   splitLine[18],
			Remaining: splitLine[19],
		}
		if err := writeJSON("game.json", g); err != nil {
			fmt.Println(err)
		}
	}
}

//MapName returns the full name for the specified map.
func mapName(name string) string {
{'fraction_non_alphanumeric': 0.12883895131086143, 'fraction_numerical': 0.024344569288389514, 'mean_word_length': 3.3150242326332795, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1299933', 'n_tokens_mistral': 1039, 'n_tokens_neox': 930, 'n_words': 294}