<commit_before>package entities

import (
	"encoding/json"
	"fmt"
	"github.com/Vladimiroff/vec2d"
	"math"
	"time"
)

type Planet struct {
	Color               Color
	coords              []int
	IsHome              bool
	Texture             int
	Size                int
	LastShipCountUpdate int64
	ShipCount           int
	MaxShipCount        int
	Owner               string
}

func (p *Planet) String() string {
	return fmt.Sprintf("Planet[%s, %s]", p.coords[0], p.coords[1])
}

func (p *Planet) GetKey() string {
	return fmt.Sprintf("planet.%d_%d", p.coords[0], p.coords[1])
}

func (p *Planet) GetCoords() []int {
	return p.coords
}

func (p *Planet) HasOwner() bool {
	return len(p.Owner) > 0
}

func (p *Planet) Serialize() (string, []byte, error) {
	_ = p.GetShipCount()
	result, err := json.Marshal(p)
	if err != nil {
		return p.GetKey(), nil, err
	}
	return p.GetKey(), result, nil
}

func (p *Planet) GetShipCount() int {
	if p.HasOwner() {
		p.UpdateShipCount()
	}
	return p.ShipCount
}

func (p *Planet) SetShipCount(count int) {
	p.ShipCount = count
	p.LastShipCountUpdate = time.Now().Unix()
}

func (p *Planet) UpdateShipCount() {<commit_msg>Marshal entities.Planet via proxy type<commit_after>package entities

import (
	"encoding/json"
	"fmt"
	"github.com/Vladimiroff/vec2d"
	"math"
	"time"
)

type Planet struct {
	Color               Color
	coords              []int
	IsHome              bool
	Texture             int
	Size                int
	LastShipCountUpdate int64
	ShipCount           int
	MaxShipCount        int
	Owner               string
}

type marshalHook Planet

func (p *Planet) String() string {
	return fmt.Sprintf("Planet[%s, %s]", p.coords[0], p.coords[1])
}

func (p *Planet) GetKey() string {
	return fmt.Sprintf("planet.%d_%d", p.coords[0], p.coords[1])
}

func (p *Planet) GetCoords() []int {
	return p.coords
}

func (p *Planet) HasOwner() bool {
	return len(p.Owner) > 0
}

func (p *Planet) MarshalJSON() ([]byte, error) {
	p.GetShipCount()
	return json.Marshal((*marshalHook)(p))
}

func (p *Planet) Serialize() (string, []byte, error) {
	_ = p.GetShipCount()
	result, err := json.Marshal(p)
	if err != nil {
		return p.GetKey(), nil, err
	}
	return p.GetKey(), result, nil
}

func (p *Planet) GetShipCount() int {
	if p.HasOwner() {
		p.UpdateShipCount()
	}
	return p.ShipCount
}

func (p *Planet) SetShipCount(count int) {
	p.ShipCount = count
	p.LastShipCountUpdate = time.Now().Unix()
}

func (p *Planet) UpdateShipCount() {
{'fraction_non_alphanumeric': 0.145748987854251, 'fraction_numerical': 0.006477732793522267, 'mean_word_length': 2.9347133757961785, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2712116', 'n_tokens_mistral': 947, 'n_tokens_neox': 953, 'n_words': 232}