diff --git a/api/checkers/checkers/tx.pulsar.go b/api/checkers/checkers/tx.pulsar.go index 0cd8a78..f2ff3c4 100644 --- a/api/checkers/checkers/tx.pulsar.go +++ b/api/checkers/checkers/tx.pulsar.go @@ -1839,6 +1839,1198 @@ func (x *fastReflection_MsgCreateGameResponse) ProtoMethods() *protoiface.Method } } +var ( + md_MsgPlayMove protoreflect.MessageDescriptor + fd_MsgPlayMove_creator protoreflect.FieldDescriptor + fd_MsgPlayMove_gameIndex protoreflect.FieldDescriptor + fd_MsgPlayMove_fromX protoreflect.FieldDescriptor + fd_MsgPlayMove_fromY protoreflect.FieldDescriptor + fd_MsgPlayMove_toX protoreflect.FieldDescriptor + fd_MsgPlayMove_toY protoreflect.FieldDescriptor +) + +func init() { + file_checkers_checkers_tx_proto_init() + md_MsgPlayMove = File_checkers_checkers_tx_proto.Messages().ByName("MsgPlayMove") + fd_MsgPlayMove_creator = md_MsgPlayMove.Fields().ByName("creator") + fd_MsgPlayMove_gameIndex = md_MsgPlayMove.Fields().ByName("gameIndex") + fd_MsgPlayMove_fromX = md_MsgPlayMove.Fields().ByName("fromX") + fd_MsgPlayMove_fromY = md_MsgPlayMove.Fields().ByName("fromY") + fd_MsgPlayMove_toX = md_MsgPlayMove.Fields().ByName("toX") + fd_MsgPlayMove_toY = md_MsgPlayMove.Fields().ByName("toY") +} + +var _ protoreflect.Message = (*fastReflection_MsgPlayMove)(nil) + +type fastReflection_MsgPlayMove MsgPlayMove + +func (x *MsgPlayMove) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgPlayMove)(x) +} + +func (x *MsgPlayMove) slowProtoReflect() protoreflect.Message { + mi := &file_checkers_checkers_tx_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgPlayMove_messageType fastReflection_MsgPlayMove_messageType +var _ protoreflect.MessageType = fastReflection_MsgPlayMove_messageType{} + +type fastReflection_MsgPlayMove_messageType struct{} + +func (x fastReflection_MsgPlayMove_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgPlayMove)(nil) +} +func (x fastReflection_MsgPlayMove_messageType) New() protoreflect.Message { + return new(fastReflection_MsgPlayMove) +} +func (x fastReflection_MsgPlayMove_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgPlayMove +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgPlayMove) Descriptor() protoreflect.MessageDescriptor { + return md_MsgPlayMove +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgPlayMove) Type() protoreflect.MessageType { + return _fastReflection_MsgPlayMove_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgPlayMove) New() protoreflect.Message { + return new(fastReflection_MsgPlayMove) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgPlayMove) Interface() protoreflect.ProtoMessage { + return (*MsgPlayMove)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgPlayMove) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Creator != "" { + value := protoreflect.ValueOfString(x.Creator) + if !f(fd_MsgPlayMove_creator, value) { + return + } + } + if x.GameIndex != "" { + value := protoreflect.ValueOfString(x.GameIndex) + if !f(fd_MsgPlayMove_gameIndex, value) { + return + } + } + if x.FromX != uint64(0) { + value := protoreflect.ValueOfUint64(x.FromX) + if !f(fd_MsgPlayMove_fromX, value) { + return + } + } + if x.FromY != uint64(0) { + value := protoreflect.ValueOfUint64(x.FromY) + if !f(fd_MsgPlayMove_fromY, value) { + return + } + } + if x.ToX != uint64(0) { + value := protoreflect.ValueOfUint64(x.ToX) + if !f(fd_MsgPlayMove_toX, value) { + return + } + } + if x.ToY != uint64(0) { + value := protoreflect.ValueOfUint64(x.ToY) + if !f(fd_MsgPlayMove_toY, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgPlayMove) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMove.creator": + return x.Creator != "" + case "checkers.checkers.MsgPlayMove.gameIndex": + return x.GameIndex != "" + case "checkers.checkers.MsgPlayMove.fromX": + return x.FromX != uint64(0) + case "checkers.checkers.MsgPlayMove.fromY": + return x.FromY != uint64(0) + case "checkers.checkers.MsgPlayMove.toX": + return x.ToX != uint64(0) + case "checkers.checkers.MsgPlayMove.toY": + return x.ToY != uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMove")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMove does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMove) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMove.creator": + x.Creator = "" + case "checkers.checkers.MsgPlayMove.gameIndex": + x.GameIndex = "" + case "checkers.checkers.MsgPlayMove.fromX": + x.FromX = uint64(0) + case "checkers.checkers.MsgPlayMove.fromY": + x.FromY = uint64(0) + case "checkers.checkers.MsgPlayMove.toX": + x.ToX = uint64(0) + case "checkers.checkers.MsgPlayMove.toY": + x.ToY = uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMove")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMove does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgPlayMove) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "checkers.checkers.MsgPlayMove.creator": + value := x.Creator + return protoreflect.ValueOfString(value) + case "checkers.checkers.MsgPlayMove.gameIndex": + value := x.GameIndex + return protoreflect.ValueOfString(value) + case "checkers.checkers.MsgPlayMove.fromX": + value := x.FromX + return protoreflect.ValueOfUint64(value) + case "checkers.checkers.MsgPlayMove.fromY": + value := x.FromY + return protoreflect.ValueOfUint64(value) + case "checkers.checkers.MsgPlayMove.toX": + value := x.ToX + return protoreflect.ValueOfUint64(value) + case "checkers.checkers.MsgPlayMove.toY": + value := x.ToY + return protoreflect.ValueOfUint64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMove")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMove does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMove) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMove.creator": + x.Creator = value.Interface().(string) + case "checkers.checkers.MsgPlayMove.gameIndex": + x.GameIndex = value.Interface().(string) + case "checkers.checkers.MsgPlayMove.fromX": + x.FromX = value.Uint() + case "checkers.checkers.MsgPlayMove.fromY": + x.FromY = value.Uint() + case "checkers.checkers.MsgPlayMove.toX": + x.ToX = value.Uint() + case "checkers.checkers.MsgPlayMove.toY": + x.ToY = value.Uint() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMove")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMove does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMove) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMove.creator": + panic(fmt.Errorf("field creator of message checkers.checkers.MsgPlayMove is not mutable")) + case "checkers.checkers.MsgPlayMove.gameIndex": + panic(fmt.Errorf("field gameIndex of message checkers.checkers.MsgPlayMove is not mutable")) + case "checkers.checkers.MsgPlayMove.fromX": + panic(fmt.Errorf("field fromX of message checkers.checkers.MsgPlayMove is not mutable")) + case "checkers.checkers.MsgPlayMove.fromY": + panic(fmt.Errorf("field fromY of message checkers.checkers.MsgPlayMove is not mutable")) + case "checkers.checkers.MsgPlayMove.toX": + panic(fmt.Errorf("field toX of message checkers.checkers.MsgPlayMove is not mutable")) + case "checkers.checkers.MsgPlayMove.toY": + panic(fmt.Errorf("field toY of message checkers.checkers.MsgPlayMove is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMove")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMove does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgPlayMove) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMove.creator": + return protoreflect.ValueOfString("") + case "checkers.checkers.MsgPlayMove.gameIndex": + return protoreflect.ValueOfString("") + case "checkers.checkers.MsgPlayMove.fromX": + return protoreflect.ValueOfUint64(uint64(0)) + case "checkers.checkers.MsgPlayMove.fromY": + return protoreflect.ValueOfUint64(uint64(0)) + case "checkers.checkers.MsgPlayMove.toX": + return protoreflect.ValueOfUint64(uint64(0)) + case "checkers.checkers.MsgPlayMove.toY": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMove")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMove does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgPlayMove) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in checkers.checkers.MsgPlayMove", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgPlayMove) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMove) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgPlayMove) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgPlayMove) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgPlayMove) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Creator) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.GameIndex) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.FromX != 0 { + n += 1 + runtime.Sov(uint64(x.FromX)) + } + if x.FromY != 0 { + n += 1 + runtime.Sov(uint64(x.FromY)) + } + if x.ToX != 0 { + n += 1 + runtime.Sov(uint64(x.ToX)) + } + if x.ToY != 0 { + n += 1 + runtime.Sov(uint64(x.ToY)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgPlayMove) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.ToY != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.ToY)) + i-- + dAtA[i] = 0x30 + } + if x.ToX != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.ToX)) + i-- + dAtA[i] = 0x28 + } + if x.FromY != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.FromY)) + i-- + dAtA[i] = 0x20 + } + if x.FromX != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.FromX)) + i-- + dAtA[i] = 0x18 + } + if len(x.GameIndex) > 0 { + i -= len(x.GameIndex) + copy(dAtA[i:], x.GameIndex) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.GameIndex))) + i-- + dAtA[i] = 0x12 + } + if len(x.Creator) > 0 { + i -= len(x.Creator) + copy(dAtA[i:], x.Creator) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Creator))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgPlayMove) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgPlayMove: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgPlayMove: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field GameIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.GameIndex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FromX", wireType) + } + x.FromX = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.FromX |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FromY", wireType) + } + x.FromY = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.FromY |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ToX", wireType) + } + x.ToX = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.ToX |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ToY", wireType) + } + x.ToY = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.ToY |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_MsgPlayMoveResponse protoreflect.MessageDescriptor + fd_MsgPlayMoveResponse_capturedX protoreflect.FieldDescriptor + fd_MsgPlayMoveResponse_capturedY protoreflect.FieldDescriptor + fd_MsgPlayMoveResponse_winner protoreflect.FieldDescriptor +) + +func init() { + file_checkers_checkers_tx_proto_init() + md_MsgPlayMoveResponse = File_checkers_checkers_tx_proto.Messages().ByName("MsgPlayMoveResponse") + fd_MsgPlayMoveResponse_capturedX = md_MsgPlayMoveResponse.Fields().ByName("capturedX") + fd_MsgPlayMoveResponse_capturedY = md_MsgPlayMoveResponse.Fields().ByName("capturedY") + fd_MsgPlayMoveResponse_winner = md_MsgPlayMoveResponse.Fields().ByName("winner") +} + +var _ protoreflect.Message = (*fastReflection_MsgPlayMoveResponse)(nil) + +type fastReflection_MsgPlayMoveResponse MsgPlayMoveResponse + +func (x *MsgPlayMoveResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgPlayMoveResponse)(x) +} + +func (x *MsgPlayMoveResponse) slowProtoReflect() protoreflect.Message { + mi := &file_checkers_checkers_tx_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgPlayMoveResponse_messageType fastReflection_MsgPlayMoveResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgPlayMoveResponse_messageType{} + +type fastReflection_MsgPlayMoveResponse_messageType struct{} + +func (x fastReflection_MsgPlayMoveResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgPlayMoveResponse)(nil) +} +func (x fastReflection_MsgPlayMoveResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgPlayMoveResponse) +} +func (x fastReflection_MsgPlayMoveResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgPlayMoveResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgPlayMoveResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgPlayMoveResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgPlayMoveResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgPlayMoveResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgPlayMoveResponse) New() protoreflect.Message { + return new(fastReflection_MsgPlayMoveResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgPlayMoveResponse) Interface() protoreflect.ProtoMessage { + return (*MsgPlayMoveResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgPlayMoveResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.CapturedX != int32(0) { + value := protoreflect.ValueOfInt32(x.CapturedX) + if !f(fd_MsgPlayMoveResponse_capturedX, value) { + return + } + } + if x.CapturedY != int32(0) { + value := protoreflect.ValueOfInt32(x.CapturedY) + if !f(fd_MsgPlayMoveResponse_capturedY, value) { + return + } + } + if x.Winner != "" { + value := protoreflect.ValueOfString(x.Winner) + if !f(fd_MsgPlayMoveResponse_winner, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgPlayMoveResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMoveResponse.capturedX": + return x.CapturedX != int32(0) + case "checkers.checkers.MsgPlayMoveResponse.capturedY": + return x.CapturedY != int32(0) + case "checkers.checkers.MsgPlayMoveResponse.winner": + return x.Winner != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMoveResponse")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMoveResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMoveResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMoveResponse.capturedX": + x.CapturedX = int32(0) + case "checkers.checkers.MsgPlayMoveResponse.capturedY": + x.CapturedY = int32(0) + case "checkers.checkers.MsgPlayMoveResponse.winner": + x.Winner = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMoveResponse")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMoveResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgPlayMoveResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "checkers.checkers.MsgPlayMoveResponse.capturedX": + value := x.CapturedX + return protoreflect.ValueOfInt32(value) + case "checkers.checkers.MsgPlayMoveResponse.capturedY": + value := x.CapturedY + return protoreflect.ValueOfInt32(value) + case "checkers.checkers.MsgPlayMoveResponse.winner": + value := x.Winner + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMoveResponse")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMoveResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMoveResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMoveResponse.capturedX": + x.CapturedX = int32(value.Int()) + case "checkers.checkers.MsgPlayMoveResponse.capturedY": + x.CapturedY = int32(value.Int()) + case "checkers.checkers.MsgPlayMoveResponse.winner": + x.Winner = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMoveResponse")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMoveResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMoveResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMoveResponse.capturedX": + panic(fmt.Errorf("field capturedX of message checkers.checkers.MsgPlayMoveResponse is not mutable")) + case "checkers.checkers.MsgPlayMoveResponse.capturedY": + panic(fmt.Errorf("field capturedY of message checkers.checkers.MsgPlayMoveResponse is not mutable")) + case "checkers.checkers.MsgPlayMoveResponse.winner": + panic(fmt.Errorf("field winner of message checkers.checkers.MsgPlayMoveResponse is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMoveResponse")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMoveResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgPlayMoveResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "checkers.checkers.MsgPlayMoveResponse.capturedX": + return protoreflect.ValueOfInt32(int32(0)) + case "checkers.checkers.MsgPlayMoveResponse.capturedY": + return protoreflect.ValueOfInt32(int32(0)) + case "checkers.checkers.MsgPlayMoveResponse.winner": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: checkers.checkers.MsgPlayMoveResponse")) + } + panic(fmt.Errorf("message checkers.checkers.MsgPlayMoveResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgPlayMoveResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in checkers.checkers.MsgPlayMoveResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgPlayMoveResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgPlayMoveResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgPlayMoveResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgPlayMoveResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgPlayMoveResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.CapturedX != 0 { + n += 1 + runtime.Sov(uint64(x.CapturedX)) + } + if x.CapturedY != 0 { + n += 1 + runtime.Sov(uint64(x.CapturedY)) + } + l = len(x.Winner) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgPlayMoveResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Winner) > 0 { + i -= len(x.Winner) + copy(dAtA[i:], x.Winner) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Winner))) + i-- + dAtA[i] = 0x1a + } + if x.CapturedY != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.CapturedY)) + i-- + dAtA[i] = 0x10 + } + if x.CapturedX != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.CapturedX)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgPlayMoveResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgPlayMoveResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgPlayMoveResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CapturedX", wireType) + } + x.CapturedX = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.CapturedX |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CapturedY", wireType) + } + x.CapturedY = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.CapturedY |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Winner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Winner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -2012,6 +3204,132 @@ func (x *MsgCreateGameResponse) GetGameIndex() string { return "" } +type MsgPlayMove struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + GameIndex string `protobuf:"bytes,2,opt,name=gameIndex,proto3" json:"gameIndex,omitempty"` + FromX uint64 `protobuf:"varint,3,opt,name=fromX,proto3" json:"fromX,omitempty"` + FromY uint64 `protobuf:"varint,4,opt,name=fromY,proto3" json:"fromY,omitempty"` + ToX uint64 `protobuf:"varint,5,opt,name=toX,proto3" json:"toX,omitempty"` + ToY uint64 `protobuf:"varint,6,opt,name=toY,proto3" json:"toY,omitempty"` +} + +func (x *MsgPlayMove) Reset() { + *x = MsgPlayMove{} + if protoimpl.UnsafeEnabled { + mi := &file_checkers_checkers_tx_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgPlayMove) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgPlayMove) ProtoMessage() {} + +// Deprecated: Use MsgPlayMove.ProtoReflect.Descriptor instead. +func (*MsgPlayMove) Descriptor() ([]byte, []int) { + return file_checkers_checkers_tx_proto_rawDescGZIP(), []int{4} +} + +func (x *MsgPlayMove) GetCreator() string { + if x != nil { + return x.Creator + } + return "" +} + +func (x *MsgPlayMove) GetGameIndex() string { + if x != nil { + return x.GameIndex + } + return "" +} + +func (x *MsgPlayMove) GetFromX() uint64 { + if x != nil { + return x.FromX + } + return 0 +} + +func (x *MsgPlayMove) GetFromY() uint64 { + if x != nil { + return x.FromY + } + return 0 +} + +func (x *MsgPlayMove) GetToX() uint64 { + if x != nil { + return x.ToX + } + return 0 +} + +func (x *MsgPlayMove) GetToY() uint64 { + if x != nil { + return x.ToY + } + return 0 +} + +type MsgPlayMoveResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CapturedX int32 `protobuf:"varint,1,opt,name=capturedX,proto3" json:"capturedX,omitempty"` + CapturedY int32 `protobuf:"varint,2,opt,name=capturedY,proto3" json:"capturedY,omitempty"` + Winner string `protobuf:"bytes,3,opt,name=winner,proto3" json:"winner,omitempty"` +} + +func (x *MsgPlayMoveResponse) Reset() { + *x = MsgPlayMoveResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_checkers_checkers_tx_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgPlayMoveResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgPlayMoveResponse) ProtoMessage() {} + +// Deprecated: Use MsgPlayMoveResponse.ProtoReflect.Descriptor instead. +func (*MsgPlayMoveResponse) Descriptor() ([]byte, []int) { + return file_checkers_checkers_tx_proto_rawDescGZIP(), []int{5} +} + +func (x *MsgPlayMoveResponse) GetCapturedX() int32 { + if x != nil { + return x.CapturedX + } + return 0 +} + +func (x *MsgPlayMoveResponse) GetCapturedY() int32 { + if x != nil { + return x.CapturedY + } + return 0 +} + +func (x *MsgPlayMoveResponse) GetWinner() string { + if x != nil { + return x.Winner + } + return "" +} + var File_checkers_checkers_tx_proto protoreflect.FileDescriptor var file_checkers_checkers_tx_proto_rawDesc = []byte{ @@ -2049,31 +3367,54 @@ var file_checkers_checkers_tx_proto_rawDesc = []byte{ 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x32, 0xc6, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5e, 0x0a, 0x0c, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x22, 0x2e, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, 0x73, - 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2a, 0x2e, - 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, - 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x0a, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, - 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x1a, 0x28, 0x2e, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, 0x73, - 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xba, 0x01, 0x0a, 0x15, 0x63, - 0x6f, 0x6d, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x65, 0x72, 0x73, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6c, 0x69, 0x6d, - 0x64, 0x7a, 0x68, 0x6f, 0x6e, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2f, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x65, 0x72, 0x73, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x11, 0x43, 0x68, 0x65, - 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0xca, 0x02, - 0x11, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x5c, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, - 0x72, 0x73, 0xe2, 0x02, 0x1d, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x5c, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x12, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x3a, 0x3a, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x78, 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x4d, 0x73, 0x67, 0x50, 0x6c, 0x61, 0x79, 0x4d, 0x6f, 0x76, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x67, + 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x67, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x72, 0x6f, + 0x6d, 0x58, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x66, 0x72, 0x6f, 0x6d, 0x58, 0x12, + 0x14, 0x0a, 0x05, 0x66, 0x72, 0x6f, 0x6d, 0x59, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, + 0x66, 0x72, 0x6f, 0x6d, 0x59, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x6f, 0x58, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x03, 0x74, 0x6f, 0x58, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x6f, 0x59, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x74, 0x6f, 0x59, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, 0x07, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x69, 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x50, 0x6c, + 0x61, 0x79, 0x4d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x58, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x09, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x58, 0x12, 0x1c, 0x0a, 0x09, + 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x59, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x59, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x69, + 0x6e, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x77, 0x69, 0x6e, 0x6e, + 0x65, 0x72, 0x32, 0x9a, 0x02, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5e, 0x0a, 0x0c, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x22, 0x2e, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, + 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2a, + 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, + 0x72, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x0a, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, 0x73, 0x67, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x1a, 0x28, 0x2e, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, + 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x79, 0x4d, 0x6f, 0x76, 0x65, + 0x12, 0x1e, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x50, 0x6c, 0x61, 0x79, 0x4d, 0x6f, 0x76, 0x65, + 0x1a, 0x26, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x50, 0x6c, 0x61, 0x79, 0x4d, 0x6f, 0x76, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, + 0xba, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, + 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6f, 0x6c, 0x69, 0x6d, 0x64, 0x7a, 0x68, 0x6f, 0x6e, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x65, 0x72, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, + 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, + 0x02, 0x11, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x65, 0x72, 0x73, 0xca, 0x02, 0x11, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x5c, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0xe2, 0x02, 0x1d, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, + 0x72, 0x73, 0x5c, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, + 0x72, 0x73, 0x3a, 0x3a, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2088,22 +3429,26 @@ func file_checkers_checkers_tx_proto_rawDescGZIP() []byte { return file_checkers_checkers_tx_proto_rawDescData } -var file_checkers_checkers_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_checkers_checkers_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_checkers_checkers_tx_proto_goTypes = []interface{}{ (*MsgUpdateParams)(nil), // 0: checkers.checkers.MsgUpdateParams (*MsgUpdateParamsResponse)(nil), // 1: checkers.checkers.MsgUpdateParamsResponse (*MsgCreateGame)(nil), // 2: checkers.checkers.MsgCreateGame (*MsgCreateGameResponse)(nil), // 3: checkers.checkers.MsgCreateGameResponse - (*Params)(nil), // 4: checkers.checkers.Params + (*MsgPlayMove)(nil), // 4: checkers.checkers.MsgPlayMove + (*MsgPlayMoveResponse)(nil), // 5: checkers.checkers.MsgPlayMoveResponse + (*Params)(nil), // 6: checkers.checkers.Params } var file_checkers_checkers_tx_proto_depIdxs = []int32{ - 4, // 0: checkers.checkers.MsgUpdateParams.params:type_name -> checkers.checkers.Params + 6, // 0: checkers.checkers.MsgUpdateParams.params:type_name -> checkers.checkers.Params 0, // 1: checkers.checkers.Msg.UpdateParams:input_type -> checkers.checkers.MsgUpdateParams 2, // 2: checkers.checkers.Msg.CreateGame:input_type -> checkers.checkers.MsgCreateGame - 1, // 3: checkers.checkers.Msg.UpdateParams:output_type -> checkers.checkers.MsgUpdateParamsResponse - 3, // 4: checkers.checkers.Msg.CreateGame:output_type -> checkers.checkers.MsgCreateGameResponse - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type + 4, // 3: checkers.checkers.Msg.PlayMove:input_type -> checkers.checkers.MsgPlayMove + 1, // 4: checkers.checkers.Msg.UpdateParams:output_type -> checkers.checkers.MsgUpdateParamsResponse + 3, // 5: checkers.checkers.Msg.CreateGame:output_type -> checkers.checkers.MsgCreateGameResponse + 5, // 6: checkers.checkers.Msg.PlayMove:output_type -> checkers.checkers.MsgPlayMoveResponse + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -2164,6 +3509,30 @@ func file_checkers_checkers_tx_proto_init() { return nil } } + file_checkers_checkers_tx_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgPlayMove); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_checkers_checkers_tx_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgPlayMoveResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2171,7 +3540,7 @@ func file_checkers_checkers_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_checkers_checkers_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 1, }, diff --git a/api/checkers/checkers/tx_grpc.pb.go b/api/checkers/checkers/tx_grpc.pb.go index 3848843..b1a6fcc 100644 --- a/api/checkers/checkers/tx_grpc.pb.go +++ b/api/checkers/checkers/tx_grpc.pb.go @@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7 const ( Msg_UpdateParams_FullMethodName = "/checkers.checkers.Msg/UpdateParams" Msg_CreateGame_FullMethodName = "/checkers.checkers.Msg/CreateGame" + Msg_PlayMove_FullMethodName = "/checkers.checkers.Msg/PlayMove" ) // MsgClient is the client API for Msg service. @@ -31,6 +32,7 @@ type MsgClient interface { // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) CreateGame(ctx context.Context, in *MsgCreateGame, opts ...grpc.CallOption) (*MsgCreateGameResponse, error) + PlayMove(ctx context.Context, in *MsgPlayMove, opts ...grpc.CallOption) (*MsgPlayMoveResponse, error) } type msgClient struct { @@ -59,6 +61,15 @@ func (c *msgClient) CreateGame(ctx context.Context, in *MsgCreateGame, opts ...g return out, nil } +func (c *msgClient) PlayMove(ctx context.Context, in *MsgPlayMove, opts ...grpc.CallOption) (*MsgPlayMoveResponse, error) { + out := new(MsgPlayMoveResponse) + err := c.cc.Invoke(ctx, Msg_PlayMove_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility @@ -67,6 +78,7 @@ type MsgServer interface { // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) CreateGame(context.Context, *MsgCreateGame) (*MsgCreateGameResponse, error) + PlayMove(context.Context, *MsgPlayMove) (*MsgPlayMoveResponse, error) mustEmbedUnimplementedMsgServer() } @@ -80,6 +92,9 @@ func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (* func (UnimplementedMsgServer) CreateGame(context.Context, *MsgCreateGame) (*MsgCreateGameResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateGame not implemented") } +func (UnimplementedMsgServer) PlayMove(context.Context, *MsgPlayMove) (*MsgPlayMoveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PlayMove not implemented") +} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -129,6 +144,24 @@ func _Msg_CreateGame_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Msg_PlayMove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPlayMove) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PlayMove(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_PlayMove_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PlayMove(ctx, req.(*MsgPlayMove)) + } + return interceptor(ctx, in, info, handler) +} + // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -144,6 +177,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "CreateGame", Handler: _Msg_CreateGame_Handler, }, + { + MethodName: "PlayMove", + Handler: _Msg_PlayMove_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "checkers/checkers/tx.proto", diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 2f1ec5b..40cfced 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -1 +1 @@ -{"id":"github.com/olimdzhon/checkers","consumes":["application/json"],"produces":["application/json"],"swagger":"2.0","info":{"description":"Chain github.com/olimdzhon/checkers REST API","title":"HTTP API Console","contact":{"name":"github.com/olimdzhon/checkers"},"version":"version not set"},"paths":{"/checkers.checkers.Msg/CreateGame":{"post":{"tags":["Msg"],"operationId":"GithubComolimdzhoncheckersMsg_CreateGame","parameters":[{"name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/checkers.checkers.MsgCreateGame"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.MsgCreateGameResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/checkers.checkers.Msg/UpdateParams":{"post":{"tags":["Msg"],"summary":"UpdateParams defines a (governance) operation for updating the module\nparameters. The authority defaults to the x/gov module account.","operationId":"GithubComolimdzhoncheckersMsg_UpdateParams","parameters":[{"description":"MsgUpdateParams is the Msg/UpdateParams request type.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/checkers.checkers.MsgUpdateParams"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.MsgUpdateParamsResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/params":{"get":{"tags":["Query"],"summary":"Parameters queries the parameters of the module.","operationId":"GithubComolimdzhoncheckersQuery_Params","responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryParamsResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/stored_game":{"get":{"tags":["Query"],"operationId":"GithubComolimdzhoncheckersQuery_StoredGameAll","parameters":[{"type":"string","format":"byte","description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","name":"pagination.key","in":"query"},{"type":"string","format":"uint64","description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","name":"pagination.offset","in":"query"},{"type":"string","format":"uint64","description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","name":"pagination.limit","in":"query"},{"type":"boolean","description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","name":"pagination.count_total","in":"query"},{"type":"boolean","description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","name":"pagination.reverse","in":"query"}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryAllStoredGameResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/stored_game/{index}":{"get":{"tags":["Query"],"summary":"Queries a list of StoredGame items.","operationId":"GithubComolimdzhoncheckersQuery_StoredGame","parameters":[{"type":"string","name":"index","in":"path","required":true}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryGetStoredGameResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/system_info":{"get":{"tags":["Query"],"summary":"Queries a SystemInfo by index.","operationId":"GithubComolimdzhoncheckersQuery_SystemInfo","responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryGetSystemInfoResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}}},"definitions":{"checkers.checkers.MsgCreateGame":{"type":"object","properties":{"black":{"type":"string"},"creator":{"type":"string"},"red":{"type":"string"}}},"checkers.checkers.MsgCreateGameResponse":{"type":"object","properties":{"gameIndex":{"type":"string"}}},"checkers.checkers.MsgUpdateParams":{"description":"MsgUpdateParams is the Msg/UpdateParams request type.","type":"object","properties":{"authority":{"description":"authority is the address that controls the module (defaults to x/gov unless overwritten).","type":"string"},"params":{"description":"NOTE: All parameters must be supplied.","$ref":"#/definitions/checkers.checkers.Params"}}},"checkers.checkers.MsgUpdateParamsResponse":{"description":"MsgUpdateParamsResponse defines the response structure for executing a\nMsgUpdateParams message.","type":"object"},"checkers.checkers.Params":{"description":"Params defines the parameters for the module.","type":"object"},"checkers.checkers.QueryAllStoredGameResponse":{"type":"object","properties":{"pagination":{"$ref":"#/definitions/cosmos.base.query.v1beta1.PageResponse"},"storedGame":{"type":"array","items":{"type":"object","$ref":"#/definitions/checkers.checkers.StoredGame"}}}},"checkers.checkers.QueryGetStoredGameResponse":{"type":"object","properties":{"storedGame":{"$ref":"#/definitions/checkers.checkers.StoredGame"}}},"checkers.checkers.QueryGetSystemInfoResponse":{"type":"object","properties":{"SystemInfo":{"$ref":"#/definitions/checkers.checkers.SystemInfo"}}},"checkers.checkers.QueryParamsResponse":{"description":"QueryParamsResponse is response type for the Query/Params RPC method.","type":"object","properties":{"params":{"description":"params holds all the parameters of this module.","$ref":"#/definitions/checkers.checkers.Params"}}},"checkers.checkers.StoredGame":{"type":"object","properties":{"black":{"type":"string"},"board":{"type":"string"},"index":{"type":"string"},"red":{"type":"string"},"turn":{"type":"string"}}},"checkers.checkers.SystemInfo":{"type":"object","properties":{"nextId":{"type":"string","format":"uint64"}}},"cosmos.base.query.v1beta1.PageRequest":{"description":"message SomeRequest {\n Foo some_parameter = 1;\n PageRequest pagination = 2;\n }","type":"object","title":"PageRequest is to be embedded in gRPC request messages for efficient\npagination. Ex:","properties":{"count_total":{"description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","type":"boolean"},"key":{"description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","type":"string","format":"byte"},"limit":{"description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","type":"string","format":"uint64"},"offset":{"description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","type":"string","format":"uint64"},"reverse":{"description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","type":"boolean"}}},"cosmos.base.query.v1beta1.PageResponse":{"description":"PageResponse is to be embedded in gRPC response messages where the\ncorresponding request message has used PageRequest.\n\n message SomeResponse {\n repeated Bar results = 1;\n PageResponse page = 2;\n }","type":"object","properties":{"next_key":{"description":"next_key is the key to be passed to PageRequest.key to\nquery the next page most efficiently. It will be empty if\nthere are no more results.","type":"string","format":"byte"},"total":{"type":"string","format":"uint64","title":"total is total number of results available if PageRequest.count_total\nwas set, its value is undefined otherwise"}}},"google.protobuf.Any":{"type":"object","properties":{"@type":{"type":"string"}},"additionalProperties":{}},"google.rpc.Status":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"details":{"type":"array","items":{"type":"object","$ref":"#/definitions/google.protobuf.Any"}},"message":{"type":"string"}}}},"tags":[{"name":"Query"},{"name":"Msg"}]} \ No newline at end of file +{"id":"github.com/olimdzhon/checkers","consumes":["application/json"],"produces":["application/json"],"swagger":"2.0","info":{"description":"Chain github.com/olimdzhon/checkers REST API","title":"HTTP API Console","contact":{"name":"github.com/olimdzhon/checkers"},"version":"version not set"},"paths":{"/checkers.checkers.Msg/CreateGame":{"post":{"tags":["Msg"],"operationId":"GithubComolimdzhoncheckersMsg_CreateGame","parameters":[{"name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/checkers.checkers.MsgCreateGame"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.MsgCreateGameResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/checkers.checkers.Msg/PlayMove":{"post":{"tags":["Msg"],"operationId":"GithubComolimdzhoncheckersMsg_PlayMove","parameters":[{"name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/checkers.checkers.MsgPlayMove"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.MsgPlayMoveResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/checkers.checkers.Msg/UpdateParams":{"post":{"tags":["Msg"],"summary":"UpdateParams defines a (governance) operation for updating the module\nparameters. The authority defaults to the x/gov module account.","operationId":"GithubComolimdzhoncheckersMsg_UpdateParams","parameters":[{"description":"MsgUpdateParams is the Msg/UpdateParams request type.","name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/checkers.checkers.MsgUpdateParams"}}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.MsgUpdateParamsResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/params":{"get":{"tags":["Query"],"summary":"Parameters queries the parameters of the module.","operationId":"GithubComolimdzhoncheckersQuery_Params","responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryParamsResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/stored_game":{"get":{"tags":["Query"],"operationId":"GithubComolimdzhoncheckersQuery_StoredGameAll","parameters":[{"type":"string","format":"byte","description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","name":"pagination.key","in":"query"},{"type":"string","format":"uint64","description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","name":"pagination.offset","in":"query"},{"type":"string","format":"uint64","description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","name":"pagination.limit","in":"query"},{"type":"boolean","description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","name":"pagination.count_total","in":"query"},{"type":"boolean","description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","name":"pagination.reverse","in":"query"}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryAllStoredGameResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/stored_game/{index}":{"get":{"tags":["Query"],"summary":"Queries a list of StoredGame items.","operationId":"GithubComolimdzhoncheckersQuery_StoredGame","parameters":[{"type":"string","name":"index","in":"path","required":true}],"responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryGetStoredGameResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}},"/olimdzhon/checkers/checkers/system_info":{"get":{"tags":["Query"],"summary":"Queries a SystemInfo by index.","operationId":"GithubComolimdzhoncheckersQuery_SystemInfo","responses":{"200":{"description":"A successful response.","schema":{"$ref":"#/definitions/checkers.checkers.QueryGetSystemInfoResponse"}},"default":{"description":"An unexpected error response.","schema":{"$ref":"#/definitions/google.rpc.Status"}}}}}},"definitions":{"checkers.checkers.MsgCreateGame":{"type":"object","properties":{"black":{"type":"string"},"creator":{"type":"string"},"red":{"type":"string"}}},"checkers.checkers.MsgCreateGameResponse":{"type":"object","properties":{"gameIndex":{"type":"string"}}},"checkers.checkers.MsgPlayMove":{"type":"object","properties":{"creator":{"type":"string"},"fromX":{"type":"string","format":"uint64"},"fromY":{"type":"string","format":"uint64"},"gameIndex":{"type":"string"},"toX":{"type":"string","format":"uint64"},"toY":{"type":"string","format":"uint64"}}},"checkers.checkers.MsgPlayMoveResponse":{"type":"object","properties":{"capturedX":{"type":"integer","format":"int32"},"capturedY":{"type":"integer","format":"int32"},"winner":{"type":"string"}}},"checkers.checkers.MsgUpdateParams":{"description":"MsgUpdateParams is the Msg/UpdateParams request type.","type":"object","properties":{"authority":{"description":"authority is the address that controls the module (defaults to x/gov unless overwritten).","type":"string"},"params":{"description":"NOTE: All parameters must be supplied.","$ref":"#/definitions/checkers.checkers.Params"}}},"checkers.checkers.MsgUpdateParamsResponse":{"description":"MsgUpdateParamsResponse defines the response structure for executing a\nMsgUpdateParams message.","type":"object"},"checkers.checkers.Params":{"description":"Params defines the parameters for the module.","type":"object"},"checkers.checkers.QueryAllStoredGameResponse":{"type":"object","properties":{"pagination":{"$ref":"#/definitions/cosmos.base.query.v1beta1.PageResponse"},"storedGame":{"type":"array","items":{"type":"object","$ref":"#/definitions/checkers.checkers.StoredGame"}}}},"checkers.checkers.QueryGetStoredGameResponse":{"type":"object","properties":{"storedGame":{"$ref":"#/definitions/checkers.checkers.StoredGame"}}},"checkers.checkers.QueryGetSystemInfoResponse":{"type":"object","properties":{"SystemInfo":{"$ref":"#/definitions/checkers.checkers.SystemInfo"}}},"checkers.checkers.QueryParamsResponse":{"description":"QueryParamsResponse is response type for the Query/Params RPC method.","type":"object","properties":{"params":{"description":"params holds all the parameters of this module.","$ref":"#/definitions/checkers.checkers.Params"}}},"checkers.checkers.StoredGame":{"type":"object","properties":{"black":{"type":"string"},"board":{"type":"string"},"index":{"type":"string"},"red":{"type":"string"},"turn":{"type":"string"}}},"checkers.checkers.SystemInfo":{"type":"object","properties":{"nextId":{"type":"string","format":"uint64"}}},"cosmos.base.query.v1beta1.PageRequest":{"description":"message SomeRequest {\n Foo some_parameter = 1;\n PageRequest pagination = 2;\n }","type":"object","title":"PageRequest is to be embedded in gRPC request messages for efficient\npagination. Ex:","properties":{"count_total":{"description":"count_total is set to true to indicate that the result set should include\na count of the total number of items available for pagination in UIs.\ncount_total is only respected when offset is used. It is ignored when key\nis set.","type":"boolean"},"key":{"description":"key is a value returned in PageResponse.next_key to begin\nquerying the next page most efficiently. Only one of offset or key\nshould be set.","type":"string","format":"byte"},"limit":{"description":"limit is the total number of results to be returned in the result page.\nIf left empty it will default to a value to be set by each app.","type":"string","format":"uint64"},"offset":{"description":"offset is a numeric offset that can be used when key is unavailable.\nIt is less efficient than using key. Only one of offset or key should\nbe set.","type":"string","format":"uint64"},"reverse":{"description":"reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43","type":"boolean"}}},"cosmos.base.query.v1beta1.PageResponse":{"description":"PageResponse is to be embedded in gRPC response messages where the\ncorresponding request message has used PageRequest.\n\n message SomeResponse {\n repeated Bar results = 1;\n PageResponse page = 2;\n }","type":"object","properties":{"next_key":{"description":"next_key is the key to be passed to PageRequest.key to\nquery the next page most efficiently. It will be empty if\nthere are no more results.","type":"string","format":"byte"},"total":{"type":"string","format":"uint64","title":"total is total number of results available if PageRequest.count_total\nwas set, its value is undefined otherwise"}}},"google.protobuf.Any":{"type":"object","properties":{"@type":{"type":"string"}},"additionalProperties":{}},"google.rpc.Status":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"details":{"type":"array","items":{"type":"object","$ref":"#/definitions/google.protobuf.Any"}},"message":{"type":"string"}}}},"tags":[{"name":"Query"},{"name":"Msg"}]} \ No newline at end of file diff --git a/proto/buf.lock b/proto/buf.lock index 11d2d2b..612a064 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -19,8 +19,8 @@ deps: - remote: buf.build owner: cosmos repository: ibc - commit: 7f7c07e11c014b1f848fa5728330e31d - digest: shake256:0d08fc2ad790a120d894f28ccd554d3060bfd602b61aa754614e3366f13da7cff7cb075ecfa7043e74609c054211472adddb37aa0d7f861334c35c0693b02f2e + commit: ef1dd1634b6c429bb2b52d983a683ce3 + digest: shake256:8325b0de8e8a2e027a8d33e0585a13273ce34b510cbedf7b785882a785baa62d42405ab2a836ea42fb1ddf098580f5cfc2414b1851dfcdd0b7c84851e96afeb9 - remote: buf.build owner: cosmos repository: ics23 @@ -29,8 +29,8 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 2bbd25900cb34c79bae97d85c948d3cf - digest: shake256:a6446e23f4408160217c22738a0c8c370ff3ff966f601d678960b803829cf53b5cf5998d20fcb3f9c9be944b24337843e7beb6e681ddbf9d036fb6491c0e47e7 + commit: 8bc2c51e08c447cd8886cdea48a73e14 + digest: shake256:a969155953a5cedc5b2df5b42c368f2bc66ff8ce1804bc96e0f14ff2ee8a893687963058909df844d1643cdbc98ff099d2daa6bc9f9f5b8886c49afdc60e19af - remote: buf.build owner: protocolbuffers repository: wellknowntypes diff --git a/proto/checkers/checkers/tx.proto b/proto/checkers/checkers/tx.proto index a25a8e2..38f441e 100644 --- a/proto/checkers/checkers/tx.proto +++ b/proto/checkers/checkers/tx.proto @@ -18,6 +18,7 @@ service Msg { // parameters. The authority defaults to the x/gov module account. rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); rpc CreateGame (MsgCreateGame ) returns (MsgCreateGameResponse ); + rpc PlayMove (MsgPlayMove ) returns (MsgPlayMoveResponse ); } // MsgUpdateParams is the Msg/UpdateParams request type. message MsgUpdateParams { @@ -48,3 +49,19 @@ message MsgCreateGameResponse { string gameIndex = 1; } +message MsgPlayMove { + option (cosmos.msg.v1.signer) = "creator"; + string creator = 1; + string gameIndex = 2; + uint64 fromX = 3; + uint64 fromY = 4; + uint64 toX = 5; + uint64 toY = 6; +} + +message MsgPlayMoveResponse { + int32 capturedX = 1; + int32 capturedY = 2; + string winner = 3; +} + diff --git a/x/checkers/keeper/common_test.go b/x/checkers/keeper/common_test.go index 599cdc6..b0e25bf 100644 --- a/x/checkers/keeper/common_test.go +++ b/x/checkers/keeper/common_test.go @@ -3,7 +3,7 @@ package keeper_test import "github.com/olimdzhon/checkers/x/checkers/testutil" const ( - alice = testutil.Alice - bob = testutil.Bob - carol = testutil.Carol -) \ No newline at end of file + alice = testutil.Alice + bob = testutil.Bob + carol = testutil.Carol +) diff --git a/x/checkers/keeper/msg_server_create_game.go b/x/checkers/keeper/msg_server_create_game.go index 2cd2fca..8acd4ce 100644 --- a/x/checkers/keeper/msg_server_create_game.go +++ b/x/checkers/keeper/msg_server_create_game.go @@ -36,10 +36,7 @@ func (k msgServer) CreateGame(goCtx context.Context, msg *types.MsgCreateGame) ( systemInfo.NextId++ k.Keeper.SetSystemInfo(ctx, systemInfo) - - - return &types.MsgCreateGameResponse{ GameIndex: newIndex, - }, nil + }, nil } diff --git a/x/checkers/keeper/msg_server_create_game_test.go b/x/checkers/keeper/msg_server_create_game_test.go index 30a004c..2271114 100644 --- a/x/checkers/keeper/msg_server_create_game_test.go +++ b/x/checkers/keeper/msg_server_create_game_test.go @@ -14,42 +14,42 @@ import ( func setupMsgServerCreateGame(t testing.TB) (types.MsgServer, keeper.Keeper, context.Context) { k, ctx := keepertest.CheckersKeeper(t) - checkers.InitGenesis(ctx, k, *types.DefaultGenesis()) - return keeper.NewMsgServerImpl(k), k , sdk.WrapSDKContext(ctx) + checkers.InitGenesis(ctx, k, *types.DefaultGenesis()) + return keeper.NewMsgServerImpl(k), k, sdk.WrapSDKContext(ctx) } func TestCreateGame(t *testing.T) { - msgServer, _, context := setupMsgServerCreateGame(t) - createResponse, err := msgServer.CreateGame(context, &types.MsgCreateGame{ - Creator: alice, - Black: bob, - Red: carol, - }) - require.Nil(t, err) - require.EqualValues(t, types.MsgCreateGameResponse{ - GameIndex: "1", // TODO: update with a proper value when updated - }, *createResponse) + msgServer, _, context := setupMsgServerCreateGame(t) + createResponse, err := msgServer.CreateGame(context, &types.MsgCreateGame{ + Creator: alice, + Black: bob, + Red: carol, + }) + require.Nil(t, err) + require.EqualValues(t, types.MsgCreateGameResponse{ + GameIndex: "1", // TODO: update with a proper value when updated + }, *createResponse) } func TestCreate1GameHasSaved(t *testing.T) { - msgSrvr, keeper, context := setupMsgServerCreateGame(t) - msgSrvr.CreateGame(context, &types.MsgCreateGame{ - Creator: alice, - Black: bob, - Red: carol, - }) - systemInfo, found := keeper.GetSystemInfo(sdk.UnwrapSDKContext(context)) - require.True(t, found) - require.EqualValues(t, types.SystemInfo{ - NextId: 2, - }, systemInfo) - game1, found1 := keeper.GetStoredGame(sdk.UnwrapSDKContext(context), "1") - require.True(t, found1) - require.EqualValues(t, types.StoredGame{ - Index: "1", - Board: "*b*b*b*b|b*b*b*b*|*b*b*b*b|********|********|r*r*r*r*|*r*r*r*r|r*r*r*r*", - Turn: "b", - Black: bob, - Red: carol, - }, game1) + msgSrvr, keeper, context := setupMsgServerCreateGame(t) + msgSrvr.CreateGame(context, &types.MsgCreateGame{ + Creator: alice, + Black: bob, + Red: carol, + }) + systemInfo, found := keeper.GetSystemInfo(sdk.UnwrapSDKContext(context)) + require.True(t, found) + require.EqualValues(t, types.SystemInfo{ + NextId: 2, + }, systemInfo) + game1, found1 := keeper.GetStoredGame(sdk.UnwrapSDKContext(context), "1") + require.True(t, found1) + require.EqualValues(t, types.StoredGame{ + Index: "1", + Board: "*b*b*b*b|b*b*b*b*|*b*b*b*b|********|********|r*r*r*r*|*r*r*r*r|r*r*r*r*", + Turn: "b", + Black: bob, + Red: carol, + }, game1) } diff --git a/x/checkers/keeper/msg_server_play_move.go b/x/checkers/keeper/msg_server_play_move.go new file mode 100644 index 0000000..757bc32 --- /dev/null +++ b/x/checkers/keeper/msg_server_play_move.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/olimdzhon/checkers/x/checkers/rules" + "github.com/olimdzhon/checkers/x/checkers/types" +) + +func (k msgServer) PlayMove(goCtx context.Context, msg *types.MsgPlayMove) (*types.MsgPlayMoveResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + storedGame, found := k.Keeper.GetStoredGame(ctx, msg.GameIndex) + if !found { + return nil, errorsmod.Wrapf(types.ErrGameNotFound, "%s", msg.GameIndex) + } + + isBlack := storedGame.Black == msg.Creator + isRed := storedGame.Red == msg.Creator + var player rules.Player + if !isBlack && !isRed { + return nil, errorsmod.Wrapf(types.ErrCreatorNotPlayer, "%s", msg.Creator) + } else if isBlack && isRed { + player = rules.StringPieces[storedGame.Turn].Player + } else if isBlack { + player = rules.BLACK_PLAYER + } else { + player = rules.RED_PLAYER + } + + game, err := storedGame.ParseGame() + if err != nil { + panic(err.Error()) + } + + if !game.TurnIs(player) { + return nil, errorsmod.Wrapf(types.ErrNotPlayerTurn, "%s", player) + } + + captured, moveErr := game.Move( + rules.Pos{ + X: int(msg.FromX), + Y: int(msg.FromY), + }, + rules.Pos{ + X: int(msg.ToX), + Y: int(msg.ToY), + }, + ) + if moveErr != nil { + return nil, errorsmod.Wrapf(types.ErrWrongMove, moveErr.Error()) + } + + storedGame.Board = game.String() + storedGame.Turn = rules.PieceStrings[game.Turn] + k.Keeper.SetStoredGame(ctx, storedGame) + + return &types.MsgPlayMoveResponse{ + CapturedX: int32(captured.X), + CapturedY: int32(captured.Y), + Winner: rules.PieceStrings[game.Winner()], + }, nil +} diff --git a/x/checkers/keeper/msg_server_play_move_test.go b/x/checkers/keeper/msg_server_play_move_test.go new file mode 100644 index 0000000..d03b4d1 --- /dev/null +++ b/x/checkers/keeper/msg_server_play_move_test.go @@ -0,0 +1,272 @@ +package keeper_test + +import ( + "context" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/olimdzhon/checkers/testutil/keeper" + "github.com/olimdzhon/checkers/x/checkers/keeper" + checkers "github.com/olimdzhon/checkers/x/checkers/module" + "github.com/olimdzhon/checkers/x/checkers/types" + "github.com/stretchr/testify/require" +) + +func setupMsgServerWithOneGameForPlayMove(t testing.TB) (types.MsgServer, keeper.Keeper, context.Context) { + k, ctx := keepertest.CheckersKeeper(t) + checkers.InitGenesis(ctx, k, *types.DefaultGenesis()) + server := keeper.NewMsgServerImpl(k) + context := sdk.WrapSDKContext(ctx) + server.CreateGame(context, &types.MsgCreateGame{ + Creator: alice, + Black: bob, + Red: carol, + }) + return server, k, context +} + +func TestPlayMove(t *testing.T) { + msgServer, _, context := setupMsgServerWithOneGameForPlayMove(t) + playMoveResponse, err := msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) + require.Nil(t, err) + require.EqualValues(t, types.MsgPlayMoveResponse{ + CapturedX: -1, + CapturedY: -1, + Winner: "*", + }, *playMoveResponse) +} + +func TestPlayMoveSavedGame(t *testing.T) { + msgServer, keeper, context := setupMsgServerWithOneGameForPlayMove(t) + ctx := sdk.UnwrapSDKContext(context) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) + systemInfo, found := keeper.GetSystemInfo(ctx) + require.True(t, found) + require.EqualValues(t, types.SystemInfo{ + NextId: 2, + }, systemInfo) + game1, found := keeper.GetStoredGame(ctx, "1") + require.True(t, found) + require.EqualValues(t, types.StoredGame{ + Index: "1", + Board: "*b*b*b*b|b*b*b*b*|***b*b*b|**b*****|********|r*r*r*r*|*r*r*r*r|r*r*r*r*", + Turn: "r", + Black: bob, + Red: carol, + }, game1) +} + +func TestPlayMoveNotPlayer(t *testing.T) { + msgServer, _, context := setupMsgServerWithOneGameForPlayMove(t) + playMoveResponse, err := msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: alice, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) + require.Nil(t, playMoveResponse) + require.Equal(t, alice+": message creator is not a player", err.Error()) +} + +func TestPlayMoveCannotParseGame(t *testing.T) { + msgServer, k, context := setupMsgServerWithOneGameForPlayMove(t) + ctx := sdk.UnwrapSDKContext(context) + storedGame, _ := k.GetStoredGame(ctx, "1") + storedGame.Board = "not a board" + k.SetStoredGame(ctx, storedGame) + defer func() { + r := recover() + require.NotNil(t, r, "The code did not panic") + require.Equal(t, r, "game cannot be parsed: invalid board string: not a board") + }() + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) +} + +func TestPlayMoveWrongOutOfTurn(t *testing.T) { + msgServer, _, context := setupMsgServerWithOneGameForPlayMove(t) + playMoveResponse, err := msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: carol, + GameIndex: "1", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }) + require.Nil(t, playMoveResponse) + require.Equal(t, "{red}: player tried to play out of turn", err.Error()) +} + +func TestPlayMoveWrongPieceAtDestination(t *testing.T) { + msgServer, _, context := setupMsgServerWithOneGameForPlayMove(t) + playMoveResponse, err := msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 0, + ToX: 0, + ToY: 1, + }) + require.Nil(t, playMoveResponse) + require.Equal(t, "Already piece at destination position: {0 1}: wrong move", err.Error()) +} + +func TestPlayMove2(t *testing.T) { + msgServer, _, context := setupMsgServerWithOneGameForPlayMove(t) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) + playMoveResponse, err := msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: carol, + GameIndex: "1", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }) + require.Nil(t, err) + require.EqualValues(t, types.MsgPlayMoveResponse{ + CapturedX: -1, + CapturedY: -1, + Winner: "*", + }, *playMoveResponse) +} + +func TestPlayMove2SavedGame(t *testing.T) { + msgServer, keeper, context := setupMsgServerWithOneGameForPlayMove(t) + ctx := sdk.UnwrapSDKContext(context) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: carol, + GameIndex: "1", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }) + systemInfo, found := keeper.GetSystemInfo(ctx) + require.True(t, found) + require.EqualValues(t, types.SystemInfo{ + NextId: 2, + }, systemInfo) + game1, found := keeper.GetStoredGame(ctx, "1") + require.True(t, found) + require.EqualValues(t, types.StoredGame{ + Index: "1", + Board: "*b*b*b*b|b*b*b*b*|***b*b*b|**b*****|*r******|**r*r*r*|*r*r*r*r|r*r*r*r*", + Turn: "b", + Black: bob, + Red: carol, + }, game1) +} + +func TestPlayMove3(t *testing.T) { + msgServer, _, context := setupMsgServerWithOneGameForPlayMove(t) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: carol, + GameIndex: "1", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }) + playMoveResponse, err := msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 2, + FromY: 3, + ToX: 0, + ToY: 5, + }) + require.Nil(t, err) + require.EqualValues(t, types.MsgPlayMoveResponse{ + CapturedX: 1, + CapturedY: 4, + Winner: "*", + }, *playMoveResponse) +} + +func TestPlayMove3SavedGame(t *testing.T) { + msgServer, keeper, context := setupMsgServerWithOneGameForPlayMove(t) + ctx := sdk.UnwrapSDKContext(context) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 1, + FromY: 2, + ToX: 2, + ToY: 3, + }) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: carol, + GameIndex: "1", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }) + msgServer.PlayMove(context, &types.MsgPlayMove{ + Creator: bob, + GameIndex: "1", + FromX: 2, + FromY: 3, + ToX: 0, + ToY: 5, + }) + systemInfo, found := keeper.GetSystemInfo(ctx) + require.True(t, found) + require.EqualValues(t, types.SystemInfo{ + NextId: 2, + }, systemInfo) + game1, found := keeper.GetStoredGame(ctx, "1") + require.True(t, found) + require.EqualValues(t, types.StoredGame{ + Index: "1", + Board: "*b*b*b*b|b*b*b*b*|***b*b*b|********|********|b*r*r*r*|*r*r*r*r|r*r*r*r*", + Turn: "r", + Black: bob, + Red: carol, + }, game1) +} \ No newline at end of file diff --git a/x/checkers/module/autocli.go b/x/checkers/module/autocli.go index 575f717..2f3910f 100644 --- a/x/checkers/module/autocli.go +++ b/x/checkers/module/autocli.go @@ -50,6 +50,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Short: "Send a createGame tx", PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "black"}, {ProtoField: "red"}}, }, + { + RpcMethod: "PlayMove", + Use: "play-move [game-index] [from-x] [from-y] [to-x] [to-y]", + Short: "Send a playMove tx", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "gameIndex"}, {ProtoField: "fromX"}, {ProtoField: "fromY"}, {ProtoField: "toX"}, {ProtoField: "toY"}}, + }, // this line is used by ignite scaffolding # autocli/tx }, }, diff --git a/x/checkers/module/simulation.go b/x/checkers/module/simulation.go index a681c16..6cdb34e 100644 --- a/x/checkers/module/simulation.go +++ b/x/checkers/module/simulation.go @@ -27,6 +27,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgCreateGame int = 100 + opWeightMsgPlayMove = "op_weight_msg_play_move" + // TODO: Determine the simulation weight value + defaultWeightMsgPlayMove int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -61,6 +65,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp checkerssimulation.SimulateMsgCreateGame(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgPlayMove int + simState.AppParams.GetOrGenerate(opWeightMsgPlayMove, &weightMsgPlayMove, nil, + func(_ *rand.Rand) { + weightMsgPlayMove = defaultWeightMsgPlayMove + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgPlayMove, + checkerssimulation.SimulateMsgPlayMove(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations @@ -77,6 +92,14 @@ func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Wei return nil }, ), + simulation.NewWeightedProposalMsg( + opWeightMsgPlayMove, + defaultWeightMsgPlayMove, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + checkerssimulation.SimulateMsgPlayMove(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/checkers/simulation/play_move.go b/x/checkers/simulation/play_move.go new file mode 100644 index 0000000..cffcc1b --- /dev/null +++ b/x/checkers/simulation/play_move.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/olimdzhon/checkers/x/checkers/keeper" + "github.com/olimdzhon/checkers/x/checkers/types" +) + +func SimulateMsgPlayMove( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgPlayMove{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the PlayMove simulation + + return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "PlayMove simulation not implemented"), nil, nil + } +} diff --git a/x/checkers/testutil/constants.go b/x/checkers/testutil/constants.go index 80416ed..ff4377f 100644 --- a/x/checkers/testutil/constants.go +++ b/x/checkers/testutil/constants.go @@ -1,7 +1,7 @@ package testutil const ( - Alice = "cosmos1jmjfq0tplp9tmx4v9uemw72y4d2wa5nr3xn9d3" - Bob = "cosmos1xyxs3skf3f4jfqeuv89yyaqvjc6lffavxqhc8g" - Carol = "cosmos1e0w5t53nrq7p66fye6c8p0ynyhf6y24l4yuxd7" -) \ No newline at end of file + Alice = "cosmos1jmjfq0tplp9tmx4v9uemw72y4d2wa5nr3xn9d3" + Bob = "cosmos1xyxs3skf3f4jfqeuv89yyaqvjc6lffavxqhc8g" + Carol = "cosmos1e0w5t53nrq7p66fye6c8p0ynyhf6y24l4yuxd7" +) diff --git a/x/checkers/types/codec.go b/x/checkers/types/codec.go index dd02f09..7942654 100644 --- a/x/checkers/types/codec.go +++ b/x/checkers/types/codec.go @@ -9,13 +9,16 @@ import ( ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgCreateGame{}, "checkers/CreateGame", nil) + cdc.RegisterConcrete(&MsgCreateGame{}, "checkers/CreateGame", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateGame{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgPlayMove{}, + ) // this line is used by starport scaffolding # 3 registry.RegisterImplementations((*sdk.Msg)(nil), diff --git a/x/checkers/types/errors.go b/x/checkers/types/errors.go index 8f70000..0b32049 100644 --- a/x/checkers/types/errors.go +++ b/x/checkers/types/errors.go @@ -13,4 +13,12 @@ var ( ErrInvalidBlack = sdkerrors.Register(ModuleName, 1102, "black address is invalid: %s") ErrInvalidRed = sdkerrors.Register(ModuleName, 1103, "red address is invalid: %s") ErrGameNotParseable = sdkerrors.Register(ModuleName, 1104, "game cannot be parsed") + ErrInvalidGameIndex = sdkerrors.Register(ModuleName, 1105, "game index is invalid") + ErrInvalidPositionIndex = sdkerrors.Register(ModuleName, 1106, "position index is invalid") + ErrMoveAbsent = sdkerrors.Register(ModuleName, 1107, "there is no move") + ErrGameNotFound = sdkerrors.Register(ModuleName, 1108, "game by id not found") + ErrCreatorNotPlayer = sdkerrors.Register(ModuleName, 1109, "message creator is not a player") + ErrNotPlayerTurn = sdkerrors.Register(ModuleName, 1110, "player tried to play out of turn") + ErrWrongMove = sdkerrors.Register(ModuleName, 1111, "wrong move") + ) diff --git a/x/checkers/types/full_game.go b/x/checkers/types/full_game.go index cccb3a3..6b3de27 100644 --- a/x/checkers/types/full_game.go +++ b/x/checkers/types/full_game.go @@ -32,14 +32,14 @@ func (storedGame StoredGame) ParseGame() (game *rules.Game, err error) { } func (storedGame StoredGame) Validate() (err error) { - _, err = storedGame.GetBlackAddress() - if err != nil { - return err - } - _, err = storedGame.GetRedAddress() - if err != nil { - return err - } - _, err = storedGame.ParseGame() - return err -} \ No newline at end of file + _, err = storedGame.GetBlackAddress() + if err != nil { + return err + } + _, err = storedGame.GetRedAddress() + if err != nil { + return err + } + _, err = storedGame.ParseGame() + return err +} diff --git a/x/checkers/types/full_game_test.go b/x/checkers/types/full_game_test.go index c9d4e63..559b72d 100644 --- a/x/checkers/types/full_game_test.go +++ b/x/checkers/types/full_game_test.go @@ -11,43 +11,43 @@ import ( ) const ( - alice = testutil.Alice - bob = testutil.Bob + alice = testutil.Alice + bob = testutil.Bob ) func GetStoredGame1() types.StoredGame { - return types.StoredGame{ - Black: alice, - Red: bob, - Index: "1", - Board: rules.New().String(), - Turn: "b", - } + return types.StoredGame{ + Black: alice, + Red: bob, + Index: "1", + Board: rules.New().String(), + Turn: "b", + } } func TestCanGetAddressBlack(t *testing.T) { - aliceAddress, err1 := sdk.AccAddressFromBech32(alice) - black, err2 := GetStoredGame1().GetBlackAddress() - require.Equal(t, aliceAddress, black) - require.Nil(t, err2) - require.Nil(t, err1) + aliceAddress, err1 := sdk.AccAddressFromBech32(alice) + black, err2 := GetStoredGame1().GetBlackAddress() + require.Equal(t, aliceAddress, black) + require.Nil(t, err2) + require.Nil(t, err1) } func TestGetAddressWrongBlack(t *testing.T) { - storedGame := GetStoredGame1() - storedGame.Black = "cosmos1jmjfq0tplp9tmx4v9uemw72y4d2wa5nr3xn9d4" // Bad last digit - black, err := storedGame.GetBlackAddress() - require.Nil(t, black) - require.EqualError(t, - err, - "black address is invalid: cosmos1jmjfq0tplp9tmx4v9uemw72y4d2wa5nr3xn9d4: decoding bech32 failed: invalid checksum (expected 3xn9d3 got 3xn9d4)") - require.EqualError(t, storedGame.Validate(), err.Error()) + storedGame := GetStoredGame1() + storedGame.Black = "cosmos1jmjfq0tplp9tmx4v9uemw72y4d2wa5nr3xn9d4" // Bad last digit + black, err := storedGame.GetBlackAddress() + require.Nil(t, black) + require.EqualError(t, + err, + "black address is invalid: cosmos1jmjfq0tplp9tmx4v9uemw72y4d2wa5nr3xn9d4: decoding bech32 failed: invalid checksum (expected 3xn9d3 got 3xn9d4)") + require.EqualError(t, storedGame.Validate(), err.Error()) } func TestCanGetAddressRed(t *testing.T) { - bobAddress, err1 := sdk.AccAddressFromBech32(alice) - red, err2 := GetStoredGame1().GetBlackAddress() - require.Equal(t, bobAddress, red) - require.Nil(t, err2) - require.Nil(t, err1) -} \ No newline at end of file + bobAddress, err1 := sdk.AccAddressFromBech32(alice) + red, err2 := GetStoredGame1().GetBlackAddress() + require.Equal(t, bobAddress, red) + require.Nil(t, err2) + require.Nil(t, err1) +} diff --git a/x/checkers/types/message_create_game.go b/x/checkers/types/message_create_game.go index 4f3f865..0197617 100644 --- a/x/checkers/types/message_create_game.go +++ b/x/checkers/types/message_create_game.go @@ -22,20 +22,20 @@ func (msg *MsgCreateGame) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } _, err = sdk.AccAddressFromBech32(msg.Black) - if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid black address (%s)", err) - } - _, err = sdk.AccAddressFromBech32(msg.Red) - if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid red address (%s)", err) - } + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid black address (%s)", err) + } + _, err = sdk.AccAddressFromBech32(msg.Red) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid red address (%s)", err) + } return nil } func (msg *MsgCreateGame) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} \ No newline at end of file + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} diff --git a/x/checkers/types/message_create_game_test.go b/x/checkers/types/message_create_game_test.go index 4b766ce..89d77e7 100644 --- a/x/checkers/types/message_create_game_test.go +++ b/x/checkers/types/message_create_game_test.go @@ -19,35 +19,35 @@ func TestMsgCreateGame_ValidateBasic(t *testing.T) { name: "invalid creator address", msg: types.MsgCreateGame{ Creator: "invalid_address", - Black: sample.AccAddress(), - Red: sample.AccAddress(), + Black: sample.AccAddress(), + Red: sample.AccAddress(), }, err: sdkerrors.ErrInvalidAddress, - }, + }, { name: "invalid black address", msg: types.MsgCreateGame{ Creator: sample.AccAddress(), - Black: "invalid_address", - Red: sample.AccAddress(), + Black: "invalid_address", + Red: sample.AccAddress(), }, err: sdkerrors.ErrInvalidAddress, - }, + }, { name: "invalid red address", msg: types.MsgCreateGame{ Creator: sample.AccAddress(), - Black: sample.AccAddress(), - Red: "invalid_address", + Black: sample.AccAddress(), + Red: "invalid_address", }, err: sdkerrors.ErrInvalidAddress, - }, + }, { name: "valid address", msg: types.MsgCreateGame{ Creator: sample.AccAddress(), - Black: sample.AccAddress(), - Red: sample.AccAddress(), + Black: sample.AccAddress(), + Red: sample.AccAddress(), }, }, } diff --git a/x/checkers/types/message_play_move.go b/x/checkers/types/message_play_move.go new file mode 100644 index 0000000..03e6c3a --- /dev/null +++ b/x/checkers/types/message_play_move.go @@ -0,0 +1,67 @@ +package types + +import ( + "strconv" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/olimdzhon/checkers/x/checkers/rules" +) + +var _ sdk.Msg = &MsgPlayMove{} + +func NewMsgPlayMove(creator string, gameIndex string, fromX uint64, fromY uint64, toX uint64, toY uint64) *MsgPlayMove { + return &MsgPlayMove{ + Creator: creator, + GameIndex: gameIndex, + FromX: fromX, + FromY: fromY, + ToX: toX, + ToY: toY, + } +} + +func (msg *MsgPlayMove) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + gameIndex, err := strconv.ParseInt(msg.GameIndex, 10, 64) + if err != nil { + return errorsmod.Wrapf(ErrInvalidGameIndex, "not parseable (%s)", err) + } + if uint64(gameIndex) < DefaultIndex { + return errorsmod.Wrapf(ErrInvalidGameIndex, "number too low (%d)", gameIndex) + } + boardChecks := []struct { + value uint64 + err string + }{ + { + value: msg.FromX, + err: "fromX out of range (%d)", + }, + { + value: msg.ToX, + err: "toX out of range (%d)", + }, + { + value: msg.FromY, + err: "fromY out of range (%d)", + }, + { + value: msg.ToY, + err: "toY out of range (%d)", + }, + } + for _, situation := range boardChecks { + if situation.value < 0 || rules.BOARD_DIM <= situation.value { + return errorsmod.Wrapf(ErrInvalidPositionIndex, situation.err, situation.value) + } + } + if msg.FromX == msg.ToX && msg.FromY == msg.ToY { + return errorsmod.Wrapf(ErrMoveAbsent, "x (%d) and y (%d)", msg.FromX, msg.FromY) + } + return nil +} diff --git a/x/checkers/types/message_play_move_test.go b/x/checkers/types/message_play_move_test.go new file mode 100644 index 0000000..01ff1fa --- /dev/null +++ b/x/checkers/types/message_play_move_test.go @@ -0,0 +1,137 @@ +package types_test + +import ( + "testing" + + "github.com/olimdzhon/checkers/x/checkers/rules" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/olimdzhon/checkers/testutil/sample" + "github.com/olimdzhon/checkers/x/checkers/types" + "github.com/stretchr/testify/require" +) + +func TestMsgPlayMove_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgPlayMove + err error + }{ + { + name: "invalid address", + msg: types.MsgPlayMove{ + Creator: "invalid_address", + GameIndex: "5", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid game index", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "invalid_index", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }, + err: types.ErrInvalidGameIndex, + }, + { + name: "invalid fromX too high", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "5", + FromX: rules.BOARD_DIM, + FromY: 5, + ToX: 1, + ToY: 4, + }, + err: types.ErrInvalidPositionIndex, + }, + { + name: "invalid fromX too high", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "5", + FromX: rules.BOARD_DIM, + FromY: 5, + ToX: 1, + ToY: 4, + }, + err: types.ErrInvalidPositionIndex, + }, + { + name: "invalid fromY too high", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "5", + FromX: 0, + FromY: rules.BOARD_DIM, + ToX: 1, + ToY: 4, + }, + err: types.ErrInvalidPositionIndex, + }, + { + name: "invalid toX too high", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "5", + FromX: 0, + FromY: 5, + ToX: rules.BOARD_DIM, + ToY: 4, + }, + err: types.ErrInvalidPositionIndex, + }, + { + name: "invalid toY too high", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "5", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: rules.BOARD_DIM, + }, + err: types.ErrInvalidPositionIndex, + }, + { + name: "invalid no move", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "5", + FromX: 0, + FromY: 5, + ToX: 0, + ToY: 5, + }, + err: types.ErrMoveAbsent, + }, + { + name: "valid address", + msg: types.MsgPlayMove{ + Creator: sample.AccAddress(), + GameIndex: "5", + FromX: 0, + FromY: 5, + ToX: 1, + ToY: 4, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/checkers/types/tx.pb.go b/x/checkers/types/tx.pb.go index 2b9a0ca..71fb7e5 100644 --- a/x/checkers/types/tx.pb.go +++ b/x/checkers/types/tx.pb.go @@ -228,45 +228,199 @@ func (m *MsgCreateGameResponse) GetGameIndex() string { return "" } +type MsgPlayMove struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + GameIndex string `protobuf:"bytes,2,opt,name=gameIndex,proto3" json:"gameIndex,omitempty"` + FromX uint64 `protobuf:"varint,3,opt,name=fromX,proto3" json:"fromX,omitempty"` + FromY uint64 `protobuf:"varint,4,opt,name=fromY,proto3" json:"fromY,omitempty"` + ToX uint64 `protobuf:"varint,5,opt,name=toX,proto3" json:"toX,omitempty"` + ToY uint64 `protobuf:"varint,6,opt,name=toY,proto3" json:"toY,omitempty"` +} + +func (m *MsgPlayMove) Reset() { *m = MsgPlayMove{} } +func (m *MsgPlayMove) String() string { return proto.CompactTextString(m) } +func (*MsgPlayMove) ProtoMessage() {} +func (*MsgPlayMove) Descriptor() ([]byte, []int) { + return fileDescriptor_57a76c3b6063f66f, []int{4} +} +func (m *MsgPlayMove) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlayMove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlayMove.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPlayMove) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlayMove.Merge(m, src) +} +func (m *MsgPlayMove) XXX_Size() int { + return m.Size() +} +func (m *MsgPlayMove) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlayMove.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlayMove proto.InternalMessageInfo + +func (m *MsgPlayMove) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgPlayMove) GetGameIndex() string { + if m != nil { + return m.GameIndex + } + return "" +} + +func (m *MsgPlayMove) GetFromX() uint64 { + if m != nil { + return m.FromX + } + return 0 +} + +func (m *MsgPlayMove) GetFromY() uint64 { + if m != nil { + return m.FromY + } + return 0 +} + +func (m *MsgPlayMove) GetToX() uint64 { + if m != nil { + return m.ToX + } + return 0 +} + +func (m *MsgPlayMove) GetToY() uint64 { + if m != nil { + return m.ToY + } + return 0 +} + +type MsgPlayMoveResponse struct { + CapturedX int32 `protobuf:"varint,1,opt,name=capturedX,proto3" json:"capturedX,omitempty"` + CapturedY int32 `protobuf:"varint,2,opt,name=capturedY,proto3" json:"capturedY,omitempty"` + Winner string `protobuf:"bytes,3,opt,name=winner,proto3" json:"winner,omitempty"` +} + +func (m *MsgPlayMoveResponse) Reset() { *m = MsgPlayMoveResponse{} } +func (m *MsgPlayMoveResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPlayMoveResponse) ProtoMessage() {} +func (*MsgPlayMoveResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_57a76c3b6063f66f, []int{5} +} +func (m *MsgPlayMoveResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlayMoveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlayMoveResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPlayMoveResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlayMoveResponse.Merge(m, src) +} +func (m *MsgPlayMoveResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPlayMoveResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlayMoveResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlayMoveResponse proto.InternalMessageInfo + +func (m *MsgPlayMoveResponse) GetCapturedX() int32 { + if m != nil { + return m.CapturedX + } + return 0 +} + +func (m *MsgPlayMoveResponse) GetCapturedY() int32 { + if m != nil { + return m.CapturedY + } + return 0 +} + +func (m *MsgPlayMoveResponse) GetWinner() string { + if m != nil { + return m.Winner + } + return "" +} + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "checkers.checkers.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "checkers.checkers.MsgUpdateParamsResponse") proto.RegisterType((*MsgCreateGame)(nil), "checkers.checkers.MsgCreateGame") proto.RegisterType((*MsgCreateGameResponse)(nil), "checkers.checkers.MsgCreateGameResponse") + proto.RegisterType((*MsgPlayMove)(nil), "checkers.checkers.MsgPlayMove") + proto.RegisterType((*MsgPlayMoveResponse)(nil), "checkers.checkers.MsgPlayMoveResponse") } func init() { proto.RegisterFile("checkers/checkers/tx.proto", fileDescriptor_57a76c3b6063f66f) } var fileDescriptor_57a76c3b6063f66f = []byte{ - // 447 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xce, 0x48, 0x4d, - 0xce, 0x4e, 0x2d, 0x2a, 0xd6, 0x87, 0x33, 0x4a, 0x2a, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, - 0x04, 0x61, 0x42, 0x7a, 0x30, 0x86, 0x94, 0x60, 0x62, 0x6e, 0x66, 0x5e, 0xbe, 0x3e, 0x98, 0x84, - 0xa8, 0x92, 0x12, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0xcf, 0x2d, 0x4e, 0xd7, 0x2f, 0x33, - 0x04, 0x51, 0x50, 0x09, 0x49, 0x88, 0x44, 0x3c, 0x98, 0xa7, 0x0f, 0xe1, 0x40, 0xa5, 0x44, 0xd2, - 0xf3, 0xd3, 0xf3, 0x21, 0xe2, 0x20, 0x16, 0x54, 0x54, 0x0e, 0xd3, 0x2d, 0x05, 0x89, 0x45, 0x89, - 0xb9, 0x50, 0x5d, 0x4a, 0xfb, 0x19, 0xb9, 0xf8, 0x7d, 0x8b, 0xd3, 0x43, 0x0b, 0x52, 0x12, 0x4b, - 0x52, 0x03, 0xc0, 0x32, 0x42, 0x66, 0x5c, 0x9c, 0x89, 0xa5, 0x25, 0x19, 0xf9, 0x45, 0x99, 0x25, - 0x95, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x12, 0x97, 0xb6, 0xe8, 0x8a, 0x40, 0xad, 0x73, - 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x0e, 0x2e, 0x29, 0xca, 0xcc, 0x4b, 0x0f, 0x42, 0x28, 0x15, - 0xb2, 0xe1, 0x62, 0x83, 0x98, 0x2d, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa9, 0x87, 0xe1, - 0x59, 0x3d, 0x88, 0x15, 0x4e, 0x9c, 0x27, 0xee, 0xc9, 0x33, 0xac, 0x78, 0xbe, 0x41, 0x8b, 0x31, - 0x08, 0xaa, 0xc7, 0xca, 0xac, 0xe9, 0xf9, 0x06, 0x2d, 0x84, 0x69, 0x5d, 0xcf, 0x37, 0x68, 0x29, - 0xc3, 0xdd, 0x5c, 0x81, 0x70, 0x3e, 0x9a, 0x6b, 0x95, 0x24, 0xb9, 0xc4, 0xd1, 0x84, 0x82, 0x52, - 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x95, 0xe2, 0xb9, 0x78, 0x7d, 0x8b, 0xd3, 0x9d, 0x8b, 0x52, - 0x13, 0x4b, 0x52, 0xdd, 0x13, 0x73, 0x53, 0x85, 0x24, 0xb8, 0xd8, 0x93, 0x41, 0xbc, 0xfc, 0x22, - 0x88, 0xbf, 0x82, 0x60, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xa4, 0x9c, 0xc4, 0xe4, 0x6c, 0xb0, 0xd3, - 0x39, 0x83, 0x20, 0x1c, 0x21, 0x01, 0x2e, 0xe6, 0xa2, 0xd4, 0x14, 0x09, 0x66, 0xb0, 0x18, 0x88, - 0x69, 0xc5, 0x03, 0x72, 0x25, 0x4c, 0x97, 0x92, 0x29, 0x97, 0x28, 0x8a, 0x05, 0x30, 0x9b, 0x85, - 0x64, 0xb8, 0x38, 0xd3, 0x13, 0x73, 0x53, 0x3d, 0xf3, 0x52, 0x52, 0x2b, 0xa0, 0x56, 0x21, 0x04, - 0x8c, 0x8e, 0x31, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0xc5, 0x71, 0xf1, 0xa0, 0x04, 0xbc, 0x12, - 0x96, 0x00, 0x43, 0xf3, 0x9b, 0x94, 0x16, 0x61, 0x35, 0x70, 0x57, 0x44, 0x70, 0x71, 0x21, 0x79, - 0x5e, 0x01, 0xbb, 0x4e, 0x84, 0x0a, 0x29, 0x0d, 0x42, 0x2a, 0x60, 0x26, 0x4b, 0xb1, 0x36, 0x80, - 0xe2, 0xce, 0xc9, 0xe3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, - 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, 0xd2, - 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xf3, 0x73, 0x32, 0x73, 0x53, 0xaa, - 0x32, 0xf2, 0xf3, 0xf4, 0xb1, 0xc5, 0x67, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x39, - 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x82, 0x6c, 0xc8, 0x3c, 0x03, 0x00, 0x00, + // 561 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xbf, 0x6f, 0xd3, 0x4c, + 0x18, 0x8e, 0x93, 0x26, 0xdf, 0x97, 0x6b, 0x11, 0xd4, 0x04, 0xea, 0x58, 0xc8, 0x44, 0x46, 0x42, + 0x51, 0x24, 0x6c, 0x51, 0x44, 0x87, 0x8a, 0x85, 0x30, 0x00, 0x43, 0xa4, 0xca, 0x08, 0x29, 0x66, + 0xa0, 0xba, 0xd8, 0xc7, 0xc5, 0x6a, 0xec, 0xb3, 0xee, 0x2e, 0x25, 0x61, 0x42, 0x8c, 0x4c, 0xcc, + 0xac, 0x2c, 0x8c, 0x19, 0xd8, 0x59, 0x3b, 0x56, 0x4c, 0x4c, 0x08, 0x25, 0x43, 0xfe, 0x0d, 0xe4, + 0x3b, 0x3b, 0x4e, 0xd2, 0xa8, 0x5d, 0x92, 0xf7, 0x79, 0x9e, 0xf7, 0xc7, 0xf3, 0xfa, 0xee, 0x80, + 0xee, 0xf5, 0x91, 0x77, 0x82, 0x28, 0xb3, 0x17, 0x01, 0x1f, 0x59, 0x31, 0x25, 0x9c, 0xa8, 0xbb, + 0x19, 0x65, 0x65, 0x81, 0xbe, 0x0b, 0xc3, 0x20, 0x22, 0xb6, 0xf8, 0x95, 0x59, 0xfa, 0x9e, 0x47, + 0x58, 0x48, 0x98, 0x1d, 0x32, 0x6c, 0x9f, 0x3e, 0x4c, 0xfe, 0x52, 0xa1, 0x2e, 0x85, 0x63, 0x81, + 0x6c, 0x09, 0x52, 0xa9, 0x86, 0x09, 0x26, 0x92, 0x4f, 0xa2, 0x94, 0x35, 0x2e, 0x7a, 0x89, 0x21, + 0x85, 0x61, 0x5a, 0x65, 0xfe, 0x54, 0xc0, 0xf5, 0x0e, 0xc3, 0xaf, 0x63, 0x1f, 0x72, 0x74, 0x24, + 0x14, 0xf5, 0x00, 0x54, 0xe1, 0x90, 0xf7, 0x09, 0x0d, 0xf8, 0x58, 0x53, 0x1a, 0x4a, 0xb3, 0xda, + 0xd6, 0x7e, 0xfd, 0x78, 0x50, 0x4b, 0xc7, 0x3d, 0xf5, 0x7d, 0x8a, 0x18, 0x7b, 0xc5, 0x69, 0x10, + 0x61, 0x27, 0x4f, 0x55, 0x9f, 0x80, 0x8a, 0xec, 0xad, 0x15, 0x1b, 0x4a, 0x73, 0x7b, 0xbf, 0x6e, + 0x5d, 0x58, 0xd6, 0x92, 0x23, 0xda, 0xd5, 0xb3, 0x3f, 0x77, 0x0b, 0xdf, 0xe7, 0x93, 0x96, 0xe2, + 0xa4, 0x35, 0x87, 0x07, 0x9f, 0xe6, 0x93, 0x56, 0xde, 0xed, 0xf3, 0x7c, 0xd2, 0xba, 0xb7, 0xf0, + 0x3c, 0xca, 0xed, 0xaf, 0xb9, 0x35, 0xeb, 0x60, 0x6f, 0x8d, 0x72, 0x10, 0x8b, 0x49, 0xc4, 0x90, + 0x79, 0x0c, 0xae, 0x75, 0x18, 0x7e, 0x46, 0x11, 0xe4, 0xe8, 0x39, 0x0c, 0x91, 0xaa, 0x81, 0xff, + 0xbc, 0x04, 0x11, 0x2a, 0xf7, 0x72, 0x32, 0xa8, 0xd6, 0x40, 0xb9, 0x37, 0x80, 0xde, 0x89, 0xb0, + 0x5e, 0x75, 0x24, 0x50, 0x6f, 0x80, 0x12, 0x45, 0xbe, 0x56, 0x12, 0x5c, 0x12, 0x1e, 0xee, 0x24, + 0x2e, 0xb3, 0x2a, 0xf3, 0x31, 0xb8, 0xb5, 0x32, 0x20, 0x9b, 0xac, 0xde, 0x01, 0x55, 0x0c, 0x43, + 0xf4, 0x32, 0xf2, 0xd1, 0x28, 0x1d, 0x95, 0x13, 0xe6, 0x37, 0x05, 0x6c, 0x77, 0x18, 0x3e, 0x1a, + 0xc0, 0x71, 0x87, 0x9c, 0x5e, 0x66, 0x6b, 0xa5, 0x4f, 0x71, 0xad, 0x4f, 0x62, 0xfa, 0x1d, 0x25, + 0x61, 0x57, 0x18, 0xdc, 0x72, 0x24, 0xc8, 0x58, 0x57, 0xdb, 0xca, 0x59, 0x37, 0x59, 0x85, 0x93, + 0xae, 0x56, 0x16, 0x5c, 0x12, 0x4a, 0xc6, 0xd5, 0x2a, 0x19, 0xe3, 0xae, 0x2d, 0x17, 0x80, 0x9b, + 0x4b, 0x26, 0x97, 0x57, 0xf3, 0x60, 0xcc, 0x87, 0x14, 0xf9, 0x5d, 0x61, 0xb7, 0xec, 0xe4, 0xc4, + 0xb2, 0xea, 0x0a, 0xc3, 0x4b, 0xaa, 0xab, 0xde, 0x06, 0x95, 0xf7, 0x41, 0x14, 0x21, 0x9a, 0x7e, + 0xd2, 0x14, 0xed, 0x7f, 0x2d, 0x82, 0x52, 0x87, 0x61, 0xf5, 0x2d, 0xd8, 0x59, 0xb9, 0x89, 0xe6, + 0x86, 0x1b, 0xb4, 0x76, 0xd8, 0x7a, 0xeb, 0xea, 0x9c, 0x85, 0xf7, 0x2e, 0x00, 0x4b, 0xb7, 0xa1, + 0xb1, 0xb9, 0x32, 0xcf, 0xd0, 0x9b, 0x57, 0x65, 0x2c, 0x3a, 0x3b, 0xe0, 0xff, 0xc5, 0x71, 0x1a, + 0x9b, 0xab, 0x32, 0x5d, 0xbf, 0x7f, 0xb9, 0x9e, 0xf5, 0xd4, 0xcb, 0x1f, 0x93, 0x07, 0xd2, 0x7e, + 0x71, 0x36, 0x35, 0x94, 0xf3, 0xa9, 0xa1, 0xfc, 0x9d, 0x1a, 0xca, 0x97, 0x99, 0x51, 0x38, 0x9f, + 0x19, 0x85, 0xdf, 0x33, 0xa3, 0xf0, 0xc6, 0xc2, 0x01, 0xef, 0x0f, 0x7b, 0x96, 0x47, 0x42, 0x9b, + 0x0c, 0x82, 0xd0, 0xff, 0xd0, 0x27, 0x91, 0xbd, 0xe9, 0xd1, 0xf0, 0x71, 0x8c, 0x58, 0xaf, 0x22, + 0xde, 0xfc, 0xa3, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xd1, 0x5a, 0x0e, 0xa1, 0x04, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -285,6 +439,7 @@ type MsgClient interface { // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) CreateGame(ctx context.Context, in *MsgCreateGame, opts ...grpc.CallOption) (*MsgCreateGameResponse, error) + PlayMove(ctx context.Context, in *MsgPlayMove, opts ...grpc.CallOption) (*MsgPlayMoveResponse, error) } type msgClient struct { @@ -313,12 +468,22 @@ func (c *msgClient) CreateGame(ctx context.Context, in *MsgCreateGame, opts ...g return out, nil } +func (c *msgClient) PlayMove(ctx context.Context, in *MsgPlayMove, opts ...grpc.CallOption) (*MsgPlayMoveResponse, error) { + out := new(MsgPlayMoveResponse) + err := c.cc.Invoke(ctx, "/checkers.checkers.Msg/PlayMove", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) CreateGame(context.Context, *MsgCreateGame) (*MsgCreateGameResponse, error) + PlayMove(context.Context, *MsgPlayMove) (*MsgPlayMoveResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -331,6 +496,9 @@ func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateP func (*UnimplementedMsgServer) CreateGame(ctx context.Context, req *MsgCreateGame) (*MsgCreateGameResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateGame not implemented") } +func (*UnimplementedMsgServer) PlayMove(ctx context.Context, req *MsgPlayMove) (*MsgPlayMoveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PlayMove not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -372,6 +540,24 @@ func _Msg_CreateGame_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Msg_PlayMove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPlayMove) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PlayMove(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/checkers.checkers.Msg/PlayMove", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PlayMove(ctx, req.(*MsgPlayMove)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "checkers.checkers.Msg", HandlerType: (*MsgServer)(nil), @@ -384,6 +570,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateGame", Handler: _Msg_CreateGame_Handler, }, + { + MethodName: "PlayMove", + Handler: _Msg_PlayMove_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "checkers/checkers/tx.proto", @@ -526,6 +716,103 @@ func (m *MsgCreateGameResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgPlayMove) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPlayMove) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlayMove) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ToY != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ToY)) + i-- + dAtA[i] = 0x30 + } + if m.ToX != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ToX)) + i-- + dAtA[i] = 0x28 + } + if m.FromY != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.FromY)) + i-- + dAtA[i] = 0x20 + } + if m.FromX != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.FromX)) + i-- + dAtA[i] = 0x18 + } + if len(m.GameIndex) > 0 { + i -= len(m.GameIndex) + copy(dAtA[i:], m.GameIndex) + i = encodeVarintTx(dAtA, i, uint64(len(m.GameIndex))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgPlayMoveResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPlayMoveResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlayMoveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Winner) > 0 { + i -= len(m.Winner) + copy(dAtA[i:], m.Winner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Winner))) + i-- + dAtA[i] = 0x1a + } + if m.CapturedY != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.CapturedY)) + i-- + dAtA[i] = 0x10 + } + if m.CapturedX != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.CapturedX)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -595,6 +882,54 @@ func (m *MsgCreateGameResponse) Size() (n int) { return n } +func (m *MsgPlayMove) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GameIndex) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.FromX != 0 { + n += 1 + sovTx(uint64(m.FromX)) + } + if m.FromY != 0 { + n += 1 + sovTx(uint64(m.FromY)) + } + if m.ToX != 0 { + n += 1 + sovTx(uint64(m.ToX)) + } + if m.ToY != 0 { + n += 1 + sovTx(uint64(m.ToY)) + } + return n +} + +func (m *MsgPlayMoveResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CapturedX != 0 { + n += 1 + sovTx(uint64(m.CapturedX)) + } + if m.CapturedY != 0 { + n += 1 + sovTx(uint64(m.CapturedY)) + } + l = len(m.Winner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -994,6 +1329,316 @@ func (m *MsgCreateGameResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgPlayMove) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPlayMove: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlayMove: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GameIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GameIndex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FromX", wireType) + } + m.FromX = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FromX |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FromY", wireType) + } + m.FromY = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FromY |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ToX", wireType) + } + m.ToX = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ToX |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ToY", wireType) + } + m.ToY = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ToY |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPlayMoveResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPlayMoveResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlayMoveResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CapturedX", wireType) + } + m.CapturedX = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CapturedX |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CapturedY", wireType) + } + m.CapturedY = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CapturedY |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Winner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Winner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0