-
Notifications
You must be signed in to change notification settings - Fork 13
/
datastore_upload_course_record_param.go
115 lines (89 loc) · 4.02 KB
/
datastore_upload_course_record_param.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Package types implements all the types used by the DataStore (Super Mario Maker) protocol
package types
import (
"fmt"
"strings"
"github.com/PretendoNetwork/nex-go"
)
// DataStoreUploadCourseRecordParam holds data for the DataStore (Super Mario Maker) protocol
type DataStoreUploadCourseRecordParam struct {
nex.Structure
DataID uint64
Slot uint8
Score int32
}
// ExtractFromStream extracts a DataStoreUploadCourseRecordParam structure from a stream
func (dataStoreUploadCourseRecordParam *DataStoreUploadCourseRecordParam) ExtractFromStream(stream *nex.StreamIn) error {
var err error
dataStoreUploadCourseRecordParam.DataID, err = stream.ReadUInt64LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreUploadCourseRecordParam.DataID from stream. %s", err.Error())
}
dataStoreUploadCourseRecordParam.Slot, err = stream.ReadUInt8()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreUploadCourseRecordParam.Slot from stream. %s", err.Error())
}
dataStoreUploadCourseRecordParam.Score, err = stream.ReadInt32LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreUploadCourseRecordParam.Score from stream. %s", err.Error())
}
return nil
}
// Bytes encodes the DataStoreUploadCourseRecordParam and returns a byte array
func (dataStoreUploadCourseRecordParam *DataStoreUploadCourseRecordParam) Bytes(stream *nex.StreamOut) []byte {
stream.WriteUInt64LE(dataStoreUploadCourseRecordParam.DataID)
stream.WriteUInt8(dataStoreUploadCourseRecordParam.Slot)
stream.WriteInt32LE(dataStoreUploadCourseRecordParam.Score)
return stream.Bytes()
}
// Copy returns a new copied instance of DataStoreUploadCourseRecordParam
func (dataStoreUploadCourseRecordParam *DataStoreUploadCourseRecordParam) Copy() nex.StructureInterface {
copied := NewDataStoreUploadCourseRecordParam()
copied.SetStructureVersion(dataStoreUploadCourseRecordParam.StructureVersion())
copied.DataID = dataStoreUploadCourseRecordParam.DataID
copied.Slot = dataStoreUploadCourseRecordParam.Slot
copied.Score = dataStoreUploadCourseRecordParam.Score
return copied
}
// Equals checks if the passed Structure contains the same data as the current instance
func (dataStoreUploadCourseRecordParam *DataStoreUploadCourseRecordParam) Equals(structure nex.StructureInterface) bool {
other := structure.(*DataStoreUploadCourseRecordParam)
if dataStoreUploadCourseRecordParam.StructureVersion() != other.StructureVersion() {
return false
}
if dataStoreUploadCourseRecordParam.DataID != other.DataID {
return false
}
if dataStoreUploadCourseRecordParam.Slot != other.Slot {
return false
}
if dataStoreUploadCourseRecordParam.Score != other.Score {
return false
}
return true
}
// String returns a string representation of the struct
func (dataStoreUploadCourseRecordParam *DataStoreUploadCourseRecordParam) String() string {
return dataStoreUploadCourseRecordParam.FormatToString(0)
}
// FormatToString pretty-prints the struct data using the provided indentation level
func (dataStoreUploadCourseRecordParam *DataStoreUploadCourseRecordParam) FormatToString(indentationLevel int) string {
indentationValues := strings.Repeat("\t", indentationLevel+1)
indentationEnd := strings.Repeat("\t", indentationLevel)
var b strings.Builder
b.WriteString("DataStoreUploadCourseRecordParam{\n")
b.WriteString(fmt.Sprintf("%sstructureVersion: %d,\n", indentationValues, dataStoreUploadCourseRecordParam.StructureVersion()))
b.WriteString(fmt.Sprintf("%sDataID: %d,\n", indentationValues, dataStoreUploadCourseRecordParam.DataID))
b.WriteString(fmt.Sprintf("%sSlot: %d,\n", indentationValues, dataStoreUploadCourseRecordParam.Slot))
b.WriteString(fmt.Sprintf("%sScore: %d,\n", indentationValues, dataStoreUploadCourseRecordParam.Score))
b.WriteString(fmt.Sprintf("%s}", indentationEnd))
return b.String()
}
// NewDataStoreUploadCourseRecordParam returns a new DataStoreUploadCourseRecordParam
func NewDataStoreUploadCourseRecordParam() *DataStoreUploadCourseRecordParam {
return &DataStoreUploadCourseRecordParam{
DataID: 0,
Slot: 0,
Score: 0,
}
}